Skip to content

Commit dc42d0d

Browse files
committed
Add overlap support for gfx_CopyRectangle and share code with gfx_BlitRectangle
1 parent fe2eb22 commit dc42d0d

7 files changed

Lines changed: 298 additions & 97 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
obj/
2+
bin/
3+
src/gfx/*.c
4+
src/gfx/*.h
5+
src/gfx/*.8xv
6+
.DS_Store
7+
convimg.yaml.lst
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"transfer_files":
3+
[
4+
"bin/DEMO.8xp"
5+
],
6+
"target":
7+
{
8+
"name": "DEMO",
9+
"isASM": true
10+
},
11+
"sequence":
12+
[
13+
"action|launch",
14+
"delay|300",
15+
"hashWait|1",
16+
"key|enter",
17+
"hashWait|2",
18+
"key|enter",
19+
"hashWait|3",
20+
"key|enter",
21+
"hashWait|4",
22+
"key|enter",
23+
"hashWait|5"
24+
],
25+
"hashes":
26+
{
27+
"1":
28+
{
29+
"description": "Horizontal overlap right",
30+
"start": "vram_start",
31+
"size": "vram_8_size",
32+
"expected_CRCs": [ "9D4993C1" ]
33+
},
34+
"2":
35+
{
36+
"description": "Horizontal overlap left",
37+
"start": "vram_start",
38+
"size": "vram_8_size",
39+
"expected_CRCs": [ "BBD76F1C" ]
40+
},
41+
"3":
42+
{
43+
"description": "Vertical overlap down",
44+
"start": "vram_start",
45+
"size": "vram_8_size",
46+
"expected_CRCs": [ "7C8FC7BE" ]
47+
},
48+
"4":
49+
{
50+
"description": "Vertical overlap up",
51+
"start": "vram_start",
52+
"size": "vram_8_size",
53+
"expected_CRCs": [ "1C46A70A" ]
54+
},
55+
"5":
56+
{
57+
"description": "Test program exit",
58+
"start": "vram_start",
59+
"size": "vram_16_size",
60+
"expected_CRCs": [ "FFAF89BA", "101734A5", "9DA19F44", "A32840C8", "349F4775" ]
61+
}
62+
}
63+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# ----------------------------
2+
# Makefile Options
3+
# ----------------------------
4+
5+
NAME = DEMO
6+
ICON = icon.png
7+
DESCRIPTION = "CE C Toolchain Demo"
8+
COMPRESSED = NO
9+
10+
CFLAGS = -Wall -Wextra -Oz
11+
CXXFLAGS = -Wall -Wextra -Oz
12+
13+
# ----------------------------
14+
15+
include $(shell cedev-config --makefile)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
### Copy Rectangle Overlap Demo
2+
3+
This example demonstrates `gfx_CopyRectangle` on overlapping regions of the same buffer.
4+
It shows horizontal and vertical moves in both directions using memmove-like behavior.
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
#include <stdint.h>
2+
#include <graphx.h>
3+
#include <ti/getcsc.h>
4+
5+
static void draw_base_pattern(void)
6+
{
7+
uint8_t stripe;
8+
9+
gfx_FillScreen(239);
10+
11+
gfx_SetColor(26);
12+
gfx_FillRectangle_NoClip(0, 0, GFX_LCD_WIDTH, 14);
13+
gfx_SetColor(27);
14+
gfx_FillRectangle_NoClip(0, GFX_LCD_HEIGHT - 12, GFX_LCD_WIDTH, 12);
15+
16+
for (stripe = 0; stripe < 6; stripe++)
17+
{
18+
static const uint8_t colors[6] = { 224, 9, 27, 56, 186, 250 };
19+
uint24_t x = 24 + stripe * 40;
20+
21+
gfx_SetColor(colors[stripe]);
22+
gfx_FillRectangle_NoClip(x, 24, 40, 120);
23+
24+
gfx_SetColor(0);
25+
gfx_VertLine_NoClip(x, 24, 120);
26+
gfx_VertLine_NoClip(x + 39, 24, 120);
27+
28+
gfx_SetColor(255);
29+
gfx_FillRectangle_NoClip(x + 6, 34 + stripe * 12, 28, 6);
30+
gfx_FillRectangle_NoClip(x + 6, 108 - stripe * 10, 28, 6);
31+
}
32+
33+
gfx_SetColor(0);
34+
gfx_Rectangle_NoClip(23, 23, 241, 121);
35+
36+
gfx_SetTextFGColor(255);
37+
gfx_SetTextBGColor(26);
38+
gfx_PrintStringXY("gfx_CopyRectangle overlap demo", 6, 3);
39+
40+
gfx_SetTextFGColor(255);
41+
gfx_SetTextBGColor(27);
42+
gfx_PrintStringXY("Black border = SRC White border = DST", 6, GFX_LCD_HEIGHT - 10);
43+
}
44+
45+
static void draw_overlay(const char *title,
46+
uint24_t src_x,
47+
uint8_t src_y,
48+
uint24_t dst_x,
49+
uint8_t dst_y,
50+
uint24_t width,
51+
uint8_t height)
52+
{
53+
gfx_SetColor(0);
54+
gfx_Rectangle_NoClip(src_x - 1, src_y - 1, width + 2, height + 2);
55+
56+
gfx_SetColor(255);
57+
gfx_Rectangle_NoClip(dst_x - 1, dst_y - 1, width + 2, height + 2);
58+
59+
gfx_SetColor(255);
60+
gfx_FillRectangle_NoClip(src_x + 2, src_y + 2, 24, 10);
61+
gfx_SetColor(0);
62+
gfx_Rectangle_NoClip(src_x + 2, src_y + 2, 24, 10);
63+
gfx_SetTextFGColor(0);
64+
gfx_SetTextBGColor(255);
65+
gfx_PrintStringXY("SRC", src_x + 4, src_y + 3);
66+
67+
gfx_SetColor(255);
68+
gfx_FillRectangle_NoClip(dst_x + 2, dst_y + 2, 24, 10);
69+
gfx_SetColor(0);
70+
gfx_Rectangle_NoClip(dst_x + 2, dst_y + 2, 24, 10);
71+
gfx_SetTextFGColor(0);
72+
gfx_SetTextBGColor(255);
73+
gfx_PrintStringXY("DST", dst_x + 4, dst_y + 3);
74+
75+
gfx_SetColor(52);
76+
gfx_FillRectangle_NoClip(188, 2, 130, 10);
77+
gfx_SetTextFGColor(255);
78+
gfx_SetTextBGColor(52);
79+
gfx_PrintStringXY(title, 192, 3);
80+
}
81+
82+
static void show_stage(void)
83+
{
84+
gfx_BlitBuffer();
85+
while (!os_GetCSC())
86+
{
87+
}
88+
}
89+
90+
int main(void)
91+
{
92+
gfx_Begin();
93+
gfx_SetDrawBuffer();
94+
95+
draw_base_pattern();
96+
gfx_CopyRectangle(gfx_buffer, gfx_buffer, 24, 18, 72, 18, 180, 64);
97+
draw_overlay("Move right", 24, 18, 72, 18, 180, 64);
98+
show_stage();
99+
100+
draw_base_pattern();
101+
gfx_CopyRectangle(gfx_buffer, gfx_buffer, 72, 18, 24, 18, 180, 64);
102+
draw_overlay("Move left", 72, 18, 24, 18, 180, 64);
103+
show_stage();
104+
105+
draw_base_pattern();
106+
gfx_CopyRectangle(gfx_buffer, gfx_buffer, 30, 24, 30, 60, 128, 96);
107+
draw_overlay("Move down", 30, 24, 30, 60, 128, 96);
108+
show_stage();
109+
110+
draw_base_pattern();
111+
gfx_CopyRectangle(gfx_buffer, gfx_buffer, 30, 60, 30, 24, 128, 96);
112+
draw_overlay("Move up", 30, 60, 30, 24, 128, 96);
113+
show_stage();
114+
115+
gfx_End();
116+
117+
return 0;
118+
}

0 commit comments

Comments
 (0)