Bug 989144 - Convert EffectChain::mSecondaryEffects to be an EnumeratedArray - r=nical
☠☠ backed out by 0ecc4193e630 ☠ ☠
authorBenoit Jacob <bjacob@mozilla.com>
Fri, 25 Apr 2014 22:34:06 -0400
changeset 180323 046c061d91c2311dbf9872ec4e9dc5abf43d9806
parent 180322 3f1b41adeaef4c4a5bb9e2330e4986b0d518066e
child 180324 a7a471cd390093824571dab6f2360452a9799236
push id42737
push userbjacob@mozilla.com
push dateSat, 26 Apr 2014 02:34:56 +0000
treeherdermozilla-inbound@610d7ccaaa9c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs989144
milestone31.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 989144 - Convert EffectChain::mSecondaryEffects to be an EnumeratedArray - r=nical
gfx/layers/Effects.h
gfx/layers/basic/BasicCompositor.cpp
gfx/layers/composite/CompositableHost.cpp
gfx/layers/opengl/CompositorOGL.cpp
--- a/gfx/layers/Effects.h
+++ b/gfx/layers/Effects.h
@@ -12,16 +12,17 @@
 #include "mozilla/gfx/Point.h"          // for IntSize
 #include "mozilla/gfx/Rect.h"           // for Rect
 #include "mozilla/gfx/Types.h"          // for Filter, etc
 #include "mozilla/layers/CompositorTypes.h"  // for EffectTypes, etc
 #include "mozilla/layers/LayersTypes.h"
 #include "mozilla/layers/TextureHost.h"  // for CompositingRenderTarget, etc
 #include "mozilla/mozalloc.h"           // for operator delete, etc
 #include "nscore.h"                     // for nsACString
+#include "mozilla/EnumeratedArray.h"
 
 namespace mozilla {
 namespace layers {
 
 /**
  * Effects and effect chains are used by the compositor API (see Compositor.h).
  * An effect chain represents a rendering method, for example some shader and
  * the data required for that shader to run. An effect is some component of the
@@ -159,17 +160,18 @@ struct EffectSolidColor : public Effect
 };
 
 struct EffectChain
 {
   EffectChain() : mLayerRef(nullptr) {}
   explicit EffectChain(void* aLayerRef) : mLayerRef(aLayerRef) {}
 
   RefPtr<Effect> mPrimaryEffect;
-  RefPtr<Effect> mSecondaryEffects[size_t(EffectTypes::MAX_SECONDARY)];
+  EnumeratedArray<EffectTypes, EffectTypes::MAX_SECONDARY, RefPtr<Effect>>
+    mSecondaryEffects;
   void* mLayerRef; //!< For LayerScope logging
 };
 
 /**
  * Create a Textured effect corresponding to aFormat and using
  * aSource as the (first) texture source.
  *
  * Note that aFormat can be different form aSource->GetFormat if, we are
--- a/gfx/layers/basic/BasicCompositor.cpp
+++ b/gfx/layers/basic/BasicCompositor.cpp
@@ -286,18 +286,18 @@ BasicCompositor::DrawQuad(const gfx::Rec
     transformBounds.MoveTo(0, 0);
   }
 
   newTransform.Translate(-offset.x, -offset.y);
   buffer->SetTransform(newTransform);
 
   RefPtr<SourceSurface> sourceMask;
   Matrix maskTransform;
-  if (aEffectChain.mSecondaryEffects[size_t(EffectTypes::MASK)]) {
-    EffectMask *effectMask = static_cast<EffectMask*>(aEffectChain.mSecondaryEffects[size_t(EffectTypes::MASK)].get());
+  if (aEffectChain.mSecondaryEffects[EffectTypes::MASK]) {
+    EffectMask *effectMask = static_cast<EffectMask*>(aEffectChain.mSecondaryEffects[EffectTypes::MASK].get());
     sourceMask = effectMask->mMaskTexture->AsSourceBasic()->GetSurface();
     MOZ_ASSERT(effectMask->mMaskTransform.Is2D(), "How did we end up with a 3D transform here?!");
     MOZ_ASSERT(!effectMask->mIs3D);
     maskTransform = effectMask->mMaskTransform.As2D();
     maskTransform.Translate(-offset.x, -offset.y);
   }
 
   switch (aEffectChain.mPrimaryEffect->mType) {
--- a/gfx/layers/composite/CompositableHost.cpp
+++ b/gfx/layers/composite/CompositableHost.cpp
@@ -153,17 +153,17 @@ CompositableHost::AddMaskEffect(EffectCh
     NS_WARNING("Using compositable with no texture host as mask layer");
     return false;
   }
 
   RefPtr<EffectMask> effect = new EffectMask(source,
                                              source->GetSize(),
                                              aTransform);
   effect->mIs3D = aIs3D;
-  aEffects.mSecondaryEffects[size_t(EffectTypes::MASK)] = effect;
+  aEffects.mSecondaryEffects[EffectTypes::MASK] = effect;
   return true;
 }
 
 void
 CompositableHost::RemoveMaskEffect()
 {
   RefPtr<TextureHost> host = GetAsTextureHost();
   if (host) {
--- a/gfx/layers/opengl/CompositorOGL.cpp
+++ b/gfx/layers/opengl/CompositorOGL.cpp
@@ -904,18 +904,18 @@ CompositorOGL::DrawQuadInternal(const Re
 
   LayerScope::SendEffectChain(mGLContext, aEffectChain,
                               aRect.width, aRect.height);
 
   MaskType maskType;
   EffectMask* effectMask;
   TextureSourceOGL* sourceMask = nullptr;
   gfx::Matrix4x4 maskQuadTransform;
-  if (aEffectChain.mSecondaryEffects[size_t(EffectTypes::MASK)]) {
-    effectMask = static_cast<EffectMask*>(aEffectChain.mSecondaryEffects[size_t(EffectTypes::MASK)].get());
+  if (aEffectChain.mSecondaryEffects[EffectTypes::MASK]) {
+    effectMask = static_cast<EffectMask*>(aEffectChain.mSecondaryEffects[EffectTypes::MASK].get());
     sourceMask = effectMask->mMaskTexture->AsSourceOGL();
 
     // NS_ASSERTION(textureMask->IsAlpha(),
     //              "OpenGL mask layers must be backed by alpha surfaces");
 
     // We're assuming that the gl backend won't cheat and use NPOT
     // textures when glContext says it can't (which seems to happen
     // on a mac when you force POT textures)