Bug 989145 - Convert ImageContainer::mBackendData to be an EnumeratedArray - r=nical
authorBenoit Jacob <bjacob@mozilla.com>
Fri, 25 Apr 2014 22:34:06 -0400
changeset 180730 a7a471cd390093824571dab6f2360452a9799236
parent 180729 046c061d91c2311dbf9872ec4e9dc5abf43d9806
child 180731 aea9916128c6bce15336b867db6d5db14df0aee1
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewersnical
bugs989145
milestone31.0a1
Bug 989145 - Convert ImageContainer::mBackendData to be an EnumeratedArray - r=nical
gfx/layers/ImageContainer.h
--- a/gfx/layers/ImageContainer.h
+++ b/gfx/layers/ImageContainer.h
@@ -25,16 +25,17 @@
 #include "nsRect.h"                     // for nsIntRect
 #include "nsSize.h"                     // for nsIntSize
 #include "nsTArray.h"                   // for nsTArray
 #include "mozilla/Atomics.h"
 #include "mozilla/WeakPtr.h"
 #include "nsThreadUtils.h"
 #include "mozilla/gfx/2D.h"
 #include "nsDataHashtable.h"
+#include "mozilla/EnumeratedArray.h"
 
 #ifndef XPCOM_GLUE_AVOID_NSPR
 /**
  * We need to be able to hold a reference to a Moz2D SourceSurface from Image
  * subclasses. This is potentially a problem since Images can be addrefed
  * or released off the main thread. We can ensure that we never AddRef
  * a SourceSurface off the main thread, but we might want to Release due
  * to an Image being destroyed off the main thread.
@@ -150,19 +151,19 @@ public:
 
   virtual gfx::IntSize GetSize() = 0;
   virtual nsIntRect GetPictureRect()
   {
     return nsIntRect(0, 0, GetSize().width, GetSize().height);
   }
 
   ImageBackendData* GetBackendData(LayersBackend aBackend)
-  { return mBackendData[size_t(aBackend)]; }
+  { return mBackendData[aBackend]; }
   void SetBackendData(LayersBackend aBackend, ImageBackendData* aData)
-  { mBackendData[size_t(aBackend)] = aData; }
+  { mBackendData[aBackend] = aData; }
 
   int32_t GetSerial() { return mSerial; }
 
   void MarkSent() { mSent = true; }
   bool IsSentToCompositor() { return mSent; }
 
   virtual TemporaryRef<gfx::SourceSurface> GetAsSourceSurface() = 0;
 
@@ -172,17 +173,20 @@ protected:
     mSerial(++sSerialCounter),
     mFormat(aFormat),
     mSent(false)
   {}
 
   // Protected destructor, to discourage deletion outside of Release():
   virtual ~Image() {}
 
-  nsAutoPtr<ImageBackendData> mBackendData[size_t(mozilla::layers::LayersBackend::LAYERS_LAST)];
+  mozilla::EnumeratedArray<mozilla::layers::LayersBackend,
+                           mozilla::layers::LayersBackend::LAYERS_LAST,
+                           nsAutoPtr<ImageBackendData>>
+    mBackendData;
 
   void* mImplData;
   int32_t mSerial;
   ImageFormat mFormat;
   static mozilla::Atomic<int32_t> sSerialCounter;
   bool mSent;
 };