Commit acb1b022 authored by Alexei Podtelezhnikov's avatar Alexei Podtelezhnikov

[graph] Check blending cache earlier.

This slightly reworks commit bfbd7826 by moving the cache
check into the initialization functions. this is especially important
to keep the direct span rendering light.

* graph/gblany.h (*): Move the cache check from here...
* graph/gblblit.c (gblender_blit_init, grSetTargetPenBrush): ... to here.
* graph/gblender.h (GBLANDER_VARS, GBLENDER_CHANNEL_VARS): Restore old macros.
parent 6ff0b61b
2021-01-14 Alexei Podtelezhnikov <apodtele@gmail.com>
[graph] Check blending cache earlier.
This slightly reworks commit bfbd78261beff2d6 by moving the cache
check into the initialization functions. this is especially important
to keep the direct span rendering light.
* graph/gblany.h (*): Move the cache check from here...
* graph/gblblit.c (gblender_blit_init, grSetTargetPenBrush): ... to
here.
* graph/gblender.h (GBLANDER_VARS, GBLENDER_CHANNEL_VARS): Restore old
macros.
2021-01-14 Alexei Podtelezhnikov <apodtele@gmail.com>
[graph] Reduce color conversions in the blender.
......
......@@ -52,15 +52,12 @@ GCONCAT( _gblender_spans_, GDST_TYPE )( int y,
{
grColor color = surface->color;
GBlender blender = surface->gblender;
unsigned char* dst_origin = surface->origin - y * surface->bitmap.pitch;
GDST_PIX;
GBLENDER_VARS;
gblender_use_channels( blender, 0 );
GBLENDER_VARS(blender,pix);
GBLENDER_VARS_SET(blender,pix);
unsigned char* dst_origin = surface->origin - y * surface->bitmap.pitch;
for ( ; count--; spans++ )
{
......@@ -102,16 +99,12 @@ GCONCAT( _gblender_blit_gray8_, GDST_TYPE )( GBlenderBlit blit,
GDST_PIX;
GBLENDER_VARS;
GBLENDER_VARS(blender,pix);
int h = blit->height;
const unsigned char* src_line = blit->src_line;
unsigned char* dst_line = blit->dst_line;
gblender_use_channels( blender, 0 );
GBLENDER_VARS_SET(blender,pix);
do
{
const unsigned char* src = src_line + (blit->src_x);
......@@ -167,16 +160,12 @@ GCONCAT( _gblender_blit_hrgb_, GDST_TYPE )( GBlenderBlit blit,
GDST_CHANNELS;
GBLENDER_CHANNEL_VARS;
GBLENDER_CHANNEL_VARS(blender,r,g,b);
int h = blit->height;
const unsigned char* src_line = blit->src_line;
unsigned char* dst_line = blit->dst_line;
gblender_use_channels( blender, 1 );
GBLENDER_CHANNEL_VARS_SET(blender,r,g,b);
do
{
const unsigned char* src = src_line + blit->src_x*3;
......@@ -256,16 +245,12 @@ GCONCAT( _gblender_blit_hbgr_, GDST_TYPE )( GBlenderBlit blit,
GDST_CHANNELS;
GBLENDER_CHANNEL_VARS;
GBLENDER_CHANNEL_VARS(blender,r,g,b);
int h = blit->height;
const unsigned char* src_line = blit->src_line;
unsigned char* dst_line = blit->dst_line;
gblender_use_channels( blender, 1 );
GBLENDER_CHANNEL_VARS_SET(blender,r,g,b);
do
{
const unsigned char* src = src_line + blit->src_x*3;
......@@ -345,17 +330,13 @@ GCONCAT( _gblender_blit_vrgb_, GDST_TYPE )( GBlenderBlit blit,
GDST_CHANNELS;
GBLENDER_CHANNEL_VARS;
GBLENDER_CHANNEL_VARS(blender,r,g,b);
int h = blit->height;
const unsigned char* src_line = blit->src_line;
int src_pitch = blit->src_pitch;
unsigned char* dst_line = blit->dst_line;
gblender_use_channels( blender, 1 );
GBLENDER_CHANNEL_VARS_SET(blender,r,g,b);
do
{
const unsigned char* src = src_line + blit->src_x;
......@@ -435,17 +416,13 @@ GCONCAT( _gblender_blit_vbgr_, GDST_TYPE )( GBlenderBlit blit,
GDST_CHANNELS;
GBLENDER_CHANNEL_VARS;
GBLENDER_CHANNEL_VARS(blender,r,g,b);
int h = blit->height;
const unsigned char* src_line = blit->src_line;
int src_pitch = blit->src_pitch;
unsigned char* dst_line = blit->dst_line;
gblender_use_channels( blender, 1 );
GBLENDER_CHANNEL_VARS_SET(blender,r,g,b);
do
{
const unsigned char* src = src_line + blit->src_x;
......
......@@ -274,12 +274,27 @@ gblender_blit_init( GBlenderBlit blit,
switch ( glyph->mode )
{
case gr_pixel_mode_gray: src_format = GBLENDER_SOURCE_GRAY8; break;
case gr_pixel_mode_lcd: src_format = GBLENDER_SOURCE_HRGB; break;
case gr_pixel_mode_lcdv: src_format = GBLENDER_SOURCE_VRGB; break;
case gr_pixel_mode_lcd2: src_format = GBLENDER_SOURCE_HBGR; break;
case gr_pixel_mode_lcdv2: src_format = GBLENDER_SOURCE_VBGR; break;
case gr_pixel_mode_bgra: src_format = GBLENDER_SOURCE_BGRA; break;
case gr_pixel_mode_gray: src_format = GBLENDER_SOURCE_GRAY8;
gblender_use_channels( surface->gblender, 0 );
break;
case gr_pixel_mode_lcd: src_format = GBLENDER_SOURCE_HRGB;
src_width /= 3;
gblender_use_channels( surface->gblender, 1 );
break;
case gr_pixel_mode_lcd2: src_format = GBLENDER_SOURCE_HBGR;
src_width /= 3;
gblender_use_channels( surface->gblender, 1 );
break;
case gr_pixel_mode_lcdv: src_format = GBLENDER_SOURCE_VRGB;
src_height /= 3;
gblender_use_channels( surface->gblender, 1 );
break;
case gr_pixel_mode_lcdv2: src_format = GBLENDER_SOURCE_VBGR;
src_height /= 3;
gblender_use_channels( surface->gblender, 1 );
break;
case gr_pixel_mode_bgra: src_format = GBLENDER_SOURCE_BGRA;
break;
default:
return -2;
}
......@@ -306,14 +321,6 @@ gblender_blit_init( GBlenderBlit blit,
return -2;
}
if ( glyph->mode == gr_pixel_mode_lcd ||
glyph->mode == gr_pixel_mode_lcd2 )
src_width /= 3;
if ( glyph->mode == gr_pixel_mode_lcdv ||
glyph->mode == gr_pixel_mode_lcdv2 )
src_height /= 3;
if ( dst_x < 0 )
{
src_width += dst_x;
......@@ -421,6 +428,8 @@ grSetTargetPenBrush( grBitmap* target,
}
surface->color = color;
gblender_use_channels( surface->gblender, 0 );
}
......
......@@ -149,15 +149,10 @@
/* no final `;'! */
#define GBLENDER_VARS \
GBlenderPixel _gback; \
GBlenderCell* _gcells; \
GBlenderPixel _gfore
#define GBLENDER_VARS_SET(_gb,_fore) \
_gback = (_gb)->cache_back; \
_gcells = ( (_fore) == (_gb)->cache_fore ? (_gb)->cache_cells : gblender_lookup( (_gb), _gback, _fore ) ); \
_gfore = (_fore)
#define GBLENDER_VARS(_gb,_fore) \
GBlenderPixel _gback = (_gb)->cache_back; \
GBlenderCell* _gcells = ( (_fore) == (_gb)->cache_fore ? (_gb)->cache_cells : gblender_lookup( (_gb), _gback, _fore ) ); \
GBlenderPixel _gfore = (_fore)
#define GBLENDER_LOOKUP(gb,back) \
GBLENDER_STAT_HIT(gb); \
......@@ -175,27 +170,16 @@
/* no final `;'! */
#define GBLENDER_CHANNEL_VARS \
unsigned int _grback; \
unsigned char* _grcells; \
unsigned int _grfore; \
unsigned int _ggback; \
unsigned char* _ggcells; \
unsigned int _ggfore; \
unsigned int _gbback; \
unsigned char* _gbcells; \
unsigned int _gbfore
#define GBLENDER_CHANNEL_VARS_SET(_gb,_rfore,_gfore,_bfore) \
_grback = (_gb)->cache_r_back; \
_grcells = ( (_rfore) == (_gb)->cache_r_fore ? (_gb)->cache_r_cells : gblender_lookup_channel( (_gb), _grback, _rfore )); \
_grfore = (_rfore); \
_ggback = (_gb)->cache_g_back; \
_ggcells = ( (_gfore) == (_gb)->cache_g_fore ? (_gb)->cache_g_cells : gblender_lookup_channel( (_gb), _ggback, _gfore )); \
_ggfore = (_gfore); \
_gbback = (_gb)->cache_b_back; \
_gbcells = ( (_bfore) == (_gb)->cache_b_fore ? (_gb)->cache_b_cells : gblender_lookup_channel( (_gb), _gbback, _bfore )); \
_gbfore = (_bfore);
#define GBLENDER_CHANNEL_VARS(_gb,_rfore,_gfore,_bfore) \
unsigned int _grback = (_gb)->cache_r_back; \
unsigned char* _grcells = ( (_rfore) == (_gb)->cache_r_fore ? (_gb)->cache_r_cells : gblender_lookup_channel( (_gb), _grback, _rfore )); \
unsigned int _grfore = (_rfore); \
unsigned int _ggback = (_gb)->cache_g_back; \
unsigned char* _ggcells = ( (_gfore) == (_gb)->cache_g_fore ? (_gb)->cache_g_cells : gblender_lookup_channel( (_gb), _ggback, _gfore )); \
unsigned int _ggfore = (_rfore); \
unsigned int _gbback = (_gb)->cache_b_back; \
unsigned char* _gbcells = ( (_bfore) == (_gb)->cache_b_fore ? (_gb)->cache_b_cells : gblender_lookup_channel( (_gb), _gbback, _bfore )); \
unsigned int _gbfore = (_bfore)
#define GBLENDER_CHANNEL_CLOSE(_gb) \
(_gb)->cache_r_back = _grback; \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment