From 94fecbdd470d030c1c6665cb8b6d89cba8f3dfa6 Mon Sep 17 00:00:00 2001 From: philippe44 Date: Sat, 22 Feb 2020 19:35:16 -0800 Subject: [PATCH] correct some inlining --- components/display/SH1106.c | 2 +- components/display/SSD1306.c | 2 +- components/display/core/gds_draw.c | 39 +++------------------- components/display/core/gds_font.c | 2 +- components/display/core/gds_private.h | 48 ++++++++++++++++++--------- 5 files changed, 40 insertions(+), 53 deletions(-) diff --git a/components/display/SH1106.c b/components/display/SH1106.c index 2847321d..2bc5ae6f 100644 --- a/components/display/SH1106.c +++ b/components/display/SH1106.c @@ -130,7 +130,7 @@ static bool Init( struct GDS_Device* Device ) { static const struct GDS_Device SH1106 = { .DisplayOn = DisplayOn, .DisplayOff = DisplayOff, .SetContrast = SetContrast, .SetVFlip = SetVFlip, .SetHFlip = SetHFlip, - .DrawPixel = GDS_DrawPixel, .DrawPixelFast = GDS_DrawPixelFast, + .DrawPixelFast = GDS_DrawPixelFast, .Update = Update, .Init = Init, }; diff --git a/components/display/SSD1306.c b/components/display/SSD1306.c index adb34b1b..e102c7ba 100644 --- a/components/display/SSD1306.c +++ b/components/display/SSD1306.c @@ -131,7 +131,7 @@ static bool Init( struct GDS_Device* Device ) { static const struct GDS_Device SSD1306 = { .DisplayOn = DisplayOn, .DisplayOff = DisplayOff, .SetContrast = SetContrast, .SetVFlip = SetVFlip, .SetHFlip = SetHFlip, - .DrawPixel = GDS_DrawPixel, .DrawPixelFast = GDS_DrawPixelFast, + .DrawPixelFast = GDS_DrawPixelFast, .Update = Update, .Init = Init, }; diff --git a/components/display/core/gds_draw.c b/components/display/core/gds_draw.c index ac9a5959..5e464993 100644 --- a/components/display/core/gds_draw.c +++ b/components/display/core/gds_draw.c @@ -38,23 +38,6 @@ static const unsigned char BitReverseTable256[] = 0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF, 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF }; -__attribute__( ( always_inline ) ) static inline bool IsPixelVisible( struct GDS_Device* Device, int x, int y ) { - bool Result = ( - ( x >= 0 ) && - ( x < Device->Width ) && - ( y >= 0 ) && - ( y < Device->Height ) - ) ? true : false; - -#if CONFIG_GDS_CLIPDEBUG > 0 - if ( Result == false ) { - ClipDebug( x, y ); - } -#endif - - return Result; -} - __attribute__( ( always_inline ) ) static inline void SwapInt( int* a, int* b ) { int Temp = *b; @@ -83,12 +66,6 @@ inline void IRAM_ATTR GDS_DrawPixelFast( struct GDS_Device* Device, int X, int Y } } -void IRAM_ATTR GDS_DrawPixel( struct GDS_Device* Device, int x, int y, int Color ) { - if ( IsPixelVisible( Device, x, y ) == true ) { - Device->DrawPixelFast( Device, x, y, Color ); - } -} - inline void IRAM_ATTR GDS_DrawPixel4Fast( struct GDS_Device* Device, int X, int Y, int Color ) { uint32_t YBit = ( Y & 0x07 ); uint8_t* FBOffset = NULL; @@ -110,12 +87,6 @@ inline void IRAM_ATTR GDS_DrawPixel4Fast( struct GDS_Device* Device, int X, int } } -void IRAM_ATTR GDS_DrawPixel4( struct GDS_Device* Device, int x, int y, int Color ) { - if ( IsPixelVisible( Device, x, y ) == true ) { - Device->DrawPixelFast( Device, x, y, Color ); - } -} - void IRAM_ATTR GDS_DrawHLine( struct GDS_Device* Device, int x, int y, int Width, int Color ) { int XEnd = x + Width; @@ -128,11 +99,11 @@ void IRAM_ATTR GDS_DrawHLine( struct GDS_Device* Device, int x, int y, int Width else if (y >= Device->Height) x = Device->Height - 1; for ( ; x < XEnd; x++ ) { - // if ( IsPixelVisible( Device, x, y ) == true ) { + if ( IsPixelVisible( Device, x, y ) == true ) { Device->DrawPixelFast( Device, x, y, Color ); - // } else { - // break; - // } + } else { + break; + } } } @@ -143,7 +114,7 @@ void IRAM_ATTR GDS_DrawVLine( struct GDS_Device* Device, int x, int y, int Heigh for ( ; y < YEnd; y++ ) { if ( IsPixelVisible( Device, x, y ) == true ) { - Device->DrawPixel( Device, x, y, Color ); + GDS_DrawPixel( Device, x, y, Color ); } else { break; } diff --git a/components/display/core/gds_font.c b/components/display/core/gds_font.c index b8dda265..e0d2981f 100644 --- a/components/display/core/gds_font.c +++ b/components/display/core/gds_font.c @@ -89,7 +89,7 @@ void GDS_FontDrawChar( struct GDS_Device* Device, char Character, int x, int y, YBit = ( i + OffsetY ) & 0x07; if ( GlyphData[ YByte ] & BIT( YBit ) ) { - Device->DrawPixel( Device, x, y, Color ); + GDS_DrawPixel( Device, x, y, Color ); } } diff --git a/components/display/core/gds_private.h b/components/display/core/gds_private.h index 52ce2766..518f4283 100644 --- a/components/display/core/gds_private.h +++ b/components/display/core/gds_private.h @@ -44,13 +44,6 @@ #define BIT( n ) ( 1 << n ) #endif -typedef enum { - AddressMode_Horizontal = 0, - AddressMode_Vertical, - AddressMode_Page, - AddressMode_Invalid -} GDS_AddressMode; - struct GDS_Device; struct GDS_FontDef; @@ -106,7 +99,6 @@ struct GDS_Device { void (*DisplayOn)( struct GDS_Device* Device ); void (*DisplayOff)( struct GDS_Device* Device ); void (*Update)( struct GDS_Device* Device ); - void (*DrawPixel)( struct GDS_Device* Device, int X, int Y, int Color ); void (*DrawPixelFast)( struct GDS_Device* Device, int X, int Y, int Color ); void (*SetHFlip)( struct GDS_Device* Device, bool On ); void (*SetVFlip)( struct GDS_Device* Device, bool On ); @@ -118,13 +110,37 @@ struct GDS_Device { bool GDS_Reset( struct GDS_Device* Device ); -/* -inline void IRAM_ATTR GDS_DrawPixelFast( struct GDS_Device* Device, int X, int Y, int Color ); -void IRAM_ATTR GDS_DrawPixel( struct GDS_Device* Device, int x, int y, int Color ); -inline void IRAM_ATTR GDS_DrawPixel4Fast( struct GDS_Device* Device, int X, int Y, int Color ); -void IRAM_ATTR GDS_DrawPixel4( struct GDS_Device* Device, int x, int y, int Color ); -*/ void IRAM_ATTR GDS_DrawPixelFast( struct GDS_Device* Device, int X, int Y, int Color ); -void IRAM_ATTR GDS_DrawPixel( struct GDS_Device* Device, int x, int y, int Color ); void IRAM_ATTR GDS_DrawPixel4Fast( struct GDS_Device* Device, int X, int Y, int Color ); -void IRAM_ATTR GDS_DrawPixel4( struct GDS_Device* Device, int x, int y, int Color ); + +inline bool IsPixelVisible( struct GDS_Device* Device, int x, int y ) { + bool Result = ( + ( x >= 0 ) && + ( x < Device->Width ) && + ( y >= 0 ) && + ( y < Device->Height ) + ) ? true : false; + +#if CONFIG_GDS_CLIPDEBUG > 0 + if ( Result == false ) { + ClipDebug( x, y ); + } +#endif + + return Result; +} + +inline void IRAM_ATTR GDS_DrawPixel( struct GDS_Device* Device, int x, int y, int Color ) { + if ( IsPixelVisible( Device, x, y ) == true ) { + Device->DrawPixelFast( Device, x, y, Color ); + } +} + +inline void IRAM_ATTR GDS_DrawPixel4( struct GDS_Device* Device, int x, int y, int Color ) { + if ( IsPixelVisible( Device, x, y ) == true ) { + Device->DrawPixelFast( Device, x, y, Color ); + } +} + + +