diff options
author | Thomas Martitz <kugel@rockbox.org> | 2013-03-26 23:15:56 +0100 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2013-12-14 23:11:30 +0100 |
commit | 47c8d3c14d8fdaf4749ef5e0380fb0c52140b5fb (patch) | |
tree | 1e34394f6367ee4f8e937ee3f610236acaefad6f /firmware | |
parent | 87c6df98a34154b77c522196c61d89c6f3797416 (diff) | |
download | rockbox-47c8d3c14d8fdaf4749ef5e0380fb0c52140b5fb.tar.gz rockbox-47c8d3c14d8fdaf4749ef5e0380fb0c52140b5fb.zip |
lcd-*: Merge common viewport operations into lcd-bitmap-common.c
Change-Id: Ibec2d039ac0ba1214c9bd1b667bc8a9538a0d3d7
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/drivers/lcd-16bit-common.c | 42 | ||||
-rw-r--r-- | firmware/drivers/lcd-1bit-vert.c | 43 | ||||
-rw-r--r-- | firmware/drivers/lcd-2bit-horz.c | 46 | ||||
-rw-r--r-- | firmware/drivers/lcd-2bit-vert.c | 47 | ||||
-rw-r--r-- | firmware/drivers/lcd-2bit-vi.c | 46 | ||||
-rw-r--r-- | firmware/drivers/lcd-bitmap-common.c | 48 |
6 files changed, 48 insertions, 224 deletions
diff --git a/firmware/drivers/lcd-16bit-common.c b/firmware/drivers/lcd-16bit-common.c index 423ea183dc..f8673ec6db 100644 --- a/firmware/drivers/lcd-16bit-common.c +++ b/firmware/drivers/lcd-16bit-common.c | |||
@@ -68,48 +68,6 @@ void lcd_init(void) | |||
68 | lcd_init_device(); | 68 | lcd_init_device(); |
69 | scroll_init(); | 69 | scroll_init(); |
70 | } | 70 | } |
71 | /*** Viewports ***/ | ||
72 | |||
73 | void lcd_set_viewport(struct viewport* vp) | ||
74 | { | ||
75 | if (vp == NULL) | ||
76 | current_vp = &default_vp; | ||
77 | else | ||
78 | current_vp = vp; | ||
79 | |||
80 | #if defined(SIMULATOR) | ||
81 | /* Force the viewport to be within bounds. If this happens it should | ||
82 | * be considered an error - the viewport will not draw as it might be | ||
83 | * expected. | ||
84 | */ | ||
85 | if((unsigned) current_vp->x > (unsigned) LCD_WIDTH | ||
86 | || (unsigned) current_vp->y > (unsigned) LCD_HEIGHT | ||
87 | || current_vp->x + current_vp->width > LCD_WIDTH | ||
88 | || current_vp->y + current_vp->height > LCD_HEIGHT) | ||
89 | { | ||
90 | #if !defined(HAVE_VIEWPORT_CLIP) | ||
91 | DEBUGF("ERROR: " | ||
92 | #else | ||
93 | DEBUGF("NOTE: " | ||
94 | #endif | ||
95 | "set_viewport out of bounds: x: %d y: %d width: %d height:%d\n", | ||
96 | current_vp->x, current_vp->y, | ||
97 | current_vp->width, current_vp->height); | ||
98 | } | ||
99 | |||
100 | #endif | ||
101 | } | ||
102 | |||
103 | void lcd_update_viewport(void) | ||
104 | { | ||
105 | lcd_update_rect(current_vp->x, current_vp->y, | ||
106 | current_vp->width, current_vp->height); | ||
107 | } | ||
108 | |||
109 | void lcd_update_viewport_rect(int x, int y, int width, int height) | ||
110 | { | ||
111 | lcd_update_rect(current_vp->x + x, current_vp->y + y, width, height); | ||
112 | } | ||
113 | 71 | ||
114 | /* Clear the current viewport */ | 72 | /* Clear the current viewport */ |
115 | void lcd_clear_viewport(void) | 73 | void lcd_clear_viewport(void) |
diff --git a/firmware/drivers/lcd-1bit-vert.c b/firmware/drivers/lcd-1bit-vert.c index 3a90856819..5cacf0a740 100644 --- a/firmware/drivers/lcd-1bit-vert.c +++ b/firmware/drivers/lcd-1bit-vert.c | |||
@@ -60,49 +60,6 @@ static struct viewport default_vp = | |||
60 | 60 | ||
61 | static struct viewport* current_vp = &default_vp; | 61 | static struct viewport* current_vp = &default_vp; |
62 | 62 | ||
63 | /*** Viewports ***/ | ||
64 | |||
65 | void LCDFN(set_viewport)(struct viewport* vp) | ||
66 | { | ||
67 | if (vp == NULL) | ||
68 | current_vp = &default_vp; | ||
69 | else | ||
70 | current_vp = vp; | ||
71 | |||
72 | #if defined(SIMULATOR) | ||
73 | /* Force the viewport to be within bounds. If this happens it should | ||
74 | * be considered an error - the viewport will not draw as it might be | ||
75 | * expected. | ||
76 | */ | ||
77 | if((unsigned) current_vp->x > (unsigned) LCDM(WIDTH) | ||
78 | || (unsigned) current_vp->y > (unsigned) LCDM(HEIGHT) | ||
79 | || current_vp->x + current_vp->width > LCDM(WIDTH) | ||
80 | || current_vp->y + current_vp->height > LCDM(HEIGHT)) | ||
81 | { | ||
82 | #if !defined(HAVE_VIEWPORT_CLIP) | ||
83 | DEBUGF("ERROR: " | ||
84 | #else | ||
85 | DEBUGF("NOTE: " | ||
86 | #endif | ||
87 | "set_viewport out of bounds: x: %d y: %d width: %d height:%d\n", | ||
88 | current_vp->x, current_vp->y, | ||
89 | current_vp->width, current_vp->height); | ||
90 | } | ||
91 | |||
92 | #endif | ||
93 | } | ||
94 | |||
95 | void LCDFN(update_viewport)(void) | ||
96 | { | ||
97 | LCDFN(update_rect)(current_vp->x, current_vp->y, | ||
98 | current_vp->width, current_vp->height); | ||
99 | } | ||
100 | |||
101 | void LCDFN(update_viewport_rect)(int x, int y, int width, int height) | ||
102 | { | ||
103 | LCDFN(update_rect)(current_vp->x + x, current_vp->y + y, width, height); | ||
104 | } | ||
105 | |||
106 | /* LCD init */ | 63 | /* LCD init */ |
107 | void LCDFN(init)(void) | 64 | void LCDFN(init)(void) |
108 | { | 65 | { |
diff --git a/firmware/drivers/lcd-2bit-horz.c b/firmware/drivers/lcd-2bit-horz.c index 3870bac644..267a22db3f 100644 --- a/firmware/drivers/lcd-2bit-horz.c +++ b/firmware/drivers/lcd-2bit-horz.c | |||
@@ -77,52 +77,6 @@ void lcd_init(void) | |||
77 | scroll_init(); | 77 | scroll_init(); |
78 | } | 78 | } |
79 | 79 | ||
80 | /*** Viewports ***/ | ||
81 | |||
82 | void lcd_set_viewport(struct viewport* vp) | ||
83 | { | ||
84 | if (vp == NULL) | ||
85 | current_vp = &default_vp; | ||
86 | else | ||
87 | current_vp = vp; | ||
88 | |||
89 | fg_pattern = 0x55 * (~current_vp->fg_pattern & 3); | ||
90 | bg_pattern = 0x55 * (~current_vp->bg_pattern & 3); | ||
91 | |||
92 | #if defined(SIMULATOR) | ||
93 | /* Force the viewport to be within bounds. If this happens it should | ||
94 | * be considered an error - the viewport will not draw as it might be | ||
95 | * expected. | ||
96 | */ | ||
97 | if((unsigned) current_vp->x > (unsigned) LCD_WIDTH | ||
98 | || (unsigned) current_vp->y > (unsigned) LCD_HEIGHT | ||
99 | || current_vp->x + current_vp->width > LCD_WIDTH | ||
100 | || current_vp->y + current_vp->height > LCD_HEIGHT) | ||
101 | { | ||
102 | #if !defined(HAVE_VIEWPORT_CLIP) | ||
103 | DEBUGF("ERROR: " | ||
104 | #else | ||
105 | DEBUGF("NOTE: " | ||
106 | #endif | ||
107 | "set_viewport out of bounds: x: %d y: %d width: %d height:%d\n", | ||
108 | current_vp->x, current_vp->y, | ||
109 | current_vp->width, current_vp->height); | ||
110 | } | ||
111 | |||
112 | #endif | ||
113 | } | ||
114 | |||
115 | void lcd_update_viewport(void) | ||
116 | { | ||
117 | lcd_update_rect(current_vp->x, current_vp->y, | ||
118 | current_vp->width, current_vp->height); | ||
119 | } | ||
120 | |||
121 | void lcd_update_viewport_rect(int x, int y, int width, int height) | ||
122 | { | ||
123 | lcd_update_rect(current_vp->x + x, current_vp->y + y, width, height); | ||
124 | } | ||
125 | |||
126 | /*** parameter handling ***/ | 80 | /*** parameter handling ***/ |
127 | 81 | ||
128 | void lcd_set_drawmode(int mode) | 82 | void lcd_set_drawmode(int mode) |
diff --git a/firmware/drivers/lcd-2bit-vert.c b/firmware/drivers/lcd-2bit-vert.c index 89c2dc365b..08ec6cac79 100644 --- a/firmware/drivers/lcd-2bit-vert.c +++ b/firmware/drivers/lcd-2bit-vert.c | |||
@@ -79,53 +79,6 @@ void lcd_init(void) | |||
79 | scroll_init(); | 79 | scroll_init(); |
80 | } | 80 | } |
81 | 81 | ||
82 | /*** Viewports ***/ | ||
83 | |||
84 | void lcd_set_viewport(struct viewport* vp) | ||
85 | { | ||
86 | if (vp == NULL) | ||
87 | current_vp = &default_vp; | ||
88 | else | ||
89 | current_vp = vp; | ||
90 | |||
91 | fg_pattern = 0x55 * (~current_vp->fg_pattern & 3); | ||
92 | bg_pattern = 0x55 * (~current_vp->bg_pattern & 3); | ||
93 | |||
94 | #if defined(SIMULATOR) | ||
95 | /* Force the viewport to be within bounds. If this happens it should | ||
96 | * be considered an error - the viewport will not draw as it might be | ||
97 | * expected. | ||
98 | */ | ||
99 | if((unsigned) current_vp->x > (unsigned) LCD_WIDTH | ||
100 | || (unsigned) current_vp->y > (unsigned) LCD_HEIGHT | ||
101 | || current_vp->x + current_vp->width > LCD_WIDTH | ||
102 | || current_vp->y + current_vp->height > LCD_HEIGHT) | ||
103 | { | ||
104 | #if !defined(HAVE_VIEWPORT_CLIP) | ||
105 | DEBUGF("ERROR: " | ||
106 | #else | ||
107 | DEBUGF("NOTE: " | ||
108 | #endif | ||
109 | "set_viewport out of bounds: x: %d y: %d width: %d height:%d\n", | ||
110 | current_vp->x, current_vp->y, | ||
111 | current_vp->width, current_vp->height); | ||
112 | } | ||
113 | |||
114 | #endif | ||
115 | } | ||
116 | |||
117 | void lcd_update_viewport(void) | ||
118 | { | ||
119 | lcd_update_rect(current_vp->x, current_vp->y, | ||
120 | current_vp->width, current_vp->height); | ||
121 | } | ||
122 | |||
123 | void lcd_update_viewport_rect(int x, int y, int width, int height) | ||
124 | { | ||
125 | lcd_update_rect(current_vp->x + x, current_vp->y + y, width, height); | ||
126 | } | ||
127 | |||
128 | |||
129 | /*** parameter handling ***/ | 82 | /*** parameter handling ***/ |
130 | 83 | ||
131 | void lcd_set_drawmode(int mode) | 84 | void lcd_set_drawmode(int mode) |
diff --git a/firmware/drivers/lcd-2bit-vi.c b/firmware/drivers/lcd-2bit-vi.c index 8dc746f521..b0c41e4fa9 100644 --- a/firmware/drivers/lcd-2bit-vi.c +++ b/firmware/drivers/lcd-2bit-vi.c | |||
@@ -74,52 +74,6 @@ static struct viewport * current_vp IBSS_ATTR; | |||
74 | static unsigned fg_pattern IBSS_ATTR; | 74 | static unsigned fg_pattern IBSS_ATTR; |
75 | static unsigned bg_pattern IBSS_ATTR; | 75 | static unsigned bg_pattern IBSS_ATTR; |
76 | 76 | ||
77 | /*** Viewports ***/ | ||
78 | |||
79 | void LCDFN(set_viewport)(struct viewport* vp) | ||
80 | { | ||
81 | if (vp == NULL) | ||
82 | current_vp = &default_vp; | ||
83 | else | ||
84 | current_vp = vp; | ||
85 | |||
86 | fg_pattern = patterns[current_vp->fg_pattern & 3]; | ||
87 | bg_pattern = patterns[current_vp->bg_pattern & 3]; | ||
88 | |||
89 | #if defined(SIMULATOR) | ||
90 | /* Force the viewport to be within bounds. If this happens it should | ||
91 | * be considered an error - the viewport will not draw as it might be | ||
92 | * expected. | ||
93 | */ | ||
94 | if((unsigned) current_vp->x > (unsigned) LCDM(WIDTH) | ||
95 | || (unsigned) current_vp->y > (unsigned) LCDM(HEIGHT) | ||
96 | || current_vp->x + current_vp->width > LCDM(WIDTH) | ||
97 | || current_vp->y + current_vp->height > LCDM(HEIGHT)) | ||
98 | { | ||
99 | #if !defined(HAVE_VIEWPORT_CLIP) | ||
100 | DEBUGF("ERROR: " | ||
101 | #else | ||
102 | DEBUGF("NOTE: " | ||
103 | #endif | ||
104 | "set_viewport out of bounds: x: %d y: %d width: %d height:%d\n", | ||
105 | current_vp->x, current_vp->y, | ||
106 | current_vp->width, current_vp->height); | ||
107 | } | ||
108 | |||
109 | #endif | ||
110 | } | ||
111 | |||
112 | void LCDFN(update_viewport)(void) | ||
113 | { | ||
114 | LCDFN(update_rect)(current_vp->x, current_vp->y, | ||
115 | current_vp->width, current_vp->height); | ||
116 | } | ||
117 | |||
118 | void LCDFN(update_viewport_rect)(int x, int y, int width, int height) | ||
119 | { | ||
120 | LCDFN(update_rect)(current_vp->x + x, current_vp->y + y, width, height); | ||
121 | } | ||
122 | |||
123 | /* LCD init */ | 77 | /* LCD init */ |
124 | void LCDFN(init)(void) | 78 | void LCDFN(init)(void) |
125 | { | 79 | { |
diff --git a/firmware/drivers/lcd-bitmap-common.c b/firmware/drivers/lcd-bitmap-common.c index a149e8aaa9..a17ac51006 100644 --- a/firmware/drivers/lcd-bitmap-common.c +++ b/firmware/drivers/lcd-bitmap-common.c | |||
@@ -141,6 +141,54 @@ void LCDFN(fill_viewport)(void) | |||
141 | LCDFN(fillrect)(0, 0, current_vp->width, current_vp->height); | 141 | LCDFN(fillrect)(0, 0, current_vp->width, current_vp->height); |
142 | } | 142 | } |
143 | 143 | ||
144 | |||
145 | /*** Viewports ***/ | ||
146 | |||
147 | void LCDFN(set_viewport)(struct viewport* vp) | ||
148 | { | ||
149 | if (vp == NULL) | ||
150 | current_vp = &default_vp; | ||
151 | else | ||
152 | current_vp = vp; | ||
153 | |||
154 | #if LCDM(DEPTH) > 1 | ||
155 | LCDFN(set_foreground)(current_vp->fg_pattern); | ||
156 | LCDFN(set_background)(current_vp->bg_pattern); | ||
157 | #endif | ||
158 | |||
159 | #if defined(SIMULATOR) | ||
160 | /* Force the viewport to be within bounds. If this happens it should | ||
161 | * be considered an error - the viewport will not draw as it might be | ||
162 | * expected. | ||
163 | */ | ||
164 | if((unsigned) current_vp->x > (unsigned) LCDM(WIDTH) | ||
165 | || (unsigned) current_vp->y > (unsigned) LCDM(HEIGHT) | ||
166 | || current_vp->x + current_vp->width > LCDM(WIDTH) | ||
167 | || current_vp->y + current_vp->height > LCDM(HEIGHT)) | ||
168 | { | ||
169 | #if !defined(HAVE_VIEWPORT_CLIP) | ||
170 | DEBUGF("ERROR: " | ||
171 | #else | ||
172 | DEBUGF("NOTE: " | ||
173 | #endif | ||
174 | "set_viewport out of bounds: x: %d y: %d width: %d height:%d\n", | ||
175 | current_vp->x, current_vp->y, | ||
176 | current_vp->width, current_vp->height); | ||
177 | } | ||
178 | #endif | ||
179 | } | ||
180 | |||
181 | void LCDFN(update_viewport)(void) | ||
182 | { | ||
183 | LCDFN(update_rect)(current_vp->x, current_vp->y, | ||
184 | current_vp->width, current_vp->height); | ||
185 | } | ||
186 | |||
187 | void LCDFN(update_viewport_rect)(int x, int y, int width, int height) | ||
188 | { | ||
189 | LCDFN(update_rect)(current_vp->x + x, current_vp->y + y, width, height); | ||
190 | } | ||
191 | |||
144 | /* put a string at a given pixel position, skipping first ofs pixel columns */ | 192 | /* put a string at a given pixel position, skipping first ofs pixel columns */ |
145 | static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str) | 193 | static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str) |
146 | { | 194 | { |