Skip to content

Commit 605ea88

Browse files
authored
Revert "Speed up internal font drawing for opaque background color"
1 parent 2fbbfa2 commit 605ea88

File tree

2 files changed

+20
-66
lines changed

2 files changed

+20
-66
lines changed

Adafruit_GFX.cpp

Lines changed: 20 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -244,37 +244,6 @@ void Adafruit_GFX::writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h,
244244
fillRect(x, y, w, h, color);
245245
}
246246

247-
/**************************************************************************/
248-
/*!
249-
@brief set the address window (memory area), overwrite in subclasses if
250-
needed
251-
@param x starting x coordinate
252-
@param y starting y coordinate
253-
@param w width in pixels
254-
@param h height in pixels
255-
*/
256-
/**************************************************************************/
257-
void Adafruit_GFX::setAddrWindow(uint16_t x, uint16_t y, uint16_t w,
258-
uint16_t h) {
259-
(void)x;
260-
(void)y;
261-
(void)w;
262-
(void)h;
263-
}
264-
265-
/**************************************************************************/
266-
/*!
267-
@brief write len pixels of the given color, overwrite in subclasses if
268-
needed
269-
@param color 16-bit 5-6-5 color to write
270-
@param len number of pixels to write
271-
*/
272-
/**************************************************************************/
273-
void Adafruit_GFX::writeColor(uint16_t color, uint32_t len) {
274-
(void)color;
275-
(void)len;
276-
}
277-
278247
/**************************************************************************/
279248
/*!
280249
@brief End a display-writing routine, overwrite in subclasses if
@@ -1178,41 +1147,28 @@ void Adafruit_GFX::drawChar(int16_t x, int16_t y, unsigned char c,
11781147
c++; // Handle 'classic' charset behavior
11791148

11801149
startWrite();
1181-
if (color != bg) { // faster opaque text
1182-
setAddrWindow(x, y, 5 * size_x, 7 * size_y);
1183-
for (int8_t j = 0; j < 7; j++) { // 7 lines
1184-
uint8_t uc, ucMask = (1 << j);
1185-
for (uint8_t k = 0; k < size_y; k++) { // repeat size_y lines
1186-
for (uint8_t i = 0; i < 5; i++) { // 5 columns
1187-
uc = pgm_read_byte(&font[(c * 5) + i]);
1188-
writeColor((uc & ucMask) ? color : bg, size_x);
1189-
} // for each column
1190-
} // repeat for each line of size_y
1191-
} // for j
1192-
} else { // slower text which doesn't overwrite the background color
1193-
for (int8_t i = 0; i < 5; i++) { // Char bitmap = 5 columns
1194-
uint8_t line = pgm_read_byte(&font[c * 5 + i]);
1195-
for (int8_t j = 0; j < 8; j++, line >>= 1) {
1196-
if (line & 1) {
1197-
if (size_x == 1 && size_y == 1)
1198-
writePixel(x + i, y + j, color);
1199-
else
1200-
writeFillRect(x + i * size_x, y + j * size_y, size_x, size_y,
1201-
color);
1202-
} else if (bg != color) {
1203-
if (size_x == 1 && size_y == 1)
1204-
writePixel(x + i, y + j, bg);
1205-
else
1206-
writeFillRect(x + i * size_x, y + j * size_y, size_x, size_y, bg);
1207-
}
1150+
for (int8_t i = 0; i < 5; i++) { // Char bitmap = 5 columns
1151+
uint8_t line = pgm_read_byte(&font[c * 5 + i]);
1152+
for (int8_t j = 0; j < 8; j++, line >>= 1) {
1153+
if (line & 1) {
1154+
if (size_x == 1 && size_y == 1)
1155+
writePixel(x + i, y + j, color);
1156+
else
1157+
writeFillRect(x + i * size_x, y + j * size_y, size_x, size_y,
1158+
color);
1159+
} else if (bg != color) {
1160+
if (size_x == 1 && size_y == 1)
1161+
writePixel(x + i, y + j, bg);
1162+
else
1163+
writeFillRect(x + i * size_x, y + j * size_y, size_x, size_y, bg);
12081164
}
12091165
}
1210-
if (bg != color) { // If opaque, draw vertical line for last column
1211-
if (size_x == 1 && size_y == 1)
1212-
writeFastVLine(x + 5, y, 8, bg);
1213-
else
1214-
writeFillRect(x + 5 * size_x, y, size_x, 8 * size_y, bg);
1215-
}
1166+
}
1167+
if (bg != color) { // If opaque, draw vertical line for last column
1168+
if (size_x == 1 && size_y == 1)
1169+
writeFastVLine(x + 5, y, 8, bg);
1170+
else
1171+
writeFillRect(x + 5 * size_x, y, size_x, 8 * size_y, bg);
12161172
}
12171173
endWrite();
12181174

Adafruit_GFX.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ class Adafruit_GFX : public Print {
3232
// These MAY be overridden by the subclass to provide device-specific
3333
// optimized code. Otherwise 'generic' versions are used.
3434
virtual void startWrite(void);
35-
virtual void setAddrWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h);
36-
virtual void writeColor(uint16_t color, uint32_t len);
3735
virtual void writePixel(int16_t x, int16_t y, uint16_t color);
3836
virtual void writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h,
3937
uint16_t color);

0 commit comments

Comments
 (0)