Use transparency for gradients fdo#45219
vclcanvas has 1bpp alpha - so cut-off transparency at 98% This looks for all practical cases close enough to full alpha.
This commit is contained in:
parent
4b475f31eb
commit
3f5efa1e76
@ -155,8 +155,9 @@ namespace vclcanvas
|
||||
tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev );
|
||||
|
||||
rOutDev.EnableMapMode( sal_False );
|
||||
rOutDev.SetLineColor( COL_TRANSPARENT );
|
||||
rOutDev.SetFillColor( COL_TRANSPARENT );
|
||||
rOutDev.SetLineColor( COL_WHITE );
|
||||
rOutDev.SetFillColor( COL_WHITE );
|
||||
rOutDev.SetClipRegion();
|
||||
rOutDev.DrawRect( Rectangle( Point(),
|
||||
rOutDev.GetOutputSizePixel()) );
|
||||
|
||||
@ -166,8 +167,9 @@ namespace vclcanvas
|
||||
|
||||
rOutDev2.SetDrawMode( DRAWMODE_DEFAULT );
|
||||
rOutDev2.EnableMapMode( sal_False );
|
||||
rOutDev2.SetLineColor( COL_TRANSPARENT );
|
||||
rOutDev2.SetFillColor( COL_TRANSPARENT );
|
||||
rOutDev2.SetLineColor( COL_WHITE );
|
||||
rOutDev2.SetFillColor( COL_WHITE );
|
||||
rOutDev2.SetClipRegion();
|
||||
rOutDev2.DrawRect( Rectangle( Point(),
|
||||
rOutDev2.GetOutputSizePixel()) );
|
||||
rOutDev2.SetDrawMode( DRAWMODE_BLACKLINE | DRAWMODE_BLACKFILL | DRAWMODE_BLACKTEXT |
|
||||
@ -500,19 +502,11 @@ namespace vclcanvas
|
||||
|
||||
if( mp2ndOutDev )
|
||||
{
|
||||
// HACK. Normally, CanvasHelper does not care
|
||||
// about actually what mp2ndOutDev is...
|
||||
// well, here we do & assume a 1bpp target.
|
||||
if( nTransparency > 127 )
|
||||
{
|
||||
mp2ndOutDev->getOutDev().SetDrawMode( DRAWMODE_WHITELINE | DRAWMODE_WHITEFILL | DRAWMODE_WHITETEXT |
|
||||
DRAWMODE_WHITEGRADIENT | DRAWMODE_WHITEBITMAP );
|
||||
mp2ndOutDev->getOutDev().SetFillColor( COL_WHITE );
|
||||
mp2ndOutDev->getOutDev().DrawPolyPolygon( aPolyPoly );
|
||||
mp2ndOutDev->getOutDev().SetDrawMode( DRAWMODE_BLACKLINE | DRAWMODE_BLACKFILL | DRAWMODE_BLACKTEXT |
|
||||
DRAWMODE_BLACKGRADIENT | DRAWMODE_BLACKBITMAP );
|
||||
}
|
||||
else
|
||||
// HACK. Normally, CanvasHelper does not care about
|
||||
// actually what mp2ndOutDev is... well, here we do &
|
||||
// assume a 1bpp target - everything beyond 97%
|
||||
// transparency is fully transparent
|
||||
if( nTransparency < 253 )
|
||||
{
|
||||
mp2ndOutDev->getOutDev().SetFillColor( COL_BLACK );
|
||||
mp2ndOutDev->getOutDev().DrawPolyPolygon( aPolyPoly );
|
||||
@ -716,8 +710,25 @@ namespace vclcanvas
|
||||
aBmpEx );
|
||||
|
||||
if( mp2ndOutDev )
|
||||
{
|
||||
// HACK. Normally, CanvasHelper does not care about
|
||||
// actually what mp2ndOutDev is... well, here we do &
|
||||
// assume a 1bpp target - everything beyond 97%
|
||||
// transparency is fully transparent
|
||||
if( aBmpEx.IsAlpha() )
|
||||
{
|
||||
Bitmap aMask( aBmpEx.GetAlpha().GetBitmap() );
|
||||
aMask.MakeMono( 253 );
|
||||
aBmpEx = BitmapEx( aBmpEx.GetBitmap(), aMask );
|
||||
}
|
||||
else if( aBmpEx.IsTransparent() )
|
||||
{
|
||||
aBmpEx = BitmapEx( aBmpEx.GetBitmap(), aBmpEx.GetMask() );
|
||||
}
|
||||
|
||||
mp2ndOutDev->getOutDev().DrawBitmapEx( ::vcl::unotools::pointFromB2DPoint( aOutputPos ),
|
||||
aBmpEx );
|
||||
}
|
||||
|
||||
// Returning a cache object is not useful, the XBitmap
|
||||
// itself serves this purpose
|
||||
|
@ -555,8 +555,6 @@ namespace vclcanvas
|
||||
const rendering::Texture& texture,
|
||||
int nTransparency )
|
||||
{
|
||||
(void)nTransparency;
|
||||
|
||||
// TODO(T2): It is maybe necessary to lock here, should
|
||||
// maGradientPoly someday cease to be const. But then, beware of
|
||||
// deadlocks, canvashelper calls this method with locked own
|
||||
@ -606,18 +604,14 @@ namespace vclcanvas
|
||||
false );
|
||||
rOutDev.Pop();
|
||||
|
||||
if( p2ndOutDev )
|
||||
if( p2ndOutDev && nTransparency < 253 )
|
||||
{
|
||||
p2ndOutDev->Push( PUSH_CLIPREGION );
|
||||
p2ndOutDev->IntersectClipRegion( aPolygonDeviceRectOrig );
|
||||
doGradientFill( *p2ndOutDev,
|
||||
rValues,
|
||||
rColors,
|
||||
aTotalTransform,
|
||||
aPolygonDeviceRectOrig,
|
||||
nStepCount,
|
||||
false );
|
||||
p2ndOutDev->Pop();
|
||||
// HACK. Normally, CanvasHelper does not care about
|
||||
// actually what mp2ndOutDev is... well, here we do &
|
||||
// assume a 1bpp target - everything beyond 97%
|
||||
// transparency is fully transparent
|
||||
p2ndOutDev->SetFillColor( COL_BLACK );
|
||||
p2ndOutDev->DrawRect( aPolygonDeviceRectOrig );
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -636,18 +630,14 @@ namespace vclcanvas
|
||||
false );
|
||||
rOutDev.Pop();
|
||||
|
||||
if( p2ndOutDev )
|
||||
if( p2ndOutDev && nTransparency < 253 )
|
||||
{
|
||||
p2ndOutDev->Push( PUSH_CLIPREGION );
|
||||
p2ndOutDev->SetClipRegion( aPolyClipRegion );
|
||||
doGradientFill( *p2ndOutDev,
|
||||
rValues,
|
||||
rColors,
|
||||
aTotalTransform,
|
||||
aPolygonDeviceRectOrig,
|
||||
nStepCount,
|
||||
false );
|
||||
p2ndOutDev->Pop();
|
||||
// HACK. Normally, CanvasHelper does not care about
|
||||
// actually what mp2ndOutDev is... well, here we do &
|
||||
// assume a 1bpp target - everything beyond 97%
|
||||
// transparency is fully transparent
|
||||
p2ndOutDev->SetFillColor( COL_BLACK );
|
||||
p2ndOutDev->DrawPolyPolygon( rPoly );
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user