From 4fa43a6bda9be0236b58970715d53028571cfb5a Mon Sep 17 00:00:00 2001 From: Jeff Muizelaar Date: Tue, 17 Dec 2013 13:33:34 -0500 Subject: [PATCH] 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 --- gfx/thebes/gfxDrawable.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gfx/thebes/gfxDrawable.cpp b/gfx/thebes/gfxDrawable.cpp index 689170dd7ef..796d998096f 100644 --- a/gfx/thebes/gfxDrawable.cpp +++ b/gfx/thebes/gfxDrawable.cpp @@ -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; }