Changeset 5713e5f in mainline for uspace/lib/c


Ignore:
Timestamp:
2014-09-01T19:17:55Z (11 years ago)
Author:
Martin Sucha <sucha14@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
21365c0
Parents:
a4666a9 (diff), 00ddb40 (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.
Message:

Merge improvements in the graphics stack.

  • Support for drawing proportional fonts (although no actual font file included yet)
  • Implementation of bilinear filter
Location:
uspace/lib/c
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/io/asprintf.c

    ra4666a9 r5713e5f  
    7676 *             the newly allocated string.
    7777 * @fmt        Format string.
     78 * @args       Variable argument list
     79 *
     80 * @return Number of characters printed or a negative error code.
     81 *
     82 */
     83int vasprintf(char **strp, const char *fmt, va_list args)
     84{
     85        va_list args2;
     86        va_copy(args2, args);
     87        int ret = vprintf_size(fmt, args2);
     88        va_end(args2);
     89       
     90        if (ret > 0) {
     91                *strp = malloc(STR_BOUNDS(ret) + 1);
     92                if (*strp == NULL)
     93                        return -1;
     94               
     95                vsnprintf(*strp, STR_BOUNDS(ret) + 1, fmt, args);
     96        }
     97       
     98        return ret;
     99}
     100
     101/** Allocate and print to string.
     102 *
     103 * @param strp Address of the pointer where to store the address of
     104 *             the newly allocated string.
     105 * @fmt        Format string.
    78106 *
    79107 * @return Number of characters printed or a negative error code.
     
    84112        va_list args;
    85113        va_start(args, fmt);
    86         int ret = vprintf_size(fmt, args);
     114        int ret = vasprintf(strp, fmt, args);
    87115        va_end(args);
    88        
    89         if (ret > 0) {
    90                 *strp = malloc(STR_BOUNDS(ret) + 1);
    91                 if (*strp == NULL)
    92                         return -1;
    93                
    94                 va_start(args, fmt);
    95                 vsnprintf(*strp, STR_BOUNDS(ret) + 1, fmt, args);
    96                 va_end(args);
    97         }
    98116       
    99117        return ret;
  • uspace/lib/c/include/io/pixelmap.h

    ra4666a9 r5713e5f  
    11/*
    22 * Copyright (c) 2011 Petr Koupy
     3 * Copyright (c) 2014 Martin Sucha
    34 * All rights reserved.
    45 *
     
    4041#include <unistd.h>
    4142#include <io/pixel.h>
     43
     44/* Defines how a pixel outside of pixmap rectangle shall be treated */
     45typedef enum {
     46        /* Pixels outside of a pixmap are PIXEL(0, 0, 0, 0) */
     47        PIXELMAP_EXTEND_TRANSPARENT_BLACK = 0,
     48       
     49        /* The pixmap is repeated infinetely */
     50        PIXELMAP_EXTEND_TILE,
     51       
     52        /* If outside of a pixmap, return closest pixel from the edge */
     53        PIXELMAP_EXTEND_SIDES,
     54       
     55        /* If outside of a pixmap, return closest pixel from the edge,
     56         * with alpha = 0
     57         */
     58        PIXELMAP_EXTEND_TRANSPARENT_SIDES
     59} pixelmap_extend_t;
    4260
    4361typedef struct {
     
    86104}
    87105
     106static inline pixel_t pixelmap_get_extended_pixel(pixelmap_t *pixmap,
     107    native_t x, native_t y, pixelmap_extend_t extend)
     108{
     109        bool transparent = false;
     110        if (extend == PIXELMAP_EXTEND_TILE) {
     111                x %= pixmap->width;
     112                y %= pixmap->height;
     113        }
     114        else if (extend == PIXELMAP_EXTEND_SIDES ||
     115            extend == PIXELMAP_EXTEND_TRANSPARENT_SIDES) {
     116                bool transparent_outside =
     117                    (extend == PIXELMAP_EXTEND_TRANSPARENT_SIDES);
     118                if (x < 0) {
     119                        x = 0;
     120                        transparent = transparent_outside;
     121                }
     122                else if (((sysarg_t) x) >= pixmap->width) {
     123                        x = pixmap->width - 1;
     124                        transparent = transparent_outside;
     125                }
     126               
     127                if (y < 0) {
     128                        y = 0;
     129                        transparent = transparent_outside;
     130                }
     131                else if (((sysarg_t) y) >= pixmap->height) {
     132                        y = pixmap->height - 1;
     133                        transparent = transparent_outside;
     134                }
     135        }
     136       
     137        if (x < 0 || ((sysarg_t) x) >= pixmap->width ||
     138            y < 0 || ((sysarg_t) y) >= pixmap->height)
     139                return PIXEL(0, 0, 0, 0);
     140
     141        pixel_t pixel = pixelmap_get_pixel(pixmap, x, y);
     142       
     143        if (transparent)
     144                pixel = PIXEL(0, RED(pixel), GREEN(pixel), BLUE(pixel));
     145       
     146        return pixel;
     147}
     148
     149
    88150#endif
    89151
  • uspace/lib/c/include/stdio.h

    ra4666a9 r5713e5f  
    120120extern int snprintf(char *, size_t , const char *, ...)
    121121    PRINTF_ATTRIBUTE(3, 4);
     122extern int vasprintf(char **, const char *, va_list);
    122123extern int asprintf(char **, const char *, ...)
    123124    PRINTF_ATTRIBUTE(2, 3);
Note: See TracChangeset for help on using the changeset viewer.