Changeset 0e6e77f in mainline for uspace/lib/gfx
- Timestamp:
- 2020-02-28T15:44:55Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a8eed5f
- Parents:
- 2a515dcd
- git-author:
- Jiri Svoboda <jiri@…> (2020-02-26 18:26:13)
- git-committer:
- Jiri Svoboda <jiri@…> (2020-02-28 15:44:55)
- Location:
- uspace/lib/gfx
- Files:
-
- 3 edited
-
include/gfx/coord.h (modified) (1 diff)
-
src/coord.c (modified) (1 diff)
-
test/coord.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/gfx/include/gfx/coord.h
r2a515dcd r0e6e77f 52 52 extern void gfx_rect_clip(gfx_rect_t *, gfx_rect_t *, gfx_rect_t *); 53 53 extern void gfx_rect_points_sort(gfx_rect_t *, gfx_rect_t *); 54 extern void gfx_rect_dims(gfx_rect_t *, gfx_coord2_t *); 54 55 extern bool gfx_rect_is_empty(gfx_rect_t *); 55 56 extern bool gfx_pix_inside_rect(gfx_coord2_t *, gfx_rect_t *); -
uspace/lib/gfx/src/coord.c
r2a515dcd r0e6e77f 235 235 } 236 236 237 /** Get rectangle dimensions. 238 * 239 * Get a vector containing the x, y dimensions of a rectangle. These are 240 * always nonnegative. 241 * 242 * @param rect Rectangle 243 * @param dims Place to store dimensions 244 */ 245 void gfx_rect_dims(gfx_rect_t *rect, gfx_coord2_t *dims) 246 { 247 gfx_rect_t srect; 248 249 gfx_rect_points_sort(rect, &srect); 250 gfx_coord2_subtract(&srect.p1, &srect.p0, dims); 251 } 252 237 253 /** Return true if pixel at coordinate @a coord lies within rectangle @a rect. */ 238 254 bool gfx_pix_inside_rect(gfx_coord2_t *coord, gfx_rect_t *rect) -
uspace/lib/gfx/test/coord.c
r2a515dcd r0e6e77f 239 239 240 240 /** Sorting span with hight start and lower end point results in transposed span. */ 241 PCUT_TEST(span_points_sort_de cs)241 PCUT_TEST(span_points_sort_desc) 242 242 { 243 243 gfx_coord_t a, b; … … 580 580 } 581 581 582 /** Rectangle dimensions for straight rectangle are computed correctly */ 583 PCUT_TEST(rect_dims_straight) 584 { 585 gfx_rect_t rect; 586 gfx_coord2_t dims; 587 588 rect.p0.x = 1; 589 rect.p0.y = 10; 590 rect.p1.x = 100; 591 rect.p1.y = 1000; 592 593 gfx_rect_dims(&rect, &dims); 594 595 PCUT_ASSERT_INT_EQUALS(99, dims.x); 596 PCUT_ASSERT_INT_EQUALS(990, dims.y); 597 } 598 599 /** Rectangle dimensions for reversed rectangle are computed correctly */ 600 PCUT_TEST(rect_dims_straight) 601 { 602 gfx_rect_t rect; 603 gfx_coord2_t dims; 604 605 rect.p0.x = 1000; 606 rect.p0.y = 100; 607 rect.p1.x = 10; 608 rect.p1.y = 1; 609 610 gfx_rect_dims(&rect, &dims); 611 612 PCUT_ASSERT_INT_EQUALS(990, dims.x); 613 PCUT_ASSERT_INT_EQUALS(99, dims.y); 614 } 615 582 616 /** gfx_rect_is_empty for straight rectangle with zero columns returns true */ 583 617 PCUT_TEST(rect_is_empty_pos_x)
Note:
See TracChangeset
for help on using the changeset viewer.
