Chromium Code Reviews| Index: Source/core/paint/SVGInlineTextBoxPainter.cpp |
| diff --git a/Source/core/paint/SVGInlineTextBoxPainter.cpp b/Source/core/paint/SVGInlineTextBoxPainter.cpp |
| index 4882b78ad3c211a9fa574b90cfd9efcf891bc25d..ac4c36c977b671d82d41a23ce587d5ca044f629e 100644 |
| --- a/Source/core/paint/SVGInlineTextBoxPainter.cpp |
| +++ b/Source/core/paint/SVGInlineTextBoxPainter.cpp |
| @@ -11,13 +11,13 @@ |
| #include "core/frame/LocalFrame.h" |
| #include "core/paint/InlinePainter.h" |
| #include "core/paint/InlineTextBoxPainter.h" |
| +#include "core/paint/SVGPaintServer.h" |
| #include "core/rendering/PaintInfo.h" |
| #include "core/rendering/RenderInline.h" |
| #include "core/rendering/RenderTheme.h" |
| #include "core/rendering/style/ShadowList.h" |
| #include "core/rendering/svg/RenderSVGInlineText.h" |
| #include "core/rendering/svg/RenderSVGResource.h" |
| -#include "core/rendering/svg/RenderSVGResourceSolidColor.h" |
| #include "core/rendering/svg/SVGInlineTextBox.h" |
| #include "core/rendering/svg/SVGRenderSupport.h" |
| #include "core/rendering/svg/SVGResourcesCache.h" |
| @@ -138,51 +138,6 @@ void SVGInlineTextBoxPainter::paint(PaintInfo& paintInfo, const LayoutPoint& pai |
| InlinePainter(toRenderInline(parentRenderer)).paintOutline(paintInfo, paintOffset); |
| } |
| -class PaintingResourceScope { |
| -public: |
| - PaintingResourceScope(RenderObject& renderer) |
| - : m_renderer(renderer) |
| - , m_paintingResource(0) |
| - { |
| - } |
| - ~PaintingResourceScope() { ASSERT(!m_paintingResource); } |
| - |
| - bool acquirePaintingResource(GraphicsContext*&, RenderStyle*, RenderSVGResourceModeFlags); |
| - void releasePaintingResource(GraphicsContext*&); |
| - |
| -private: |
| - RenderObject& m_renderer; |
| - RenderSVGResource* m_paintingResource; |
| -}; |
| - |
| -bool PaintingResourceScope::acquirePaintingResource(GraphicsContext*& context, RenderStyle* style, RenderSVGResourceModeFlags resourceModeFlags) |
| -{ |
| - ASSERT(style); |
| - RenderSVGResourceMode resourceMode = static_cast<RenderSVGResourceMode>(resourceModeFlags & (ApplyToFillMode | ApplyToStrokeMode)); |
| - ASSERT(resourceMode == ApplyToFillMode || resourceMode == ApplyToStrokeMode); |
| - |
| - bool hasFallback = false; |
| - m_paintingResource = RenderSVGResource::requestPaintingResource(resourceMode, &m_renderer, style, hasFallback); |
| - if (!m_paintingResource) |
| - return false; |
| - |
| - if (!m_paintingResource->applyResource(&m_renderer, style, context, resourceModeFlags)) { |
| - if (hasFallback) { |
| - m_paintingResource = RenderSVGResource::sharedSolidPaintingResource(); |
| - m_paintingResource->applyResource(&m_renderer, style, context, resourceModeFlags); |
| - } |
| - } |
| - return true; |
| -} |
| - |
| -void PaintingResourceScope::releasePaintingResource(GraphicsContext*& context) |
| -{ |
| - ASSERT(m_paintingResource); |
| - |
| - m_paintingResource->postApplyResource(context); |
| - m_paintingResource = 0; |
| -} |
| - |
| void SVGInlineTextBoxPainter::paintSelectionBackground(PaintInfo& paintInfo) |
| { |
| if (m_svgInlineTextBox.renderer().style()->visibility() != VISIBLE) |
| @@ -328,11 +283,10 @@ void SVGInlineTextBoxPainter::paintDecorationWithStyle(GraphicsContext* context, |
| Path path; |
| path.addRect(FloatRect(decorationOrigin, FloatSize(fragment.width, thickness / scalingFactor))); |
| - PaintingResourceScope resourceScope(*decorationRenderer); |
| - if (resourceScope.acquirePaintingResource(context, decorationStyle, resourceMode)) { |
| - SVGRenderSupport::fillOrStrokePath(context, resourceMode, path); |
| - resourceScope.releasePaintingResource(context); |
| - } |
| + GraphicsContextStateSaver stateSaver(*context, false); |
| + if (!SVGPaintServer::updateGraphicsContext(stateSaver, decorationStyle, *decorationRenderer, resourceMode)) |
| + return; |
| + SVGRenderSupport::fillOrStrokePath(context, resourceMode, path); |
| } |
| void SVGInlineTextBoxPainter::paintTextWithShadows(GraphicsContext* context, RenderStyle* style, |
| @@ -353,38 +307,36 @@ void SVGInlineTextBoxPainter::paintTextWithShadows(GraphicsContext* context, Ren |
| FloatPoint textOrigin(fragment.x, fragment.y); |
| FloatSize textSize(fragment.width, fragment.height); |
| + GraphicsContextStateSaver stateSaver(*context, false); |
| if (scalingFactor != 1) { |
| textOrigin.scale(scalingFactor, scalingFactor); |
| textSize.scale(scalingFactor); |
| - context->save(); |
| + stateSaver.save(); |
| context->scale(1 / scalingFactor, 1 / scalingFactor); |
| } |
| + if (!SVGPaintServer::updateGraphicsContext(stateSaver, style, m_svgInlineTextBox.parent()->renderer(), resourceMode | ApplyToTextMode)) |
| + return; |
| + |
| if (hasShadow) |
| context->setDrawLooper(shadowList->createDrawLooper(DrawLooperBuilder::ShadowRespectsAlpha)); |
| - PaintingResourceScope resourceScope(m_svgInlineTextBox.parent()->renderer()); |
| - if (resourceScope.acquirePaintingResource(context, style, resourceMode | ApplyToTextMode)) { |
| - context->setTextDrawingMode(resourceMode == ApplyToFillMode ? TextModeFill : TextModeStroke); |
| + context->setTextDrawingMode(resourceMode == ApplyToFillMode ? TextModeFill : TextModeStroke); |
| - if (scalingFactor != 1 && resourceMode == ApplyToStrokeMode) |
| - context->setStrokeThickness(context->strokeThickness() * scalingFactor); |
| + if (scalingFactor != 1 && resourceMode == ApplyToStrokeMode) |
| + context->setStrokeThickness(context->strokeThickness() * scalingFactor); |
| - TextRunPaintInfo textRunPaintInfo(textRun); |
| - textRunPaintInfo.from = startPosition; |
| - textRunPaintInfo.to = endPosition; |
| + TextRunPaintInfo textRunPaintInfo(textRun); |
| + textRunPaintInfo.from = startPosition; |
| + textRunPaintInfo.to = endPosition; |
| - float baseline = scaledFont.fontMetrics().floatAscent(); |
| - textRunPaintInfo.bounds = FloatRect(textOrigin.x(), textOrigin.y() - baseline, |
| - textSize.width(), textSize.height()); |
| + float baseline = scaledFont.fontMetrics().floatAscent(); |
| + textRunPaintInfo.bounds = FloatRect(textOrigin.x(), textOrigin.y() - baseline, |
| + textSize.width(), textSize.height()); |
| - scaledFont.drawText(context, textRunPaintInfo, textOrigin); |
| - resourceScope.releasePaintingResource(context); |
| - } |
| + scaledFont.drawText(context, textRunPaintInfo, textOrigin); |
| - if (scalingFactor != 1) |
| - context->restore(); |
| - else if (hasShadow) |
| + if (hasShadow && !stateSaver.saved()) |
|
f(malita)
2014/10/10 15:49:07
Could we saveIfNeeded in the hasShadow conditional
fs
2014/10/10 16:10:23
Done.
|
| context->clearShadow(); |
| } |