Skip to content

Commit

Permalink
Make canvas buffers protected instead of private members
Browse files Browse the repository at this point in the history
A use case came up where it was helpful to be able to alter the buffer pointer in a subclass. This is esoteric and should be used with care.
  • Loading branch information
PaintYourDragon committed Jan 16, 2023
1 parent 91d916d commit 740677a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
11 changes: 3 additions & 8 deletions Adafruit_GFX.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,9 @@ class GFXcanvas1 : public Adafruit_GFX {
bool getRawPixel(int16_t x, int16_t y) const;
void drawFastRawVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
void drawFastRawHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
uint8_t *buffer; // protected (no longer private) for subclass flexibility

private:
uint8_t *buffer;

#ifdef __AVR__
// Bitmask tables of 0x80>>X and ~(0x80>>X), because X>>Y is slow on AVR
static const uint8_t PROGMEM GFXsetBit[], GFXclrBit[];
Expand Down Expand Up @@ -360,9 +359,7 @@ class GFXcanvas8 : public Adafruit_GFX {
uint8_t getRawPixel(int16_t x, int16_t y) const;
void drawFastRawVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
void drawFastRawHLine(int16_t x, int16_t y, int16_t w, uint16_t color);

private:
uint8_t *buffer;
uint8_t *buffer; // protected (no longer private) for subclass flexibility
};

/// A GFX 16-bit canvas context for graphics
Expand All @@ -388,9 +385,7 @@ class GFXcanvas16 : public Adafruit_GFX {
uint16_t getRawPixel(int16_t x, int16_t y) const;
void drawFastRawVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
void drawFastRawHLine(int16_t x, int16_t y, int16_t w, uint16_t color);

private:
uint16_t *buffer;
uint16_t *buffer; // protected (no longer private) for subclass flexibility
};

#endif // _ADAFRUIT_GFX_H
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Adafruit GFX Library
version=1.11.3
version=1.11.4
author=Adafruit
maintainer=Adafruit <[email protected]>
sentence=Adafruit GFX graphics core library, this is the 'core' class that all our other graphics libraries derive from.
Expand Down

0 comments on commit 740677a

Please sign in to comment.