Navigation Menu

Skip to content

Commit

Permalink
Optimize 16 bit color computation.
Browse files Browse the repository at this point in the history
Compute 16 bit as 3 pieces instead of 4 pieces.
  • Loading branch information
freddy77 committed Nov 3, 2013
1 parent 61d0ed4 commit e54ac12
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/dlo_grfx.c
Expand Up @@ -35,14 +35,10 @@
/** Maximum number of pixels that will fit into the scrape buffer. */ /** Maximum number of pixels that will fit into the scrape buffer. */
#define SCRAPE_MAX_PIXELS (2048) #define SCRAPE_MAX_PIXELS (2048)


/** Return red/green/blue component of a 16 bpp colour number (565). */
#define DLO_RGB16(red, grn, blu) (uint16_t)(((((red) & 0xF8) << 8) | (((grn) & 0xFC) << 3) | (((blu) >> 3))) & 0xFFFF)


/** Return red/green component of a 16 bpp colour number. */ /** Return 8 bpp colour number from red, green and blue components (323). */
#define DLO_RG16(red, grn) (uint8_t)((((red) & 0xF8) | ((grn) >> 5)) & 0xFF)

/** Return green/blue component of a 16 bpp colour number. */
#define DLO_GB16(grn, blu) (uint8_t)(((((grn) & 0x1C) << 3) | ((blu) >> 3)) & 0xFF)

/** Return 8 bpp colour number from red, green and blue components. */
#define DLO_RGB8(red, grn, blu) ((((red) << 5) | (((grn) & 3) << 3) | ((blu) & 7)) & 0xFF) #define DLO_RGB8(red, grn, blu) ((((red) << 5) | (((grn) & 3) << 3) | ((blu) & 7)) & 0xFF)




Expand Down Expand Up @@ -823,7 +819,7 @@ static dlo_col16_t rgb16(dlo_col32_t col)
uint8_t grn = DLO_RGB_GETGRN(col); uint8_t grn = DLO_RGB_GETGRN(col);
uint8_t blu = DLO_RGB_GETBLU(col); uint8_t blu = DLO_RGB_GETBLU(col);


return (DLO_RG16(red, grn) << 8) + DLO_GB16(grn, blu); return DLO_RGB16(red, grn, blu);
} }




Expand Down

0 comments on commit e54ac12

Please sign in to comment.