Skip to content

Commit

Permalink
Faster multiband color renderer in some circumstances
Browse files Browse the repository at this point in the history
(cherry picked from commit c0d2924)
  • Loading branch information
nyalldawson committed Dec 21, 2020
1 parent d9d5f20 commit 3f091dd
Showing 1 changed file with 30 additions and 9 deletions.
39 changes: 30 additions & 9 deletions src/core/raster/qgsmultibandcolorrenderer.cpp
Expand Up @@ -266,23 +266,44 @@ QgsRasterBlock *QgsMultiBandColorRenderer::block( int bandNo, QgsRectangle cons
{
if ( fastDraw ) //fast rendering if no transparency, stretching, color inversion, etc.
{
if ( redBlock->isNoData( i ) ||
greenBlock->isNoData( i ) ||
blueBlock->isNoData( i ) )
if ( hasByteRgb )
{
outputBlock->setColor( i, myDefaultColor );
if ( redBlock->isNoData( i ) ||
greenBlock->isNoData( i ) ||
blueBlock->isNoData( i ) )
{
outputBlock->setColor( i, myDefaultColor );
}
else
{
outputBlockColorData[i] = qRgb( redData[i], greenData[i], blueData[i] );
}
}
else
{
if ( hasByteRgb )
bool redIsNoData = false;
bool greenIsNoData = false;
bool blueIsNoData = false;
int redVal = 0;
int greenVal = 0;
int blueVal = 0;

redVal = redBlock->valueAndNoData( i, redIsNoData );
// as soon as any channel has a no data value, don't do any more work -- the result will
// always be the nodata color!
if ( !redIsNoData )
greenVal = greenBlock->valueAndNoData( i, greenIsNoData );
if ( !redIsNoData && !greenIsNoData )
blueVal = blueBlock->valueAndNoData( i, blueIsNoData );

if ( redIsNoData ||
greenIsNoData ||
blueIsNoData )
{
outputBlockColorData[i] = qRgb( redData[i], greenData[i], blueData[i] );
outputBlock->setColor( i, myDefaultColor );
}
else
{
int redVal = static_cast<int>( redBlock->value( i ) );
int greenVal = static_cast<int>( greenBlock->value( i ) );
int blueVal = static_cast<int>( blueBlock->value( i ) );
outputBlockColorData[i] = qRgb( redVal, greenVal, blueVal );
}
}
Expand Down

0 comments on commit 3f091dd

Please sign in to comment.