diff options
Diffstat (limited to 'canvas/source/vcl')
-rw-r--r-- | canvas/source/vcl/backbuffer.cxx | 20 | ||||
-rw-r--r-- | canvas/source/vcl/bitmapbackbuffer.cxx | 36 | ||||
-rw-r--r-- | canvas/source/vcl/canvashelper.cxx | 144 | ||||
-rw-r--r-- | canvas/source/vcl/devicehelper.cxx | 24 | ||||
-rw-r--r-- | canvas/source/vcl/spritecanvashelper.cxx | 80 | ||||
-rw-r--r-- | canvas/source/vcl/spritehelper.cxx | 414 |
6 files changed, 359 insertions, 359 deletions
diff --git a/canvas/source/vcl/backbuffer.cxx b/canvas/source/vcl/backbuffer.cxx index 291842dfda11..427f77f12d53 100644 --- a/canvas/source/vcl/backbuffer.cxx +++ b/canvas/source/vcl/backbuffer.cxx @@ -31,19 +31,19 @@ namespace vclcanvas maVDev( VclPtr<VirtualDevice>::Create( rRefDevice, bMonochromeBuffer ? DeviceFormat::BITMASK : DeviceFormat::DEFAULT ) ) { - if( !bMonochromeBuffer ) - { - // #i95645# + if( bMonochromeBuffer ) + return; + + // #i95645# #if defined( MACOSX ) - // use AA on VCLCanvas for Mac - maVDev->SetAntialiasing( AntialiasingFlags::EnableB2dDraw | maVDev->GetAntialiasing() ); + // use AA on VCLCanvas for Mac + maVDev->SetAntialiasing( AntialiasingFlags::EnableB2dDraw | maVDev->GetAntialiasing() ); #else - // switch off AA for WIN32 and UNIX, the VCLCanvas does not look good with it and - // is not required to do AA. It would need to be adapted to use it correctly - // (especially gradient painting). This will need extra work. - maVDev->SetAntialiasing( maVDev->GetAntialiasing() & ~AntialiasingFlags::EnableB2dDraw); + // switch off AA for WIN32 and UNIX, the VCLCanvas does not look good with it and + // is not required to do AA. It would need to be adapted to use it correctly + // (especially gradient painting). This will need extra work. + maVDev->SetAntialiasing( maVDev->GetAntialiasing() & ~AntialiasingFlags::EnableB2dDraw); #endif - } } BackBuffer::~BackBuffer() diff --git a/canvas/source/vcl/bitmapbackbuffer.cxx b/canvas/source/vcl/bitmapbackbuffer.cxx index 598f1ef04f64..0072a807ea31 100644 --- a/canvas/source/vcl/bitmapbackbuffer.cxx +++ b/canvas/source/vcl/bitmapbackbuffer.cxx @@ -106,30 +106,30 @@ namespace vclcanvas void BitmapBackBuffer::createVDev() const { - if( !mpVDev ) - { - // VDev not yet created, do it now. Create an alpha-VDev, - // if bitmap has transparency. - mpVDev = maBitmap->IsTransparent() ? - VclPtr<VirtualDevice>::Create( mrRefDevice, DeviceFormat::DEFAULT, DeviceFormat::DEFAULT ) : - VclPtr<VirtualDevice>::Create( mrRefDevice ); + if( mpVDev ) + return; + + // VDev not yet created, do it now. Create an alpha-VDev, + // if bitmap has transparency. + mpVDev = maBitmap->IsTransparent() ? + VclPtr<VirtualDevice>::Create( mrRefDevice, DeviceFormat::DEFAULT, DeviceFormat::DEFAULT ) : + VclPtr<VirtualDevice>::Create( mrRefDevice ); - OSL_ENSURE( mpVDev, - "BitmapBackBuffer::createVDev(): Unable to create VirtualDevice" ); + OSL_ENSURE( mpVDev, + "BitmapBackBuffer::createVDev(): Unable to create VirtualDevice" ); - mpVDev->SetOutputSizePixel( maBitmap->GetSizePixel() ); + mpVDev->SetOutputSizePixel( maBitmap->GetSizePixel() ); - // #i95645# + // #i95645# #if defined( MACOSX ) - // use AA on VCLCanvas for Mac - mpVDev->SetAntialiasing( AntialiasingFlags::EnableB2dDraw | mpVDev->GetAntialiasing() ); + // use AA on VCLCanvas for Mac + mpVDev->SetAntialiasing( AntialiasingFlags::EnableB2dDraw | mpVDev->GetAntialiasing() ); #else - // switch off AA for WIN32 and UNIX, the VCLCanvas does not look good with it and - // is not required to do AA. It would need to be adapted to use it correctly - // (especially gradient painting). This will need extra work. - mpVDev->SetAntialiasing(mpVDev->GetAntialiasing() & ~AntialiasingFlags::EnableB2dDraw); + // switch off AA for WIN32 and UNIX, the VCLCanvas does not look good with it and + // is not required to do AA. It would need to be adapted to use it correctly + // (especially gradient painting). This will need extra work. + mpVDev->SetAntialiasing(mpVDev->GetAntialiasing() & ~AntialiasingFlags::EnableB2dDraw); #endif - } } void BitmapBackBuffer::updateVDev() const diff --git a/canvas/source/vcl/canvashelper.cxx b/canvas/source/vcl/canvashelper.cxx index 7a1578bef92b..9f1808c858e7 100644 --- a/canvas/source/vcl/canvashelper.cxx +++ b/canvas/source/vcl/canvashelper.cxx @@ -154,35 +154,35 @@ namespace vclcanvas void CanvasHelper::clear() { // are we disposed? - if( mpOutDevProvider ) - { - OutputDevice& rOutDev( mpOutDevProvider->getOutDev() ); - tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDevProvider ); + if( !mpOutDevProvider ) + return; - rOutDev.EnableMapMode( false ); - rOutDev.SetAntialiasing( AntialiasingFlags::EnableB2dDraw ); - rOutDev.SetLineColor( COL_WHITE ); - rOutDev.SetFillColor( COL_WHITE ); - rOutDev.SetClipRegion(); - rOutDev.DrawRect( ::tools::Rectangle( Point(), - rOutDev.GetOutputSizePixel()) ); + OutputDevice& rOutDev( mpOutDevProvider->getOutDev() ); + tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDevProvider ); - if( mp2ndOutDevProvider ) - { - OutputDevice& rOutDev2( mp2ndOutDevProvider->getOutDev() ); - - rOutDev2.SetDrawMode( DrawModeFlags::Default ); - rOutDev2.EnableMapMode( false ); - rOutDev2.SetAntialiasing( AntialiasingFlags::EnableB2dDraw ); - rOutDev2.SetLineColor( COL_WHITE ); - rOutDev2.SetFillColor( COL_WHITE ); - rOutDev2.SetClipRegion(); - rOutDev2.DrawRect( ::tools::Rectangle( Point(), - rOutDev2.GetOutputSizePixel()) ); - rOutDev2.SetDrawMode( DrawModeFlags::BlackLine | DrawModeFlags::BlackFill | DrawModeFlags::BlackText | - DrawModeFlags::BlackGradient | DrawModeFlags::BlackBitmap ); - } - } + rOutDev.EnableMapMode( false ); + rOutDev.SetAntialiasing( AntialiasingFlags::EnableB2dDraw ); + rOutDev.SetLineColor( COL_WHITE ); + rOutDev.SetFillColor( COL_WHITE ); + rOutDev.SetClipRegion(); + rOutDev.DrawRect( ::tools::Rectangle( Point(), + rOutDev.GetOutputSizePixel()) ); + + if( !mp2ndOutDevProvider ) + return; + + OutputDevice& rOutDev2( mp2ndOutDevProvider->getOutDev() ); + + rOutDev2.SetDrawMode( DrawModeFlags::Default ); + rOutDev2.EnableMapMode( false ); + rOutDev2.SetAntialiasing( AntialiasingFlags::EnableB2dDraw ); + rOutDev2.SetLineColor( COL_WHITE ); + rOutDev2.SetFillColor( COL_WHITE ); + rOutDev2.SetClipRegion(); + rOutDev2.DrawRect( ::tools::Rectangle( Point(), + rOutDev2.GetOutputSizePixel()) ); + rOutDev2.SetDrawMode( DrawModeFlags::BlackLine | DrawModeFlags::BlackFill | DrawModeFlags::BlackText | + DrawModeFlags::BlackGradient | DrawModeFlags::BlackBitmap ); } void CanvasHelper::drawLine( const rendering::XCanvas* , @@ -192,22 +192,22 @@ namespace vclcanvas const rendering::RenderState& renderState ) { // are we disposed? - if( mpOutDevProvider ) - { - // nope, render - tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDevProvider ); - setupOutDevState( viewState, renderState, LINE_COLOR ); + if( !mpOutDevProvider ) + return; - const Point aStartPoint( tools::mapRealPoint2D( aStartRealPoint2D, - viewState, renderState ) ); - const Point aEndPoint( tools::mapRealPoint2D( aEndRealPoint2D, - viewState, renderState ) ); - // TODO(F2): alpha - mpOutDevProvider->getOutDev().DrawLine( aStartPoint, aEndPoint ); + // nope, render + tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDevProvider ); + setupOutDevState( viewState, renderState, LINE_COLOR ); - if( mp2ndOutDevProvider ) - mp2ndOutDevProvider->getOutDev().DrawLine( aStartPoint, aEndPoint ); - } + const Point aStartPoint( tools::mapRealPoint2D( aStartRealPoint2D, + viewState, renderState ) ); + const Point aEndPoint( tools::mapRealPoint2D( aEndRealPoint2D, + viewState, renderState ) ); + // TODO(F2): alpha + mpOutDevProvider->getOutDev().DrawLine( aStartPoint, aEndPoint ); + + if( mp2ndOutDevProvider ) + mp2ndOutDevProvider->getOutDev().DrawLine( aStartPoint, aEndPoint ); } void CanvasHelper::drawBezier( const rendering::XCanvas* , @@ -216,38 +216,38 @@ namespace vclcanvas const rendering::ViewState& viewState, const rendering::RenderState& renderState ) { - if( mpOutDevProvider ) - { - tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDevProvider ); - setupOutDevState( viewState, renderState, LINE_COLOR ); - - const Point& rStartPoint( tools::mapRealPoint2D( geometry::RealPoint2D(aBezierSegment.Px, - aBezierSegment.Py), - viewState, renderState ) ); - const Point& rCtrlPoint1( tools::mapRealPoint2D( geometry::RealPoint2D(aBezierSegment.C1x, - aBezierSegment.C1y), - viewState, renderState ) ); - const Point& rCtrlPoint2( tools::mapRealPoint2D( geometry::RealPoint2D(aBezierSegment.C2x, - aBezierSegment.C2y), - viewState, renderState ) ); - const Point& rEndPoint( tools::mapRealPoint2D( _aEndPoint, - viewState, renderState ) ); - - ::tools::Polygon aPoly(4); - aPoly.SetPoint( rStartPoint, 0 ); - aPoly.SetFlags( 0, PolyFlags::Normal ); - aPoly.SetPoint( rCtrlPoint1, 1 ); - aPoly.SetFlags( 1, PolyFlags::Control ); - aPoly.SetPoint( rCtrlPoint2, 2 ); - aPoly.SetFlags( 2, PolyFlags::Control ); - aPoly.SetPoint( rEndPoint, 3 ); - aPoly.SetFlags( 3, PolyFlags::Normal ); + if( !mpOutDevProvider ) + return; - // TODO(F2): alpha - mpOutDevProvider->getOutDev().DrawPolygon( aPoly ); - if( mp2ndOutDevProvider ) - mp2ndOutDevProvider->getOutDev().DrawPolygon( aPoly ); - } + tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDevProvider ); + setupOutDevState( viewState, renderState, LINE_COLOR ); + + const Point& rStartPoint( tools::mapRealPoint2D( geometry::RealPoint2D(aBezierSegment.Px, + aBezierSegment.Py), + viewState, renderState ) ); + const Point& rCtrlPoint1( tools::mapRealPoint2D( geometry::RealPoint2D(aBezierSegment.C1x, + aBezierSegment.C1y), + viewState, renderState ) ); + const Point& rCtrlPoint2( tools::mapRealPoint2D( geometry::RealPoint2D(aBezierSegment.C2x, + aBezierSegment.C2y), + viewState, renderState ) ); + const Point& rEndPoint( tools::mapRealPoint2D( _aEndPoint, + viewState, renderState ) ); + + ::tools::Polygon aPoly(4); + aPoly.SetPoint( rStartPoint, 0 ); + aPoly.SetFlags( 0, PolyFlags::Normal ); + aPoly.SetPoint( rCtrlPoint1, 1 ); + aPoly.SetFlags( 1, PolyFlags::Control ); + aPoly.SetPoint( rCtrlPoint2, 2 ); + aPoly.SetFlags( 2, PolyFlags::Control ); + aPoly.SetPoint( rEndPoint, 3 ); + aPoly.SetFlags( 3, PolyFlags::Normal ); + + // TODO(F2): alpha + mpOutDevProvider->getOutDev().DrawPolygon( aPoly ); + if( mp2ndOutDevProvider ) + mp2ndOutDevProvider->getOutDev().DrawPolygon( aPoly ); } uno::Reference< rendering::XCachedPrimitive > CanvasHelper::drawPolyPolygon( const rendering::XCanvas* , diff --git a/canvas/source/vcl/devicehelper.cxx b/canvas/source/vcl/devicehelper.cxx index 3a48c3f1a490..b9d4138aade1 100644 --- a/canvas/source/vcl/devicehelper.cxx +++ b/canvas/source/vcl/devicehelper.cxx @@ -196,21 +196,21 @@ namespace vclcanvas { static sal_Int32 nFilePostfixCount(0); - if( mpOutDev ) - { - OUString aFilename = "dbg_frontbuffer" + OUString::number(nFilePostfixCount) + ".bmp"; + if( !mpOutDev ) + return; - SvFileStream aStream( aFilename, StreamMode::STD_READWRITE ); + OUString aFilename = "dbg_frontbuffer" + OUString::number(nFilePostfixCount) + ".bmp"; - const ::Point aEmptyPoint; - OutputDevice& rOutDev = mpOutDev->getOutDev(); - bool bOldMap( rOutDev.IsMapModeEnabled() ); - rOutDev.EnableMapMode( false ); - WriteDIB(rOutDev.GetBitmapEx(aEmptyPoint, rOutDev.GetOutputSizePixel()), aStream, false); - rOutDev.EnableMapMode( bOldMap ); + SvFileStream aStream( aFilename, StreamMode::STD_READWRITE ); + + const ::Point aEmptyPoint; + OutputDevice& rOutDev = mpOutDev->getOutDev(); + bool bOldMap( rOutDev.IsMapModeEnabled() ); + rOutDev.EnableMapMode( false ); + WriteDIB(rOutDev.GetBitmapEx(aEmptyPoint, rOutDev.GetOutputSizePixel()), aStream, false); + rOutDev.EnableMapMode( bOldMap ); - ++nFilePostfixCount; - } + ++nFilePostfixCount; } } diff --git a/canvas/source/vcl/spritecanvashelper.cxx b/canvas/source/vcl/spritecanvashelper.cxx index 8d58f4fcb359..d7fe7d37be0a 100644 --- a/canvas/source/vcl/spritecanvashelper.cxx +++ b/canvas/source/vcl/spritecanvashelper.cxx @@ -597,64 +597,64 @@ namespace vclcanvas void SpriteCanvasHelper::renderSpriteCount( OutputDevice& rOutDev ) { - if( mpRedrawManager ) - { - sal_Int32 nCount(0); + if( !mpRedrawManager ) + return; - mpRedrawManager->forEachSprite( makeAdder(nCount,sal_Int32(1)) ); - OUString text( OUString::number(nCount) ); + sal_Int32 nCount(0); - // pad with leading space - while( text.getLength() < 3 ) - text = " " + text; + mpRedrawManager->forEachSprite( makeAdder(nCount,sal_Int32(1)) ); + OUString text( OUString::number(nCount) ); - text = "Sprites: " + text; + // pad with leading space + while( text.getLength() < 3 ) + text = " " + text; - renderInfoText( rOutDev, - text, - Point(0, 30) ); - } + text = "Sprites: " + text; + + renderInfoText( rOutDev, + text, + Point(0, 30) ); } void SpriteCanvasHelper::renderMemUsage( OutputDevice& rOutDev ) { BackBufferSharedPtr pBackBuffer( mpOwningSpriteCanvas->getBackBuffer() ); - if( mpRedrawManager && - pBackBuffer ) - { - double nPixel(0.0); + if( !(mpRedrawManager && + pBackBuffer) ) + return; - // accumulate pixel count for each sprite into fCount - mpRedrawManager->forEachSprite( - [&nPixel]( const ::canvas::Sprite::Reference& rSprite ) - { makeAdder( nPixel, 1.0 )( calcNumPixel(rSprite) ); } - ); + double nPixel(0.0); + + // accumulate pixel count for each sprite into fCount + mpRedrawManager->forEachSprite( + [&nPixel]( const ::canvas::Sprite::Reference& rSprite ) + { makeAdder( nPixel, 1.0 )( calcNumPixel(rSprite) ); } + ); - static const int NUM_VIRDEV(2); - static const int BYTES_PER_PIXEL(3); + static const int NUM_VIRDEV(2); + static const int BYTES_PER_PIXEL(3); - const Size& rVDevSize( maVDev->GetOutputSizePixel() ); - const Size& rBackBufferSize( pBackBuffer->getOutDev().GetOutputSizePixel() ); + const Size& rVDevSize( maVDev->GetOutputSizePixel() ); + const Size& rBackBufferSize( pBackBuffer->getOutDev().GetOutputSizePixel() ); - const double nMemUsage( nPixel * NUM_VIRDEV * BYTES_PER_PIXEL + - rVDevSize.Width()*rVDevSize.Height() * BYTES_PER_PIXEL + - rBackBufferSize.Width()*rBackBufferSize.Height() * BYTES_PER_PIXEL ); + const double nMemUsage( nPixel * NUM_VIRDEV * BYTES_PER_PIXEL + + rVDevSize.Width()*rVDevSize.Height() * BYTES_PER_PIXEL + + rBackBufferSize.Width()*rBackBufferSize.Height() * BYTES_PER_PIXEL ); - OUString text( ::rtl::math::doubleToUString( nMemUsage / 1048576.0, - rtl_math_StringFormat_F, - 2,'.',nullptr,' ') ); + OUString text( ::rtl::math::doubleToUString( nMemUsage / 1048576.0, + rtl_math_StringFormat_F, + 2,'.',nullptr,' ') ); - // pad with leading space - while( text.getLength() < 4 ) - text = " " + text; + // pad with leading space + while( text.getLength() < 4 ) + text = " " + text; - text = "Mem: " + text + "MB"; + text = "Mem: " + text + "MB"; - renderInfoText( rOutDev, - text, - Point(0, 60) ); - } + renderInfoText( rOutDev, + text, + Point(0, 60) ); } } diff --git a/canvas/source/vcl/spritehelper.cxx b/canvas/source/vcl/spritehelper.cxx index 5bad0ae9697d..63a9407642a7 100644 --- a/canvas/source/vcl/spritehelper.cxx +++ b/canvas/source/vcl/spritehelper.cxx @@ -98,248 +98,248 @@ namespace vclcanvas const double fAlpha( getAlpha() ); - if( isActive() && - !::basegfx::fTools::equalZero( fAlpha ) ) - { - const Point aEmptyPoint; - const ::basegfx::B2DVector& rOrigOutputSize( getSizePixel() ); + if( !(isActive() && + !::basegfx::fTools::equalZero( fAlpha )) ) + return; + + const Point aEmptyPoint; + const ::basegfx::B2DVector& rOrigOutputSize( getSizePixel() ); - // might get changed below (e.g. adapted for - // transformations). IMPORTANT: both position and size are - // rounded to integer values. From now on, only those - // rounded values are used, to keep clip and content in - // sync. - ::Size aOutputSize( vcl::unotools::sizeFromB2DSize( rOrigOutputSize ) ); - ::Point aOutPos( vcl::unotools::pointFromB2DPoint( rPos ) ); + // might get changed below (e.g. adapted for + // transformations). IMPORTANT: both position and size are + // rounded to integer values. From now on, only those + // rounded values are used, to keep clip and content in + // sync. + ::Size aOutputSize( vcl::unotools::sizeFromB2DSize( rOrigOutputSize ) ); + ::Point aOutPos( vcl::unotools::pointFromB2DPoint( rPos ) ); - // TODO(F3): Support for alpha-VDev + // TODO(F3): Support for alpha-VDev - // Do we have to update our bitmaps (necessary if virdev - // was painted to, or transformation changed)? - const bool bNeedBitmapUpdate( io_bSurfacesDirty || - hasTransformChanged() || - maContent->IsEmpty() ); + // Do we have to update our bitmaps (necessary if virdev + // was painted to, or transformation changed)? + const bool bNeedBitmapUpdate( io_bSurfacesDirty || + hasTransformChanged() || + maContent->IsEmpty() ); - // updating content of sprite cache - surface is no - // longer dirty in relation to our cache - io_bSurfacesDirty = false; - transformUpdated(); + // updating content of sprite cache - surface is no + // longer dirty in relation to our cache + io_bSurfacesDirty = false; + transformUpdated(); + + if( bNeedBitmapUpdate ) + { + BitmapEx aBmp( mpBackBuffer->getOutDev().GetBitmapEx( aEmptyPoint, + aOutputSize ) ); - if( bNeedBitmapUpdate ) + if( isContentFullyOpaque() ) { - BitmapEx aBmp( mpBackBuffer->getOutDev().GetBitmapEx( aEmptyPoint, - aOutputSize ) ); + // optimized case: content canvas is fully + // opaque. Note: since we retrieved aBmp directly + // from an OutDev, it's already a 'display bitmap' + // on windows. + maContent = aBmp; + } + else + { + // sprite content might contain alpha, create + // BmpEx, then. + BitmapEx aMask( mpBackBufferMask->getOutDev().GetBitmapEx( aEmptyPoint, + aOutputSize ) ); + + // bitmasks are much faster than alphamasks on some platforms + // so convert to bitmask if useful + bool convertTo1Bpp = aMask.GetBitCount() != 1; +#ifdef MACOSX + convertTo1Bpp = false; +#endif + if( SkiaHelper::isVCLSkiaEnabled()) + convertTo1Bpp = false; - if( isContentFullyOpaque() ) + if( convertTo1Bpp ) { - // optimized case: content canvas is fully - // opaque. Note: since we retrieved aBmp directly - // from an OutDev, it's already a 'display bitmap' - // on windows. - maContent = aBmp; + OSL_FAIL("CanvasCustomSprite::redraw(): Mask bitmap is not " + "monochrome (performance!)"); + BitmapEx aMaskEx(aMask); + BitmapFilter::Filter(aMaskEx, BitmapMonochromeFilter(255)); + aMask = aMaskEx.GetBitmap(); } + + // Note: since we retrieved aBmp and aMask + // directly from an OutDev, it's already a + // 'display bitmap' on windows. + if( aMask.GetBitCount() == 1 ) + maContent = BitmapEx( aBmp.GetBitmap(), aMask.GetBitmap() ); else - { - // sprite content might contain alpha, create - // BmpEx, then. - BitmapEx aMask( mpBackBufferMask->getOutDev().GetBitmapEx( aEmptyPoint, - aOutputSize ) ); - - // bitmasks are much faster than alphamasks on some platforms - // so convert to bitmask if useful - bool convertTo1Bpp = aMask.GetBitCount() != 1; -#ifdef MACOSX - convertTo1Bpp = false; -#endif - if( SkiaHelper::isVCLSkiaEnabled()) - convertTo1Bpp = false; - - if( convertTo1Bpp ) - { - OSL_FAIL("CanvasCustomSprite::redraw(): Mask bitmap is not " - "monochrome (performance!)"); - BitmapEx aMaskEx(aMask); - BitmapFilter::Filter(aMaskEx, BitmapMonochromeFilter(255)); - aMask = aMaskEx.GetBitmap(); - } - - // Note: since we retrieved aBmp and aMask - // directly from an OutDev, it's already a - // 'display bitmap' on windows. - if( aMask.GetBitCount() == 1 ) - maContent = BitmapEx( aBmp.GetBitmap(), aMask.GetBitmap() ); - else - maContent = BitmapEx( aBmp.GetBitmap(), AlphaMask( aMask.GetBitmap()) ); - } + maContent = BitmapEx( aBmp.GetBitmap(), AlphaMask( aMask.GetBitmap()) ); } + } - ::basegfx::B2DHomMatrix aTransform( getTransformation() ); + ::basegfx::B2DHomMatrix aTransform( getTransformation() ); - // check whether matrix is "easy" to handle - pure - // translations or scales are handled by OutputDevice - // alone - const bool bIdentityTransform( aTransform.isIdentity() ); + // check whether matrix is "easy" to handle - pure + // translations or scales are handled by OutputDevice + // alone + const bool bIdentityTransform( aTransform.isIdentity() ); - // make transformation absolute (put sprite to final - // output position). Need to happen here, as we also have - // to translate the clip polygon - aTransform.translate( aOutPos.X(), - aOutPos.Y() ); + // make transformation absolute (put sprite to final + // output position). Need to happen here, as we also have + // to translate the clip polygon + aTransform.translate( aOutPos.X(), + aOutPos.Y() ); - if( !bIdentityTransform ) - { - // Avoid the trick with the negative width in the OpenGL case, - // OutputDevice::DrawDeviceAlphaBitmap() doesn't like it. - if (!::basegfx::fTools::equalZero( aTransform.get(0,1) ) || - !::basegfx::fTools::equalZero( aTransform.get(1,0) ) + if( !bIdentityTransform ) + { + // Avoid the trick with the negative width in the OpenGL case, + // OutputDevice::DrawDeviceAlphaBitmap() doesn't like it. + if (!::basegfx::fTools::equalZero( aTransform.get(0,1) ) || + !::basegfx::fTools::equalZero( aTransform.get(1,0) ) #if HAVE_FEATURE_UI - || OpenGLHelper::isVCLOpenGLEnabled() + || OpenGLHelper::isVCLOpenGLEnabled() #endif - || SkiaHelper::isVCLSkiaEnabled() - ) - { - // "complex" transformation, employ affine - // transformator - - // modify output position, to account for the fact - // that transformBitmap() always normalizes its output - // bitmap into the smallest enclosing box. - ::basegfx::B2DRectangle aDestRect; - ::canvas::tools::calcTransformedRectBounds( aDestRect, - ::basegfx::B2DRectangle(0, - 0, - rOrigOutputSize.getX(), - rOrigOutputSize.getY()), - aTransform ); - - aOutPos.setX( ::basegfx::fround( aDestRect.getMinX() ) ); - aOutPos.setY( ::basegfx::fround( aDestRect.getMinY() ) ); - - // TODO(P3): Use optimized bitmap transformation here. - - // actually re-create the bitmap ONLY if necessary - if( bNeedBitmapUpdate ) - maContent = tools::transformBitmap( *maContent, + || SkiaHelper::isVCLSkiaEnabled() + ) + { + // "complex" transformation, employ affine + // transformator + + // modify output position, to account for the fact + // that transformBitmap() always normalizes its output + // bitmap into the smallest enclosing box. + ::basegfx::B2DRectangle aDestRect; + ::canvas::tools::calcTransformedRectBounds( aDestRect, + ::basegfx::B2DRectangle(0, + 0, + rOrigOutputSize.getX(), + rOrigOutputSize.getY()), aTransform ); - aOutputSize = maContent->GetSizePixel(); - } - else - { - // relatively 'simplistic' transformation - - // retrieve scale and translational offset - aOutputSize.setWidth ( - ::basegfx::fround( rOrigOutputSize.getX() * aTransform.get(0,0) ) ); - aOutputSize.setHeight( - ::basegfx::fround( rOrigOutputSize.getY() * aTransform.get(1,1) ) ); - - aOutPos.setX( ::basegfx::fround( aTransform.get(0,2) ) ); - aOutPos.setY( ::basegfx::fround( aTransform.get(1,2) ) ); - } - } + aOutPos.setX( ::basegfx::fround( aDestRect.getMinX() ) ); + aOutPos.setY( ::basegfx::fround( aDestRect.getMinY() ) ); + + // TODO(P3): Use optimized bitmap transformation here. - // transformBitmap() might return empty bitmaps, for tiny - // scales. - if( !!(*maContent) ) + // actually re-create the bitmap ONLY if necessary + if( bNeedBitmapUpdate ) + maContent = tools::transformBitmap( *maContent, + aTransform ); + + aOutputSize = maContent->GetSizePixel(); + } + else { - rTargetSurface.Push( PushFlags::CLIPREGION ); + // relatively 'simplistic' transformation - + // retrieve scale and translational offset + aOutputSize.setWidth ( + ::basegfx::fround( rOrigOutputSize.getX() * aTransform.get(0,0) ) ); + aOutputSize.setHeight( + ::basegfx::fround( rOrigOutputSize.getY() * aTransform.get(1,1) ) ); + + aOutPos.setX( ::basegfx::fround( aTransform.get(0,2) ) ); + aOutPos.setY( ::basegfx::fround( aTransform.get(1,2) ) ); + } + } - // apply clip (if any) - if( getClip().is() ) - { - ::basegfx::B2DPolyPolygon aClipPoly( - ::basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D( - getClip() )); - - if( aClipPoly.count() ) - { - // aTransform already contains the - // translational component, moving the clip to - // the final sprite output position. - aClipPoly.transform( aTransform ); - - if( mbShowSpriteBounds ) - { - // Paint green sprite clip area - rTargetSurface.SetLineColor( Color( 0,255,0 ) ); - rTargetSurface.SetFillColor(); - - rTargetSurface.DrawPolyPolygon(::tools::PolyPolygon(aClipPoly)); // #i76339# - } - - vcl::Region aClipRegion( aClipPoly ); - rTargetSurface.SetClipRegion( aClipRegion ); - } - } + // transformBitmap() might return empty bitmaps, for tiny + // scales. + if( !(*maContent) ) + return; - if( ::rtl::math::approxEqual(fAlpha, 1.0) ) - { - // no alpha modulation -> just copy to output - if( maContent->IsTransparent() ) - rTargetSurface.DrawBitmapEx( aOutPos, aOutputSize, *maContent ); - else - rTargetSurface.DrawBitmap( aOutPos, aOutputSize, maContent->GetBitmap() ); - } - else - { - // TODO(P3): Switch to OutputDevice::DrawTransparent() - // here - - // draw semi-transparent - sal_uInt8 nColor( static_cast<sal_uInt8>( ::basegfx::fround( 255.0*(1.0 - fAlpha) + .5) ) ); - AlphaMask aAlpha( maContent->GetSizePixel(), - &nColor ); - - // mask out fully transparent areas - if( maContent->IsTransparent() ) - aAlpha.Replace( maContent->GetMask(), 255 ); - - // alpha-blend to output - rTargetSurface.DrawBitmapEx( aOutPos, aOutputSize, - BitmapEx( maContent->GetBitmap(), - aAlpha ) ); - } + rTargetSurface.Push( PushFlags::CLIPREGION ); + + // apply clip (if any) + if( getClip().is() ) + { + ::basegfx::B2DPolyPolygon aClipPoly( + ::basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D( + getClip() )); - rTargetSurface.Pop(); + if( aClipPoly.count() ) + { + // aTransform already contains the + // translational component, moving the clip to + // the final sprite output position. + aClipPoly.transform( aTransform ); if( mbShowSpriteBounds ) { - ::tools::PolyPolygon aMarkerPoly( - ::canvas::tools::getBoundMarksPolyPolygon( - ::basegfx::B2DRectangle(aOutPos.X(), - aOutPos.Y(), - aOutPos.X() + aOutputSize.Width()-1, - aOutPos.Y() + aOutputSize.Height()-1) ) ); - - // Paint little red sprite area markers - rTargetSurface.SetLineColor( COL_RED ); + // Paint green sprite clip area + rTargetSurface.SetLineColor( Color( 0,255,0 ) ); rTargetSurface.SetFillColor(); - for( int i=0; i<aMarkerPoly.Count(); ++i ) - { - rTargetSurface.DrawPolyLine( aMarkerPoly.GetObject(static_cast<sal_uInt16>(i)) ); - } + rTargetSurface.DrawPolyPolygon(::tools::PolyPolygon(aClipPoly)); // #i76339# + } + + vcl::Region aClipRegion( aClipPoly ); + rTargetSurface.SetClipRegion( aClipRegion ); + } + } + + if( ::rtl::math::approxEqual(fAlpha, 1.0) ) + { + // no alpha modulation -> just copy to output + if( maContent->IsTransparent() ) + rTargetSurface.DrawBitmapEx( aOutPos, aOutputSize, *maContent ); + else + rTargetSurface.DrawBitmap( aOutPos, aOutputSize, maContent->GetBitmap() ); + } + else + { + // TODO(P3): Switch to OutputDevice::DrawTransparent() + // here + + // draw semi-transparent + sal_uInt8 nColor( static_cast<sal_uInt8>( ::basegfx::fround( 255.0*(1.0 - fAlpha) + .5) ) ); + AlphaMask aAlpha( maContent->GetSizePixel(), + &nColor ); + + // mask out fully transparent areas + if( maContent->IsTransparent() ) + aAlpha.Replace( maContent->GetMask(), 255 ); + + // alpha-blend to output + rTargetSurface.DrawBitmapEx( aOutPos, aOutputSize, + BitmapEx( maContent->GetBitmap(), + aAlpha ) ); + } - // paint sprite prio - vcl::Font aVCLFont; - aVCLFont.SetFontHeight( std::min(long(20),aOutputSize.Height()) ); - aVCLFont.SetColor( COL_RED ); + rTargetSurface.Pop(); - rTargetSurface.SetTextAlign(ALIGN_TOP); - rTargetSurface.SetTextColor( COL_RED ); - rTargetSurface.SetFont( aVCLFont ); + if( !mbShowSpriteBounds ) + return; - OUString text( ::rtl::math::doubleToUString( getPriority(), - rtl_math_StringFormat_F, - 2,'.',nullptr,' ') ); + ::tools::PolyPolygon aMarkerPoly( + ::canvas::tools::getBoundMarksPolyPolygon( + ::basegfx::B2DRectangle(aOutPos.X(), + aOutPos.Y(), + aOutPos.X() + aOutputSize.Width()-1, + aOutPos.Y() + aOutputSize.Height()-1) ) ); - rTargetSurface.DrawText( aOutPos+Point(2,2), text ); - SAL_INFO( "canvas.vcl", - "sprite " << this << " has prio " << getPriority()); - } - } + // Paint little red sprite area markers + rTargetSurface.SetLineColor( COL_RED ); + rTargetSurface.SetFillColor(); + + for( int i=0; i<aMarkerPoly.Count(); ++i ) + { + rTargetSurface.DrawPolyLine( aMarkerPoly.GetObject(static_cast<sal_uInt16>(i)) ); } + + // paint sprite prio + vcl::Font aVCLFont; + aVCLFont.SetFontHeight( std::min(long(20),aOutputSize.Height()) ); + aVCLFont.SetColor( COL_RED ); + + rTargetSurface.SetTextAlign(ALIGN_TOP); + rTargetSurface.SetTextColor( COL_RED ); + rTargetSurface.SetFont( aVCLFont ); + + OUString text( ::rtl::math::doubleToUString( getPriority(), + rtl_math_StringFormat_F, + 2,'.',nullptr,' ') ); + + rTargetSurface.DrawText( aOutPos+Point(2,2), text ); + SAL_INFO( "canvas.vcl", + "sprite " << this << " has prio " << getPriority()); } ::basegfx::B2DPolyPolygon SpriteHelper::polyPolygonFromXPolyPolygon2D( uno::Reference< rendering::XPolyPolygon2D >& xPoly ) const |