Changeset 946a666 in mainline
- Timestamp:
- 2020-01-17T15:40:43Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c79545e
- Parents:
- a40ae0d
- git-author:
- Jiri Svoboda <jiri@…> (2020-01-16 18:38:00)
- git-committer:
- Jiri Svoboda <jiri@…> (2020-01-17 15:40:43)
- Location:
- uspace/srv/hid/display
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/display/types/display/window.h
ra40ae0d r946a666 41 41 #include <gfx/context.h> 42 42 #include <gfx/coord.h> 43 #include <io/pixelmap.h> 43 44 44 45 typedef sysarg_t ds_wnd_id_t; … … 70 71 /** Graphic context */ 71 72 gfx_context_t *gc; 73 /** Bitmap in the display device */ 74 gfx_bitmap_t *bitmap; 75 /** Pixel map for accessing the window bitmap */ 76 pixelmap_t pixelmap; 77 /** Current drawing color */ 78 pixel_t color; 72 79 73 80 /** State */ -
uspace/srv/hid/display/window.c
ra40ae0d r946a666 42 42 #include <gfx/render.h> 43 43 #include <io/log.h> 44 #include <io/pixelmap.h> 44 45 #include <stdlib.h> 45 46 #include "client.h" … … 76 77 { 77 78 ds_window_t *wnd = (ds_window_t *) arg; 79 uint16_t r, g, b; 78 80 79 81 log_msg(LOG_DEFAULT, LVL_NOTE, "gc_set_color gc=%p", 80 82 ds_display_get_gc(wnd->display)); 83 84 gfx_color_get_rgb_i16(color, &r, &g, &b); 85 wnd->color = PIXEL(0, r >> 8, g >> 8, b >> 8); 86 81 87 return gfx_set_color(ds_display_get_gc(wnd->display), color); 82 88 } … … 94 100 gfx_rect_t crect; 95 101 gfx_rect_t drect; 102 gfx_coord_t x, y; 96 103 97 104 log_msg(LOG_DEFAULT, LVL_NOTE, "gc_fill_rect"); 105 98 106 gfx_rect_clip(rect, &wnd->rect, &crect); 99 107 gfx_rect_translate(&wnd->dpos, &crect, &drect); 108 109 /* Render a copy to the backbuffer */ 110 for (y = crect.p0.y; y < crect.p1.y; y++) { 111 for (x = crect.p0.x; x < crect.p1.x; x++) { 112 pixelmap_put_pixel(&wnd->pixelmap, x - wnd->rect.p0.x, 113 y - wnd->rect.p0.y, wnd->color); 114 } 115 } 116 100 117 return gfx_fill_rect(ds_display_get_gc(wnd->display), &drect); 101 118 } 102 119 103 /** Create bitmap in canvasGC.104 * 105 * @param arg CanvasGC120 /** Create bitmap in window GC. 121 * 122 * @param arg Window GC 106 123 * @param params Bitmap params 107 124 * @param alloc Bitmap allocation info or @c NULL … … 135 152 } 136 153 137 /** Destroy bitmap in canvasGC.154 /** Destroy bitmap in window GC. 138 155 * 139 156 * @param bm Bitmap … … 149 166 } 150 167 151 /** Render bitmap in canvasGC.168 /** Render bitmap in window GC. 152 169 * 153 170 * @param bm Bitmap … … 165 182 gfx_rect_t swrect; 166 183 gfx_rect_t crect; 184 gfx_coord_t x, y; 185 pixelmap_t pixelmap; 186 gfx_bitmap_alloc_t alloc; 187 pixel_t pixel; 188 errno_t rc; 167 189 168 190 if (srect0 != NULL) { … … 190 212 gfx_coord2_add(&cbm->wnd->dpos, &offs, &doffs); 191 213 192 return gfx_bitmap_render(cbm->bitmap, srect0, &doffs); 193 } 194 195 /** Get allocation info for bitmap in canvas GC. 214 rc = gfx_bitmap_get_alloc(cbm->bitmap, &alloc); 215 if (rc != EOK) 216 return rc; 217 218 pixelmap.width = cbm->rect.p1.x - cbm->rect.p0.x; 219 pixelmap.height = cbm->rect.p1.y - cbm->rect.p0.y; 220 pixelmap.data = alloc.pixels; 221 222 /* Render a copy to the backbuffer */ 223 for (y = crect.p0.y; y < crect.p1.y; y++) { 224 for (x = crect.p0.x; x < crect.p1.x; x++) { 225 pixel = pixelmap_get_pixel(&pixelmap, 226 x - cbm->rect.p0.x, y - cbm->rect.p0.y); 227 pixelmap_put_pixel(&cbm->wnd->pixelmap, 228 x + offs.x - cbm->rect.p0.x + cbm->wnd->rect.p0.x, 229 y + offs.y - cbm->rect.p0.y + cbm->wnd->rect.p0.y, 230 pixel); 231 } 232 } 233 234 return gfx_bitmap_render(cbm->bitmap, &crect, &doffs); 235 } 236 237 /** Get allocation info for bitmap in window GC. 196 238 * 197 239 * @param bm Bitmap … … 221 263 ds_window_t *wnd = NULL; 222 264 gfx_context_t *gc = NULL; 265 gfx_context_t *dgc; 266 gfx_rect_t rect; 267 gfx_coord2_t dims; 268 gfx_bitmap_params_t bparams; 269 gfx_bitmap_alloc_t alloc; 223 270 errno_t rc; 224 271 … … 235 282 ds_client_add_window(client, wnd); 236 283 ds_display_add_window(client->display, wnd); 284 285 gfx_rect_points_sort(¶ms->rect, &rect); 286 gfx_coord2_subtract(&rect.p1, &rect.p0, &dims); 287 288 bparams.rect = params->rect; 289 290 dgc = ds_display_get_gc(wnd->display); // XXX 291 if (dgc != NULL) { 292 rc = gfx_bitmap_create(dgc, &bparams, NULL, &wnd->bitmap); 293 if (rc != EOK) 294 goto error; 295 296 rc = gfx_bitmap_get_alloc(wnd->bitmap, &alloc); 297 if (rc != EOK) 298 goto error; 299 300 wnd->pixelmap.width = dims.x; 301 wnd->pixelmap.height = dims.y; 302 wnd->pixelmap.data = alloc.pixels; 303 } 304 305 if (wnd->pixelmap.data == NULL) { 306 rc = ENOMEM; 307 goto error; 308 } 237 309 238 310 wnd->rect = params->rect; … … 241 313 return EOK; 242 314 error: 243 if (wnd != NULL) 315 if (wnd != NULL) { 316 if (wnd->bitmap != NULL) 317 gfx_bitmap_destroy(wnd->bitmap); 244 318 free(wnd); 319 } 320 245 321 gfx_context_delete(gc); 246 322 return rc; … … 256 332 ds_display_remove_window(wnd); 257 333 (void) gfx_context_delete(wnd->gc); 334 if (wnd->bitmap != NULL) 335 gfx_bitmap_destroy(wnd->bitmap); 258 336 259 337 free(wnd); … … 268 346 { 269 347 return wnd->gc; 348 } 349 350 /** Repaint a window using its backing bitmap. 351 * 352 * @param wnd Window to repaint 353 * @return EOK on success or an error code 354 */ 355 static errno_t ds_window_repaint(ds_window_t *wnd) 356 { 357 log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_start_repaint"); 358 return gfx_bitmap_render(wnd->bitmap, NULL, &wnd->dpos); 270 359 } 271 360 … … 309 398 wnd->dpos = nwpos; 310 399 wnd->state = dsw_idle; 400 401 (void) ds_window_repaint(wnd); 311 402 } 312 403 … … 343 434 gc = ds_display_get_gc(wnd->display); // XXX 344 435 if (gc != NULL) { 345 gfx_set_color( ds_display_get_gc(wnd->display), color);346 gfx_fill_rect( ds_display_get_gc(wnd->display), &drect);436 gfx_set_color(gc, color); 437 gfx_fill_rect(gc, &drect); 347 438 } 348 439
Note:
See TracChangeset
for help on using the changeset viewer.