Bug 951216. Avoid unnecessary Snapshot() copies by clearing the pattern. r=Bas

gfxSurfaceDrawable::Draw() sets a gfxPattern(Snapshot()) to the gfxContext's
pattern. If the gfxSurfaceDrawable is created by
CreateSamplingRestrictedDrawable it will be destroyed before the Snapshot().
This causes the Snapshot to be copied unnecessarily.

If we set the pattern to something else we'll destroy the snapshot before the
gfxSurfaceDrawable and save a copy.

--HG--
extra : rebase_source : 03864e8a0fe021940747cf691df30ec51e4d8b2d
This commit is contained in:
Jeff Muizelaar 2013-12-17 13:33:34 -05:00
parent 124f372395
commit 4fa43a6bda

View File

@ -7,6 +7,7 @@
#include "gfxASurface.h"
#include "gfxContext.h"
#include "gfxPlatform.h"
#include "gfxColor.h"
#ifdef MOZ_X11
#include "cairo.h"
#include "gfxXlibSurface.h"
@ -165,6 +166,9 @@ gfxSurfaceDrawable::Draw(gfxContext* aContext,
aContext->SetPattern(pattern);
aContext->Rectangle(aFillRect);
aContext->Fill();
// clear the pattern so that the snapshot is released before the
// drawable is destroyed
aContext->SetDeviceColor(gfxRGBA(0.0, 0.0, 0.0, 0.0));
return true;
}