Changeset 0e6e77f in mainline for uspace/lib/gfx


Ignore:
Timestamp:
2020-02-28T15:44:55Z (6 years ago)
Author:
Jiri Svoboda <jiri@…>
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)
Message:

Window resize by client request

Location:
uspace/lib/gfx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/gfx/include/gfx/coord.h

    r2a515dcd r0e6e77f  
    5252extern void gfx_rect_clip(gfx_rect_t *, gfx_rect_t *, gfx_rect_t *);
    5353extern void gfx_rect_points_sort(gfx_rect_t *, gfx_rect_t *);
     54extern void gfx_rect_dims(gfx_rect_t *, gfx_coord2_t *);
    5455extern bool gfx_rect_is_empty(gfx_rect_t *);
    5556extern bool gfx_pix_inside_rect(gfx_coord2_t *, gfx_rect_t *);
  • uspace/lib/gfx/src/coord.c

    r2a515dcd r0e6e77f  
    235235}
    236236
     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 */
     245void 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
    237253/** Return true if pixel at coordinate @a coord lies within rectangle @a rect. */
    238254bool gfx_pix_inside_rect(gfx_coord2_t *coord, gfx_rect_t *rect)
  • uspace/lib/gfx/test/coord.c

    r2a515dcd r0e6e77f  
    239239
    240240/** Sorting span with hight start and lower end point results in transposed span. */
    241 PCUT_TEST(span_points_sort_decs)
     241PCUT_TEST(span_points_sort_desc)
    242242{
    243243        gfx_coord_t a, b;
     
    580580}
    581581
     582/** Rectangle dimensions for straight rectangle are computed correctly */
     583PCUT_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 */
     600PCUT_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
    582616/** gfx_rect_is_empty for straight rectangle with zero columns returns true */
    583617PCUT_TEST(rect_is_empty_pos_x)
Note: See TracChangeset for help on using the changeset viewer.