27 #include <rtl/math.hxx>
34 using namespace ::
cairo;
49 "SpriteHelper::init(): Invalid device, sprite canvas or surface" );
55 CanvasCustomSpriteHelper::init( rSpriteSize, rSpriteCanvas );
69 CanvasCustomSpriteHelper::disposing();
73 const ::basegfx::B2DPoint& rPos,
77 #ifdef CAIRO_CANVAS_PERF_TRACE
78 struct timespec aTimer;
79 mxDevice->startPerfTrace( &aTimer );
88 SAL_INFO(
"canvas.cairo",
"CanvasCustomSprite::redraw called");
93 cairo_save( pCairo.get() );
100 if( !aTransform.isIdentity() )
102 cairo_matrix_t aMatrix, aInverseMatrix;
103 cairo_matrix_init( &aMatrix,
104 aTransform.get( 0, 0 ), aTransform.get( 1, 0 ), aTransform.get( 0, 1 ),
105 aTransform.get( 1, 1 ), aTransform.get( 0, 2 ), aTransform.get( 1, 2 ) );
110 cairo_matrix_init( &aInverseMatrix, aMatrix.xx, aMatrix.yx, aMatrix.xy, aMatrix.yy, aMatrix.x0, aMatrix.y0 );
111 cairo_matrix_invert( &aInverseMatrix );
112 cairo_matrix_transform_distance( &aInverseMatrix, &fX, &fY );
114 cairo_set_matrix( pCairo.get(), &aMatrix );
120 cairo_matrix_t aOrigMatrix;
121 cairo_get_matrix( pCairo.get(), &aOrigMatrix );
122 cairo_translate( pCairo.get(), fX, fY );
126 const uno::Reference<rendering::XPolyPolygon2D>& rClip(
getClip() );
134 rClip->getFillRule() );
137 SAL_INFO(
"canvas.cairo",
"aSize " << aSize.
getX() <<
" x " << aSize.
getY() <<
" position: " << fX <<
"," << fY );
138 cairo_rectangle( pCairo.get(), 0, 0, floor( aSize.
getX() ), floor( aSize.
getY() ) );
139 cairo_clip( pCairo.get() );
140 cairo_set_matrix( pCairo.get(), &aOrigMatrix );
143 cairo_set_operator( pCairo.get(), CAIRO_OPERATOR_SOURCE );
144 cairo_set_source_surface( pCairo.get(),
147 if( ::rtl::math::approxEqual( fAlpha, 1.0 ) )
148 cairo_paint( pCairo.get() );
150 cairo_paint_with_alpha( pCairo.get(), fAlpha );
152 cairo_restore( pCairo.get() );
154 #ifdef CAIRO_CANVAS_PERF_TRACE
155 mxDevice->stopPerfTrace( &aTimer,
"sprite redraw" );
161 return ::basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(xPoly);
const ::basegfx::B2DHomMatrix & getTransformation() const
bool isContentFullyOpaque() const
Returns true, if sprite content bitmap is fully opaque.
virtual ::basegfx::B2DPolyPolygon polyPolygonFromXPolyPolygon2D(css::uno::Reference< css::rendering::XPolyPolygon2D > &xPoly) const override
Called to convert an API polygon to a basegfx polygon.
double getAlpha() const
Retrieve current alpha value.
const cppcanvas::SpriteCanvasSharedPtr mpSpriteCanvas
void setSurface(const ::cairo::SurfaceSharedPtr &pBufferSurface)
std::shared_ptr< cairo_t > CairoSharedPtr
void init(const css::geometry::RealSize2D &rSpriteSize, const SpriteCanvasRef &rSpriteCanvas)
Late-init the sprite helper.
B2IRange fround(const B2DRange &rRange)
const css::uno::Reference< css::rendering::XPolyPolygon2D > & getClip() const
Retrieve current clip.
std::shared_ptr< Surface > SurfaceSharedPtr
void doPolyPolygonImplementation(const ::basegfx::B2DPolyPolygon &aPolyPolygon, Operation aOperation, cairo_t *pCairo, const uno::Sequence< rendering::Texture > *pTextures, const SurfaceProviderRef &pDevice, rendering::FillRule eFillrule)
const ::basegfx::B2DVector & getSizePixel() const
SpriteCanvasRef mpSpriteCanvas
#define ENSURE_OR_THROW(c, m)
#define SAL_INFO(area, stream)
void redraw(const ::cairo::CairoSharedPtr &pCairo, const ::basegfx::B2DPoint &rPos, bool &bSurfacesDirty, bool bBufferedUpdate) const
Repaint sprite content to associated sprite canvas.
bool isActive() const
Retrieve current activation state.
SpriteHelper()
Create sprite helper.
::rtl::Reference< SurfaceProvider > SurfaceProviderRef
::cairo::SurfaceSharedPtr mpBufferSurface