From 524b31d2ff89d8d99a7d4525705dd00a7a0e8882 Mon Sep 17 00:00:00 2001 From: Jeff Muizelaar Date: Wed, 29 Nov 2017 23:51:52 -0500 Subject: [PATCH] Bug 1421860. Remove unused gfxContext::SetSource. This removes some state from AzureState which will make gfxContext creation and save()/restore() cheaper --- gfx/thebes/gfxContext.cpp | 74 +-------------------------------------- gfx/thebes/gfxContext.h | 15 +------- gfx/thebes/gfxFont.cpp | 6 ---- 3 files changed, 2 insertions(+), 93 deletions(-) diff --git a/gfx/thebes/gfxContext.cpp b/gfx/thebes/gfxContext.cpp index b7e1670ba57f..ce3c3688e4f2 100644 --- a/gfx/thebes/gfxContext.cpp +++ b/gfx/thebes/gfxContext.cpp @@ -50,24 +50,6 @@ PatternFromState::operator mozilla::gfx::Pattern&() return *state.pattern->GetPattern(mContext->mDT, state.patternTransformChanged ? &state.patternTransform : nullptr); } - if (state.sourceSurface) { - Matrix transform = state.surfTransform; - - if (state.patternTransformChanged) { - Matrix mat = mContext->GetDTTransform(); - if (!mat.Invert()) { - mPattern = new (mColorPattern.addr()) - ColorPattern(Color()); // transparent black to paint nothing - return *mPattern; - } - transform = transform * state.patternTransform * mat; - } - - mPattern = new (mSurfacePattern.addr()) - SurfacePattern(state.sourceSurface, ExtendMode::CLAMP, transform); - return *mPattern; - } - mPattern = new (mColorPattern.addr()) ColorPattern(state.color); return *mPattern; @@ -693,8 +675,6 @@ gfxContext::SetColor(const Color& aColor) { CURRENTSTATE_CHANGED() CurrentState().pattern = nullptr; - CurrentState().sourceSurfCairo = nullptr; - CurrentState().sourceSurface = nullptr; CurrentState().color = ToDeviceColor(aColor); } @@ -703,17 +683,12 @@ gfxContext::SetDeviceColor(const Color& aColor) { CURRENTSTATE_CHANGED() CurrentState().pattern = nullptr; - CurrentState().sourceSurfCairo = nullptr; - CurrentState().sourceSurface = nullptr; CurrentState().color = aColor; } bool gfxContext::GetDeviceColor(Color& aColorOut) { - if (CurrentState().sourceSurface) { - return false; - } if (CurrentState().pattern) { return CurrentState().pattern->GetSolidColor(aColorOut); } @@ -722,27 +697,10 @@ gfxContext::GetDeviceColor(Color& aColorOut) return true; } -void -gfxContext::SetSource(gfxASurface *surface, const gfxPoint& offset) -{ - CURRENTSTATE_CHANGED() - CurrentState().surfTransform = Matrix(1.0f, 0, 0, 1.0f, Float(offset.x), Float(offset.y)); - CurrentState().pattern = nullptr; - CurrentState().patternTransformChanged = false; - // Keep the underlying cairo surface around while we keep the - // sourceSurface. - CurrentState().sourceSurfCairo = surface; - CurrentState().sourceSurface = - gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(mDT, surface); - CurrentState().color = Color(0, 0, 0, 0); -} - void gfxContext::SetPattern(gfxPattern *pattern) { CURRENTSTATE_CHANGED() - CurrentState().sourceSurfCairo = nullptr; - CurrentState().sourceSurface = nullptr; CurrentState().patternTransformChanged = false; CurrentState().pattern = pattern; } @@ -755,8 +713,6 @@ gfxContext::GetPattern() AzureState &state = CurrentState(); if (state.pattern) { pat = state.pattern; - } else if (state.sourceSurface) { - NS_ASSERTION(false, "Ugh, this isn't good."); } else { pat = new gfxPattern(state.color); } @@ -791,28 +747,6 @@ gfxContext::Paint(gfxFloat alpha) { AUTO_PROFILER_LABEL("gfxContext::Paint", GRAPHICS); - AzureState &state = CurrentState(); - - if (state.sourceSurface && !state.sourceSurfCairo && - !state.patternTransformChanged) - { - // This is the case where a PopGroupToSource has been done and this - // paint is executed without changing the transform or the source. - Matrix oldMat = mDT->GetTransform(); - - IntSize surfSize = state.sourceSurface->GetSize(); - - mDT->SetTransform(Matrix::Translation(-state.deviceOffset.x, - -state.deviceOffset.y)); - - mDT->DrawSurface(state.sourceSurface, - Rect(state.sourceSurfaceDeviceOffset, Size(surfSize.width, surfSize.height)), - Rect(Point(), Size(surfSize.width, surfSize.height)), - DrawSurfaceOptions(), DrawOptions(alpha, GetOp())); - mDT->SetTransform(oldMat); - return; - } - Matrix mat = mDT->GetTransform(); mat.Invert(); Rect paintRect = mat.TransformBounds(Rect(Point(0, 0), Size(mDT->GetSize()))); @@ -992,12 +926,6 @@ gfxContext::GetOp() } else { return CompositionOp::OP_SOURCE; } - } else if (state.sourceSurface) { - if (state.sourceSurface->GetFormat() == SurfaceFormat::B8G8R8X8) { - return CompositionOp::OP_OVER; - } else { - return CompositionOp::OP_SOURCE; - } } else { if (state.color.a > 0.999) { return CompositionOp::OP_OVER; @@ -1023,7 +951,7 @@ gfxContext::ChangeTransform(const Matrix &aNewMatrix, bool aUpdatePatternTransfo { AzureState &state = CurrentState(); - if (aUpdatePatternTransform && (state.pattern || state.sourceSurface) + if (aUpdatePatternTransform && (state.pattern) && !state.patternTransformChanged) { state.patternTransform = GetDTTransform(); state.patternTransformChanged = true; diff --git a/gfx/thebes/gfxContext.h b/gfx/thebes/gfxContext.h index 83964d3c4951..7c2e76368a1f 100644 --- a/gfx/thebes/gfxContext.h +++ b/gfx/thebes/gfxContext.h @@ -40,7 +40,7 @@ class ClipExporter; * All drawing happens by creating a path and then stroking or filling it. * The functions like Rectangle and Arc do not do any drawing themselves. * When a path is drawn (stroked or filled), it is filled/stroked with a - * pattern set by SetPattern, SetColor or SetSource. + * pattern set by SetPattern or SetColor. * * Note that the gfxContext takes coordinates in device pixels, * as opposed to app units. @@ -269,15 +269,6 @@ public: */ void SetColor(const mozilla::gfx::Color& aColor); - /** - * Uses a surface for drawing. This is a shorthand for creating a - * pattern and setting it. - * - * @param offset from the source surface, to use only part of it. - * May need to make it negative. - */ - void SetSource(gfxASurface *surface, const gfxPoint& offset = gfxPoint(0.0, 0.0)); - /** * Uses a pattern for drawing. */ @@ -489,10 +480,6 @@ private: mozilla::gfx::CompositionOp op; Color color; RefPtr pattern; - RefPtr sourceSurfCairo; - RefPtr sourceSurface; - mozilla::gfx::Point sourceSurfaceDeviceOffset; - Matrix surfTransform; Matrix transform; struct PushedClip { RefPtr path; diff --git a/gfx/thebes/gfxFont.cpp b/gfx/thebes/gfxFont.cpp index cb40402db7eb..ab9eb68c5e1b 100644 --- a/gfx/thebes/gfxFont.cpp +++ b/gfx/thebes/gfxFont.cpp @@ -1708,12 +1708,6 @@ private: mRunParams.dt->FillGlyphs(mFontParams.scaledFont, buf, *pat, mFontParams.drawOptions); } - } else if (state.sourceSurface) { - mRunParams.dt->FillGlyphs(mFontParams.scaledFont, buf, - SurfacePattern(state.sourceSurface, - ExtendMode::CLAMP, - state.surfTransform), - mFontParams.drawOptions); } else { mRunParams.dt->FillGlyphs(mFontParams.scaledFont, buf, ColorPattern(state.color),