Changeset 7470d97 in mainline
- Timestamp:
- 2021-04-30T15:05:06Z (3 years ago)
- Branches:
- master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 051349b
- Parents:
- 252d03c
- Location:
- uspace
- Files:
-
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/fb/amdm37x_dispc/amdm37x_dispc.c
r252d03c r7470d97 1 1 /* 2 * Copyright (c) 202 0Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * Copyright (c) 2013 Jan Vesely 4 4 * All rights reserved. … … 67 67 static errno_t amdm37x_ddev_get_info(void *, ddev_info_t *); 68 68 69 static errno_t amdm37x_gc_set_clip_rect(void *, gfx_rect_t *); 69 70 static errno_t amdm37x_gc_set_color(void *, gfx_color_t *); 70 71 static errno_t amdm37x_gc_fill_rect(void *, gfx_rect_t *); … … 81 82 82 83 gfx_context_ops_t amdm37x_gc_ops = { 84 .set_clip_rect = amdm37x_gc_set_clip_rect, 83 85 .set_color = amdm37x_gc_set_color, 84 86 .fill_rect = amdm37x_gc_fill_rect, … … 291 293 dispc->rect.p1.x = x; 292 294 dispc->rect.p1.y = y; 295 dispc->clip_rect = dispc->rect; 293 296 dispc->size = size; 294 297 … … 321 324 } 322 325 326 /** Set clipping rectangle on AMDM37x display controller. 327 * 328 * @param arg AMDM37x display controller 329 * @param rect Rectangle 330 * 331 * @return EOK on success or an error code 332 */ 333 static errno_t amdm37x_gc_set_clip_rect(void *arg, gfx_rect_t *rect) 334 { 335 amdm37x_dispc_t *dispc = (amdm37x_dispc_t *) arg; 336 337 if (rect != NULL) 338 gfx_rect_clip(rect, &dispc->rect, &dispc->clip_rect); 339 else 340 dispc->clip_rect = dispc->rect; 341 342 return EOK; 343 } 344 323 345 /** Set color on AMDM37x display controller. 324 346 * … … 354 376 355 377 /* Make sure we have a sorted, clipped rectangle */ 356 gfx_rect_clip(rect, &dispc-> rect, &crect);378 gfx_rect_clip(rect, &dispc->clip_rect, &crect); 357 379 358 380 for (y = crect.p0.y; y < crect.p1.y; y++) { … … 479 501 pbm.data = dcbm->alloc.pixels; 480 502 481 /* Transform AMDM37x bounding rectangle back to bitmap coordinate system */482 gfx_rect_rtranslate(&offs, &dispc-> rect, &skfbrect);503 /* Transform AMDM37x clipping rectangle back to bitmap coordinate system */ 504 gfx_rect_rtranslate(&offs, &dispc->clip_rect, &skfbrect); 483 505 484 506 /* -
uspace/drv/fb/amdm37x_dispc/amdm37x_dispc.h
r252d03c r7470d97 1 1 /* 2 * Copyright (c) 202 0Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * Copyright (c) 2013 Jan Vesely 4 4 * All rights reserved. … … 63 63 pixel_t color; 64 64 gfx_rect_t rect; 65 gfx_rect_t clip_rect; 65 66 size_t size; 66 67 void *fb_data; -
uspace/drv/fb/kfb/port.c
r252d03c r7470d97 1 1 /* 2 * Copyright (c) 20 19Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * Copyright (c) 2006 Jakub Vana 4 4 * Copyright (c) 2006 Ondrej Palkovsky … … 69 69 sysarg_t paddr; 70 70 gfx_rect_t rect; 71 gfx_rect_t clip_rect; 71 72 size_t offset; 72 73 size_t scanline; … … 97 98 static errno_t kfb_ddev_get_info(void *, ddev_info_t *); 98 99 100 static errno_t kfb_gc_set_clip_rect(void *, gfx_rect_t *); 99 101 static errno_t kfb_gc_set_color(void *, gfx_color_t *); 100 102 static errno_t kfb_gc_fill_rect(void *, gfx_rect_t *); … … 111 113 112 114 static gfx_context_ops_t kfb_gc_ops = { 115 .set_clip_rect = kfb_gc_set_clip_rect, 113 116 .set_color = kfb_gc_set_color, 114 117 .fill_rect = kfb_gc_fill_rect, … … 134 137 ddev_info_init(info); 135 138 info->rect = kfb->rect; 139 return EOK; 140 } 141 142 /** Set clipping rectangle on KFB. 143 * 144 * @param arg KFB 145 * @param rect Rectangle or @c NULL 146 * 147 * @return EOK on success or an error code 148 */ 149 static errno_t kfb_gc_set_clip_rect(void *arg, gfx_rect_t *rect) 150 { 151 kfb_t *kfb = (kfb_t *) arg; 152 153 if (rect != NULL) 154 gfx_rect_clip(rect, &kfb->rect, &kfb->clip_rect); 155 else 156 kfb->clip_rect = kfb->rect; 157 136 158 return EOK; 137 159 } … … 361 383 } 362 384 363 #include <stdio.h>364 385 static void kfb_client_conn(ipc_call_t *icall, void *arg) 365 386 { … … 372 393 kfb = (kfb_t *) ddf_fun_data_get((ddf_fun_t *) arg); 373 394 374 printf("kfb_client_conn arg2=%lu arg3=%lu arg4=%lu\n",375 (unsigned long) ipc_get_arg2(icall),376 (unsigned long) ipc_get_arg3(icall),377 (unsigned long) ipc_get_arg4(icall));378 379 395 gc_id = ipc_get_arg3(icall); 380 396 … … 500 516 kfb->rect.p1.x = width; 501 517 kfb->rect.p1.y = height; 518 519 kfb->clip_rect = kfb->rect; 502 520 503 521 kfb->paddr = paddr; -
uspace/lib/congfx/private/console.h
r252d03c r7470d97 55 55 /** Console bounding rectangle */ 56 56 gfx_rect_t rect; 57 /** Clipping rectangle */ 58 gfx_rect_t clip_rect; 57 59 /** File for printing characters */ 58 60 FILE *fout; -
uspace/lib/congfx/src/console.c
r252d03c r7470d97 48 48 #include "../private/color.h" 49 49 50 static errno_t console_gc_set_clip_rect(void *, gfx_rect_t *); 50 51 static errno_t console_gc_set_color(void *, gfx_color_t *); 51 52 static errno_t console_gc_fill_rect(void *, gfx_rect_t *); … … 58 59 59 60 gfx_context_ops_t console_gc_ops = { 61 .set_clip_rect = console_gc_set_clip_rect, 60 62 .set_color = console_gc_set_color, 61 63 .fill_rect = console_gc_fill_rect, … … 67 69 }; 68 70 71 /** Set clipping rectangle on console GC. 72 * 73 * @param arg Console GC 74 * @param rect Rectangle 75 * 76 * @return EOK on success or an error code 77 */ 78 static errno_t console_gc_set_clip_rect(void *arg, gfx_rect_t *rect) 79 { 80 console_gc_t *cgc = (console_gc_t *) arg; 81 82 if (rect != NULL) 83 gfx_rect_clip(rect, &cgc->rect, &cgc->clip_rect); 84 else 85 cgc->clip_rect = cgc->rect; 86 87 return EOK; 88 } 89 69 90 /** Set color on console GC. 70 91 * … … 100 121 101 122 /* Make sure rectangle is clipped and sorted */ 102 gfx_rect_clip(rect, &cgc-> rect, &crect);123 gfx_rect_clip(rect, &cgc->clip_rect, &crect); 103 124 104 125 cols = cgc->rect.p1.x - cgc->rect.p0.x; … … 188 209 cgc->rect.p1.x = cols; 189 210 cgc->rect.p1.y = rows; 211 cgc->clip_rect = cgc->rect; 190 212 cgc->buf = buf; 191 213 … … 330 352 331 353 gfx_rect_translate(&offs, &srect, &drect); 332 gfx_rect_clip(&drect, &cbm->cgc-> rect, &crect);354 gfx_rect_clip(&drect, &cbm->cgc->clip_rect, &crect); 333 355 334 356 pixelmap.width = cbm->rect.p1.x - cbm->rect.p0.x; -
uspace/lib/gfx/include/gfx/render.h
r252d03c r7470d97 42 42 #include <types/gfx/context.h> 43 43 44 extern errno_t gfx_set_clip_rect(gfx_context_t *, gfx_rect_t *); 44 45 extern errno_t gfx_set_color(gfx_context_t *, gfx_color_t *); 45 46 extern errno_t gfx_fill_rect(gfx_context_t *, gfx_rect_t *); -
uspace/lib/gfx/include/types/gfx/ops/context.h
r252d03c r7470d97 47 47 /** Graphics context ops */ 48 48 typedef struct { 49 /** Set clipping rectangle */ 50 errno_t (*set_clip_rect)(void *, gfx_rect_t *); 49 51 /** Set drawing color */ 50 52 errno_t (*set_color)(void *, gfx_color_t *); -
uspace/lib/gfx/src/render.c
r252d03c r7470d97 36 36 #include <gfx/render.h> 37 37 #include "../private/context.h" 38 39 /** Set clipping rectangle. 40 * 41 * @param gc Graphic context 42 * @param rect Rectangle or @c NULL (no extra clipping) 43 * 44 * @return EOK on success, ENOMEM if insufficient resources, 45 * EIO if grahic device connection was lost 46 */ 47 errno_t gfx_set_clip_rect(gfx_context_t *gc, gfx_rect_t *rect) 48 { 49 return gc->ops->set_clip_rect(gc->arg, rect); 50 } 38 51 39 52 /** Set drawing color. -
uspace/lib/gfx/test/render.c
r252d03c r7470d97 38 38 PCUT_TEST_SUITE(render); 39 39 40 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *); 40 41 static errno_t testgc_set_color(void *, gfx_color_t *); 41 42 static errno_t testgc_fill_rect(void *, gfx_rect_t *); … … 43 44 44 45 static gfx_context_ops_t ops = { 46 .set_clip_rect = testgc_set_clip_rect, 45 47 .set_color = testgc_set_color, 46 48 .fill_rect = testgc_fill_rect, … … 50 52 /** Test graphics context data */ 51 53 typedef struct { 54 errno_t rc; 55 56 bool set_clip_rect; 57 gfx_rect_t crect; 58 bool do_clip; 59 60 bool set_color; 52 61 gfx_color_t *dclr; 53 gfx_rect_t *rect; 54 bool updated; 62 63 bool fill_rect; 64 gfx_rect_t frect; 65 66 bool update; 55 67 } test_gc_t; 56 68 69 /** Set clipping rectangle */ 70 PCUT_TEST(set_clip_rect) 71 { 72 errno_t rc; 73 gfx_rect_t rect; 74 gfx_context_t *gc = NULL; 75 test_gc_t tgc; 76 77 memset(&tgc, 0, sizeof(tgc)); 78 79 rc = gfx_context_new(&ops, &tgc, &gc); 80 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 81 82 rect.p0.x = 1; 83 rect.p0.y = 2; 84 rect.p1.x = 3; 85 rect.p1.y = 4; 86 87 tgc.rc = EOK; 88 89 rc = gfx_set_clip_rect(gc, &rect); 90 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 91 92 PCUT_ASSERT_TRUE(tgc.set_clip_rect); 93 PCUT_ASSERT_TRUE(tgc.do_clip); 94 PCUT_ASSERT_INT_EQUALS(rect.p0.x, tgc.crect.p0.x); 95 PCUT_ASSERT_INT_EQUALS(rect.p0.y, tgc.crect.p0.y); 96 PCUT_ASSERT_INT_EQUALS(rect.p1.x, tgc.crect.p1.x); 97 PCUT_ASSERT_INT_EQUALS(rect.p1.y, tgc.crect.p1.y); 98 99 rc = gfx_context_delete(gc); 100 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 101 } 102 103 /** Set null clipping rectangle */ 104 PCUT_TEST(set_clip_rect_null) 105 { 106 errno_t rc; 107 gfx_context_t *gc = NULL; 108 test_gc_t tgc; 109 110 memset(&tgc, 0, sizeof(tgc)); 111 112 rc = gfx_context_new(&ops, &tgc, &gc); 113 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 114 115 tgc.rc = EOK; 116 117 rc = gfx_set_clip_rect(gc, NULL); 118 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 119 120 PCUT_ASSERT_TRUE(tgc.set_clip_rect); 121 PCUT_ASSERT_FALSE(tgc.do_clip); 122 123 rc = gfx_context_delete(gc); 124 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 125 } 126 127 /** Set clipping rectangle with error return */ 128 PCUT_TEST(set_clip_rect_failure) 129 { 130 errno_t rc; 131 gfx_rect_t rect; 132 gfx_context_t *gc = NULL; 133 test_gc_t tgc; 134 135 memset(&tgc, 0, sizeof(tgc)); 136 137 rc = gfx_context_new(&ops, &tgc, &gc); 138 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 139 140 tgc.rc = EIO; 141 142 rc = gfx_set_clip_rect(gc, &rect); 143 PCUT_ASSERT_ERRNO_VAL(EIO, rc); 144 145 rc = gfx_context_delete(gc); 146 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 147 } 148 149 /** Set drawing color */ 57 150 PCUT_TEST(set_color) 58 151 { … … 60 153 gfx_color_t *color; 61 154 gfx_context_t *gc = NULL; 155 uint16_t r, g, b; 62 156 test_gc_t tgc; 63 157 … … 70 164 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 71 165 166 PCUT_ASSERT_FALSE(tgc.set_color); 167 168 tgc.rc = EOK; 169 72 170 rc = gfx_set_color(gc, color); 73 171 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 74 PCUT_ASSERT_EQUALS(color, tgc.dclr); 75 PCUT_ASSERT_NULL(tgc.rect); 172 173 PCUT_ASSERT_TRUE(tgc.set_color); 174 175 gfx_color_get_rgb_i16(tgc.dclr, &r, &g, &b); 176 177 PCUT_ASSERT_INT_EQUALS(0xffff, r); 178 PCUT_ASSERT_INT_EQUALS(0xffff, g); 179 PCUT_ASSERT_INT_EQUALS(0xffff, b); 180 181 rc = gfx_context_delete(gc); 182 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 183 } 184 185 /** Set drawing color with error return */ 186 PCUT_TEST(set_color_failure) 187 { 188 errno_t rc; 189 gfx_color_t *color; 190 gfx_context_t *gc = NULL; 191 test_gc_t tgc; 192 193 memset(&tgc, 0, sizeof(tgc)); 194 195 rc = gfx_context_new(&ops, &tgc, &gc); 196 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 197 198 rc = gfx_color_new_rgb_i16(0xffff, 0xffff, 0xffff, &color); 199 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 200 201 PCUT_ASSERT_FALSE(tgc.set_color); 202 203 tgc.rc = EIO; 204 205 rc = gfx_set_color(gc, color); 206 PCUT_ASSERT_ERRNO_VAL(EIO, rc); 76 207 77 208 gfx_color_delete(color); … … 81 212 } 82 213 214 /** Fill rectangle */ 83 215 PCUT_TEST(fill_rect) 84 216 { 85 217 errno_t rc; 86 gfx_color_t *color;87 218 gfx_rect_t rect; 88 219 gfx_context_t *gc = NULL; … … 94 225 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 95 226 96 rc = gfx_color_new_rgb_i16(0xffff, 0xffff, 0xffff, &color); 97 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 98 99 rc = gfx_set_color(gc, color); 100 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 101 PCUT_ASSERT_EQUALS(color, tgc.dclr); 227 rect.p0.x = 1; 228 rect.p0.y = 2; 229 rect.p1.x = 3; 230 rect.p1.y = 4; 231 232 PCUT_ASSERT_FALSE(tgc.fill_rect); 233 234 tgc.rc = EOK; 102 235 103 236 rc = gfx_fill_rect(gc, &rect); 104 237 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 105 PCUT_ASSERT_EQUALS(&rect, tgc.rect); 106 107 gfx_color_delete(color); 108 109 rc = gfx_context_delete(gc); 110 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 111 } 112 238 239 PCUT_ASSERT_TRUE(tgc.fill_rect); 240 PCUT_ASSERT_INT_EQUALS(rect.p0.x, tgc.frect.p0.x); 241 PCUT_ASSERT_INT_EQUALS(rect.p0.y, tgc.frect.p0.y); 242 PCUT_ASSERT_INT_EQUALS(rect.p1.x, tgc.frect.p1.x); 243 PCUT_ASSERT_INT_EQUALS(rect.p1.y, tgc.frect.p1.y); 244 245 rc = gfx_context_delete(gc); 246 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 247 } 248 249 /** Fill rectangle with error return */ 250 PCUT_TEST(fill_rect_failure) 251 { 252 errno_t rc; 253 gfx_rect_t rect; 254 gfx_context_t *gc = NULL; 255 test_gc_t tgc; 256 257 memset(&tgc, 0, sizeof(tgc)); 258 259 rc = gfx_context_new(&ops, &tgc, &gc); 260 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 261 262 rect.p0.x = 1; 263 rect.p0.y = 2; 264 rect.p1.x = 3; 265 rect.p1.y = 4; 266 267 PCUT_ASSERT_FALSE(tgc.fill_rect); 268 269 tgc.rc = EIO; 270 271 rc = gfx_fill_rect(gc, &rect); 272 PCUT_ASSERT_ERRNO_VAL(EIO, rc); 273 274 rc = gfx_context_delete(gc); 275 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 276 } 277 278 /** Update GC */ 113 279 PCUT_TEST(update) 114 280 { … … 122 288 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 123 289 124 PCUT_ASSERT_FALSE(tgc.updated); 125 gfx_update(gc); 126 PCUT_ASSERT_TRUE(tgc.updated); 127 128 rc = gfx_context_delete(gc); 129 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 290 tgc.rc = EOK; 291 292 PCUT_ASSERT_FALSE(tgc.update); 293 rc = gfx_update(gc); 294 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 295 PCUT_ASSERT_TRUE(tgc.update); 296 297 rc = gfx_context_delete(gc); 298 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 299 } 300 301 /** Update GC with error return */ 302 PCUT_TEST(update_failure) 303 { 304 errno_t rc; 305 gfx_context_t *gc = NULL; 306 test_gc_t tgc; 307 308 memset(&tgc, 0, sizeof(tgc)); 309 310 rc = gfx_context_new(&ops, &tgc, &gc); 311 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 312 313 tgc.rc = EIO; 314 rc = gfx_update(gc); 315 316 PCUT_ASSERT_ERRNO_VAL(EIO, rc); 317 318 rc = gfx_context_delete(gc); 319 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 320 } 321 322 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect) 323 { 324 test_gc_t *tgc = (test_gc_t *) arg; 325 326 tgc->set_clip_rect = true; 327 if (rect != NULL) { 328 tgc->do_clip = true; 329 tgc->crect = *rect; 330 } else { 331 tgc->do_clip = false; 332 } 333 334 return tgc->rc; 130 335 } 131 336 … … 133 338 { 134 339 test_gc_t *tgc = (test_gc_t *) arg; 340 341 tgc->set_color = true; 135 342 136 343 /* Technically we should copy the data */ 137 344 tgc->dclr = color; 138 return EOK;345 return tgc->rc; 139 346 } 140 347 … … 143 350 test_gc_t *tgc = (test_gc_t *) arg; 144 351 145 /* Technically we should copy the data */146 tgc-> rect =rect;147 return EOK;352 tgc->fill_rect = true; 353 tgc->frect = *rect; 354 return tgc->rc; 148 355 } 149 356 … … 152 359 test_gc_t *tgc = (test_gc_t *) arg; 153 360 154 tgc->update d= true;155 return EOK;361 tgc->update = true; 362 return tgc->rc; 156 363 } 157 364 -
uspace/lib/gfxfont/test/font.c
r252d03c r7470d97 1 1 /* 2 * Copyright (c) 202 0Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 39 39 PCUT_TEST_SUITE(font); 40 40 41 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *); 41 42 static errno_t testgc_set_color(void *, gfx_color_t *); 42 43 static errno_t testgc_fill_rect(void *, gfx_rect_t *); … … 48 49 49 50 static gfx_context_ops_t test_ops = { 51 .set_clip_rect = testgc_set_clip_rect, 50 52 .set_color = testgc_set_color, 51 53 .fill_rect = testgc_fill_rect, … … 568 570 } 569 571 } 572 } 573 574 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect) 575 { 576 return EOK; 570 577 } 571 578 -
uspace/lib/gfxfont/test/glyph.c
r252d03c r7470d97 1 1 /* 2 * Copyright (c) 202 0Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 43 43 PCUT_TEST_SUITE(glyph); 44 44 45 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *); 45 46 static errno_t testgc_set_color(void *, gfx_color_t *); 46 47 static errno_t testgc_fill_rect(void *, gfx_rect_t *); … … 52 53 53 54 static gfx_context_ops_t test_ops = { 55 .set_clip_rect = testgc_set_clip_rect, 54 56 .set_color = testgc_set_color, 55 57 .fill_rect = testgc_fill_rect, … … 567 569 rc = gfx_context_delete(gc); 568 570 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 571 } 572 573 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect) 574 { 575 return EOK; 569 576 } 570 577 -
uspace/lib/gfxfont/test/glyph_bmp.c
r252d03c r7470d97 1 1 /* 2 * Copyright (c) 202 0Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 39 39 PCUT_TEST_SUITE(glyph_bmp); 40 40 41 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *); 41 42 static errno_t testgc_set_color(void *, gfx_color_t *); 42 43 static errno_t testgc_fill_rect(void *, gfx_rect_t *); … … 48 49 49 50 static gfx_context_ops_t test_ops = { 51 .set_clip_rect = testgc_set_clip_rect, 50 52 .set_color = testgc_set_color, 51 53 .fill_rect = testgc_fill_rect, … … 581 583 rc = gfx_context_delete(gc); 582 584 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 585 } 586 587 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect) 588 { 589 return EOK; 583 590 } 584 591 -
uspace/lib/gfxfont/test/text.c
r252d03c r7470d97 1 1 /* 2 * Copyright (c) 202 0Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 40 40 PCUT_TEST_SUITE(text); 41 41 42 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *); 42 43 static errno_t testgc_set_color(void *, gfx_color_t *); 43 44 static errno_t testgc_fill_rect(void *, gfx_rect_t *); … … 49 50 50 51 static gfx_context_ops_t test_ops = { 52 .set_clip_rect = testgc_set_clip_rect, 51 53 .set_color = testgc_set_color, 52 54 .fill_rect = testgc_fill_rect, … … 145 147 rc = gfx_context_delete(gc); 146 148 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 149 } 150 151 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect) 152 { 153 return EOK; 147 154 } 148 155 -
uspace/lib/gfxfont/test/tpf.c
r252d03c r7470d97 1 1 /* 2 * Copyright (c) 202 0Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 41 41 PCUT_TEST_SUITE(tpf); 42 42 43 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *); 43 44 static errno_t testgc_set_color(void *, gfx_color_t *); 44 45 static errno_t testgc_fill_rect(void *, gfx_rect_t *); … … 50 51 51 52 static gfx_context_ops_t test_ops = { 53 .set_clip_rect = testgc_set_clip_rect, 52 54 .set_color = testgc_set_color, 53 55 .fill_rect = testgc_fill_rect, … … 208 210 } 209 211 212 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect) 213 { 214 return EOK; 215 } 216 210 217 static errno_t testgc_set_color(void *arg, gfx_color_t *color) 211 218 { -
uspace/lib/gfxfont/test/typeface.c
r252d03c r7470d97 1 1 /* 2 * Copyright (c) 202 0Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 37 37 PCUT_TEST_SUITE(typeface); 38 38 39 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *); 39 40 static errno_t testgc_set_color(void *, gfx_color_t *); 40 41 static errno_t testgc_fill_rect(void *, gfx_rect_t *); … … 46 47 47 48 static gfx_context_ops_t test_ops = { 49 .set_clip_rect = testgc_set_clip_rect, 48 50 .set_color = testgc_set_color, 49 51 .fill_rect = testgc_fill_rect, … … 94 96 { 95 97 // TODO 98 } 99 100 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect) 101 { 102 return EOK; 96 103 } 97 104 -
uspace/lib/ipcgfx/include/ipcgfx/ipc/gc.h
r252d03c r7470d97 39 39 40 40 typedef enum { 41 GC_SET_RGB_COLOR = IPC_FIRST_USER_METHOD, 41 GC_SET_CLIP_RECT = IPC_FIRST_USER_METHOD, 42 GC_SET_CLIP_RECT_NULL, 43 GC_SET_RGB_COLOR, 42 44 GC_FILL_RECT, 43 45 GC_UPDATE, -
uspace/lib/ipcgfx/src/client.c
r252d03c r7470d97 45 45 #include "../private/client.h" 46 46 47 static errno_t ipc_gc_set_clip_rect(void *, gfx_rect_t *); 47 48 static errno_t ipc_gc_set_color(void *, gfx_color_t *); 48 49 static errno_t ipc_gc_fill_rect(void *, gfx_rect_t *); … … 55 56 56 57 gfx_context_ops_t ipc_gc_ops = { 58 .set_clip_rect = ipc_gc_set_clip_rect, 57 59 .set_color = ipc_gc_set_color, 58 60 .fill_rect = ipc_gc_fill_rect, … … 63 65 .bitmap_get_alloc = ipc_gc_bitmap_get_alloc 64 66 }; 67 68 /** Set clipping rectangle on IPC GC. 69 * 70 * @param arg IPC GC 71 * @param rect Rectangle 72 * 73 * @return EOK on success or an error code 74 */ 75 static errno_t ipc_gc_set_clip_rect(void *arg, gfx_rect_t *rect) 76 { 77 ipc_gc_t *ipcgc = (ipc_gc_t *) arg; 78 async_exch_t *exch; 79 errno_t rc; 80 81 exch = async_exchange_begin(ipcgc->sess); 82 if (rect != NULL) { 83 rc = async_req_4_0(exch, GC_SET_CLIP_RECT, rect->p0.x, rect->p0.y, 84 rect->p1.x, rect->p1.y); 85 } else { 86 rc = async_req_0_0(exch, GC_SET_CLIP_RECT_NULL); 87 } 88 89 async_exchange_end(exch); 90 91 return rc; 92 } 65 93 66 94 /** Set color on IPC GC. -
uspace/lib/ipcgfx/src/server.c
r252d03c r7470d97 52 52 static ipc_gc_srv_bitmap_t *gc_bitmap_lookup(ipc_gc_srv_t *, sysarg_t); 53 53 54 static void gc_set_clip_rect_srv(ipc_gc_srv_t *srvgc, ipc_call_t *call) 55 { 56 gfx_rect_t rect; 57 errno_t rc; 58 59 rect.p0.x = ipc_get_arg1(call); 60 rect.p0.y = ipc_get_arg2(call); 61 rect.p1.x = ipc_get_arg3(call); 62 rect.p1.y = ipc_get_arg4(call); 63 64 rc = gfx_set_clip_rect(srvgc->gc, &rect); 65 async_answer_0(call, rc); 66 } 67 68 static void gc_set_clip_rect_null_srv(ipc_gc_srv_t *srvgc, ipc_call_t *call) 69 { 70 errno_t rc; 71 72 rc = gfx_set_clip_rect(srvgc->gc, NULL); 73 async_answer_0(call, rc); 74 } 75 54 76 static void gc_set_rgb_color_srv(ipc_gc_srv_t *srvgc, ipc_call_t *call) 55 77 { … … 361 383 362 384 switch (method) { 385 case GC_SET_CLIP_RECT: 386 gc_set_clip_rect_srv(&srvgc, &call); 387 break; 388 case GC_SET_CLIP_RECT_NULL: 389 gc_set_clip_rect_null_srv(&srvgc, &call); 390 break; 363 391 case GC_SET_RGB_COLOR: 364 392 gc_set_rgb_color_srv(&srvgc, &call); -
uspace/lib/ipcgfx/test/ipcgfx.c
r252d03c r7470d97 50 50 static void test_ipcgc_conn(ipc_call_t *, void *); 51 51 52 static errno_t test_gc_set_clip_rect(void *, gfx_rect_t *); 52 53 static errno_t test_gc_set_color(void *, gfx_color_t *); 53 54 static errno_t test_gc_fill_rect(void *, gfx_rect_t *); … … 60 61 61 62 static gfx_context_ops_t test_gc_ops = { 63 .set_clip_rect = test_gc_set_clip_rect, 62 64 .set_color = test_gc_set_color, 63 65 .fill_rect = test_gc_fill_rect, … … 75 77 errno_t rc; 76 78 79 bool set_clip_rect_called; 80 bool do_clip; 81 gfx_rect_t set_clip_rect_rect; 82 77 83 bool set_color_called; 78 84 uint16_t set_color_r; … … 103 109 gfx_bitmap_alloc_t alloc; 104 110 } test_bitmap_t; 111 112 /** gfx_set_clip_rect with server returning failure */ 113 PCUT_TEST(set_clip_rect_failure) 114 { 115 errno_t rc; 116 service_id_t sid; 117 test_response_t resp; 118 gfx_context_t *gc; 119 gfx_rect_t rect; 120 async_sess_t *sess; 121 ipc_gc_t *ipcgc; 122 123 async_set_fallback_port_handler(test_ipcgc_conn, &resp); 124 125 // FIXME This causes this test to be non-reentrant! 126 rc = loc_server_register(test_ipcgfx_server); 127 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 128 129 rc = loc_service_register(test_ipcgfx_svc, &sid); 130 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 131 132 sess = loc_service_connect(sid, INTERFACE_GC, 0); 133 PCUT_ASSERT_NOT_NULL(sess); 134 135 rc = ipc_gc_create(sess, &ipcgc); 136 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 137 138 gc = ipc_gc_get_ctx(ipcgc); 139 PCUT_ASSERT_NOT_NULL(gc); 140 141 resp.rc = ENOMEM; 142 resp.set_clip_rect_called = false; 143 rect.p0.x = 1; 144 rect.p0.y = 2; 145 rect.p1.x = 3; 146 rect.p1.y = 4; 147 rc = gfx_set_clip_rect(gc, &rect); 148 PCUT_ASSERT_ERRNO_VAL(resp.rc, rc); 149 PCUT_ASSERT_TRUE(resp.set_clip_rect_called); 150 PCUT_ASSERT_EQUALS(rect.p0.x, resp.set_clip_rect_rect.p0.x); 151 PCUT_ASSERT_EQUALS(rect.p0.y, resp.set_clip_rect_rect.p0.y); 152 PCUT_ASSERT_EQUALS(rect.p1.x, resp.set_clip_rect_rect.p1.x); 153 PCUT_ASSERT_EQUALS(rect.p1.y, resp.set_clip_rect_rect.p1.y); 154 155 ipc_gc_delete(ipcgc); 156 async_hangup(sess); 157 158 rc = loc_service_unregister(sid); 159 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 160 } 161 162 /** gfx_set_clip_rect with server returning success */ 163 PCUT_TEST(set_clip_rect_success) 164 { 165 errno_t rc; 166 service_id_t sid; 167 test_response_t resp; 168 gfx_context_t *gc; 169 gfx_rect_t rect; 170 async_sess_t *sess; 171 ipc_gc_t *ipcgc; 172 173 async_set_fallback_port_handler(test_ipcgc_conn, &resp); 174 175 // FIXME This causes this test to be non-reentrant! 176 rc = loc_server_register(test_ipcgfx_server); 177 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 178 179 rc = loc_service_register(test_ipcgfx_svc, &sid); 180 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 181 182 sess = loc_service_connect(sid, INTERFACE_GC, 0); 183 PCUT_ASSERT_NOT_NULL(sess); 184 185 rc = ipc_gc_create(sess, &ipcgc); 186 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 187 188 gc = ipc_gc_get_ctx(ipcgc); 189 PCUT_ASSERT_NOT_NULL(gc); 190 191 resp.rc = EOK; 192 resp.set_clip_rect_called = false; 193 rect.p0.x = 1; 194 rect.p0.y = 2; 195 rect.p1.x = 3; 196 rect.p1.y = 4; 197 rc = gfx_set_clip_rect(gc, &rect); 198 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 199 PCUT_ASSERT_TRUE(resp.set_clip_rect_called); 200 PCUT_ASSERT_TRUE(resp.do_clip); 201 PCUT_ASSERT_EQUALS(rect.p0.x, resp.set_clip_rect_rect.p0.x); 202 PCUT_ASSERT_EQUALS(rect.p0.y, resp.set_clip_rect_rect.p0.y); 203 PCUT_ASSERT_EQUALS(rect.p1.x, resp.set_clip_rect_rect.p1.x); 204 PCUT_ASSERT_EQUALS(rect.p1.y, resp.set_clip_rect_rect.p1.y); 205 206 ipc_gc_delete(ipcgc); 207 async_hangup(sess); 208 209 rc = loc_service_unregister(sid); 210 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 211 } 212 213 /** gfx_set_clip_rect with null rectangle, server returning success */ 214 PCUT_TEST(set_clip_rect_null_success) 215 { 216 errno_t rc; 217 service_id_t sid; 218 test_response_t resp; 219 gfx_context_t *gc; 220 async_sess_t *sess; 221 ipc_gc_t *ipcgc; 222 223 async_set_fallback_port_handler(test_ipcgc_conn, &resp); 224 225 // FIXME This causes this test to be non-reentrant! 226 rc = loc_server_register(test_ipcgfx_server); 227 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 228 229 rc = loc_service_register(test_ipcgfx_svc, &sid); 230 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 231 232 sess = loc_service_connect(sid, INTERFACE_GC, 0); 233 PCUT_ASSERT_NOT_NULL(sess); 234 235 rc = ipc_gc_create(sess, &ipcgc); 236 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 237 238 gc = ipc_gc_get_ctx(ipcgc); 239 PCUT_ASSERT_NOT_NULL(gc); 240 241 resp.rc = EOK; 242 resp.set_clip_rect_called = false; 243 244 rc = gfx_set_clip_rect(gc, NULL); 245 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 246 PCUT_ASSERT_TRUE(resp.set_clip_rect_called); 247 PCUT_ASSERT_FALSE(resp.do_clip); 248 249 ipc_gc_delete(ipcgc); 250 async_hangup(sess); 251 252 rc = loc_service_unregister(sid); 253 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 254 } 105 255 106 256 /** gfx_set_color with server returning failure */ … … 234 384 235 385 resp.rc = ENOMEM; 236 resp. set_color_called = false;386 resp.fill_rect_called = false; 237 387 rect.p0.x = 1; 238 388 rect.p0.y = 2; … … 284 434 285 435 resp.rc = EOK; 286 resp. set_color_called = false;436 resp.fill_rect_called = false; 287 437 rect.p0.x = 1; 288 438 rect.p0.y = 2; … … 898 1048 } 899 1049 1050 /** Set clipping rectangle in test GC. 1051 * 1052 * @param arg Test GC 1053 * @param rect Rectangle 1054 * 1055 * @return EOK on success or an error code 1056 */ 1057 static errno_t test_gc_set_clip_rect(void *arg, gfx_rect_t *rect) 1058 { 1059 test_response_t *resp = (test_response_t *) arg; 1060 1061 resp->set_clip_rect_called = true; 1062 if (rect != NULL) { 1063 resp->do_clip = true; 1064 resp->set_clip_rect_rect = *rect; 1065 } else { 1066 resp->do_clip = false; 1067 } 1068 1069 return resp->rc; 1070 } 1071 900 1072 /** Set color in test GC. 901 1073 * -
uspace/lib/memgfx/private/memgc.h
r252d03c r7470d97 49 49 /** Bounding rectangle */ 50 50 gfx_rect_t rect; 51 /** Clipping rectangle */ 52 gfx_rect_t clip_rect; 51 53 /** Allocation info */ 52 54 gfx_bitmap_alloc_t alloc; -
uspace/lib/memgfx/src/memgc.c
r252d03c r7470d97 48 48 #include "../private/memgc.h" 49 49 50 static errno_t mem_gc_set_clip_rect(void *, gfx_rect_t *); 50 51 static errno_t mem_gc_set_color(void *, gfx_color_t *); 51 52 static errno_t mem_gc_fill_rect(void *, gfx_rect_t *); … … 59 60 60 61 gfx_context_ops_t mem_gc_ops = { 62 .set_clip_rect = mem_gc_set_clip_rect, 61 63 .set_color = mem_gc_set_color, 62 64 .fill_rect = mem_gc_fill_rect, … … 68 70 }; 69 71 72 /** Set clipping rectangle on memory GC. 73 * 74 * @param arg Memory GC 75 * @param rect Rectangle 76 * 77 * @return EOK on success or an error code 78 */ 79 static errno_t mem_gc_set_clip_rect(void *arg, gfx_rect_t *rect) 80 { 81 mem_gc_t *mgc = (mem_gc_t *) arg; 82 83 if (rect != NULL) 84 gfx_rect_clip(rect, &mgc->rect, &mgc->clip_rect); 85 else 86 mgc->clip_rect = mgc->rect; 87 88 return EOK; 89 } 90 70 91 /** Set color on memory GC. 71 92 * … … 102 123 103 124 /* Make sure we have a sorted, clipped rectangle */ 104 gfx_rect_clip(rect, &mgc-> rect, &crect);125 gfx_rect_clip(rect, &mgc->clip_rect, &crect); 105 126 106 127 assert(mgc->rect.p0.x == 0); … … 167 188 mgc->gc = gc; 168 189 mgc->rect = *rect; 190 mgc->clip_rect = *rect; 169 191 mgc->alloc = *alloc; 170 192 … … 208 230 { 209 231 mgc->rect = *rect; 232 mgc->clip_rect = *rect; 210 233 mgc->alloc = *alloc; 211 234 } … … 370 393 gfx_rect_translate(&offs, &srect, &drect); 371 394 395 /* XXX Clip destination rectangle?! */ 396 372 397 assert(mbm->alloc.pitch == (mbm->rect.p1.x - mbm->rect.p0.x) * 373 398 (int)sizeof(uint32_t)); -
uspace/lib/ui/src/dummygc.c
r252d03c r7470d97 41 41 #include "../private/dummygc.h" 42 42 43 static errno_t dummygc_set_clip_rect(void *, gfx_rect_t *); 43 44 static errno_t dummygc_set_color(void *, gfx_color_t *); 44 45 static errno_t dummygc_fill_rect(void *, gfx_rect_t *); … … 52 53 /** Dummy GC operations */ 53 54 gfx_context_ops_t dummygc_ops = { 55 .set_clip_rect = dummygc_set_clip_rect, 54 56 .set_color = dummygc_set_color, 55 57 .fill_rect = dummygc_fill_rect, … … 105 107 { 106 108 return dgc->gc; 109 } 110 111 /** Set clipping rectangle on dummy GC 112 * 113 * @param arg Argument (dummy_gc_t) 114 * @param rect Rectangle 115 * @return EOK on success or an error code 116 */ 117 static errno_t dummygc_set_clip_rect(void *arg, gfx_rect_t *rect) 118 { 119 (void) arg; 120 (void) rect; 121 return EOK; 107 122 } 108 123 -
uspace/lib/ui/test/checkbox.c
r252d03c r7470d97 41 41 PCUT_TEST_SUITE(checkbox); 42 42 43 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *); 43 44 static errno_t testgc_set_color(void *, gfx_color_t *); 44 45 static errno_t testgc_fill_rect(void *, gfx_rect_t *); … … 51 52 52 53 static gfx_context_ops_t ops = { 54 .set_clip_rect = testgc_set_clip_rect, 53 55 .set_color = testgc_set_color, 54 56 .fill_rect = testgc_fill_rect, … … 481 483 rc = gfx_context_delete(gc); 482 484 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 485 } 486 487 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect) 488 { 489 (void) arg; 490 (void) rect; 491 return EOK; 483 492 } 484 493 -
uspace/lib/ui/test/entry.c
r252d03c r7470d97 41 41 PCUT_TEST_SUITE(entry); 42 42 43 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *); 43 44 static errno_t testgc_set_color(void *, gfx_color_t *); 44 45 static errno_t testgc_fill_rect(void *, gfx_rect_t *); … … 51 52 52 53 static gfx_context_ops_t ops = { 54 .set_clip_rect = testgc_set_clip_rect, 53 55 .set_color = testgc_set_color, 54 56 .fill_rect = testgc_fill_rect, … … 209 211 rc = gfx_context_delete(gc); 210 212 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 213 } 214 215 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect) 216 { 217 (void) arg; 218 (void) rect; 219 return EOK; 211 220 } 212 221 -
uspace/lib/ui/test/label.c
r252d03c r7470d97 41 41 PCUT_TEST_SUITE(label); 42 42 43 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *); 43 44 static errno_t testgc_set_color(void *, gfx_color_t *); 44 45 static errno_t testgc_fill_rect(void *, gfx_rect_t *); … … 51 52 52 53 static gfx_context_ops_t ops = { 54 .set_clip_rect = testgc_set_clip_rect, 53 55 .set_color = testgc_set_color, 54 56 .fill_rect = testgc_fill_rect, … … 209 211 rc = gfx_context_delete(gc); 210 212 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 213 } 214 215 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect) 216 { 217 (void) arg; 218 (void) rect; 219 return EOK; 211 220 } 212 221 -
uspace/lib/ui/test/paint.c
r252d03c r7470d97 1 1 /* 2 * Copyright (c) 202 0Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 39 39 PCUT_TEST_SUITE(paint); 40 40 41 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *); 41 42 static errno_t testgc_set_color(void *, gfx_color_t *); 42 43 static errno_t testgc_fill_rect(void *, gfx_rect_t *); … … 48 49 49 50 static gfx_context_ops_t ops = { 51 .set_clip_rect = testgc_set_clip_rect, 50 52 .set_color = testgc_set_color, 51 53 .fill_rect = testgc_fill_rect, … … 165 167 rc = gfx_context_delete(gc); 166 168 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 169 } 170 171 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect) 172 { 173 (void) arg; 174 (void) rect; 175 return EOK; 167 176 } 168 177 -
uspace/lib/ui/test/pbutton.c
r252d03c r7470d97 41 41 PCUT_TEST_SUITE(pbutton); 42 42 43 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *); 43 44 static errno_t testgc_set_color(void *, gfx_color_t *); 44 45 static errno_t testgc_fill_rect(void *, gfx_rect_t *); … … 51 52 52 53 static gfx_context_ops_t ops = { 54 .set_clip_rect = testgc_set_clip_rect, 53 55 .set_color = testgc_set_color, 54 56 .fill_rect = testgc_fill_rect, … … 488 490 rc = gfx_context_delete(gc); 489 491 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 492 } 493 494 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect) 495 { 496 (void) arg; 497 (void) rect; 498 return EOK; 490 499 } 491 500 -
uspace/lib/ui/test/rbutton.c
r252d03c r7470d97 41 41 PCUT_TEST_SUITE(rbutton); 42 42 43 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *); 43 44 static errno_t testgc_set_color(void *, gfx_color_t *); 44 45 static errno_t testgc_fill_rect(void *, gfx_rect_t *); … … 51 52 52 53 static gfx_context_ops_t ops = { 54 .set_clip_rect = testgc_set_clip_rect, 53 55 .set_color = testgc_set_color, 54 56 .fill_rect = testgc_fill_rect, … … 553 555 rc = gfx_context_delete(gc); 554 556 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 557 } 558 559 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect) 560 { 561 (void) arg; 562 (void) rect; 563 return EOK; 555 564 } 556 565 -
uspace/lib/ui/test/slider.c
r252d03c r7470d97 41 41 PCUT_TEST_SUITE(slider); 42 42 43 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *); 43 44 static errno_t testgc_set_color(void *, gfx_color_t *); 44 45 static errno_t testgc_fill_rect(void *, gfx_rect_t *); … … 51 52 52 53 static gfx_context_ops_t ops = { 54 .set_clip_rect = testgc_set_clip_rect, 53 55 .set_color = testgc_set_color, 54 56 .fill_rect = testgc_fill_rect, … … 428 430 rc = gfx_context_delete(gc); 429 431 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 432 } 433 434 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect) 435 { 436 (void) arg; 437 (void) rect; 438 return EOK; 430 439 } 431 440 -
uspace/lib/ui/test/wdecor.c
r252d03c r7470d97 41 41 PCUT_TEST_SUITE(wdecor); 42 42 43 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *); 43 44 static errno_t testgc_set_color(void *, gfx_color_t *); 44 45 static errno_t testgc_fill_rect(void *, gfx_rect_t *); … … 51 52 52 53 static gfx_context_ops_t ops = { 54 .set_clip_rect = testgc_set_clip_rect, 53 55 .set_color = testgc_set_color, 54 56 .fill_rect = testgc_fill_rect, … … 845 847 } 846 848 849 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect) 850 { 851 (void) arg; 852 (void) rect; 853 return EOK; 854 } 855 847 856 static errno_t testgc_set_color(void *arg, gfx_color_t *color) 848 857 { -
uspace/srv/hid/display/clonegc.c
r252d03c r7470d97 1 1 /* 2 * Copyright (c) 202 0Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 44 44 #include "clonegc.h" 45 45 46 static errno_t ds_clonegc_set_clip_rect(void *, gfx_rect_t *); 46 47 static errno_t ds_clonegc_set_color(void *, gfx_color_t *); 47 48 static errno_t ds_clonegc_fill_rect(void *, gfx_rect_t *); … … 65 66 66 67 gfx_context_ops_t ds_clonegc_ops = { 68 .set_clip_rect = ds_clonegc_set_clip_rect, 67 69 .set_color = ds_clonegc_set_color, 68 70 .fill_rect = ds_clonegc_fill_rect, … … 73 75 }; 74 76 77 /** Set clipping rectangle on clone GC. 78 * 79 * @param arg Clone GC 80 * @param rect Rectangle 81 * 82 * @return EOK on success or an error code 83 */ 84 static errno_t ds_clonegc_set_clip_rect(void *arg, gfx_rect_t *rect) 85 { 86 ds_clonegc_t *cgc = (ds_clonegc_t *)arg; 87 ds_clonegc_output_t *output; 88 errno_t rc; 89 90 output = ds_clonegc_first_output(cgc); 91 while (output != NULL) { 92 rc = gfx_set_clip_rect(output->gc, rect); 93 if (rc != EOK) 94 return rc; 95 96 output = ds_clonegc_next_output(output); 97 } 98 99 return EOK; 100 } 101 75 102 /** Set color on clone GC. 76 103 * -
uspace/srv/hid/display/test/clonegc.c
r252d03c r7470d97 1 1 /* 2 * Copyright (c) 202 0Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 39 39 PCUT_TEST_SUITE(clonegc); 40 40 41 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *); 41 42 static errno_t testgc_set_color(void *, gfx_color_t *); 42 43 static errno_t testgc_fill_rect(void *, gfx_rect_t *); … … 48 49 49 50 static gfx_context_ops_t ops = { 51 .set_clip_rect = testgc_set_clip_rect, 50 52 .set_color = testgc_set_color, 51 53 .fill_rect = testgc_fill_rect, … … 59 61 /** Error code to return */ 60 62 errno_t rc; 63 64 bool set_clip_rect_called; 65 gfx_rect_t *set_clip_rect_rect; 61 66 62 67 bool set_color_called; … … 95 100 rc = ds_clonegc_create(NULL, &cgc); 96 101 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 102 103 rc = ds_clonegc_delete(cgc); 104 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 105 } 106 107 /** Set clipping rectangle with two output GCs */ 108 PCUT_TEST(set_clip_rect) 109 { 110 ds_clonegc_t *cgc; 111 gfx_context_t *gc; 112 test_gc_t tgc1; 113 gfx_context_t *gc1; 114 test_gc_t tgc2; 115 gfx_context_t *gc2; 116 gfx_rect_t rect; 117 errno_t rc; 118 119 /* Create clone GC */ 120 rc = ds_clonegc_create(NULL, &cgc); 121 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 122 123 gc = ds_clonegc_get_ctx(cgc); 124 PCUT_ASSERT_NOT_NULL(gc); 125 126 /* Add two output GCs */ 127 128 rc = gfx_context_new(&ops, &tgc1, &gc1); 129 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 130 131 rc = ds_clonegc_add_output(cgc, gc1); 132 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 133 134 rc = gfx_context_new(&ops, &tgc2, &gc2); 135 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 136 137 rc = ds_clonegc_add_output(cgc, gc2); 138 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 139 140 rect.p0.x = 1; 141 rect.p0.y = 2; 142 rect.p1.x = 3; 143 rect.p1.y = 4; 144 145 /* Set clipping rectangle returning error */ 146 147 tgc1.set_clip_rect_called = false; 148 tgc2.set_clip_rect_called = false; 149 tgc1.rc = EINVAL; 150 tgc2.rc = EINVAL; 151 152 rc = gfx_set_clip_rect(gc, &rect); 153 PCUT_ASSERT_ERRNO_VAL(EINVAL, rc); 154 155 PCUT_ASSERT_TRUE(tgc1.set_clip_rect_called); 156 PCUT_ASSERT_EQUALS(&rect, tgc1.set_clip_rect_rect); 157 PCUT_ASSERT_FALSE(tgc2.set_clip_rect_called); 158 159 /* Set clipping rectangle returning success for all outputs */ 160 tgc1.set_clip_rect_called = false; 161 tgc2.set_clip_rect_called = false; 162 tgc1.rc = EOK; 163 tgc2.rc = EOK; 164 165 rc = gfx_set_clip_rect(gc, &rect); 166 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 167 168 PCUT_ASSERT_TRUE(tgc1.set_clip_rect_called); 169 PCUT_ASSERT_EQUALS(&rect, tgc1.set_clip_rect_rect); 170 PCUT_ASSERT_TRUE(tgc2.set_clip_rect_called); 171 PCUT_ASSERT_EQUALS(&rect, tgc2.set_clip_rect_rect); 97 172 98 173 rc = ds_clonegc_delete(cgc); … … 628 703 } 629 704 705 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect) 706 { 707 test_gc_t *tgc = (test_gc_t *) arg; 708 709 tgc->set_clip_rect_called = true; 710 tgc->set_clip_rect_rect = rect; 711 712 return tgc->rc; 713 } 714 630 715 static errno_t testgc_set_color(void *arg, gfx_color_t *color) 631 716 { -
uspace/srv/hid/rfb/main.c
r252d03c r7470d97 1 1 /* 2 * Copyright (c) 2021 Jiri Svoboda 2 3 * Copyright (c) 2013 Martin Sucha 3 4 * All rights reserved. … … 50 51 static errno_t rfb_ddev_get_info(void *, ddev_info_t *); 51 52 53 static errno_t rfb_gc_set_clip_rect(void *, gfx_rect_t *); 52 54 static errno_t rfb_gc_set_color(void *, gfx_color_t *); 53 55 static errno_t rfb_gc_fill_rect(void *, gfx_rect_t *); … … 66 68 rfb_t rfb; 67 69 pixel_t color; 70 gfx_rect_t rect; 71 gfx_rect_t clip_rect; 68 72 } rfb_gc_t; 69 73 … … 78 82 79 83 static gfx_context_ops_t rfb_gc_ops = { 84 .set_clip_rect = rfb_gc_set_clip_rect, 80 85 .set_color = rfb_gc_set_color, 81 86 .fill_rect = rfb_gc_fill_rect, … … 134 139 } 135 140 141 /** Create RFB GC. 142 * 143 * @param rrgb Place to store pointer to new RFB GC 144 * @return EOK on success, ENOMEM if out of memory 145 */ 146 static errno_t rgb_gc_create(rfb_gc_t **rrfb) 147 { 148 rfb_gc_t *rfb; 149 150 rfb = calloc(1, sizeof(rfb_gc_t)); 151 if (rfb == NULL) 152 return ENOMEM; 153 154 *rrfb = rfb; 155 return EOK; 156 } 157 158 /** Destroy RFB GC. 159 * 160 * @param rfb RFB GC 161 */ 162 static void rfb_gc_destroy(rfb_gc_t *rfb) 163 { 164 free(rfb); 165 } 166 167 /** Set clipping rectangle on RFB. 168 * 169 * @param arg RFB 170 * @param rect Rectangle or @c NULL 171 * 172 * @return EOK on success or an error code 173 */ 174 static errno_t rfb_gc_set_clip_rect(void *arg, gfx_rect_t *rect) 175 { 176 rfb_gc_t *rfb = (rfb_gc_t *) arg; 177 178 if (rect != NULL) 179 gfx_rect_clip(rect, &rfb->rect, &rfb->clip_rect); 180 else 181 rfb->clip_rect = rfb->rect; 182 183 return EOK; 184 } 185 136 186 /** Set color on RFB. 137 187 * … … 163 213 { 164 214 rfb_gc_t *rfb = (rfb_gc_t *) arg; 215 gfx_rect_t crect; 165 216 gfx_coord_t x, y; 166 217 167 // XXX We should handle p0.x > p1.x and p0.y > p1.y168 169 for (y = rect->p0.y; y < rect->p1.y; y++) {170 for (x = rect->p0.x; x < rect->p1.x; x++) {218 gfx_rect_clip(rect, &rfb->clip_rect, &crect); 219 220 for (y = crect.p0.y; y < crect.p1.y; y++) { 221 for (x = crect.p0.x; x < crect.p1.x; x++) { 171 222 pixelmap_put_pixel(&rfb->rfb.framebuffer, x, y, 172 223 rfb->color); … … 174 225 } 175 226 176 rfb_gc_invalidate_rect(rfb, rect);227 rfb_gc_invalidate_rect(rfb, &crect); 177 228 178 229 return EOK; … … 258 309 gfx_rect_t srect; 259 310 gfx_rect_t drect; 311 gfx_rect_t crect; 260 312 gfx_coord2_t offs; 261 313 gfx_coord2_t bmdim; … … 279 331 /* Destination rectangle */ 280 332 gfx_rect_translate(&offs, &srect, &drect); 281 gfx_coord2_subtract(&drect.p1, &drect.p0, &dim); 333 gfx_rect_clip(&drect, &rfbbm->rfb->clip_rect, &crect); 334 gfx_coord2_subtract(&crect.p1, &crect.p0, &dim); 282 335 gfx_coord2_subtract(&rfbbm->rect.p1, &rfbbm->rect.p0, &bmdim); 283 336 … … 320 373 } 321 374 322 rfb_gc_invalidate_rect(rfbbm->rfb, & drect);375 rfb_gc_invalidate_rect(rfbbm->rfb, &crect); 323 376 324 377 return EOK; … … 346 399 { 347 400 rfb_t *rfb = (rfb_t *) arg; 401 rfb_gc_t *rfbgc; 348 402 ddev_srv_t srv; 349 403 sysarg_t svc_id; … … 362 416 ddev_conn(icall, &srv); 363 417 } else { 364 rc = gfx_context_new(&rfb_gc_ops, (void *) rfb, &gc);418 rc = rgb_gc_create(&rfbgc); 365 419 if (rc != EOK) { 420 async_answer_0(icall, ENOMEM); 421 return; 422 } 423 424 rfbgc->rect.p0.x = 0; 425 rfbgc->rect.p0.y = 0; 426 rfbgc->rect.p1.x = rfb->width; 427 rfbgc->rect.p1.y = rfb->height; 428 rfbgc->clip_rect = rfbgc->rect; 429 430 rc = gfx_context_new(&rfb_gc_ops, (void *) rfbgc, &gc); 431 if (rc != EOK) { 432 rfb_gc_destroy(rfbgc); 366 433 async_answer_0(icall, ENOMEM); 367 434 return;
Note:
See TracChangeset
for help on using the changeset viewer.