Bug 982339 - Get rid of TextureClientPoolMember and use nsTArray so that we releases references when we shutdown. r=Bas, a=1.4+
☠☠ backed out by 95ed6fad0a6c ☠ ☠
authorSotaro Ikeda <sotaro.ikeda.g>
Wed, 23 Apr 2014 13:49:00 -0400
changeset 193088 44385c27892860a099fe95d643e121a65666e72a
parent 193087 37237034e45c30e22b70f8755eea22314ec68214
child 193089 f45d255f2e4c585359ef313f99068d752b190eea
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas, 1
bugs982339
milestone30.0a2
Bug 982339 - Get rid of TextureClientPoolMember and use nsTArray so that we releases references when we shutdown. r=Bas, a=1.4+
gfx/layers/client/ClientLayerManager.cpp
gfx/layers/client/ClientLayerManager.h
gfx/layers/client/TextureClientPool.h
--- a/gfx/layers/client/ClientLayerManager.cpp
+++ b/gfx/layers/client/ClientLayerManager.cpp
@@ -32,21 +32,16 @@
 #endif
 
 using namespace mozilla::dom;
 using namespace mozilla::gfx;
 
 namespace mozilla {
 namespace layers {
 
-  TextureClientPoolMember::TextureClientPoolMember(SurfaceFormat aFormat, TextureClientPool* aTexturePool)
-  : mFormat(aFormat)
-  , mTexturePool(aTexturePool)
-{}
-
 ClientLayerManager::ClientLayerManager(nsIWidget* aWidget)
   : mPhase(PHASE_NONE)
   , mWidget(aWidget) 
   , mTargetRotation(ROTATION_0)
   , mRepeatTransaction(false)
   , mIsRepeatTransaction(false)
   , mTransactionIncomplete(false)
   , mCompositorMightResample(false)
@@ -56,18 +51,16 @@ ClientLayerManager::ClientLayerManager(n
   MOZ_COUNT_CTOR(ClientLayerManager);
 }
 
 ClientLayerManager::~ClientLayerManager()
 {
   mRoot = nullptr;
 
   MOZ_COUNT_DTOR(ClientLayerManager);
-
-  mTexturePools.clear();
 }
 
 int32_t
 ClientLayerManager::GetMaxTextureSize() const
 {
   return mForwarder->GetMaxTextureSize();
 }
 
@@ -228,19 +221,18 @@ ClientLayerManager::EndTransaction(DrawT
     mIsRepeatTransaction = true;
     BeginTransaction();
     ClientLayerManager::EndTransaction(aCallback, aCallbackData, aFlags);
     mIsRepeatTransaction = false;
   } else {
     MakeSnapshotIfRequired();
   }
 
-  for (const TextureClientPoolMember* item = mTexturePools.getFirst();
-       item; item = item->getNext()) {
-    item->mTexturePool->ReturnDeferredClients();
+  for (size_t i = 0; i < mTexturePools.Length(); i++) {
+    mTexturePools[i]->ReturnDeferredClients();
   }
 }
 
 bool
 ClientLayerManager::EndEmptyTransaction(EndTransactionFlags aFlags)
 {
   mInTransaction = false;
 
@@ -453,31 +445,28 @@ void
 ClientLayerManager::SetIsFirstPaint()
 {
   mForwarder->SetIsFirstPaint();
 }
 
 TextureClientPool*
 ClientLayerManager::GetTexturePool(SurfaceFormat aFormat)
 {
-  for (const TextureClientPoolMember* item = mTexturePools.getFirst();
-       item; item = item->getNext()) {
-    if (item->mFormat == aFormat) {
-      return item->mTexturePool;
+  for (size_t i = 0; i < mTexturePools.Length(); i++) {
+    if (mTexturePools[i]->GetFormat() == aFormat) {
+      return mTexturePools[i];
     }
   }
 
-  TextureClientPoolMember* texturePoolMember =
-    new TextureClientPoolMember(aFormat,
+  mTexturePools.AppendElement(
       new TextureClientPool(aFormat, IntSize(TILEDLAYERBUFFER_TILE_SIZE,
                                              TILEDLAYERBUFFER_TILE_SIZE),
                             mForwarder));
-  mTexturePools.insertBack(texturePoolMember);
 
-  return texturePoolMember->mTexturePool;
+  return mTexturePools.LastElement();
 }
 
 SimpleTextureClientPool*
 ClientLayerManager::GetSimpleTileTexturePool(SurfaceFormat aFormat)
 {
   int index = (int) aFormat;
   mSimpleTilePools.EnsureLengthAtLeast(index+1);
 
@@ -497,19 +486,18 @@ ClientLayerManager::ClearCachedResources
   if (LayerTransactionChild* manager = mForwarder->GetShadowManager()) {
     manager->SendClearCachedResources();
   }
   if (aSubtree) {
     ClearLayer(aSubtree);
   } else if (mRoot) {
     ClearLayer(mRoot);
   }
-  for (const TextureClientPoolMember* item = mTexturePools.getFirst();
-       item; item = item->getNext()) {
-    item->mTexturePool->Clear();
+  for (size_t i = 0; i < mTexturePools.Length(); i++) {
+    mTexturePools[i]->Clear();
   }
 }
 
 void
 ClientLayerManager::ClearLayer(Layer* aLayer)
 {
   ClientLayer::ToClientLayer(aLayer)->ClearCachedResources();
   for (Layer* child = aLayer->GetFirstChild(); child;
--- a/gfx/layers/client/ClientLayerManager.h
+++ b/gfx/layers/client/ClientLayerManager.h
@@ -31,25 +31,16 @@ namespace layers {
 
 class ClientThebesLayer;
 class CompositorChild;
 class ImageLayer;
 class PLayerChild;
 class TextureClientPool;
 class SimpleTextureClientPool;
 
-class TextureClientPoolMember
-  : public LinkedListElement<TextureClientPoolMember> {
-public:
-  TextureClientPoolMember(gfx::SurfaceFormat aFormat, TextureClientPool* aTexturePool);
-
-  gfx::SurfaceFormat mFormat;
-  RefPtr<TextureClientPool> mTexturePool;
-};
-
 class ClientLayerManager : public LayerManager
 {
   typedef nsTArray<nsRefPtr<Layer> > LayerRefArray;
 
 public:
   ClientLayerManager(nsIWidget* aWidget);
   virtual ~ClientLayerManager();
 
@@ -224,17 +215,17 @@ private:
   // a display list) to support progressive drawing.
   bool mRepeatTransaction;
   bool mIsRepeatTransaction;
   bool mTransactionIncomplete;
   bool mCompositorMightResample;
   bool mNeedsComposite;
 
   RefPtr<ShadowLayerForwarder> mForwarder;
-  LinkedList<TextureClientPoolMember> mTexturePools;
+  nsAutoTArray<RefPtr<TextureClientPool>,2> mTexturePools;
 
   // indexed by gfx::SurfaceFormat
   nsTArray<RefPtr<SimpleTextureClientPool> > mSimpleTilePools;
 };
 
 class ClientLayer : public ShadowableLayer
 {
 public:
--- a/gfx/layers/client/TextureClientPool.h
+++ b/gfx/layers/client/TextureClientPool.h
@@ -73,16 +73,18 @@ public:
   void ReportClientLost() { mOutstandingClients--; }
 
   /**
    * Calling this will cause the pool to attempt to relinquish any unused
    * clients.
    */
   void Clear();
 
+  gfx::SurfaceFormat GetFormat() { return mFormat; }
+
 private:
   // The time in milliseconds before the pool will be shrunk to the minimum
   // size after returning a client.
   static const uint32_t sShrinkTimeout = 1000;
 
   // The minimum size of the pool (the number of tiles that will be kept after
   // shrinking).
   static const uint32_t sMinCacheSize = 0;