From d5e66ff9f47b4bbd59808c75ede6e30ad35a5cd4 Mon Sep 17 00:00:00 2001
authorCgg <clement.geiger@gmail.com>
Sat, 21 Jun 2014 14:32:30 +0200
changeset 190047 29bc4fa125d9b34e4edbe34ddfb5019b84b60e95
parent 190046 28357f609779937e29389318d63f01214244c7c6
child 190048 b2563b5f12f53d14c69de0af03fb4e6825469a5f
push id8288
push userryanvm@gmail.com
push dateMon, 23 Jun 2014 14:59:00 +0000
treeherderb2g-inbound@c65bf5a0595c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs783043
milestone33.0a1
From d5e66ff9f47b4bbd59808c75ede6e30ad35a5cd4 Mon Sep 17 00:00:00 2001 Bug 783043 - Restore original image factory after paint operations. r=nical --- gfx/layers/ImageContainer.h | 5 +++++ gfx/layers/basic/BasicImageLayer.cpp | 7 +++++++ 2 files changed, 12 insertions(+)
gfx/layers/ImageContainer.h
gfx/layers/basic/BasicImageLayer.cpp
--- a/gfx/layers/ImageContainer.h
+++ b/gfx/layers/ImageContainer.h
@@ -506,16 +506,21 @@ public:
   { mScaleHint = aScaleHint; }
 
   void SetImageFactory(ImageFactory *aFactory)
   {
     ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     mImageFactory = aFactory ? aFactory : new ImageFactory();
   }
 
+  ImageFactory* GetImageFactory() const
+  {
+    return mImageFactory;
+  }
+
   /**
    * Returns the time at which the currently contained image was first
    * painted.  This is reset every time a new image is set as the current
    * image.  Note this may return a null timestamp if the current image
    * has not yet been painted.  Can be called from any thread.
    */
   TimeStamp GetPaintTime() {
     ReentrantMonitorAutoEnter mon(mReentrantMonitor);
--- a/gfx/layers/basic/BasicImageLayer.cpp
+++ b/gfx/layers/basic/BasicImageLayer.cpp
@@ -69,68 +69,75 @@ void
 BasicImageLayer::Paint(DrawTarget* aDT,
                        const gfx::Point& aDeviceOffset,
                        Layer* aMaskLayer)
 {
   if (IsHidden() || !mContainer) {
     return;
   }
 
+  nsRefPtr<ImageFactory> originalIF = mContainer->GetImageFactory();
   mContainer->SetImageFactory(mManager->IsCompositingCheap() ? nullptr : BasicManager()->GetImageFactory());
 
   RefPtr<gfx::SourceSurface> surface;
   AutoLockImage autoLock(mContainer, &surface);
   Image *image = autoLock.GetImage();
   gfx::IntSize size = mSize = autoLock.GetSize();
 
   if (!surface || !surface->IsValid()) {
+    mContainer->SetImageFactory(originalIF);
     return;
   }
 
   FillRectWithMask(aDT, aDeviceOffset, Rect(0, 0, size.width, size.height), 
                    surface, ToFilter(mFilter),
                    DrawOptions(GetEffectiveOpacity(), GetEffectiveOperator(this)),
                    aMaskLayer);
 
+  mContainer->SetImageFactory(originalIF);
   GetContainer()->NotifyPaintedImage(image);
 }
 
 void
 BasicImageLayer::GetAndPaintCurrentImage(DrawTarget* aTarget,
                                          float aOpacity,
                                          SourceSurface* aMaskSurface)
 {
   if (!mContainer) {
     return;
   }
 
+  nsRefPtr<ImageFactory> originalIF = mContainer->GetImageFactory();
   mContainer->SetImageFactory(mManager->IsCompositingCheap() ?
                               nullptr :
                               BasicManager()->GetImageFactory());
   IntSize size;
   Image* image = nullptr;
   RefPtr<SourceSurface> surf =
     mContainer->LockCurrentAsSourceSurface(&size, &image);
 
   if (!surf) {
+    mContainer->SetImageFactory(originalIF);
     return;
   }
 
   if (aTarget) {
     // The visible region can extend outside the image, so just draw
     // within the image bounds.
     SurfacePattern pat(surf, ExtendMode::CLAMP, Matrix(), ToFilter(mFilter));
     CompositionOp op = GetEffectiveOperator(this);
     DrawOptions opts(aOpacity, op);
 
     aTarget->MaskSurface(pat, aMaskSurface, Point(0, 0), opts);
 
     GetContainer()->NotifyPaintedImage(image);
   }
 
+  mContainer->SetImageFactory(originalIF);
+
   mContainer->UnlockCurrentImage();
 }
 
 TemporaryRef<SourceSurface>
 BasicImageLayer::GetAsSourceSurface()
 {
   if (!mContainer) {
     return nullptr;