summaryrefslogtreecommitdiff
path: root/firmware/drivers/lcd-bitmap-common.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/lcd-bitmap-common.c')
-rw-r--r--firmware/drivers/lcd-bitmap-common.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/firmware/drivers/lcd-bitmap-common.c b/firmware/drivers/lcd-bitmap-common.c
index 6a3fd5f825..07ed509229 100644
--- a/firmware/drivers/lcd-bitmap-common.c
+++ b/firmware/drivers/lcd-bitmap-common.c
@@ -58,15 +58,13 @@ extern void viewport_set_buffer(struct viewport *vp,
58 * In-viewport clipping functions: 58 * In-viewport clipping functions:
59 * 59 *
60 * These clip a primitive (pixel, line, rect) given in 60 * These clip a primitive (pixel, line, rect) given in
61 * viewport-relative coordinates to the current viewport, 61 * viewport-relative coordinates to the specified viewport,
62 * and translate it to screen coordinates. They return 62 * and translate it to screen coordinates. They return
63 * false if the resulting primitive would be off-screen. 63 * false if the resulting primitive would be off-screen.
64 */ 64 */
65 65
66static bool LCDFN(clip_viewport_pixel)(int *x, int *y) 66static inline bool clip_viewport_pixel(struct viewport *vp, int *x, int *y)
67{ 67{
68 struct viewport *vp = LCDFN(current_viewport);
69
70 if (*x < 0 || *x >= vp->width || 68 if (*x < 0 || *x >= vp->width ||
71 *y < 0 || *y >= vp->height) 69 *y < 0 || *y >= vp->height)
72 return false; 70 return false;
@@ -76,10 +74,9 @@ static bool LCDFN(clip_viewport_pixel)(int *x, int *y)
76 return true; 74 return true;
77} 75}
78 76
79static bool LCDFN(clip_viewport_hline)(int *x1, int *x2, int *y) 77static inline bool clip_viewport_hline(struct viewport *vp,
78 int *x1, int *x2, int *y)
80{ 79{
81 struct viewport *vp = LCDFN(current_viewport);
82
83 if (*y < 0 || *y > vp->height) 80 if (*y < 0 || *y > vp->height)
84 return false; 81 return false;
85 82
@@ -105,10 +102,9 @@ static bool LCDFN(clip_viewport_hline)(int *x1, int *x2, int *y)
105 return true; 102 return true;
106} 103}
107 104
108static bool LCDFN(clip_viewport_vline)(int *x, int *y1, int *y2) 105static inline bool clip_viewport_vline(struct viewport *vp,
106 int *x, int *y1, int *y2)
109{ 107{
110 struct viewport *vp = LCDFN(current_viewport);
111
112 if (*x < 0 || *x > vp->width) 108 if (*x < 0 || *x > vp->width)
113 return false; 109 return false;
114 110
@@ -134,11 +130,10 @@ static bool LCDFN(clip_viewport_vline)(int *x, int *y1, int *y2)
134 return true; 130 return true;
135} 131}
136 132
137static bool LCDFN(clip_viewport_rect)(int *x, int *y, int *width, int *height, 133static inline bool clip_viewport_rect(struct viewport *vp,
134 int *x, int *y, int *width, int *height,
138 int *src_x, int *src_y) 135 int *src_x, int *src_y)
139{ 136{
140 struct viewport *vp = LCDFN(current_viewport);
141
142 if (*x < 0) { 137 if (*x < 0) {
143 *width += *x; 138 *width += *x;
144 if (src_x) 139 if (src_x)
@@ -844,7 +839,7 @@ void LCDFN(nine_segment_bmp)(const struct bitmap* bm, int x, int y,
844void LCDFN(drawpixel)(int x, int y) 839void LCDFN(drawpixel)(int x, int y)
845{ 840{
846 struct viewport *vp = LCDFN(current_viewport); 841 struct viewport *vp = LCDFN(current_viewport);
847 if (LCDFN(clip_viewport_pixel(&x, &y))) 842 if (clip_viewport_pixel(vp, &x, &y))
848 { 843 {
849#if LCDM(DEPTH) >= 8 844#if LCDM(DEPTH) >= 8
850 LCDFN(fastpixelfunc_type) *pfunc = LCDFN(fastpixelfuncs)[vp->drawmode]; 845 LCDFN(fastpixelfunc_type) *pfunc = LCDFN(fastpixelfuncs)[vp->drawmode];