Bug 765845: Reduce calling frequency of SetTextRenderingParams. r=jrmuizel a=lsblakk THUNDERBIRD_15_0b2_BUILD1 THUNDERBIRD_15_0b2_RELEASE
authorBas Schouten <bschouten@mozilla.com>
Tue, 31 Jul 2012 13:55:48 -0400
changeset 100401 1ac588e89dd5df64c9a5e93330b6cdf7b153887a
parent 100400 52fa7e3938663cdf1ada7fea98f727ad3e146933
child 100402 0f180e96041b9f6077d1f5479c0fa48235ea17d7
child 100404 21c5fe3f451ec549fd2cc9134cdfd032d82eb3d7
child 100406 b339706f3e2ce424cfa79bfe8e6432935b98a634
child 100407 ca388f2eea7d241100bce75acadac4b3d0bd80b8
push id1
push usersledru@mozilla.com
push dateThu, 04 Dec 2014 17:57:20 +0000
reviewersjrmuizel, lsblakk
bugs765845
milestone15.0
Bug 765845: Reduce calling frequency of SetTextRenderingParams. r=jrmuizel a=lsblakk
gfx/2d/DrawTargetD2D.cpp
gfx/2d/DrawTargetD2D.h
--- a/gfx/2d/DrawTargetD2D.cpp
+++ b/gfx/2d/DrawTargetD2D.cpp
@@ -852,19 +852,19 @@ DrawTargetD2D::FillGlyphs(ScaledFont *aF
     return;
   }
 
   ScaledFontDWrite *font = static_cast<ScaledFontDWrite*>(aFont);
 
   IDWriteRenderingParams *params = NULL;
   if (aRenderOptions) {
     if (aRenderOptions->GetType() != FONT_DWRITE) {
-    gfxDebug() << *this << ": Ignoring incompatible GlyphRenderingOptions.";
-    // This should never happen.
-    MOZ_ASSERT(false);
+      gfxDebug() << *this << ": Ignoring incompatible GlyphRenderingOptions.";
+      // This should never happen.
+      MOZ_ASSERT(false);
     } else {
       params = static_cast<const GlyphRenderingOptionsDWrite*>(aRenderOptions)->mParams;
     }
   }
 
   if (mFormat == FORMAT_B8G8R8A8 && mPermitSubpixelAA &&
       aOptions.mCompositionOp == OP_OVER && aPattern.GetType() == PATTERN_COLOR) {
     if (FillGlyphsManual(font, aBuffer,
@@ -873,17 +873,22 @@ DrawTargetD2D::FillGlyphs(ScaledFont *aF
       return;
     }
   }
 
   ID2D1RenderTarget *rt = GetRTForOperation(aOptions.mCompositionOp, aPattern);
 
   PrepareForDrawing(rt);
 
-  rt->SetTextRenderingParams(params);
+  if (rt != mRT || params != mTextRenderingParams) {
+    rt->SetTextRenderingParams(params);
+    if (rt == mRT) {
+      mTextRenderingParams = params;
+    }
+  }
 
   RefPtr<ID2D1Brush> brush = CreateBrushForPattern(aPattern, aOptions.mAlpha);
 
   AutoDWriteGlyphRun autoRun;
   DWriteGlyphRunFromGlyphs(aBuffer, font, &autoRun);
 
   if (brush) {
     rt->DrawGlyphRun(D2D1::Point2F(), &autoRun, brush);
--- a/gfx/2d/DrawTargetD2D.h
+++ b/gfx/2d/DrawTargetD2D.h
@@ -193,16 +193,19 @@ private:
   IntSize mSize;
 
   RefPtr<ID3D10Device1> mDevice;
   RefPtr<ID3D10Texture2D> mTexture;
   RefPtr<ID3D10Texture2D> mCurrentClipMaskTexture;
   RefPtr<ID2D1PathGeometry> mCurrentClippedGeometry;
   mutable RefPtr<ID2D1RenderTarget> mRT;
 
+  // We store this to prevent excessive SetTextRenderingParams calls.
+  RefPtr<IDWriteRenderingParams> mTextRenderingParams;
+
   // Temporary texture and render target used for supporting alternative operators.
   RefPtr<ID3D10Texture2D> mTempTexture;
   RefPtr<ID3D10RenderTargetView> mRTView;
   RefPtr<ID3D10ShaderResourceView> mSRView;
   RefPtr<ID2D1RenderTarget> mTempRT;
   RefPtr<ID3D10RenderTargetView> mTempRTView;
 
   // List of pushed clips.