Changeset a35b458 in mainline for uspace/lib/draw/codec/tga.c


Ignore:
Timestamp:
2018-03-02T20:10:49Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f1380b7
Parents:
3061bc1
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
Message:

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/draw/codec/tga.c

    r3061bc1 ra35b458  
    4646        uint8_t cmap_type;
    4747        uint8_t img_type;
    48        
     48
    4949        uint16_t cmap_first_entry;
    5050        uint16_t cmap_entries;
    5151        uint8_t cmap_bpp;
    52        
     52
    5353        uint16_t startx;
    5454        uint16_t starty;
     
    7979        cmap_type_t cmap_type;
    8080        img_type_t img_type;
    81        
     81
    8282        uint16_t cmap_first_entry;
    8383        uint16_t cmap_entries;
    8484        uint8_t cmap_bpp;
    85        
     85
    8686        uint16_t startx;
    8787        uint16_t starty;
     
    9191        uint8_t img_alpha_bpp;
    9292        uint8_t img_alpha_dir;
    93        
     93
    9494        void *id_data;
    9595        size_t id_length;
    96        
     96
    9797        void *cmap_data;
    9898        size_t cmap_length;
    99        
     99
    100100        void *img_data;
    101101        size_t img_length;
     
    117117        if (size < sizeof(tga_header_t))
    118118                return false;
    119        
     119
    120120        tga_header_t *head = (tga_header_t *) data;
    121        
     121
    122122        /* Image ID field */
    123123        tga->id_data = data + sizeof(tga_header_t);
    124124        tga->id_length = head->id_length;
    125        
     125
    126126        if (size < sizeof(tga_header_t) + tga->id_length)
    127127                return false;
    128        
     128
    129129        /* Color map type */
    130130        tga->cmap_type = head->cmap_type;
    131        
     131
    132132        /* Image type */
    133133        tga->img_type = head->img_type;
    134        
     134
    135135        /* Color map specification */
    136136        tga->cmap_first_entry = uint16_t_le2host(head->cmap_first_entry);
     
    139139        tga->cmap_data = tga->id_data + tga->id_length;
    140140        tga->cmap_length = ALIGN_UP(tga->cmap_entries * tga->cmap_bpp, 8) >> 3;
    141        
     141
    142142        if (size < sizeof(tga_header_t) + tga->id_length +
    143143            tga->cmap_length)
    144144                return false;
    145        
     145
    146146        /* Image specification */
    147147        tga->startx = uint16_t_le2host(head->startx);
     
    154154        tga->img_data = tga->cmap_data + tga->cmap_length;
    155155        tga->img_length = ALIGN_UP(tga->width * tga->height * tga->img_bpp, 8) >> 3;
    156        
     156
    157157        if (size < sizeof(tga_header_t) + tga->id_length +
    158158            tga->cmap_length + tga->img_length)
    159159                return false;
    160        
     160
    161161        return true;
    162162}
     
    182182        if (!decode_tga_header(data, size, &tga))
    183183                return NULL;
    184        
     184
    185185        /*
    186186         * Check for unsupported features.
    187187         */
    188        
     188
    189189        switch (tga.cmap_type) {
    190190        case CMAP_NOT_PRESENT:
     
    194194                return NULL;
    195195        }
    196        
     196
    197197        switch (tga.img_type) {
    198198        case IMG_BGRA:
     
    208208                return NULL;
    209209        }
    210        
     210
    211211        if (tga.img_alpha_bpp != 0)
    212212                return NULL;
    213        
     213
    214214        sysarg_t twidth = tga.startx + tga.width;
    215215        sysarg_t theight = tga.starty + tga.height;
    216        
     216
    217217        surface_t *surface = surface_create(twidth, theight, NULL, flags);
    218218        if (surface == NULL)
    219219                return NULL;
    220        
     220
    221221        /*
    222222         * TGA is encoded in a bottom-up manner, the true-color
    223223         * variant is in BGR 8:8:8 encoding.
    224224         */
    225        
     225
    226226        switch (tga.img_type) {
    227227        case IMG_BGRA:
     
    230230                                size_t offset =
    231231                                    ((y - tga.starty) * tga.width + (x - tga.startx)) * 3;
    232                                
     232
    233233                                pixel_t pixel =
    234234                                    bgr_888_2pixel(((uint8_t *) tga.img_data) + offset);
     
    242242                                size_t offset =
    243243                                    (y - tga.starty) * tga.width + (x - tga.startx);
    244                                
     244
    245245                                pixel_t pixel =
    246246                                    gray_8_2pixel(((uint8_t *) tga.img_data) + offset);
     
    252252                break;
    253253        }
    254        
     254
    255255        return surface;
    256256}
Note: See TracChangeset for help on using the changeset viewer.