fdo#30519 paint scrolled area from the right surface
This adds a way to test whether mpCompositeSurface contains the front buffer image, so it can be used as a source in painting operations. It means the mpCompositeSurface changed status from 'temporary' to 'persistent' (which it was anyway, from implementation POV :-) Change-Id: Iee4fc7a97cd60e47d0abb148e7337f0b50cabb40
This commit is contained in:
@@ -144,7 +144,8 @@ namespace cairocanvas
|
|||||||
mpRedrawManager( NULL ),
|
mpRedrawManager( NULL ),
|
||||||
mpOwningSpriteCanvas( NULL ),
|
mpOwningSpriteCanvas( NULL ),
|
||||||
mpCompositingSurface(),
|
mpCompositingSurface(),
|
||||||
maCompositingSurfaceSize()
|
maCompositingSurfaceSize(),
|
||||||
|
mbCompositingSurfaceDirty(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,7 +223,7 @@ namespace cairocanvas
|
|||||||
|
|
||||||
// TODO(P1): Might be worthwile to track areas of background
|
// TODO(P1): Might be worthwile to track areas of background
|
||||||
// changes, too.
|
// changes, too.
|
||||||
if( !bUpdateAll && !io_bSurfaceDirty )
|
if( !bUpdateAll && !io_bSurfaceDirty && !mbCompositingSurfaceDirty )
|
||||||
{
|
{
|
||||||
// background has not changed, so we're free to optimize
|
// background has not changed, so we're free to optimize
|
||||||
// repaint to areas where a sprite has changed
|
// repaint to areas where a sprite has changed
|
||||||
@@ -270,6 +271,7 @@ namespace cairocanvas
|
|||||||
// rendering and sprite changing
|
// rendering and sprite changing
|
||||||
mpRedrawManager->clearChangeRecords();
|
mpRedrawManager->clearChangeRecords();
|
||||||
|
|
||||||
|
mbCompositingSurfaceDirty = false;
|
||||||
io_bSurfaceDirty = false;
|
io_bSurfaceDirty = false;
|
||||||
|
|
||||||
// commit to screen
|
// commit to screen
|
||||||
@@ -351,16 +353,33 @@ namespace cairocanvas
|
|||||||
::basegfx::B2IRange aDestRect( rDestRect );
|
::basegfx::B2IRange aDestRect( rDestRect );
|
||||||
aDestRect.intersect( aOutputBounds );
|
aDestRect.intersect( aOutputBounds );
|
||||||
|
|
||||||
cairo_save( pCompositingCairo.get() );
|
::basegfx::B2ISize aScrollSize( aDestRect.getWidth(), aDestRect.getHeight() );
|
||||||
// scroll content in device back buffer
|
SurfaceSharedPtr pScrollSurface( getTemporarySurface() );
|
||||||
cairo_set_source_surface( pCompositingCairo.get(),
|
CairoSharedPtr pScrollCairo( pScrollSurface->getCairo() );
|
||||||
mpOwningSpriteCanvas->getBufferSurface()->getCairoSurface().get(),
|
|
||||||
|
cairo_save( pScrollCairo.get() );
|
||||||
|
// scroll the current content of the compositing surface (and,
|
||||||
|
// thus, of the window) in temp. surface
|
||||||
|
cairo_set_source_surface( pScrollCairo.get(),
|
||||||
|
pCompositingSurface->getCairoSurface().get(),
|
||||||
aDestPos.getX() - aSourceUpperLeftPos.getX(),
|
aDestPos.getX() - aSourceUpperLeftPos.getX(),
|
||||||
aDestPos.getY() - aSourceUpperLeftPos.getY() );
|
aDestPos.getY() - aSourceUpperLeftPos.getY() );
|
||||||
|
cairo_rectangle( pScrollCairo.get(),
|
||||||
|
aDestPos.getX(), aDestPos.getY(),
|
||||||
|
aScrollSize.getX(), aScrollSize.getY() );
|
||||||
|
cairo_clip( pScrollCairo.get() );
|
||||||
|
cairo_set_operator( pScrollCairo.get(), CAIRO_OPERATOR_SOURCE );
|
||||||
|
cairo_paint( pScrollCairo.get() );
|
||||||
|
cairo_restore( pScrollCairo.get() );
|
||||||
|
|
||||||
|
cairo_save( pCompositingCairo.get() );
|
||||||
|
// copy the scrolled area back onto the compositing surface
|
||||||
|
cairo_set_source_surface( pCompositingCairo.get(),
|
||||||
|
pScrollSurface->getCairoSurface().get(),
|
||||||
|
0, 0 );
|
||||||
cairo_rectangle( pCompositingCairo.get(),
|
cairo_rectangle( pCompositingCairo.get(),
|
||||||
aDestPos.getX(), aDestPos.getY(),
|
aDestPos.getX(), aDestPos.getY(),
|
||||||
sal::static_int_cast<sal_Int32>(aDestRect.getWidth()),
|
aScrollSize.getX(), aScrollSize.getY() );
|
||||||
sal::static_int_cast<sal_Int32>(aDestRect.getHeight()) );
|
|
||||||
cairo_clip( pCompositingCairo.get() );
|
cairo_clip( pCompositingCairo.get() );
|
||||||
cairo_set_operator( pCompositingCairo.get(), CAIRO_OPERATOR_SOURCE );
|
cairo_set_operator( pCompositingCairo.get(), CAIRO_OPERATOR_SOURCE );
|
||||||
cairo_paint( pCompositingCairo.get() );
|
cairo_paint( pCompositingCairo.get() );
|
||||||
@@ -530,15 +549,28 @@ namespace cairocanvas
|
|||||||
|
|
||||||
if( !mpCompositingSurface )
|
if( !mpCompositingSurface )
|
||||||
{
|
{
|
||||||
mpCompositingSurface =
|
mpCompositingSurface = createSurface( rNeededSize );
|
||||||
mpOwningSpriteCanvas->getWindowSurface()->getSimilar(
|
|
||||||
CAIRO_CONTENT_COLOR,
|
|
||||||
rNeededSize.getX(), rNeededSize.getY() );
|
|
||||||
maCompositingSurfaceSize = rNeededSize;
|
maCompositingSurfaceSize = rNeededSize;
|
||||||
|
mbCompositingSurfaceDirty = true;
|
||||||
|
mpTemporarySurface.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
return mpCompositingSurface;
|
return mpCompositingSurface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
::cairo::SurfaceSharedPtr SpriteCanvasHelper::getTemporarySurface()
|
||||||
|
{
|
||||||
|
if ( !mpTemporarySurface )
|
||||||
|
mpTemporarySurface = createSurface( maCompositingSurfaceSize );
|
||||||
|
return mpTemporarySurface;
|
||||||
|
}
|
||||||
|
|
||||||
|
::cairo::SurfaceSharedPtr SpriteCanvasHelper::createSurface( const ::basegfx::B2ISize& rNeededSize ) const
|
||||||
|
{
|
||||||
|
return mpOwningSpriteCanvas->getWindowSurface()->getSimilar(
|
||||||
|
CAIRO_CONTENT_COLOR,
|
||||||
|
rNeededSize.getX(), rNeededSize.getY() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
@@ -131,6 +131,8 @@ namespace cairocanvas
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
::cairo::SurfaceSharedPtr getCompositingSurface( const ::basegfx::B2ISize& rNeededSize );
|
::cairo::SurfaceSharedPtr getCompositingSurface( const ::basegfx::B2ISize& rNeededSize );
|
||||||
|
::cairo::SurfaceSharedPtr getTemporarySurface();
|
||||||
|
::cairo::SurfaceSharedPtr createSurface( const ::basegfx::B2ISize& rNeededSize ) const;
|
||||||
|
|
||||||
/// Set from the SpriteCanvas: instance coordinating sprite redraw
|
/// Set from the SpriteCanvas: instance coordinating sprite redraw
|
||||||
::canvas::SpriteRedrawManager* mpRedrawManager;
|
::canvas::SpriteRedrawManager* mpRedrawManager;
|
||||||
@@ -138,9 +140,13 @@ namespace cairocanvas
|
|||||||
/// Set from the init method. used to generate sprites
|
/// Set from the init method. used to generate sprites
|
||||||
SpriteCanvas* mpOwningSpriteCanvas;
|
SpriteCanvas* mpOwningSpriteCanvas;
|
||||||
|
|
||||||
/// a temporary surface used to composite the frontbuffer image
|
/// a surface used to composite the frontbuffer image
|
||||||
::cairo::SurfaceSharedPtr mpCompositingSurface;
|
::cairo::SurfaceSharedPtr mpCompositingSurface;
|
||||||
::basegfx::B2ISize maCompositingSurfaceSize;
|
::basegfx::B2ISize maCompositingSurfaceSize;
|
||||||
|
bool mbCompositingSurfaceDirty;
|
||||||
|
/// a temporary surface that is guaranteed to be the same size
|
||||||
|
//as the compositing surface
|
||||||
|
::cairo::SurfaceSharedPtr mpTemporarySurface;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user