Changeset 8565a42 in mainline for uspace/lib/draw


Ignore:
Timestamp:
2018-03-02T20:34:50Z (8 years ago)
Author:
GitHub <noreply@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a1a81f69, d5e5fd1
Parents:
3061bc1 (diff), 34e1206 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:34:50)
git-committer:
GitHub <noreply@…> (2018-03-02 20:34:50)
Message:

Remove all trailing whitespace, everywhere.

See individual commit messages for details.

Location:
uspace/lib/draw
Files:
13 edited

Legend:

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

    r3061bc1 r8565a42  
    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}
  • uspace/lib/draw/codec/tga.gz.c

    r3061bc1 r8565a42  
    5858        void *data_expanded;
    5959        size_t size_expanded;
    60        
     60
    6161        errno_t ret = gzip_expand(data, size, &data_expanded, &size_expanded);
    6262        if (ret != EOK)
    6363                return NULL;
    64        
     64
    6565        surface_t *surface = decode_tga(data_expanded, size_expanded, flags);
    66        
     66
    6767        free(data_expanded);
    6868        return surface;
  • uspace/lib/draw/codec/webp.c

    r3061bc1 r8565a42  
    8484        bool alpha_used;
    8585        uint8_t version;
    86        
     86
    8787        uint8_t *src;     /**< Input buffer */
    8888        size_t srclen;    /**< Input buffer size */
    8989        size_t srccnt;    /**< Position in the input buffer */
    90        
     90
    9191        uint32_t bitbuf;  /**< Bit buffer */
    9292        size_t bitlen;    /**< Number of bits in the bit buffer */
    93        
     93
    9494        bool overrun;     /**< Overrun condition */
    9595} webp_t;
     
    107107        /* Bit accumulator for at least 36 bits */
    108108        uint64_t val = state->bitbuf;
    109        
     109
    110110        while (state->bitlen < cnt) {
    111111                if (state->srccnt == state->srclen) {
     
    113113                        return 0;
    114114                }
    115                
     115
    116116                /* Load 8 more bits */
    117117                val |= ((uint64_t) state->src[state->srccnt]) << state->bitlen;
     
    119119                state->bitlen += 8;
    120120        }
    121        
     121
    122122        /* Update bits in the buffer */
    123123        state->bitbuf = (uint32_t) (val >> cnt);
    124124        state->bitlen -= cnt;
    125        
     125
    126126        return ((uint32_t) (val & ((1 << cnt) - 1)));
    127127}
     
    143143            (size - sizeof(riff_header_t) < sizeof(webp_header_t)))
    144144                return false;
    145        
     145
    146146        riff_header_t *riff_header = (riff_header_t *) data;
    147147        if (riff_header->fourcc != FOURCC_RIFF)
    148148                return false;
    149        
     149
    150150        /* Check payload size */
    151151        size_t payload_size = uint32_t_le2host(riff_header->payload_size);
    152152        if (payload_size + sizeof(riff_header_t) > size)
    153153                return false;
    154        
     154
    155155        data += sizeof(riff_header_t);
    156156        webp_header_t *webp_header = (webp_header_t *) data;
    157157        if (webp_header->fourcc != FOURCC_WEBP)
    158158                return false;
    159        
     159
    160160        /* Only lossless encoding supported so far */
    161161        if (webp_header->encoding != FOURCC_WEBP_LOSSLESS)
    162162                return false;
    163        
     163
    164164        webp->stream_size = uint32_t_le2host(webp_header->stream_size);
    165165        if (webp->stream_size + sizeof(riff_header_t) +
    166166            sizeof(webp_header_t) > size)
    167167                return false;
    168        
     168
    169169        if (webp_header->signature != SIGNATURE_WEBP_LOSSLESS)
    170170                return false;
    171        
     171
    172172        data += sizeof(webp_header_t);
    173        
     173
    174174        /* Setup decoding state */
    175175        webp->src = (uint8_t *) data;
     
    179179        webp->bitlen = 0;
    180180        webp->overrun = false;
    181        
     181
    182182        /* Decode the rest of the metadata */
    183183        webp->width = get_bits(webp, 14) + 1;
    184184        CHECK_OVERRUN(*webp, false);
    185        
     185
    186186        webp->height = get_bits(webp, 14) + 1;
    187187        CHECK_OVERRUN(*webp, false);
    188        
     188
    189189        webp->alpha_used = get_bits(webp, 1);
    190190        CHECK_OVERRUN(*webp, false);
    191        
     191
    192192        webp->version = get_bits(webp, 3);
    193193        CHECK_OVERRUN(*webp, false);
    194        
     194
    195195        if (webp->version != 0)
    196196                return false;
    197        
     197
    198198        return true;
    199199}
     
    218218        if (!decode_webp_header(data, size, &webp))
    219219                return NULL;
    220        
     220
    221221        bool transform_present = false;
    222        
     222
    223223        do {
    224224                transform_present = get_bits(&webp, 1);
    225225                CHECK_OVERRUN(webp, NULL);
    226                
     226
    227227                if (transform_present) {
    228228                        webp_transform_t transform = get_bits(&webp, 2);
    229229                        CHECK_OVERRUN(webp, NULL);
    230                        
     230
    231231                        if (transform == TRANSFORM_PREDICTOR) {
    232232                                // FIXME TODO
    233233                        } else
    234234                                return NULL;
    235                        
     235
    236236                        // FIXME: decode other transforms
    237237                }
    238238        } while (transform_present);
    239        
     239
    240240        // FIXME: decode image data
    241        
     241
    242242        return NULL;
    243243}
  • uspace/lib/draw/cursor/embedded.c

    r3061bc1 r8565a42  
    4747        assert(state_count);
    4848        assert(data);
    49        
     49
    5050        (*state_count) = 1;
    5151        (*data) = NULL;
     
    5656        if (state != 0)
    5757                return NULL;
    58        
     58
    5959        surface_t *surface = surface_create(CURSOR_WIDTH, CURSOR_HEIGHT, NULL, 0);
    6060        if (!surface)
    6161                return NULL;
    62        
     62
    6363        for (unsigned int y = 0; y < CURSOR_HEIGHT; ++y) {
    6464                for (unsigned int x = 0; x < CURSOR_WIDTH; ++x) {
     
    6767                        pixel_t pixel = (cursor_texture[offset] & (1 << (x % 8))) ?
    6868                            PIXEL(255, 0, 0, 0) : PIXEL(255, 255, 255, 255);
    69                        
     69
    7070                        if (visible)
    7171                                surface_put_pixel(surface, x, y, pixel);
    7272                }
    7373        }
    74        
     74
    7575        return surface;
    7676}
  • uspace/lib/draw/font.c

    r3061bc1 r8565a42  
    4848        if (font == NULL)
    4949                return NULL;
    50        
     50
    5151        font->backend = backend;
    5252        font->backend_data = backend_data;
    53        
     53
    5454        return font;
    5555}
     
    9797                if (c == 0)
    9898                        break;
    99                
     99
    100100                glyph_id_t glyph_id;
    101101                rc = font_resolve_glyph(font, c, &glyph_id);
     
    106106                        }
    107107                }
    108                
     108
    109109                glyph_metrics_t glyph_metrics;
    110110                rc = font_get_glyph_metrics(font, glyph_id, &glyph_metrics);
    111111                if (rc != EOK)
    112112                        return rc;
    113                
     113
    114114                x += glyph_metrics_get_advancement(&glyph_metrics);
    115115        }
     
    140140                if (c == 0)
    141141                        break;
    142                
     142
    143143                glyph_id_t glyph_id;
    144144                rc = font_resolve_glyph(font, c, &glyph_id);
     
    149149                        }
    150150                }
    151                
     151
    152152                glyph_metrics_t glyph_metrics;
    153153                rc = font_get_glyph_metrics(font, glyph_id, &glyph_metrics);
  • uspace/lib/draw/font.h

    r3061bc1 r8565a42  
    5151        /* Horizontal distance between origin and left side of the glyph */
    5252        metric_t left_side_bearing;
    53        
     53
    5454        /* Width of the actual glyph drawn */
    5555        metric_t width;
    56        
     56
    5757        /* Horizontal distance between right side of the glyph and origin
    5858           of the next glyph */
    5959        metric_t right_side_bearing;
    60        
     60
    6161        /* Vertical distance between baseline and top of the glyph
    6262           (positive to top) */
    6363        metric_t ascender;
    64        
     64
    6565        /* Height of the actual glyph drawn */
    6666        metric_t height;
     
    8080        /* Distance between top of the line and baseline */
    8181        metric_t ascender;
    82        
     82
    8383        /* Distance between baseline and bottom of the line */
    8484        metric_t descender;
    85        
     85
    8686        /* Distance between bottom of the line and top of the next line */
    8787        metric_t leading;
  • uspace/lib/draw/font/bitmap_backend.c

    r3061bc1 r8565a42  
    6262{
    6363        bitmap_backend_data_t *data = (bitmap_backend_data_t *) backend_data;
    64        
     64
    6565        *font_metrics = data->font_metrics;
    66        
     66
    6767        return EOK;
    6868}
     
    7878{
    7979        bitmap_backend_data_t *data = (bitmap_backend_data_t *) backend_data;
    80        
     80
    8181        if (glyph_id >= data->glyph_count)
    8282                return ENOENT;
    83        
     83
    8484        if (data->glyph_cache[glyph_id].metrics_loaded) {
    8585                *glyph_metrics = data->glyph_cache[glyph_id].metrics;
    8686                return EOK;
    8787        }
    88        
     88
    8989        glyph_metrics_t gm;
    90        
     90
    9191        errno_t rc = data->decoder->load_glyph_metrics(data->decoder_data, glyph_id,
    9292            &gm);
    9393        if (rc != EOK)
    9494                return rc;
    95        
     95
    9696        if (data->scale) {
    9797                gm.left_side_bearing = (metric_t)
     
    106106                    (data->scale_ratio * gm.height + 0.5);
    107107        }
    108        
    109        
    110        
     108
     109
     110
    111111        data->glyph_cache[glyph_id].metrics = gm;
    112112        data->glyph_cache[glyph_id].metrics_loaded = true;
     
    120120        if (glyph_id >= data->glyph_count)
    121121                return ENOENT;
    122        
     122
    123123        if (data->glyph_cache[glyph_id].surface != NULL) {
    124124                *result = data->glyph_cache[glyph_id].surface;
    125125                return EOK;
    126126        }
    127        
     127
    128128        surface_t *raw_surface;
    129129        errno_t rc = data->decoder->load_glyph_surface(data->decoder_data, glyph_id,
     
    131131        if (rc != EOK)
    132132                return rc;
    133        
     133
    134134        sysarg_t w;
    135135        sysarg_t h;
    136136        surface_get_resolution(raw_surface, &w, &h);
    137        
     137
    138138        if (!data->scale) {
    139139                *result = raw_surface;
    140140                return EOK;
    141141        }
    142        
     142
    143143        source_t source;
    144144        source_init(&source);
     
    167167
    168168        surface_destroy(raw_surface);
    169        
     169
    170170        data->glyph_cache[glyph_id].surface = scaled_surface;
    171171        *result = scaled_surface;
     
    177177{
    178178        bitmap_backend_data_t *data = (bitmap_backend_data_t *) backend_data;
    179        
     179
    180180        glyph_metrics_t glyph_metrics;
    181181        errno_t rc = bb_get_glyph_metrics(backend_data, glyph_id, &glyph_metrics);
    182182        if (rc != EOK)
    183183                return rc;
    184        
     184
    185185        surface_t *glyph_surface;
    186186        rc = get_glyph_surface(data, glyph_id, &glyph_surface);
    187187        if (rc != EOK)
    188188                return rc;
    189        
     189
    190190        native_t x = ox + glyph_metrics.left_side_bearing;
    191191        native_t y = oy - glyph_metrics.ascender;
    192        
     192
    193193        transform_t transform;
    194194        transform_identity(&transform);
     
    230230        if (glyph_count == 0)
    231231                return EINVAL;
    232        
     232
    233233        bitmap_backend_data_t *data = malloc(sizeof(bitmap_backend_data_t));
    234234        if (data == NULL)
     
    275275                return ENOMEM;
    276276        }
    277        
     277
    278278        *out_font = font;
    279279        return EOK;
  • uspace/lib/draw/font/embedded.c

    r3061bc1 r8565a42  
    5151        if (!found)
    5252                return ENOENT;
    53        
     53
    5454        *glyph_id = glyph;
    5555        return EOK;
     
    6262        if (!surface)
    6363                return ENOMEM;
    64        
     64
    6565        for (unsigned int y = 0; y < FONT_SCANLINES; ++y) {
    6666                for (unsigned int x = 0; x < FONT_WIDTH; ++x) {
     
    7070                }
    7171        }
    72        
     72
    7373        *out_surface = surface;
    7474        return EOK;
     
    8484        gm->ascender = FONT_ASCENDER;
    8585        gm->height = FONT_SCANLINES;
    86        
     86
    8787        return EOK;
    8888}
  • uspace/lib/draw/font/pcf.c

    r3061bc1 r8565a42  
    151151{
    152152        pcf_data_t *data = (pcf_data_t *) opaque_data;
    153        
     153
    154154        /* TODO is this correct? */
    155155        uint8_t byte1 = (chr >> 8) & 0xff;
     
    160160            (byte1 - e->min_byte1) * (e->max_byte2 - e->min_byte2 + 1) +
    161161            (byte2 - e->min_byte2);
    162        
     162
    163163        aoff64_t entry_offset = data->encodings_table.offset +
    164164            (sizeof(uint32_t) + 5 * sizeof(uint16_t)) +
    165165            entry_index * sizeof(uint16_t);
    166        
     166
    167167        int rc = fseek(data->file, entry_offset, SEEK_SET);
    168168        if (rc != 0)
    169169                return errno;
    170        
     170
    171171        uint16_t glyph = 0;
    172172        size_t records_read = fread(&glyph, sizeof(uint16_t), 1, data->file);
    173173        if (records_read != 1)
    174174                return EINVAL;
    175        
     175
    176176        glyph = uint16_t_pcf2host(glyph, data->encodings_table.format);
    177        
     177
    178178        if (glyph == 0xffff)
    179179                return ENOENT;
    180        
     180
    181181        *glyph_id = glyph;
    182        
     182
    183183        return EOK;
    184184}
     
    190190        int rc;
    191191        size_t records_read;
    192        
     192
    193193        if (table->format & PCF_FORMAT_COMPRESSED_METRICS) {
    194194                offset = table->offset + sizeof(uint32_t) + sizeof(uint16_t) +
    195195                    glyph_id * sizeof(pcf_compressed_metrics_t);
    196                
     196
    197197                rc = fseek(data->file, offset, SEEK_SET);
    198198                if (rc != 0)
    199199                        return errno;
    200                
     200
    201201                pcf_compressed_metrics_t compressed_metrics;
    202202                records_read = fread(&compressed_metrics,
     
    204204                if (records_read != 1)
    205205                        return EINVAL;
    206                
     206
    207207                metrics->left_side_bearing =
    208208                    compressed2int(compressed_metrics.left_side_bearing);
     
    220220                offset = table->offset + 2 * sizeof(uint32_t) +
    221221                    glyph_id * sizeof(pcf_default_metrics_t);
    222                
     222
    223223                rc = fseek(data->file, offset, SEEK_SET);
    224224                if (rc != 0)
    225225                        return errno;
    226        
     226
    227227                pcf_default_metrics_t uncompressed_metrics;
    228228                records_read = fread(&uncompressed_metrics,
     
    230230                if (records_read != 1)
    231231                        return EINVAL;
    232                
     232
    233233                metrics->left_side_bearing =
    234234                    int16_t_pcf2host(uncompressed_metrics.left_side_bearing,
     
    250250                    table->format);
    251251        }
    252        
     252
    253253        return EOK;
    254254}
     
    258258{
    259259        pcf_data_t *data = (pcf_data_t *) opaque_data;
    260        
     260
    261261        pcf_default_metrics_t pcf_metrics;
    262262        memset(&pcf_metrics, 0, sizeof(pcf_default_metrics_t));
     
    265265        if (rc != EOK)
    266266                return rc;
    267        
     267
    268268        aoff64_t offset = data->bitmap_table.offset + (2 * sizeof(uint32_t)) +
    269269            (glyph_id * sizeof(uint32_t));
    270        
     270
    271271        if (fseek(data->file, offset, SEEK_SET) < 0)
    272272                return errno;
    273        
     273
    274274        uint32_t bitmap_offset = 0;
    275275        size_t records_read = fread(&bitmap_offset, sizeof(uint32_t), 1,
     
    279279        bitmap_offset = uint32_t_pcf2host(bitmap_offset,
    280280            data->bitmap_table.format);
    281        
     281
    282282        offset = data->bitmap_table.offset + (2 * sizeof(uint32_t)) +
    283283            (data->glyph_count * sizeof(uint32_t)) + (4 * sizeof(uint32_t))
    284284            + bitmap_offset;
    285        
     285
    286286        if (fseek(data->file, offset, SEEK_SET) < 0)
    287287                return errno;
    288        
     288
    289289        surface_coord_t width = pcf_metrics.character_width;
    290290        surface_coord_t height = pcf_metrics.character_ascent +
     
    294294        size_t row_bytes = ALIGN_UP(ALIGN_UP(width, 8) / 8, row_padding_bytes);
    295295        size_t bitmap_bytes = height * row_bytes;
    296        
     296
    297297        uint8_t *bitmap = malloc(bitmap_bytes);
    298298        if (bitmap == NULL)
    299299                return ENOMEM;
    300        
     300
    301301        records_read = fread(bitmap, sizeof(uint8_t), bitmap_bytes,
    302302            data->file);
    303        
     303
    304304        surface_t *surface = surface_create(width, height, NULL, 0);
    305305        if (!surface) {
     
    307307                return ENOMEM;
    308308        }
    309        
     309
    310310        for (unsigned int y = 0; y < height; ++y) {
    311311                size_t row_offset = row_bytes * y;
     
    334334                }
    335335        }
    336        
     336
    337337        *out_surface = surface;
    338338        free(bitmap);
     
    344344{
    345345        pcf_data_t *data = (pcf_data_t *) opaque_data;
    346        
     346
    347347        pcf_default_metrics_t pcf_metrics;
    348348        memset(&pcf_metrics, 0, sizeof(pcf_default_metrics_t));
     
    351351        if (rc != EOK)
    352352                return rc;
    353        
     353
    354354        gm->left_side_bearing = pcf_metrics.left_side_bearing;
    355355        gm->width = pcf_metrics.character_width;
     
    359359            pcf_metrics.character_ascent;
    360360        gm->ascender = pcf_metrics.character_ascent;
    361        
     361
    362362        return EOK;
    363363}
     
    366366{
    367367        pcf_data_t *data = (pcf_data_t *) opaque_data;
    368        
     368
    369369        fclose(data->file);
    370370        free(data);
     
    383383        if (rc != 0)
    384384                return errno;
    385        
     385
    386386        aoff64_t file_size = ftell(data->file);
    387        
     387
    388388        rc = fseek(data->file, 0, SEEK_SET);
    389389        if (rc != 0)
    390390                return errno;
    391        
     391
    392392        char header[4];
    393393        size_t records_read = fread(header, sizeof(char), 4, data->file);
    394394        if (records_read != 4)
    395395                return EINVAL;
    396        
     396
    397397        if (header[0] != 1 || header[1] != 'f' || header[2] != 'c' ||
    398398            header[3] != 'p')
    399399                return EINVAL;
    400        
     400
    401401        uint32_t table_count;
    402402        records_read = fread(&table_count, sizeof(uint32_t), 1,
     
    404404        if (records_read != 1)
    405405                return EINVAL;
    406        
     406
    407407        table_count = uint32_t_le2host(table_count);
    408        
     408
    409409        bool found_bitmap_table = false;
    410410        bool found_metrics_table = false;
    411411        bool found_encodings_table = false;
    412412        bool found_accelerators_table = false;
    413        
     413
    414414        for (uint32_t index = 0; index < table_count; index++) {
    415415                pcf_toc_entry_t toc_entry;
     
    420420                toc_entry.size = uint32_t_le2host(toc_entry.size);
    421421                toc_entry.offset = uint32_t_le2host(toc_entry.offset);
    422                
     422
    423423                if (toc_entry.offset >= file_size)
    424424                        continue;
    425                
     425
    426426                aoff64_t end = ((aoff64_t) toc_entry.offset) + ((aoff64_t) toc_entry.size);
    427427                if (end > file_size)
    428428                        continue;
    429                
     429
    430430                if (toc_entry.type == PCF_TABLE_BITMAPS) {
    431431                        if (found_bitmap_table)
     
    453453                }
    454454        }
    455        
     455
    456456        if (!found_bitmap_table || !found_metrics_table ||
    457457            !found_encodings_table || !found_accelerators_table)
    458458                return EINVAL;
    459        
     459
    460460        return EOK;
    461461}
     
    467467        if (rc != 0)
    468468                return errno;
    469        
     469
    470470        size_t records_read = fread(&format, sizeof(uint32_t), 1, data->file);
    471471        if (records_read != 1)
    472472                return EINVAL;
    473        
     473
    474474        format = uint32_t_le2host(format);
    475475        if (format != table->format)
    476476                return EINVAL;
    477        
     477
    478478        return EOK;
    479479}
     
    484484        if (rc != EOK)
    485485                return rc;
    486        
     486
    487487        if ((data->bitmap_table.format & PCF_FORMAT_MASK) != PCF_FORMAT_DEFAULT)
    488488                return EINVAL;
    489        
     489
    490490        uint32_t glyph_count = 0;
    491491        size_t records_read = fread(&glyph_count, sizeof(uint32_t), 1,
     
    504504        if (rc != EOK)
    505505                return rc;
    506        
     506
    507507        size_t records_read;
    508508        uint32_t metrics_count;
     
    525525                    data->metrics_table.format);
    526526        }
    527        
     527
    528528        if (metrics_count != data->glyph_count)
    529529                return EINVAL;
    530        
     530
    531531        return EOK;
    532532}
     
    537537        if (rc != EOK)
    538538                return rc;
    539        
     539
    540540        pcf_encoding_t encoding;
    541541        size_t records_read = fread(&encoding, sizeof(pcf_encoding_t), 1,
     
    543543        if (records_read != 1)
    544544                return EINVAL;
    545        
     545
    546546        encoding.min_byte1 = uint16_t_pcf2host(encoding.min_byte1,
    547547            data->encodings_table.format);
     
    554554        encoding.default_char = uint16_t_pcf2host(encoding.default_char,
    555555            data->encodings_table.format);
    556        
     556
    557557        data->encoding = encoding;
    558558        return EOK;
     
    564564        if (rc != EOK)
    565565                return rc;
    566        
     566
    567567        pcf_accelerators_t accelerators;
    568568        size_t records_read = fread(&accelerators, sizeof(pcf_accelerators_t),
     
    570570        if (records_read != 1)
    571571                return EINVAL;
    572        
     572
    573573        data->font_metrics.ascender = int32_t_pcf2host(accelerators.font_ascent,
    574574            data->accelerators_table.format);
     
    576576            data->accelerators_table.format);
    577577        data->font_metrics.leading = 0;
    578        
     578
    579579        return EOK;
    580580}
     
    586586        if (data == NULL)
    587587                return ENOMEM;
    588        
     588
    589589        data->file = fopen(filename, "rb");
    590590        if (data->file == NULL)
    591591                goto read_error;
    592        
     592
    593593        rc = pcf_read_toc(data);
    594594        if (rc != EOK)
    595595                goto error;
    596        
     596
    597597        rc = pcf_read_bitmap_table_header(data);
    598598        if (rc != EOK)
    599599                goto error;
    600        
     600
    601601        rc = pcf_read_metrics_table_header(data);
    602602        if (rc != EOK)
    603603                goto error;
    604        
     604
    605605        rc = pcf_read_encodings_table_header(data);
    606606        if (rc != EOK)
    607607                goto error;
    608        
     608
    609609        rc = pcf_read_accelerators_table(data);
    610610        if (rc != EOK)
    611611                goto error;
    612        
     612
    613613        rc = bitmap_font_create(&fd_pcf, data, data->glyph_count,
    614614            data->font_metrics, points, font);
    615615        if (rc != EOK)
    616616                goto error;
    617        
     617
    618618        return EOK;
    619619read_error:
  • uspace/lib/draw/gfx/font-8x16.c

    r3061bc1 r8565a42  
    5151        if (found)
    5252                *found = true;
    53        
     53
    5454        if (ch == 0x0000)
    5555                return 0;
    56        
     56
    5757        if ((ch >= 0x0020) && (ch <= 0x007f))
    5858                return (ch - 32);
    59        
     59
    6060        if ((ch >= 0x00a0) && (ch <= 0x021f))
    6161                return (ch - 64);
    62        
     62
    6363        if ((ch >= 0x0222) && (ch <= 0x0233))
    6464                return (ch - 66);
    65        
     65
    6666        if ((ch >= 0x0250) && (ch <= 0x02ad))
    6767                return (ch - 94);
    68        
     68
    6969        if ((ch >= 0x02b0) && (ch <= 0x02cf))
    7070                return (ch - 96);
    71        
     71
    7272        if ((ch >= 0x02d8) && (ch <= 0x02dd))
    7373                return (ch - 104);
    74        
     74
    7575        if (ch == 0x02ee)
    7676                return 630;
    77        
     77
    7878        if ((ch >= 0x0300) && (ch <= 0x0301))
    7979                return (ch - 137);
    80        
     80
    8181        if (ch == 0x0303)
    8282                return 633;
    83        
     83
    8484        if (ch == 0x0309)
    8585                return 634;
    86        
     86
    8787        if ((ch >= 0x0312) && (ch <= 0x0314))
    8888                return (ch - 151);
    89        
     89
    9090        if (ch == 0x0323)
    9191                return 638;
    92        
     92
    9393        if ((ch >= 0x0340) && (ch <= 0x0341))
    9494                return (ch - 193);
    95        
     95
    9696        if ((ch >= 0x0374) && (ch <= 0x0375))
    9797                return (ch - 243);
    98        
     98
    9999        if (ch == 0x037a)
    100100                return 643;
    101        
     101
    102102        if (ch == 0x037e)
    103103                return 644;
    104        
     104
    105105        if ((ch >= 0x0384) && (ch <= 0x038a))
    106106                return (ch - 255);
    107        
     107
    108108        if (ch == 0x038c)
    109109                return 652;
    110        
     110
    111111        if ((ch >= 0x038e) && (ch <= 0x03a1))
    112112                return (ch - 257);
    113        
     113
    114114        if ((ch >= 0x03a3) && (ch <= 0x03ce))
    115115                return (ch - 258);
    116        
     116
    117117        if ((ch >= 0x03d0) && (ch <= 0x03d7))
    118118                return (ch - 259);
    119        
     119
    120120        if ((ch >= 0x03da) && (ch <= 0x03f3))
    121121                return (ch - 261);
    122        
     122
    123123        if ((ch >= 0x0400) && (ch <= 0x0486))
    124124                return (ch - 273);
    125        
     125
    126126        if ((ch >= 0x0488) && (ch <= 0x04ce))
    127127                return (ch - 274);
    128        
     128
    129129        if ((ch >= 0x04d0) && (ch <= 0x04f5))
    130130                return (ch - 275);
    131        
     131
    132132        if ((ch >= 0x04f8) && (ch <= 0x04f9))
    133133                return (ch - 277);
    134        
     134
    135135        if ((ch >= 0x0500) && (ch <= 0x050f))
    136136                return (ch - 283);
    137        
     137
    138138        if ((ch >= 0x0530) && (ch <= 0x0556))
    139139                return (ch - 315);
    140        
     140
    141141        if ((ch >= 0x0559) && (ch <= 0x055f))
    142142                return (ch - 317);
    143        
     143
    144144        if ((ch >= 0x0561) && (ch <= 0x0587))
    145145                return (ch - 318);
    146        
     146
    147147        if ((ch >= 0x0589) && (ch <= 0x058a))
    148148                return (ch - 319);
    149        
     149
    150150        if ((ch >= 0x0591) && (ch <= 0x05a1))
    151151                return (ch - 325);
    152        
     152
    153153        if ((ch >= 0x05a3) && (ch <= 0x05b9))
    154154                return (ch - 326);
    155        
     155
    156156        if ((ch >= 0x05bb) && (ch <= 0x05c4))
    157157                return (ch - 327);
    158        
     158
    159159        if ((ch >= 0x05d0) && (ch <= 0x05ea))
    160160                return (ch - 338);
    161        
     161
    162162        if ((ch >= 0x05f0) && (ch <= 0x05f4))
    163163                return (ch - 343);
    164        
     164
    165165        if (ch == 0x060c)
    166166                return 1182;
    167        
     167
    168168        if (ch == 0x061b)
    169169                return 1183;
    170        
     170
    171171        if (ch == 0x061f)
    172172                return 1184;
    173        
     173
    174174        if ((ch >= 0x0621) && (ch <= 0x063a))
    175175                return (ch - 384);
    176        
     176
    177177        if ((ch >= 0x0640) && (ch <= 0x0655))
    178178                return (ch - 389);
    179        
     179
    180180        if ((ch >= 0x0660) && (ch <= 0x066d))
    181181                return (ch - 399);
    182        
     182
    183183        if ((ch >= 0x0670) && (ch <= 0x06ed))
    184184                return (ch - 401);
    185        
     185
    186186        if ((ch >= 0x06f0) && (ch <= 0x06fe))
    187187                return (ch - 403);
    188        
     188
    189189        if (ch == 0x10d3)
    190190                return 1388;
    191        
     191
    192192        if (ch == 0x10d7)
    193193                return 1389;
    194        
     194
    195195        if (ch == 0x10da)
    196196                return 1390;
    197        
     197
    198198        if (ch == 0x10dd)
    199199                return 1391;
    200        
     200
    201201        if (ch == 0x10e6)
    202202                return 1392;
    203        
     203
    204204        if ((ch >= 0x1e00) && (ch <= 0x1e9b))
    205205                return (ch - 6287);
    206        
     206
    207207        if ((ch >= 0x1ea0) && (ch <= 0x1ef9))
    208208                return (ch - 6291);
    209        
     209
    210210        if ((ch >= 0x1f00) && (ch <= 0x1f07))
    211211                return (ch - 6297);
    212        
     212
    213213        if ((ch >= 0x2000) && (ch <= 0x2027))
    214214                return (ch - 6545);
    215        
     215
    216216        if ((ch >= 0x2030) && (ch <= 0x2046))
    217217                return (ch - 6553);
    218        
     218
    219219        if ((ch >= 0x2048) && (ch <= 0x204d))
    220220                return (ch - 6554);
    221        
     221
    222222        if (ch == 0x2070)
    223223                return 1716;
    224        
     224
    225225        if ((ch >= 0x2074) && (ch <= 0x208f))
    226226                return (ch - 6591);
    227        
     227
    228228        if ((ch >= 0x20a0) && (ch <= 0x20af))
    229229                return (ch - 6607);
    230        
     230
    231231        if ((ch >= 0x2100) && (ch <= 0x213a))
    232232                return (ch - 6687);
    233        
     233
    234234        if ((ch >= 0x2153) && (ch <= 0x2183))
    235235                return (ch - 6711);
    236        
     236
    237237        if ((ch >= 0x2190) && (ch <= 0x21f3))
    238238                return (ch - 6723);
    239        
     239
    240240        if ((ch >= 0x2200) && (ch <= 0x22f1))
    241241                return (ch - 6735);
    242        
     242
    243243        if (ch == 0x2300)
    244244                return 2211;
    245        
     245
    246246        if (ch == 0x2302)
    247247                return 2212;
    248        
     248
    249249        if ((ch >= 0x2308) && (ch <= 0x230b))
    250250                return (ch - 6755);
    251        
     251
    252252        if (ch == 0x2310)
    253253                return 2217;
    254        
     254
    255255        if (ch == 0x2318)
    256256                return 2218;
    257        
     257
    258258        if ((ch >= 0x231a) && (ch <= 0x231b))
    259259                return (ch - 6767);
    260        
     260
    261261        if ((ch >= 0x2320) && (ch <= 0x2321))
    262262                return (ch - 6771);
    263        
     263
    264264        if ((ch >= 0x2329) && (ch <= 0x232a))
    265265                return (ch - 6778);
    266        
     266
    267267        if ((ch >= 0x239b) && (ch <= 0x23bd))
    268268                return (ch - 6890);
    269        
     269
    270270        if (ch == 0x23ce)
    271271                return 2260;
    272        
     272
    273273        if ((ch >= 0x2409) && (ch <= 0x240d))
    274274                return (ch - 6964);
    275        
     275
    276276        if ((ch >= 0x2423) && (ch <= 0x2424))
    277277                return (ch - 6985);
    278        
     278
    279279        if (ch == 0x2426)
    280280                return 2268;
    281        
     281
    282282        if ((ch >= 0x2500) && (ch <= 0x2595))
    283283                return (ch - 7203);
    284        
     284
    285285        if ((ch >= 0x25a0) && (ch <= 0x25f7))
    286286                return (ch - 7213);
    287        
     287
    288288        if ((ch >= 0x2600) && (ch <= 0x2602))
    289289                return (ch - 7221);
    290        
     290
    291291        if ((ch >= 0x2605) && (ch <= 0x260d))
    292292                return (ch - 7223);
    293        
     293
    294294        if ((ch >= 0x2610) && (ch <= 0x2613))
    295295                return (ch - 7225);
    296        
     296
    297297        if (ch == 0x2620)
    298298                return 2523;
    299        
     299
    300300        if (ch == 0x2622)
    301301                return 2524;
    302        
     302
    303303        if (ch == 0x2626)
    304304                return 2525;
    305        
     305
    306306        if ((ch >= 0x2628) && (ch <= 0x262b))
    307307                return (ch - 7242);
    308        
     308
    309309        if ((ch >= 0x262e) && (ch <= 0x2637))
    310310                return (ch - 7244);
    311        
     311
    312312        if ((ch >= 0x2639) && (ch <= 0x2653))
    313313                return (ch - 7245);
    314        
     314
    315315        if ((ch >= 0x2660) && (ch <= 0x2667))
    316316                return (ch - 7257);
    317        
     317
    318318        if ((ch >= 0x2669) && (ch <= 0x266f))
    319319                return (ch - 7258);
    320        
     320
    321321        if ((ch >= 0xfb00) && (ch <= 0xfb05))
    322322                return (ch - 61674);
    323        
     323
    324324        if ((ch >= 0xfb50) && (ch <= 0xfbb1))
    325325                return (ch - 61748);
    326        
     326
    327327        if ((ch >= 0xfbd3) && (ch <= 0xfbe9))
    328328                return (ch - 61781);
    329        
     329
    330330        if ((ch >= 0xfbfc) && (ch <= 0xfbff))
    331331                return (ch - 61799);
    332        
     332
    333333        if ((ch >= 0xfc5b) && (ch <= 0xfc63))
    334334                return (ch - 61890);
    335        
     335
    336336        if (ch == 0xfc90)
    337337                return 2722;
    338        
     338
    339339        if ((ch >= 0xfcf2) && (ch <= 0xfcf4))
    340340                return (ch - 62031);
    341        
     341
    342342        if ((ch >= 0xfd3c) && (ch <= 0xfd3f))
    343343                return (ch - 62102);
    344        
     344
    345345        if (ch == 0xfdf2)
    346346                return 2730;
    347        
     347
    348348        if ((ch >= 0xfe50) && (ch <= 0xfe52))
    349349                return (ch - 62373);
    350        
     350
    351351        if ((ch >= 0xfe54) && (ch <= 0xfe66))
    352352                return (ch - 62374);
    353        
     353
    354354        if ((ch >= 0xfe68) && (ch <= 0xfe6b))
    355355                return (ch - 62375);
    356        
     356
    357357        if ((ch >= 0xfe70) && (ch <= 0xfe72))
    358358                return (ch - 62379);
    359        
     359
    360360        if (ch == 0xfe74)
    361361                return 2760;
    362        
     362
    363363        if ((ch >= 0xfe76) && (ch <= 0xfefc))
    364364                return (ch - 62381);
    365        
     365
    366366        if (ch == 0xfeff)
    367367                return 2896;
    368        
     368
    369369        if (found)
    370370                *found = false;
    371        
     371
    372372        return 2898;
    373373}
     
    32723272        {0xf1, 0x35, 0x55, 0x8a, 0xe0, 0x06, 0x95, 0xd6, 0xb5, 0x97, 0x00, 0xee, 0x8a, 0xee, 0x28, 0xe8},
    32733273        {0x00, 0x38, 0x7c, 0x7c, 0xc6, 0x92, 0xf2, 0xe6, 0xfe, 0xe6, 0x7c, 0x7c, 0x38, 0x00, 0x00, 0x00},
    3274        
     3274
    32753275        /* Special glyph for unknown character */
    32763276        {0x00, 0x00, 0x7c, 0xc6, 0xc6, 0x0c, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00}
  • uspace/lib/draw/path.c

    r3061bc1 r8565a42  
    8383                step->to_y = path->cur_y;
    8484                list_append(&step->link, &path->list);
    85                
     85
    8686        }
    8787}
  • uspace/lib/draw/source.c

    r3061bc1 r8565a42  
    4242        transform_identity(&source->transform);
    4343        source->filter = filter_nearest;
    44        
     44
    4545        source->color = PIXEL(0, 0, 0, 0);
    4646        source->texture = NULL;
  • uspace/lib/draw/surface.c

    r3061bc1 r8565a42  
    5959                return NULL;
    6060        }
    61        
     61
    6262        size_t pixbuf_size = width * height * sizeof(pixel_t);
    6363
     
    124124        assert(width);
    125125        assert(height);
    126        
     126
    127127        *width = surface->pixmap.width;
    128128        *height = surface->pixmap.height;
Note: See TracChangeset for help on using the changeset viewer.