Bug 951216 - Avoid unnecessary Snapshot() copies by clearing the pattern. r=Bas, a=lsblakk
authorJeff Muizelaar <jmuizelaar@mozilla.com>
Tue, 17 Dec 2013 13:33:34 -0500
changeset 169278 54709f91b97203542555a4b13a1237ecd76c567e
parent 169277 33d11d7daa7c4c4639e46b2ab6e54b93580f6fd5
child 169279 08706d24334b692a960d23b141eb1120348d3eee
push id4964
push userryanvm@gmail.com
push dateThu, 16 Jan 2014 15:31:24 +0000
treeherdermozilla-aurora@1ff5838f2a32 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas, lsblakk
Bug 951216 - Avoid unnecessary Snapshot() copies by clearing the pattern. r=Bas, a=lsblakk 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.
--- a/gfx/thebes/gfxDrawable.cpp
+++ b/gfx/thebes/gfxDrawable.cpp
@@ -2,16 +2,17 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #include "gfxDrawable.h"
 #include "gfxASurface.h"
 #include "gfxContext.h"
 #include "gfxPlatform.h"
+#include "gfxColor.h"
 #ifdef MOZ_X11
 #include "cairo.h"
 #include "gfxXlibSurface.h"
 using namespace mozilla;
 using namespace mozilla::gfx;
@@ -149,16 +150,19 @@ gfxSurfaceDrawable::Draw(gfxContext* aCo
         PreparePatternForUntiledDrawing(pattern, deviceSpaceToImageSpace,
                                         currentTarget, filter);
+    // 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;
     if (mDrawTarget) {
       // TODO: Find a way to implement this. The caller really wants a 'sub-image' of