Changeset 00ddb40 in mainline
- Timestamp:
- 2014-08-31T20:10:20Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5713e5f
- Parents:
- 8d3512f1
- Location:
- uspace
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/include/io/pixelmap.h
r8d3512f1 r00ddb40 1 1 /* 2 2 * Copyright (c) 2011 Petr Koupy 3 * Copyright (c) 2014 Martin Sucha 3 4 * All rights reserved. 4 5 * … … 40 41 #include <unistd.h> 41 42 #include <io/pixel.h> 43 44 /* Defines how a pixel outside of pixmap rectangle shall be treated */ 45 typedef 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; 42 60 43 61 typedef struct { … … 86 104 } 87 105 106 static 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 88 150 #endif 89 151 -
uspace/lib/draw/font/bitmap_backend.c
r8d3512f1 r00ddb40 143 143 source_t source; 144 144 source_init(&source); 145 source_set_texture(&source, raw_surface, false);145 source_set_texture(&source, raw_surface, PIXELMAP_EXTEND_TRANSPARENT_BLACK); 146 146 147 147 transform_t transform; -
uspace/lib/draw/source.c
r8d3512f1 r00ddb40 45 45 source->color = PIXEL(0, 0, 0, 0); 46 46 source->texture = NULL; 47 source->texture_ tile = false;47 source->texture_extend = PIXELMAP_EXTEND_TRANSPARENT_BLACK; 48 48 49 49 source->alpha = PIXEL(255, 0, 0, 0); 50 50 source->mask = NULL; 51 source->mask_ tile = false;51 source->mask_extend = PIXELMAP_EXTEND_TRANSPARENT_BLACK; 52 52 } 53 53 … … 73 73 } 74 74 75 void source_set_texture(source_t *source, surface_t *texture, bool tile) 75 void source_set_texture(source_t *source, surface_t *texture, 76 pixelmap_extend_t extend) 76 77 { 77 78 source->texture = texture; 78 source->texture_ tile = tile;79 source->texture_extend = extend; 79 80 } 80 81 … … 84 85 } 85 86 86 void source_set_mask(source_t *source, surface_t *mask, bool tile) 87 void source_set_mask(source_t *source, surface_t *mask, 88 pixelmap_extend_t extend) 87 89 { 88 90 source->mask = mask; 89 source->mask_ tile = tile;91 source->mask_extend = extend; 90 92 } 91 93 … … 95 97 (source->alpha == (pixel_t) PIXEL(255, 0, 0, 0)) && 96 98 (source->texture != NULL) && 97 (source->texture_ tile == false) &&99 (source->texture_extend == PIXELMAP_EXTEND_TRANSPARENT_BLACK) && 98 100 (transform_is_fast(&source->transform))); 99 101 } … … 120 122 mask_pix = source->filter( 121 123 surface_pixmap_access(source->mask), 122 x, y, source->mask_ tile);124 x, y, source->mask_extend); 123 125 } else { 124 126 mask_pix = source->alpha; … … 133 135 texture_pix = source->filter( 134 136 surface_pixmap_access(source->texture), 135 x, y, source->texture_ tile);137 x, y, source->texture_extend); 136 138 } else { 137 139 texture_pix = source->color; -
uspace/lib/draw/source.h
r8d3512f1 r00ddb40 42 42 #include <transform.h> 43 43 #include <filter.h> 44 #include <io/pixelmap.h> 44 45 45 46 #include "surface.h" … … 51 52 pixel_t color; 52 53 surface_t *texture; 53 bool texture_tile;54 pixelmap_extend_t texture_extend; 54 55 55 56 pixel_t alpha; 56 57 surface_t *mask; 57 bool mask_tile;58 pixelmap_extend_t mask_extend; 58 59 } source_t; 59 60 … … 66 67 67 68 extern void source_set_color(source_t *, pixel_t); 68 extern void source_set_texture(source_t *, surface_t *, bool);69 extern void source_set_texture(source_t *, surface_t *, pixelmap_extend_t); 69 70 70 71 extern void source_set_alpha(source_t *, pixel_t); 71 extern void source_set_mask(source_t *, surface_t *, bool);72 extern void source_set_mask(source_t *, surface_t *, pixelmap_extend_t); 72 73 73 74 extern bool source_is_fast(source_t *); -
uspace/lib/gui/canvas.c
r8d3512f1 r00ddb40 58 58 source_init(&source); 59 59 source_set_transform(&source, transform); 60 source_set_texture(&source, canvas->surface, false); 60 source_set_texture(&source, canvas->surface, 61 PIXELMAP_EXTEND_TRANSPARENT_BLACK); 61 62 62 63 drawctx_t drawctx; -
uspace/lib/softrend/filter.c
r8d3512f1 r00ddb40 38 38 #include <io/pixel.h> 39 39 40 40 41 static long round(double val) 41 42 { … … 59 60 } 60 61 61 static pixel_t get_pixel(pixelmap_t *pixmap, sysarg_t x, sysarg_t y, bool tile)62 {63 if (tile) {64 x %= pixmap->width;65 y %= pixmap->height;66 }67 68 return pixelmap_get_pixel(pixmap, (sysarg_t) x, (sysarg_t) y);69 }70 62 71 63 static inline pixel_t blend_pixels(size_t count, float *weights, … … 84 76 } 85 77 86 pixel_t filter_nearest(pixelmap_t *pixmap, double x, double y, bool tile) 78 pixel_t filter_nearest(pixelmap_t *pixmap, double x, double y, 79 pixelmap_extend_t extend) 87 80 { 88 return get_pixel(pixmap, round(x), round(y), tile);81 return pixelmap_get_extended_pixel(pixmap, round(x), round(y), extend); 89 82 } 90 83 91 pixel_t filter_bilinear(pixelmap_t *pixmap, double x, double y, bool tile) 84 pixel_t filter_bilinear(pixelmap_t *pixmap, double x, double y, 85 pixelmap_extend_t extend) 92 86 { 93 87 long x1 = floor(x); … … 97 91 98 92 if (y1 == y2 && x1 == x2) { 99 return get_pixel(pixmap, (sysarg_t) x1, (sysarg_t) y1,100 tile);93 return pixelmap_get_extended_pixel(pixmap, 94 (sysarg_t) x1, (sysarg_t) y1, extend); 101 95 } 102 96 … … 105 99 106 100 pixel_t pixels[4]; 107 pixels[0] = get_pixel(pixmap, x1, y1, tile);108 pixels[1] = get_pixel(pixmap, x2, y1, tile);109 pixels[2] = get_pixel(pixmap, x1, y2, tile);110 pixels[3] = get_pixel(pixmap, x2, y2, tile);101 pixels[0] = pixelmap_get_extended_pixel(pixmap, x1, y1, extend); 102 pixels[1] = pixelmap_get_extended_pixel(pixmap, x2, y1, extend); 103 pixels[2] = pixelmap_get_extended_pixel(pixmap, x1, y2, extend); 104 pixels[3] = pixelmap_get_extended_pixel(pixmap, x2, y2, extend); 111 105 112 106 float weights[4]; … … 119 113 } 120 114 121 pixel_t filter_bicubic(pixelmap_t *pixmap, double x, double y, bool tile) 115 pixel_t filter_bicubic(pixelmap_t *pixmap, double x, double y, 116 pixelmap_extend_t extend) 122 117 { 123 118 // TODO -
uspace/lib/softrend/filter.h
r8d3512f1 r00ddb40 40 40 #include <io/pixelmap.h> 41 41 42 typedef pixel_t (*filter_t)(pixelmap_t *, double, double, bool);42 typedef pixel_t (*filter_t)(pixelmap_t *, double, double, pixelmap_extend_t); 43 43 44 extern pixel_t filter_nearest(pixelmap_t *, double, double, bool);45 extern pixel_t filter_bilinear(pixelmap_t *, double, double, bool);46 extern pixel_t filter_bicubic(pixelmap_t *, double, double, bool);44 extern pixel_t filter_nearest(pixelmap_t *, double, double, pixelmap_extend_t); 45 extern pixel_t filter_bilinear(pixelmap_t *, double, double, pixelmap_extend_t); 46 extern pixel_t filter_bicubic(pixelmap_t *, double, double, pixelmap_extend_t); 47 47 48 48 #endif -
uspace/srv/hid/compositor/compositor.c
r8d3512f1 r00ddb40 444 444 445 445 source_set_transform(&source, transform); 446 source_set_texture(&source, win->surface, false); 446 source_set_texture(&source, win->surface, 447 PIXELMAP_EXTEND_TRANSPARENT_SIDES); 447 448 source_set_alpha(&source, PIXEL(win->opacity, 0, 0, 0)); 448 449
Note:
See TracChangeset
for help on using the changeset viewer.