Changeset 7e38970d in mainline for uspace/lib/c/include/io/pixelmap.h
- Timestamp:
- 2020-12-07T00:08:37Z (4 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 25f26600
- Parents:
- 7a873f0 (diff), 8596474 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/include/io/pixelmap.h
r7a873f0 r7e38970d 42 42 #include <stddef.h> 43 43 #include <io/pixel.h> 44 45 /* Defines how a pixel outside of pixmap rectangle shall be treated */46 typedef enum {47 /* Pixels outside of a pixmap are PIXEL(0, 0, 0, 0) */48 PIXELMAP_EXTEND_TRANSPARENT_BLACK = 0,49 50 /* The pixmap is repeated infinetely */51 PIXELMAP_EXTEND_TILE,52 53 /* If outside of a pixmap, return closest pixel from the edge */54 PIXELMAP_EXTEND_SIDES,55 56 /*57 * If outside of a pixmap, return closest pixel from the edge,58 * with alpha = 059 */60 PIXELMAP_EXTEND_TRANSPARENT_SIDES61 } pixelmap_extend_t;62 44 63 45 typedef struct { … … 106 88 } 107 89 108 static inline pixel_t pixelmap_get_extended_pixel(pixelmap_t *pixmap,109 native_t x, native_t y, pixelmap_extend_t extend)110 {111 bool transparent = false;112 if (extend == PIXELMAP_EXTEND_TILE) {113 x %= pixmap->width;114 y %= pixmap->height;115 } else if (extend == PIXELMAP_EXTEND_SIDES ||116 extend == PIXELMAP_EXTEND_TRANSPARENT_SIDES) {117 bool transparent_outside =118 (extend == PIXELMAP_EXTEND_TRANSPARENT_SIDES);119 if (x < 0) {120 x = 0;121 transparent = transparent_outside;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 } else if (((sysarg_t) y) >= pixmap->height) {131 y = pixmap->height - 1;132 transparent = transparent_outside;133 }134 }135 136 if (x < 0 || ((sysarg_t) x) >= pixmap->width ||137 y < 0 || ((sysarg_t) y) >= pixmap->height)138 return PIXEL(0, 0, 0, 0);139 140 pixel_t pixel = pixelmap_get_pixel(pixmap, x, y);141 142 if (transparent)143 pixel = PIXEL(0, RED(pixel), GREEN(pixel), BLUE(pixel));144 145 return pixel;146 }147 148 90 #endif 149 91
Note:
See TracChangeset
for help on using the changeset viewer.