Bug 1008211 - Don't use CreateBufferTextureClient with CanvasClient2D on Windows. r=bas a=lmandel
authorNicolas Silva <nsilva@mozilla.com>
Mon, 16 Jun 2014 07:53:19 -0400
changeset 208091 f2413cf1965ec1339c6ef68ad8e7e84c60fcc9e7
parent 208090 00594a5ed74de18eb6aaa0c2a6506fb830d68309
child 208092 93b24685a72dfbc4984014f094f615b12d82aaaf
push id494
push userraliiev@mozilla.com
push dateMon, 25 Aug 2014 18:42:16 +0000
treeherdermozilla-release@a3cc3e46b571 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbas, lmandel
bugs1008211
milestone32.0a2
Bug 1008211 - Don't use CreateBufferTextureClient with CanvasClient2D on Windows. r=bas a=lmandel
gfx/layers/client/CanvasClient.cpp
gfx/layers/client/CanvasClient.h
--- a/gfx/layers/client/CanvasClient.cpp
+++ b/gfx/layers/client/CanvasClient.cpp
@@ -69,27 +69,17 @@ CanvasClient2D::Update(gfx::IntSize aSiz
     gfxImageFormat format
       = gfxPlatform::GetPlatform()->OptimalFormatForContent(contentType);
     TextureFlags flags = TextureFlags::DEFAULT;
     if (mTextureFlags & TextureFlags::NEEDS_Y_FLIP) {
       flags |= TextureFlags::NEEDS_Y_FLIP;
     }
 
     gfx::SurfaceFormat surfaceFormat = gfx::ImageFormatToSurfaceFormat(format);
-    if (aLayer->IsGLLayer()) {
-      // We want a cairo backend here as we don't want to be copying into
-      // an accelerated backend and we like LockBits to work. This is currently
-      // the most effective way to make this work.
-      mBuffer = CreateBufferTextureClient(surfaceFormat, flags, BackendType::CAIRO);
-    } else {
-      // XXX - We should use CreateTextureClientForDrawing, but we first need
-      // to use double buffering.
-      mBuffer = CreateBufferTextureClient(surfaceFormat, flags,
-        gfxPlatform::GetPlatform()->GetPreferredCanvasBackend());
-    }
+    mBuffer = CreateTextureClientForCanvas(surfaceFormat, aSize, flags, aLayer);
     MOZ_ASSERT(mBuffer->CanExposeDrawTarget());
     mBuffer->AllocateForSurface(aSize);
 
     bufferCreated = true;
   }
 
   if (!mBuffer->Lock(OpenMode::OPEN_WRITE_ONLY)) {
     mBuffer = nullptr;
@@ -114,16 +104,39 @@ CanvasClient2D::Update(gfx::IntSize aSiz
   }
 
   if (updated) {
     GetForwarder()->UpdatedTexture(this, mBuffer, nullptr);
     GetForwarder()->UseTexture(this, mBuffer);
   }
 }
 
+TemporaryRef<TextureClient>
+CanvasClient2D::CreateTextureClientForCanvas(gfx::SurfaceFormat aFormat,
+                                             gfx::IntSize aSize,
+                                             TextureFlags aFlags,
+                                             ClientCanvasLayer* aLayer)
+{
+  if (aLayer->IsGLLayer()) {
+    // We want a cairo backend here as we don't want to be copying into
+    // an accelerated backend and we like LockBits to work. This is currently
+    // the most effective way to make this work.
+    return CreateBufferTextureClient(aFormat, aFlags, BackendType::CAIRO);
+  }
+
+  gfx::BackendType backend = gfxPlatform::GetPlatform()->GetPreferredCanvasBackend();
+#ifdef XP_WIN
+  return CreateTextureClientForDrawing(aFormat, aFlags, backend, aSize);
+#else
+  // XXX - We should use CreateTextureClientForDrawing, but we first need
+  // to use double buffering.
+  return CreateBufferTextureClient(aFormat, aFlags, backend);
+#endif
+}
+
 CanvasClientSurfaceStream::CanvasClientSurfaceStream(CompositableForwarder* aLayerForwarder,
                                                      TextureFlags aFlags)
   : CanvasClient(aLayerForwarder, aFlags)
 {
 }
 
 void
 CanvasClientSurfaceStream::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
--- a/gfx/layers/client/CanvasClient.h
+++ b/gfx/layers/client/CanvasClient.h
@@ -96,16 +96,21 @@ public:
   }
 
   virtual void OnDetach() MOZ_OVERRIDE
   {
     mBuffer = nullptr;
   }
 
 private:
+  TemporaryRef<TextureClient> CreateTextureClientForCanvas(gfx::SurfaceFormat aFormat,
+                                                           gfx::IntSize aSize,
+                                                           TextureFlags aFlags,
+                                                           ClientCanvasLayer* aLayer);
+
   RefPtr<TextureClient> mBuffer;
 };
 
 // Used for GL canvases where we don't need to do any readback, i.e., with a
 // GL backend.
 class CanvasClientSurfaceStream : public CanvasClient
 {
 public: