Changeset 1167ad34 in mainline
- Timestamp:
- 2021-05-06T17:28:27Z (4 years ago)
- Branches:
- master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ae634f4
- Parents:
- 43ffecf
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/gfxdemo/gfxdemo.c
r43ffecf r1167ad34 665 665 } 666 666 667 /** Run demo loopon a graphic context.667 /** Run clipping demo on a graphic context. 668 668 * 669 669 * @param gc Graphic context … … 671 671 * @param h Height 672 672 */ 673 static errno_t demo_clip(gfx_context_t *gc, gfx_coord_t w, gfx_coord_t h) 674 { 675 gfx_bitmap_t *bitmap; 676 gfx_color_t *color; 677 gfx_bitmap_params_t params; 678 int i, j; 679 gfx_coord2_t offs; 680 gfx_rect_t rect; 681 errno_t rc; 682 683 if (quit) 684 return EOK; 685 686 rc = clear_scr(gc, w, h); 687 if (rc != EOK) 688 return rc; 689 690 gfx_bitmap_params_init(¶ms); 691 params.rect.p0.x = 0; 692 params.rect.p0.y = 0; 693 params.rect.p1.x = 40; 694 params.rect.p1.y = 20; 695 696 rc = gfx_bitmap_create(gc, ¶ms, NULL, &bitmap); 697 if (rc != EOK) 698 return rc; 699 700 rc = bitmap_moire(bitmap, 40, 20); 701 if (rc != EOK) 702 goto error; 703 704 for (j = 0; j < 10; j++) { 705 rect.p0.x = w / 8; 706 rect.p0.y = h / 8; 707 rect.p1.x = w * 7 / 8; 708 rect.p1.y = h * 3 / 8; 709 710 rc = gfx_set_clip_rect(gc, &rect); 711 if (rc != EOK) 712 return rc; 713 714 rc = gfx_color_new_rgb_i16(rand() % 0x10000, rand() % 0x10000, 715 rand() % 0x10000, &color); 716 if (rc != EOK) 717 return rc; 718 719 rc = gfx_set_color(gc, color); 720 if (rc != EOK) 721 return rc; 722 723 for (i = 0; i < 10; i++) { 724 rect.p0.x = rand() % (w - 1); 725 rect.p0.y = rand() % (h - 1); 726 rect.p1.x = rect.p0.x + rand() % (w - 1 - rect.p0.x); 727 rect.p1.y = rect.p0.y + rand() % (h - 1 - rect.p0.y); 728 729 rc = gfx_fill_rect(gc, &rect); 730 if (rc != EOK) 731 return rc; 732 } 733 734 gfx_color_delete(color); 735 736 rect.p0.x = w / 8; 737 rect.p0.y = h * 5 / 8; 738 rect.p1.x = w * 7 / 8; 739 rect.p1.y = h * 7 / 8; 740 741 rc = gfx_set_clip_rect(gc, &rect); 742 if (rc != EOK) 743 return rc; 744 745 for (i = 0; i < 10; i++) { 746 offs.x = rand() % (w - 40); 747 offs.y = rand() % (h - 20); 748 749 rc = gfx_bitmap_render(bitmap, NULL, &offs); 750 if (rc != EOK) 751 goto error; 752 } 753 754 fibril_usleep(500 * 1000); 755 756 if (quit) 757 break; 758 } 759 760 (void) gfx_set_clip_rect(gc, NULL); 761 gfx_bitmap_destroy(bitmap); 762 return EOK; 763 error: 764 (void) gfx_set_clip_rect(gc, NULL); 765 gfx_bitmap_destroy(bitmap); 766 return rc; 767 } 768 769 770 /** Run demo loop on a graphic context. 771 * 772 * @param gc Graphic context 773 * @param w Width 774 * @param h Height 775 */ 673 776 static errno_t demo_loop(gfx_context_t *gc, gfx_coord_t w, gfx_coord_t h) 674 777 { … … 693 796 694 797 rc = demo_text(gc, w, h); 798 if (rc != EOK) 799 return rc; 800 801 rc = demo_clip(gc, w, h); 695 802 if (rc != EOK) 696 803 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.