Index: Source/core/paint/SVGInlineTextBoxPainter.cpp |
diff --git a/Source/core/paint/SVGInlineTextBoxPainter.cpp b/Source/core/paint/SVGInlineTextBoxPainter.cpp |
index 4882b78ad3c211a9fa574b90cfd9efcf891bc25d..3c108b61d46d08150a1628b7ec373bf1d17fac26 100644 |
--- a/Source/core/paint/SVGInlineTextBoxPainter.cpp |
+++ b/Source/core/paint/SVGInlineTextBoxPainter.cpp |
@@ -17,7 +17,6 @@ |
#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 +137,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 +282,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 (!SVGRenderSupport::updateGraphicsContext(stateSaver, decorationStyle, *decorationRenderer, resourceMode)) |
+ return; |
+ SVGRenderSupport::fillOrStrokePath(context, resourceMode, path); |
} |
void SVGInlineTextBoxPainter::paintTextWithShadows(GraphicsContext* context, RenderStyle* style, |
@@ -353,39 +306,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 (hasShadow) |
- context->setDrawLooper(shadowList->createDrawLooper(DrawLooperBuilder::ShadowRespectsAlpha)); |
+ if (!SVGRenderSupport::updateGraphicsContext(stateSaver, style, m_svgInlineTextBox.parent()->renderer(), resourceMode | ApplyToTextMode)) |
+ return; |
- PaintingResourceScope resourceScope(m_svgInlineTextBox.parent()->renderer()); |
- if (resourceScope.acquirePaintingResource(context, style, resourceMode | ApplyToTextMode)) { |
- context->setTextDrawingMode(resourceMode == ApplyToFillMode ? TextModeFill : TextModeStroke); |
+ if (hasShadow) { |
+ stateSaver.saveIfNeeded(); |
+ context->setDrawLooper(shadowList->createDrawLooper(DrawLooperBuilder::ShadowRespectsAlpha)); |
+ } |
- if (scalingFactor != 1 && resourceMode == ApplyToStrokeMode) |
- context->setStrokeThickness(context->strokeThickness() * scalingFactor); |
+ context->setTextDrawingMode(resourceMode == ApplyToFillMode ? TextModeFill : TextModeStroke); |
- TextRunPaintInfo textRunPaintInfo(textRun); |
- textRunPaintInfo.from = startPosition; |
- textRunPaintInfo.to = endPosition; |
+ if (scalingFactor != 1 && resourceMode == ApplyToStrokeMode) |
+ context->setStrokeThickness(context->strokeThickness() * scalingFactor); |
- float baseline = scaledFont.fontMetrics().floatAscent(); |
- textRunPaintInfo.bounds = FloatRect(textOrigin.x(), textOrigin.y() - baseline, |
- textSize.width(), textSize.height()); |
+ TextRunPaintInfo textRunPaintInfo(textRun); |
+ textRunPaintInfo.from = startPosition; |
+ textRunPaintInfo.to = endPosition; |
- scaledFont.drawText(context, textRunPaintInfo, textOrigin); |
- resourceScope.releasePaintingResource(context); |
- } |
+ float baseline = scaledFont.fontMetrics().floatAscent(); |
+ textRunPaintInfo.bounds = FloatRect(textOrigin.x(), textOrigin.y() - baseline, |
+ textSize.width(), textSize.height()); |
- if (scalingFactor != 1) |
- context->restore(); |
- else if (hasShadow) |
- context->clearShadow(); |
+ scaledFont.drawText(context, textRunPaintInfo, textOrigin); |
} |
void SVGInlineTextBoxPainter::paintText(GraphicsContext* context, RenderStyle* style, |