Bug 1197534 - Send RecycleTexture messages from the ImageBridge thread. r=sotaro
☠☠ backed out by 3f02dab20a51 ☠ ☠
authorMatt Woodrow <mwoodrow@mozilla.com>
Mon, 14 Sep 2015 14:17:39 -0400
changeset 295007 be88a56c48561612de43572a2e5ed03ebc98b9eb
parent 295006 7c9a7c6cd636bf940a10547a2f78540556863f9b
child 295008 302f955a522753026f16c43ad3803cdfe7221087
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssotaro
bugs1197534
milestone43.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 1197534 - Send RecycleTexture messages from the ImageBridge thread. r=sotaro
gfx/layers/client/TextureClientRecycleAllocator.cpp
--- a/gfx/layers/client/TextureClientRecycleAllocator.cpp
+++ b/gfx/layers/client/TextureClientRecycleAllocator.cpp
@@ -48,16 +48,34 @@ TextureClientRecycleAllocator::~TextureC
 }
 
 void
 TextureClientRecycleAllocator::SetMaxPoolSize(uint32_t aMax)
 {
   mMaxPooledSize = aMax;
 }
 
+class TextureClientRecycleTask : public Task
+{
+public:
+  explicit TextureClientRecycleTask(TextureClient* aClient, TextureFlags aFlags)
+    : mTextureClient(aClient)
+    , mFlags(aFlags)
+  {}
+
+  virtual void Run() override
+  {
+    mTextureClient->RecycleTexture(mFlags);
+  }
+
+private:
+  mozilla::RefPtr<TextureClient> mTextureClient;
+  TextureFlags mFlags;
+};
+
 already_AddRefed<TextureClient>
 TextureClientRecycleAllocator::CreateOrRecycle(gfx::SurfaceFormat aFormat,
                                                gfx::IntSize aSize,
                                                BackendSelector aSelector,
                                                TextureFlags aTextureFlags,
                                                TextureAllocationFlags aAllocFlags)
 {
   // TextureAllocationFlags is actually used only by ContentClient.
@@ -69,27 +87,28 @@ TextureClientRecycleAllocator::CreateOrR
 
   RefPtr<TextureClientHolder> textureHolder;
 
   {
     MutexAutoLock lock(mLock);
     if (!mPooledClients.empty()) {
       textureHolder = mPooledClients.top();
       mPooledClients.pop();
+      Task* task = nullptr;
       // If a pooled TextureClient is not compatible, release it.
       if (textureHolder->GetTextureClient()->GetFormat() != aFormat ||
           textureHolder->GetTextureClient()->GetSize() != aSize) {
-        TextureClientReleaseTask* task = new TextureClientReleaseTask(textureHolder->GetTextureClient());
+        // Release TextureClient.
+        task = new TextureClientReleaseTask(textureHolder->GetTextureClient());
         textureHolder->ClearTextureClient();
         textureHolder = nullptr;
-        // Release TextureClient.
-        mSurfaceAllocator->GetMessageLoop()->PostTask(FROM_HERE, task);
       } else {
-        textureHolder->GetTextureClient()->RecycleTexture(aTextureFlags);
+        task = new TextureClientRecycleTask(textureHolder->GetTextureClient(), aTextureFlags);
       }
+      mSurfaceAllocator->GetMessageLoop()->PostTask(FROM_HERE, task);
     }
   }
 
   if (!textureHolder) {
     // Allocate new TextureClient
     RefPtr<TextureClient> texture = Allocate(aFormat, aSize, aSelector, aTextureFlags, aAllocFlags);
     if (!texture) {
       return nullptr;