Changeset afcf704 in mainline for uspace/lib/gfx
- Timestamp:
- 2020-06-14T22:23:34Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c45d8696
- Parents:
- 28f8f6f2
- Location:
- uspace/lib/gfx
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/gfx/include/gfx/coord.h
r28f8f6f2 rafcf704 55 55 extern bool gfx_rect_is_empty(gfx_rect_t *); 56 56 extern bool gfx_rect_is_incident(gfx_rect_t *, gfx_rect_t *); 57 extern bool gfx_rect_is_inside(gfx_rect_t *, gfx_rect_t *); 57 58 extern bool gfx_pix_inside_rect(gfx_coord2_t *, gfx_rect_t *); 58 59 -
uspace/lib/gfx/include/types/gfx/bitmap.h
r28f8f6f2 rafcf704 48 48 typedef enum { 49 49 /** Enable color key */ 50 bmpf_color_key = 0x1 50 bmpf_color_key = 0x1, 51 /** Directly map GC output into this bitmap */ 52 bmpf_direct_output = 0x2 51 53 } gfx_bitmap_flags_t; 52 54 -
uspace/lib/gfx/src/coord.c
r28f8f6f2 rafcf704 255 255 } 256 256 257 /** Return true if rectangle @a a is contained in rectangle @a b. 258 * 259 * @param a Inside rectangle 260 * @param b Outside rectangle 261 * @return @c true iff @a a is (non-strictly) inside @a b 262 */ 263 bool gfx_rect_is_inside(gfx_rect_t *a, gfx_rect_t *b) 264 { 265 gfx_rect_t sa; 266 gfx_rect_t sb; 267 268 gfx_rect_points_sort(a, &sa); 269 gfx_rect_points_sort(b, &sb); 270 271 if (sa.p0.x < sb.p0.x || sa.p0.y < sb.p0.y) 272 return false; 273 274 if (sa.p1.x > sb.p1.x || sa.p1.y > sb.p1.y) 275 return false; 276 277 return true; 278 } 279 257 280 /** Get rectangle dimensions. 258 281 * -
uspace/lib/gfx/test/coord.c
r28f8f6f2 rafcf704 775 775 } 776 776 777 /** gfx_rect_is_inside is true for rectangle strictly inside */ 778 PCUT_TEST(rect_is_inside_strict) 779 { 780 gfx_rect_t a; 781 gfx_rect_t b; 782 783 a.p0.x = 2; 784 a.p0.y = 3; 785 a.p1.x = 4; 786 a.p1.y = 5; 787 788 b.p0.x = 1; 789 b.p0.y = 2; 790 b.p1.x = 5; 791 b.p1.y = 6; 792 793 PCUT_ASSERT_TRUE(gfx_rect_is_inside(&a, &b)); 794 } 795 796 /** gfx_rect_is_inside is true for two equal rectangles */ 797 PCUT_TEST(rect_is_inside_same) 798 { 799 gfx_rect_t a; 800 gfx_rect_t b; 801 802 a.p0.x = 1; 803 a.p0.y = 2; 804 a.p1.x = 3; 805 a.p1.y = 4; 806 807 b.p0.x = 1; 808 b.p0.y = 2; 809 b.p1.x = 3; 810 b.p1.y = 4; 811 812 PCUT_ASSERT_TRUE(gfx_rect_is_inside(&a, &b)); 813 } 814 815 /** gfx_rect_is_inside is false for @c a.p0 outside */ 816 PCUT_TEST(rect_is_inside_p0_outside) 817 { 818 gfx_rect_t a; 819 gfx_rect_t b; 820 821 a.p0.x = 0; 822 a.p0.y = 2; 823 a.p1.x = 3; 824 a.p1.y = 4; 825 826 b.p0.x = 1; 827 b.p0.y = 2; 828 b.p1.x = 3; 829 b.p1.y = 4; 830 831 PCUT_ASSERT_FALSE(gfx_rect_is_inside(&a, &b)); 832 833 a.p0.x = 1; 834 a.p0.y = 1; 835 a.p1.x = 3; 836 a.p1.y = 4; 837 838 b.p0.x = 1; 839 b.p0.y = 2; 840 b.p1.x = 3; 841 b.p1.y = 4; 842 843 PCUT_ASSERT_FALSE(gfx_rect_is_inside(&a, &b)); 844 } 845 846 /** gfx_rect_is_inside is false for @c a.p1 outside */ 847 PCUT_TEST(rect_is_inside_p1_outside) 848 { 849 gfx_rect_t a; 850 gfx_rect_t b; 851 852 a.p0.x = 1; 853 a.p0.y = 2; 854 a.p1.x = 4; 855 a.p1.y = 4; 856 857 b.p0.x = 1; 858 b.p0.y = 2; 859 b.p1.x = 3; 860 b.p1.y = 4; 861 862 PCUT_ASSERT_FALSE(gfx_rect_is_inside(&a, &b)); 863 864 a.p0.x = 1; 865 a.p0.y = 2; 866 a.p1.x = 3; 867 a.p1.y = 5; 868 869 b.p0.x = 1; 870 b.p0.y = 2; 871 b.p1.x = 3; 872 b.p1.y = 4; 873 874 PCUT_ASSERT_FALSE(gfx_rect_is_inside(&a, &b)); 875 } 876 777 877 /** gfx_pix_inside_rect for */ 778 878 PCUT_TEST(pix_inside_rect)
Note:
See TracChangeset
for help on using the changeset viewer.