@@ -170,27 +170,71 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
170170#endif
171171
172172#if GDISP_HARDWARE_STREAM_WRITE
173+ static int16_t stream_write_x = 0 ;
174+ static int16_t stream_write_cx = 0 ;
175+ static int16_t stream_write_y = 0 ;
176+ static int16_t stream_write_cy = 0 ;
173177 LLDSPEC void gdisp_lld_write_start (GDisplay * g ) {
178+ stream_write_x = g -> p .x ;
179+ stream_write_cx = g -> p .cx ;
180+ stream_write_y = g -> p .y ;
181+ stream_write_cy = g -> p .cy ;
174182 }
175183 LLDSPEC void gdisp_lld_write_color (GDisplay * g ) {
176- LLDCOLOR_TYPE c ;
177- c = gdispColor2Native (g -> p .color );
178- * ((uint8_t * )g -> priv + (g -> p .y * g -> g .Width + g -> p .x ) * 2 + 0 ) = c >> 8 ;
179- * ((uint8_t * )g -> priv + (g -> p .y * g -> g .Width + g -> p .x ) * 2 + 1 ) = c ;
184+ LLDCOLOR_TYPE c = gdispColor2Native (g -> p .color );
185+ * ((uint8_t * )g -> priv + (stream_write_x + stream_write_y * g -> g .Width ) * 2 + 0 ) = c >> 8 ;
186+ * ((uint8_t * )g -> priv + (stream_write_x + stream_write_y * g -> g .Width ) * 2 + 1 ) = c ;
187+ stream_write_x ++ ;
188+ if (-- stream_write_cx <= 0 ) {
189+ stream_write_x = g -> p .x ;
190+ stream_write_cx = g -> p .cx ;
191+ stream_write_y ++ ;
192+ if (-- stream_write_cy <= 0 ) {
193+ stream_write_y = g -> p .y ;
194+ stream_write_cy = g -> p .cy ;
195+ }
196+ }
180197 }
181198 LLDSPEC void gdisp_lld_write_stop (GDisplay * g ) {
199+ stream_write_x = 0 ;
200+ stream_write_cx = 0 ;
201+ stream_write_y = 0 ;
202+ stream_write_cy = 0 ;
182203 g -> flags |= GDISP_FLG_NEEDFLUSH ;
183204 }
184205#endif
185206
186207#if GDISP_HARDWARE_STREAM_READ
208+ static int16_t stream_read_x = 0 ;
209+ static int16_t stream_read_cx = 0 ;
210+ static int16_t stream_read_y = 0 ;
211+ static int16_t stream_read_cy = 0 ;
187212 LLDSPEC void gdisp_lld_read_start (GDisplay * g ) {
213+ stream_read_x = g -> p .x ;
214+ stream_read_cx = g -> p .cx ;
215+ stream_read_y = g -> p .y ;
216+ stream_read_cy = g -> p .cy ;
188217 }
189218 LLDSPEC color_t gdisp_lld_read_color (GDisplay * g ) {
190- return (* ((uint8_t * )g -> priv + (g -> p .y * g -> g .Width + g -> p .x ) * 2 + 0 ) << 8 ) |
191- (* ((uint8_t * )g -> priv + (g -> p .y * g -> g .Width + g -> p .x ) * 2 + 1 ));
219+ LLDCOLOR_TYPE c = (* ((uint8_t * )g -> priv + (stream_read_x + stream_read_y * g -> g .Width ) * 2 + 0 ) << 8 )
220+ | (* ((uint8_t * )g -> priv + (stream_read_x + stream_read_y * g -> g .Width ) * 2 + 1 ));
221+ stream_read_x ++ ;
222+ if (-- stream_read_cx <= 0 ) {
223+ stream_read_x = g -> p .x ;
224+ stream_read_cx = g -> p .cx ;
225+ stream_read_y ++ ;
226+ if (-- stream_read_cy <= 0 ) {
227+ stream_read_y = g -> p .y ;
228+ stream_read_cy = g -> p .cy ;
229+ }
230+ }
231+ return c ;
192232 }
193233 LLDSPEC void gdisp_lld_read_stop (GDisplay * g ) {
234+ stream_read_x = 0 ;
235+ stream_read_cx = 0 ;
236+ stream_read_y = 0 ;
237+ stream_read_cy = 0 ;
194238 }
195239#endif
196240
0 commit comments