Changeset e1f2079 in mainline for uspace/lib/gfx
- Timestamp:
- 2020-02-14T19:54:40Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b0a94854
- Parents:
- b252e87
- Location:
- uspace/lib/gfx
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/gfx/include/gfx/coord.h
rb252e87 re1f2079 42 42 extern void gfx_coord2_add(gfx_coord2_t *, gfx_coord2_t *, gfx_coord2_t *); 43 43 extern void gfx_coord2_subtract(gfx_coord2_t *, gfx_coord2_t *, gfx_coord2_t *); 44 extern void gfx_coord2_clip(gfx_coord2_t *, gfx_rect_t *, gfx_coord2_t *); 44 45 extern void gfx_span_points_sort(gfx_coord_t, gfx_coord_t, gfx_coord_t *, 45 46 gfx_coord_t *); -
uspace/lib/gfx/src/coord.c
rb252e87 re1f2079 62 62 } 63 63 64 void gfx_coord2_clip(gfx_coord2_t *a, gfx_rect_t *clip, gfx_coord2_t *d) 65 { 66 gfx_rect_t sclip; 67 gfx_coord2_t t; 68 69 gfx_rect_points_sort(clip, &sclip); 70 71 t.x = min(a->x, clip->p1.x - 1); 72 t.y = min(a->y, clip->p1.y - 1); 73 74 d->x = max(clip->p0.x, t.x); 75 d->y = max(clip->p0.y, t.y); 76 } 77 64 78 /** Sort points of a span. 65 79 * -
uspace/lib/gfx/test/coord.c
rb252e87 re1f2079 68 68 } 69 69 70 /** gfx_coord2_clip with point to lower-left of clipping rectangle */ 71 PCUT_TEST(coord2_clip_ll) 72 { 73 gfx_coord2_t p; 74 gfx_coord2_t cp; 75 gfx_rect_t rect; 76 77 p.x = 1; 78 p.y = 2; 79 80 rect.p0.x = 3; 81 rect.p0.y = 4; 82 rect.p1.x = 5; 83 rect.p1.y = 6; 84 85 gfx_coord2_clip(&p, &rect, &cp); 86 87 PCUT_ASSERT_INT_EQUALS(3, cp.x); 88 PCUT_ASSERT_INT_EQUALS(4, cp.y); 89 } 90 91 /** gfx_coord2_clip with point inside the clipping rectangle */ 92 PCUT_TEST(coord2_clip_mm) 93 { 94 gfx_coord2_t p; 95 gfx_coord2_t cp; 96 gfx_rect_t rect; 97 98 p.x = 2; 99 p.y = 3; 100 101 rect.p0.x = 1; 102 rect.p0.y = 2; 103 rect.p1.x = 3; 104 rect.p1.y = 4; 105 106 gfx_coord2_clip(&p, &rect, &cp); 107 108 PCUT_ASSERT_INT_EQUALS(2, cp.x); 109 PCUT_ASSERT_INT_EQUALS(3, cp.y); 110 } 111 112 /** gfx_coord2_clip with point to upper-right of clipping rectangle */ 113 PCUT_TEST(coord2_clip_hh) 114 { 115 gfx_coord2_t p; 116 gfx_coord2_t cp; 117 gfx_rect_t rect; 118 119 p.x = 5; 120 p.y = 6; 121 122 rect.p0.x = 1; 123 rect.p0.y = 2; 124 rect.p1.x = 3; 125 rect.p1.y = 4; 126 127 gfx_coord2_clip(&p, &rect, &cp); 128 129 PCUT_ASSERT_INT_EQUALS(2, cp.x); 130 PCUT_ASSERT_INT_EQUALS(3, cp.y); 131 } 132 70 133 /** gfx_rect_translate should translate rectangle */ 71 134 PCUT_TEST(rect_translate)
Note:
See TracChangeset
for help on using the changeset viewer.