Changeset 7dba813 in mainline for uspace/lib/draw
- Timestamp:
- 2012-11-22T09:03:39Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ba733e83
- Parents:
- 8e6ec6e
- Location:
- uspace/lib/draw
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/draw/drawctx.c
r8e6ec6e r7dba813 129 129 } 130 130 131 bool clipped = false; 132 bool masked = false; 133 134 for (sysarg_t _y = y; _y < y + height; ++_y) { 135 for (sysarg_t _x = x; _x < x + width; ++_x) { 136 if (context->shall_clip) { 137 clipped = _x < context->clip_x && _x >= context->clip_width 138 && _y < context->clip_y && _y >= context->clip_height; 139 } 140 141 if (context->mask) { 142 pixel_t p = surface_get_pixel(context->mask, _x, _y); 143 masked = p > 0 ? false : true; 144 } 145 146 if (!clipped && !masked) { 147 pixel_t p_src = source_determine_pixel(context->source, _x, _y); 148 pixel_t p_dst = surface_get_pixel(context->surface, _x, _y); 149 pixel_t p_res = context->compose(p_src, p_dst); 150 surface_put_pixel(context->surface, _x, _y, p_res); 131 bool transfer_fast = source_is_fast(context->source) 132 && (context->shall_clip == false) 133 && (context->mask == NULL) 134 && (context->compose == compose_src || context->compose == compose_over); 135 136 if (transfer_fast) { 137 138 for (sysarg_t _y = y; _y < y + height; ++_y) { 139 pixel_t *src = source_direct_access(context->source, x, _y); 140 pixel_t *dst = pixelmap_pixel_at(surface_pixmap_access(context->surface), x, _y); 141 if (src && dst) { 142 sysarg_t count = width; 143 while (count-- != 0) { 144 *dst++ = *src++; 145 } 151 146 } 152 147 } 148 surface_add_damaged_region(context->surface, x, y, width, height); 149 150 } else { 151 152 bool clipped = false; 153 bool masked = false; 154 for (sysarg_t _y = y; _y < y + height; ++_y) { 155 for (sysarg_t _x = x; _x < x + width; ++_x) { 156 if (context->shall_clip) { 157 clipped = _x < context->clip_x && _x >= context->clip_width 158 && _y < context->clip_y && _y >= context->clip_height; 159 } 160 161 if (context->mask) { 162 pixel_t p = surface_get_pixel(context->mask, _x, _y); 163 masked = p > 0 ? false : true; 164 } 165 166 if (!clipped && !masked) { 167 pixel_t p_src = source_determine_pixel(context->source, _x, _y); 168 pixel_t p_dst = surface_get_pixel(context->surface, _x, _y); 169 pixel_t p_res = context->compose(p_src, p_dst); 170 surface_put_pixel(context->surface, _x, _y, p_res); 171 } 172 } 173 } 174 153 175 } 154 176 } -
uspace/lib/draw/source.c
r8e6ec6e r7dba813 90 90 } 91 91 92 bool source_is_fast(source_t *source) 93 { 94 return (source->mask == NULL) 95 && (source->alpha == (pixel_t) PIXEL(255, 0, 0, 0)) 96 && (source->texture != NULL) 97 && (source->texture_tile == false) 98 && transform_is_fast(&source->transform); 99 } 100 101 pixel_t *source_direct_access(source_t *source, double x, double y) 102 { 103 assert(source_is_fast(source)); 104 105 long _x = (long) (x + source->transform.m[0][2]); 106 long _y = (long) (y + source->transform.m[1][2]); 107 108 pixelmap_t *pixmap = surface_pixmap_access(source->texture); 109 if (_x < 0 || _x >= (long) pixmap->width || _y < 0 || _y >= (long) pixmap->height) { 110 return NULL; 111 } 112 113 return pixelmap_pixel_at(pixmap, (sysarg_t) _x, (sysarg_t) _y); 114 } 115 92 116 pixel_t source_determine_pixel(source_t *source, double x, double y) 93 117 { -
uspace/lib/draw/source.h
r8e6ec6e r7dba813 71 71 extern void source_set_mask(source_t *, surface_t *, bool); 72 72 73 extern bool source_is_fast(source_t *); 74 extern pixel_t *source_direct_access(source_t *, double, double); 73 75 extern pixel_t source_determine_pixel(source_t *, double, double); 74 76 -
uspace/lib/draw/surface.c
r8e6ec6e r7dba813 143 143 } 144 144 145 void surface_add_damaged_region(surface_t *surface, surface_coord_t x, surface_coord_t y, 146 surface_coord_t width, surface_coord_t height) 147 { 148 surface->dirty_x_lo = surface->dirty_x_lo > x ? x : surface->dirty_x_lo; 149 surface->dirty_y_lo = surface->dirty_y_lo > y ? y : surface->dirty_y_lo; 150 151 surface_coord_t x_hi = x + width - 1; 152 surface_coord_t y_hi = y + height - 1; 153 154 surface->dirty_x_hi = surface->dirty_x_hi < x_hi ? x_hi : surface->dirty_x_hi; 155 surface->dirty_y_hi = surface->dirty_y_hi < y_hi ? y_hi : surface->dirty_y_hi; 156 } 157 145 158 void surface_reset_damaged_region(surface_t *surface) 146 159 { -
uspace/lib/draw/surface.h
r8e6ec6e r7dba813 61 61 extern void surface_get_damaged_region(surface_t *, surface_coord_t *, surface_coord_t *, 62 62 surface_coord_t *, surface_coord_t *); 63 extern void surface_add_damaged_region(surface_t *, surface_coord_t , surface_coord_t , 64 surface_coord_t , surface_coord_t ); 63 65 extern void surface_reset_damaged_region(surface_t *); 64 66
Note:
See TracChangeset
for help on using the changeset viewer.