Changeset bea947f in mainline for uspace/srv/hid/display/window.c
- Timestamp:
- 2020-05-24T17:59:02Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b3b00b6
- Parents:
- ef20a91
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/display/window.c
ref20a91 rbea947f 131 131 { 132 132 ds_window_t *wnd = (ds_window_t *) arg; 133 ds_window_bitmap_t * cbm = NULL;133 ds_window_bitmap_t *wbm = NULL; 134 134 errno_t rc; 135 135 136 cbm = calloc(1, sizeof(ds_window_bitmap_t));137 if ( cbm == NULL)136 wbm = calloc(1, sizeof(ds_window_bitmap_t)); 137 if (wbm == NULL) 138 138 return ENOMEM; 139 139 140 140 rc = gfx_bitmap_create(ds_display_get_gc(wnd->display), params, alloc, 141 & cbm->bitmap);141 &wbm->bitmap); 142 142 if (rc != EOK) 143 143 goto error; 144 144 145 cbm->wnd = wnd; 146 cbm->rect = params->rect; 147 *rbm = (void *)cbm; 145 wbm->wnd = wnd; 146 wbm->rect = params->rect; 147 wbm->flags = params->flags; 148 wbm->key_color = params->key_color; 149 *rbm = (void *)wbm; 148 150 return EOK; 149 151 error: 150 if ( cbm != NULL)151 free( cbm);152 if (wbm != NULL) 153 free(wbm); 152 154 return rc; 153 155 } … … 160 162 static errno_t ds_window_bitmap_destroy(void *bm) 161 163 { 162 ds_window_bitmap_t * cbm = (ds_window_bitmap_t *)bm;163 164 gfx_bitmap_destroy( cbm->bitmap);165 free( cbm);164 ds_window_bitmap_t *wbm = (ds_window_bitmap_t *)bm; 165 166 gfx_bitmap_destroy(wbm->bitmap); 167 free(wbm); 166 168 return EOK; 167 169 } … … 177 179 gfx_coord2_t *offs0) 178 180 { 179 ds_window_bitmap_t * cbm = (ds_window_bitmap_t *)bm;181 ds_window_bitmap_t *wbm = (ds_window_bitmap_t *)bm; 180 182 gfx_coord2_t doffs; 181 183 gfx_coord2_t offs; … … 192 194 if (srect0 != NULL) { 193 195 /* Clip source rectangle to bitmap rectangle */ 194 gfx_rect_clip(srect0, & cbm->rect, &srect);196 gfx_rect_clip(srect0, &wbm->rect, &srect); 195 197 } else { 196 198 /* Source is entire bitmap rectangle */ 197 srect = cbm->rect;199 srect = wbm->rect; 198 200 } 199 201 … … 206 208 207 209 /* Transform window rectangle back to bitmap coordinate system */ 208 gfx_rect_rtranslate(&offs, & cbm->wnd->rect, &swrect);210 gfx_rect_rtranslate(&offs, &wbm->wnd->rect, &swrect); 209 211 210 212 /* Clip so that transformed rectangle will be inside the window */ … … 212 214 213 215 /* Offset for rendering on screen = window pos + offs */ 214 gfx_coord2_add(& cbm->wnd->dpos, &offs, &doffs);216 gfx_coord2_add(&wbm->wnd->dpos, &offs, &doffs); 215 217 216 218 /* Resulting rectangle on the screen we are drawing into */ 217 219 gfx_rect_translate(&doffs, &crect, &drect); 218 220 219 rc = gfx_bitmap_get_alloc( cbm->bitmap, &alloc);221 rc = gfx_bitmap_get_alloc(wbm->bitmap, &alloc); 220 222 if (rc != EOK) 221 223 return rc; 222 224 223 pixelmap.width = cbm->rect.p1.x - cbm->rect.p0.x;224 pixelmap.height = cbm->rect.p1.y - cbm->rect.p0.y;225 pixelmap.width = wbm->rect.p1.x - wbm->rect.p0.x; 226 pixelmap.height = wbm->rect.p1.y - wbm->rect.p0.y; 225 227 pixelmap.data = alloc.pixels; 226 228 227 229 /* Render a copy to the backbuffer */ 228 for (y = crect.p0.y; y < crect.p1.y; y++) { 229 for (x = crect.p0.x; x < crect.p1.x; x++) { 230 pixel = pixelmap_get_pixel(&pixelmap, 231 x - cbm->rect.p0.x, y - cbm->rect.p0.y); 232 pixelmap_put_pixel(&cbm->wnd->pixelmap, 233 x + offs.x - cbm->rect.p0.x + cbm->wnd->rect.p0.x, 234 y + offs.y - cbm->rect.p0.y + cbm->wnd->rect.p0.y, 235 pixel); 230 if ((wbm->flags & bmpf_color_key) == 0) { 231 for (y = crect.p0.y; y < crect.p1.y; y++) { 232 for (x = crect.p0.x; x < crect.p1.x; x++) { 233 pixel = pixelmap_get_pixel(&pixelmap, 234 x - wbm->rect.p0.x, y - wbm->rect.p0.y); 235 pixelmap_put_pixel(&wbm->wnd->pixelmap, 236 x + offs.x - wbm->rect.p0.x + wbm->wnd->rect.p0.x, 237 y + offs.y - wbm->rect.p0.y + wbm->wnd->rect.p0.y, 238 pixel); 239 } 236 240 } 241 } else { 242 for (y = crect.p0.y; y < crect.p1.y; y++) { 243 for (x = crect.p0.x; x < crect.p1.x; x++) { 244 pixel = pixelmap_get_pixel(&pixelmap, 245 x - wbm->rect.p0.x, y - wbm->rect.p0.y); 246 if (pixel != wbm->key_color) { 247 pixelmap_put_pixel(&wbm->wnd->pixelmap, 248 x + offs.x - wbm->rect.p0.x + 249 wbm->wnd->rect.p0.x, 250 y + offs.y - wbm->rect.p0.y + 251 wbm->wnd->rect.p0.y, 252 pixel); 253 } 254 } 255 } 237 256 } 238 257 239 258 /* Repaint this area of the display */ 240 return ds_display_paint( cbm->wnd->display, &drect);259 return ds_display_paint(wbm->wnd->display, &drect); 241 260 } 242 261 … … 249 268 static errno_t ds_window_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc) 250 269 { 251 ds_window_bitmap_t * cbm = (ds_window_bitmap_t *)bm;252 253 return gfx_bitmap_get_alloc( cbm->bitmap, alloc);270 ds_window_bitmap_t *wbm = (ds_window_bitmap_t *)bm; 271 272 return gfx_bitmap_get_alloc(wbm->bitmap, alloc); 254 273 } 255 274
Note:
See TracChangeset
for help on using the changeset viewer.