Defer image surface destruction until next paint
Fixes #4043 (cherry picked from commit dbf786e456f2792476791caf9dadfeb43e9ab383)
This commit is contained in:
parent
161b73e55b
commit
23c1baae8e
|
@ -83,6 +83,9 @@ CAIRO_GAL_BASE::~CAIRO_GAL_BASE()
|
||||||
|
|
||||||
if( context )
|
if( context )
|
||||||
cairo_destroy( context );
|
cairo_destroy( context );
|
||||||
|
|
||||||
|
for( auto imageSurface : imageSurfaces )
|
||||||
|
cairo_surface_destroy( imageSurface );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -508,7 +511,9 @@ void CAIRO_GAL_BASE::DrawBitmap( const BITMAP_BASE& aBitmap )
|
||||||
cairo_surface_mark_dirty( image );
|
cairo_surface_mark_dirty( image );
|
||||||
cairo_set_source_surface( currentContext, image, 0, 0 );
|
cairo_set_source_surface( currentContext, image, 0, 0 );
|
||||||
cairo_paint( currentContext );
|
cairo_paint( currentContext );
|
||||||
cairo_surface_destroy( image );
|
|
||||||
|
// store the image handle so it can be destroyed later
|
||||||
|
imageSurfaces.push_back( image );
|
||||||
|
|
||||||
isElementAdded = true;
|
isElementAdded = true;
|
||||||
|
|
||||||
|
@ -929,6 +934,11 @@ void CAIRO_GAL_BASE::EnableDepthTest( bool aEnabled )
|
||||||
|
|
||||||
void CAIRO_GAL_BASE::resetContext()
|
void CAIRO_GAL_BASE::resetContext()
|
||||||
{
|
{
|
||||||
|
for( auto imageSurface : imageSurfaces )
|
||||||
|
cairo_surface_destroy( imageSurface );
|
||||||
|
|
||||||
|
imageSurfaces.clear();
|
||||||
|
|
||||||
ClearScreen();
|
ClearScreen();
|
||||||
|
|
||||||
// Compute the world <-> screen transformations
|
// Compute the world <-> screen transformations
|
||||||
|
|
|
@ -304,6 +304,9 @@ protected:
|
||||||
cairo_t* context; ///< Cairo image
|
cairo_t* context; ///< Cairo image
|
||||||
cairo_surface_t* surface; ///< Cairo surface
|
cairo_surface_t* surface; ///< Cairo surface
|
||||||
|
|
||||||
|
/// List of surfaces that were created by painting images, to be cleaned up later
|
||||||
|
std::vector<cairo_surface_t*> imageSurfaces;
|
||||||
|
|
||||||
std::vector<cairo_matrix_t> xformStack;
|
std::vector<cairo_matrix_t> xformStack;
|
||||||
|
|
||||||
void flushPath();
|
void flushPath();
|
||||||
|
|
Loading…
Reference in New Issue