Bug 1368776 - Part 1. Move RasterImage's ImageContainer state to ImageResource. r=tnikkel
authorAndrew Osmond <aosmond@mozilla.com>
Fri, 17 Nov 2017 06:45:23 -0500
changeset 444217 ef34a21c32b7847db008a9a261e2c799e6018fc0
parent 444216 6dfe9e9f880079c77f54ae7d6501a7815ec4e772
child 444218 ebd9a647eca91474a7fb92235414153b766ca092
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstnikkel
bugs1368776
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1368776 - Part 1. Move RasterImage's ImageContainer state to ImageResource. r=tnikkel This state will eventually be used by VectorImage when it supports image containers. For now, it is harmless beyond using slightly more memory for SVGs.
image/Image.cpp
image/Image.h
image/RasterImage.cpp
image/RasterImage.h
--- a/image/Image.cpp
+++ b/image/Image.cpp
@@ -53,17 +53,20 @@ ImageMemoryCounter::ImageMemoryCounter(I
 // Constructor
 ImageResource::ImageResource(ImageURL* aURI) :
   mURI(aURI),
   mInnerWindowId(0),
   mAnimationConsumers(0),
   mAnimationMode(kNormalAnimMode),
   mInitialized(false),
   mAnimating(false),
-  mError(false)
+  mError(false),
+  mImageProducerID(ImageContainer::AllocateProducerID()),
+  mLastFrameID(0),
+  mLastImageContainerDrawResult(DrawResult::NOT_READY)
 { }
 
 ImageResource::~ImageResource()
 {
   // Ask our ProgressTracker to drop its weak reference to us.
   mProgressTracker->ResetImage();
 }
 
--- a/image/Image.h
+++ b/image/Image.h
@@ -6,16 +6,17 @@
 #ifndef mozilla_image_Image_h
 #define mozilla_image_Image_h
 
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/TimeStamp.h"
 #include "gfx2DGlue.h"
 #include "imgIContainer.h"
 #include "ImageURL.h"
+#include "ImageContainer.h"
 #include "nsStringFwd.h"
 #include "ProgressTracker.h"
 #include "SurfaceCache.h"
 
 class nsIRequest;
 class nsIInputStream;
 
 namespace mozilla {
@@ -328,14 +329,25 @@ protected:
   RefPtr<ImageURL>            mURI;
   TimeStamp                     mLastRefreshTime;
   uint64_t                      mInnerWindowId;
   uint32_t                      mAnimationConsumers;
   uint16_t                      mAnimationMode; // Enum values in imgIContainer
   bool                          mInitialized:1; // Have we been initalized?
   bool                          mAnimating:1;   // Are we currently animating?
   bool                          mError:1;       // Error handling
+
+  // A weak pointer to our ImageContainer, which stays alive only as long as
+  // the layer system needs it.
+  WeakPtr<layers::ImageContainer> mImageContainer;
+
+  layers::ImageContainer::ProducerID mImageProducerID;
+  layers::ImageContainer::FrameID mLastFrameID;
+
+  // If mImageContainer is non-null, this contains the DrawResult we obtained
+  // the last time we updated it.
+  DrawResult mLastImageContainerDrawResult;
 };
 
 } // namespace image
 } // namespace mozilla
 
 #endif // mozilla_image_Image_h
--- a/image/RasterImage.cpp
+++ b/image/RasterImage.cpp
@@ -11,17 +11,16 @@
 
 #include "gfxPlatform.h"
 #include "nsComponentManagerUtils.h"
 #include "nsError.h"
 #include "Decoder.h"
 #include "prenv.h"
 #include "prsystem.h"
 #include "IDecodingTask.h"
-#include "ImageContainer.h"
 #include "ImageRegion.h"
 #include "Layers.h"
 #include "LookupResult.h"
 #include "nsIConsoleService.h"
 #include "nsIInputStream.h"
 #include "nsIScriptError.h"
 #include "nsISupportsPrimitives.h"
 #include "nsPresContext.h"
@@ -68,19 +67,16 @@ NS_IMPL_ISUPPORTS(RasterImage, imgIConta
 #endif
 
 //******************************************************************************
 RasterImage::RasterImage(ImageURL* aURI /* = nullptr */) :
   ImageResource(aURI), // invoke superclass's constructor
   mSize(0,0),
   mLockCount(0),
   mDecodeCount(0),
-  mImageProducerID(ImageContainer::AllocateProducerID()),
-  mLastFrameID(0),
-  mLastImageContainerDrawResult(DrawResult::NOT_READY),
 #ifdef DEBUG
   mFramesNotified(0),
 #endif
   mSourceBuffer(MakeNotNull<SourceBuffer*>()),
   mHasSize(false),
   mTransient(false),
   mSyncLoad(false),
   mDiscardable(false),
--- a/image/RasterImage.h
+++ b/image/RasterImage.h
@@ -395,27 +395,16 @@ private: // data
 
   // The type of decoder this image needs. Computed from the MIME type in Init().
   DecoderType                mDecoderType;
 
   // How many times we've decoded this image.
   // This is currently only used for statistics
   int32_t                        mDecodeCount;
 
-  // A weak pointer to our ImageContainer, which stays alive only as long as
-  // the layer system needs it.
-  WeakPtr<layers::ImageContainer> mImageContainer;
-
-  layers::ImageContainer::ProducerID mImageProducerID;
-  layers::ImageContainer::FrameID mLastFrameID;
-
-  // If mImageContainer is non-null, this contains the DrawResult we obtained
-  // the last time we updated it.
-  DrawResult mLastImageContainerDrawResult;
-
 #ifdef DEBUG
   uint32_t                       mFramesNotified;
 #endif
 
   // The source data for this image.
   NotNull<RefPtr<SourceBuffer>>  mSourceBuffer;
 
   // Boolean flags (clustered together to conserve space):