Bug 923434 - Don't use operator source for D2D in ThebesLayerBuffer since it's slower. r=Bas, a=bajaj
authorMatt Woodrow <mwoodrow@mozilla.com>
Tue, 05 Nov 2013 17:50:56 +1300
changeset 166556 07df7f3a0306d38cf1c73bc9fec504bb9f786f85
parent 166555 f1f0c01ef96e9ca48b1110f8dcdb2d285913e7a9
child 166557 b4b8a4057dac0492694b070a08437cceb42fff52
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas, bajaj
bugs923434
milestone27.0a2
Bug 923434 - Don't use operator source for D2D in ThebesLayerBuffer since it's slower. r=Bas, a=bajaj
gfx/layers/ThebesLayerBuffer.cpp
--- a/gfx/layers/ThebesLayerBuffer.cpp
+++ b/gfx/layers/ThebesLayerBuffer.cpp
@@ -173,16 +173,29 @@ RotatedBuffer::DrawBufferQuadrant(gfx::D
   // mBufferRect
   nsIntRect quadrantRect = GetQuadrantRectangle(aXSide, aYSide);
   nsIntRect fillRect;
   if (!fillRect.IntersectRect(mBufferRect, quadrantRect))
     return;
 
   gfx::Point quadrantTranslation(quadrantRect.x, quadrantRect.y);
 
+  MOZ_ASSERT(aOperator == OP_OVER || aOperator == OP_SOURCE);
+  // direct2d is much slower when using OP_SOURCE so use OP_OVER and
+  // (maybe) a clear instead. Normally we need to draw in a single operation
+  // (to avoid flickering) but direct2d is ok since it defers rendering.
+  // We should try abstract this logic in a helper when we have other use
+  // cases.
+  if (aTarget->GetType() == BACKEND_DIRECT2D && aOperator == OP_SOURCE) {
+    aOperator = OP_OVER;
+    if (mDTBuffer->GetFormat() == FORMAT_B8G8R8A8) {
+      aTarget->ClearRect(ToRect(fillRect));
+    }
+  }
+
   RefPtr<SourceSurface> snapshot;
   if (aSource == BUFFER_BLACK) {
     snapshot = mDTBuffer->Snapshot();
   } else {
     MOZ_ASSERT(aSource == BUFFER_WHITE);
     snapshot = mDTBufferOnWhite->Snapshot();
   }