Skip to content

Commit 123327c

Browse files
committed
etc
1 parent 2b5eb99 commit 123327c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Marlin/src/lcd/tft/canvas.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ void Canvas::addImage(int16_t x, int16_t y, MarlinImage image, uint16_t *colors)
132132

133133
static struct {
134134
bool has_rle_state = false;
135-
uint16_t dstx, dsty, srcx, srcy;
135+
int16_t dstx, dsty, srcx, srcy;
136136
uint32_t rle_offset;
137137
} rle_state;
138138

@@ -146,23 +146,23 @@ void Canvas::addImage(int16_t x, int16_t y, MarlinImage image, uint16_t *colors)
146146
dsty = y, dstx = x; // Destination line / column index
147147

148148
uint16_t color = 0; // Persist the last fetched color value
149-
if (rle_state.has_rle_state) { // do we have rle position data
149+
if (rle_state.has_rle_state) { // do we have RLE position data?
150+
rle_state.has_rle_state = false; // invalidate stored RLE state
150151
dstx = rle_state.dstx; // restore required states
151152
dsty = rle_state.dsty;
152153
srcx = rle_state.srcx;
153154
srcy = rle_state.srcy;
154-
bytedata = (uint8_t *)images[image].data + rle_state.rle_offset; // restart decode from here instead of the start of data
155-
rle_state.has_rle_state = false; // invalidate stored rle state
155+
bytedata = (uint8_t *)images[image].data + rle_state.rle_offset; // Restart decode from here instead of the start of data
156156
}
157157

158158
bool done = false;
159159
while (!done) {
160-
if (dsty >= endLine -1 || srcy >= image_height -1) { // Store state?
161-
rle_state.dstx = dstx; // save required states
160+
if (dsty >= endLine - 1 || srcy >= image_height - 1) { // Store state?
161+
rle_state.dstx = dstx; // Save required states
162162
rle_state.dsty = dsty;
163163
rle_state.srcx = srcx;
164164
rle_state.srcy = srcy;
165-
rle_state.rle_offset = bytedata - (uint8_t *)images[image].data;; // Keep these for skipping full rle decode on future iteratons
165+
rle_state.rle_offset = bytedata - (uint8_t *)images[image].data;; // Keep these for skipping full RLE decode on future iteratons
166166
}
167167

168168
uint8_t count = *bytedata++; // Get the count byte
@@ -193,7 +193,7 @@ void Canvas::addImage(int16_t x, int16_t y, MarlinImage image, uint16_t *colors)
193193
srcx = 0; dstx = x; // May be shifted within the canvas, but usually not
194194
if (dsty >= endLine || srcy >= image_height) { // Done with the segment or the image?
195195
done = true; // Set a flag to end the loop...
196-
rle_state.has_rle_state = true; // rle state is stored
196+
rle_state.has_rle_state = true; // RLE state is stored
197197
break; // ...and break out of while(count--)
198198
}
199199
}

0 commit comments

Comments
 (0)