From 8aeea96caff2600bf59142c0f3f338716cb622b8 Mon Sep 17 00:00:00 2001 From: cku Date: Sun, 9 Jul 2017 00:49:24 +0800 Subject: [PATCH] Bug 1379404 - Part 4. Prevent unnecessary AzureState copy in GlyphBufferAzure::Flush. r=mattwoodrow ~AzureState is expensive, especially in GlyphBufferAzure::Flush, which is a high fan-in function. MozReview-Commit-ID: 4JfjMje0Kgs --HG-- extra : rebase_source : bbc2f06871d9bde9130ddb95d053d16a3f2a091d --- gfx/thebes/gfxFont.cpp | 6 ++++-- gfx/thebes/gfxPattern.cpp | 2 +- gfx/thebes/gfxPattern.h | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/gfx/thebes/gfxFont.cpp b/gfx/thebes/gfxFont.cpp index c29780227a90..d9b405d7c468 100644 --- a/gfx/thebes/gfxFont.cpp +++ b/gfx/thebes/gfxFont.cpp @@ -1645,7 +1645,7 @@ private: buf.mGlyphs = mGlyphBuffer; buf.mNumGlyphs = mNumGlyphs; - gfxContext::AzureState state = mRunParams.context->CurrentState(); + const gfxContext::AzureState &state = mRunParams.context->CurrentState(); if (mRunParams.drawMode & DrawMode::GLYPH_FILL) { if (state.pattern || mFontParams.contextPaint) { Pattern *pat; @@ -1661,7 +1661,9 @@ private: } if (!fillPattern) { if (state.pattern) { - pat = state.pattern->GetPattern(mRunParams.dt, + RefPtr statePattern = + mRunParams.context->CurrentState().pattern; + pat = statePattern->GetPattern(mRunParams.dt, state.patternTransformChanged ? &state.patternTransform : nullptr); } else { diff --git a/gfx/thebes/gfxPattern.cpp b/gfx/thebes/gfxPattern.cpp index 7ed9abb82cb5..302613f0e7dd 100644 --- a/gfx/thebes/gfxPattern.cpp +++ b/gfx/thebes/gfxPattern.cpp @@ -106,7 +106,7 @@ gfxPattern::GetInverseMatrix() const Pattern* gfxPattern::GetPattern(const DrawTarget *aTarget, - Matrix *aOriginalUserToDevice) + const Matrix *aOriginalUserToDevice) { Matrix patternToUser = mPatternToUserSpace; diff --git a/gfx/thebes/gfxPattern.h b/gfx/thebes/gfxPattern.h index 52f19b5c18db..cd1a694f4e62 100644 --- a/gfx/thebes/gfxPattern.h +++ b/gfx/thebes/gfxPattern.h @@ -48,7 +48,7 @@ public: * to the current transform. */ mozilla::gfx::Pattern *GetPattern(const mozilla::gfx::DrawTarget *aTarget, - mozilla::gfx::Matrix *aOriginalUserToDevice = nullptr); + const mozilla::gfx::Matrix *aOriginalUserToDevice = nullptr); bool IsOpaque(); // clamp, repeat, reflect