Changeset 7470d97 in mainline for uspace/lib
- Timestamp:
- 2021-04-30T15:05:06Z (4 years ago)
- Branches:
- master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 051349b
- Parents:
- 252d03c
- Location:
- uspace/lib
- Files:
-
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
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 {
Note:
See TracChangeset
for help on using the changeset viewer.