Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1647)

Unified Diff: Source/core/rendering/svg/SVGRenderSupport.cpp

Issue 655263002: Let the paint-server client compute and pass any additional transform (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/rendering/svg/SVGRenderSupport.cpp
diff --git a/Source/core/rendering/svg/SVGRenderSupport.cpp b/Source/core/rendering/svg/SVGRenderSupport.cpp
index b8579383c2fb007d3d7c1c3054e255607b0d48ad..8949527810815fb10dd8f4583d1a76f41640babc 100644
--- a/Source/core/rendering/svg/SVGRenderSupport.cpp
+++ b/Source/core/rendering/svg/SVGRenderSupport.cpp
@@ -39,7 +39,6 @@
#include "core/rendering/svg/RenderSVGShape.h"
#include "core/rendering/svg/RenderSVGText.h"
#include "core/rendering/svg/RenderSVGViewportContainer.h"
-#include "core/rendering/svg/SVGRenderingContext.h"
#include "core/rendering/svg/SVGResources.h"
#include "core/rendering/svg/SVGResourcesCache.h"
#include "core/svg/SVGElement.h"
@@ -394,57 +393,10 @@ void SVGRenderSupport::applyStrokeStyleToStrokeData(StrokeData* strokeData, cons
strokeData->setLineDash(dashArray, svgStyle.strokeDashOffset()->value(lengthContext));
}
-static bool shouldTransformOnTextPainting(RenderObject& renderer, AffineTransform& resourceTransform)
-{
- // This method should only be called for RenderObjects that deal with text rendering. Cmp. RenderObject.h's is*() methods.
- ASSERT(renderer.isSVGText() || renderer.isSVGTextPath() || renderer.isSVGInline());
-
- // In text drawing, the scaling part of the graphics context CTM is removed, compare SVGInlineTextBox::paintTextWithShadows.
- // So, we use that scaling factor here, too, and then push it down to pattern or gradient space
- // in order to keep the pattern or gradient correctly scaled.
- float scalingFactor = SVGRenderingContext::calculateScreenFontSizeScalingFactor(&renderer);
- if (scalingFactor == 1)
- return false;
- resourceTransform.scale(scalingFactor);
- return true;
-}
-
-static AffineTransform transformOnNonScalingStroke(RenderObject& renderer, const AffineTransform& resourceTransform)
-{
- ASSERT(renderer.isSVGShape());
- SVGGraphicsElement* element = toSVGGraphicsElement(renderer.node());
- AffineTransform transform = element->getScreenCTM(SVGGraphicsElement::DisallowStyleUpdate);
- transform *= resourceTransform;
- return transform;
-}
-
-static AffineTransform computeResourceSpaceTransform(RenderObject& renderer, const SVGRenderStyle& svgStyle, RenderSVGResourceModeFlags resourceModeFlags)
-{
- AffineTransform computedSpaceTransform;
- if (resourceModeFlags & ApplyToTextMode) {
- // Depending on the font scaling factor, we may need to apply an
- // additional transform (scale-factor) to the paintserver, since text
- // painting removes the scale factor from the context. (See
- // SVGInlineTextBoxPainter::paintTextWithShadows.)
- AffineTransform additionalTextTransformation;
- if (shouldTransformOnTextPainting(renderer, additionalTextTransformation))
- computedSpaceTransform = additionalTextTransformation;
- }
- if (resourceModeFlags & ApplyToStrokeMode) {
- // Non-scaling stroke needs to reset the transform back to the host transform.
- if (renderer.isSVGShape() && svgStyle.vectorEffect() == VE_NON_SCALING_STROKE)
- computedSpaceTransform = transformOnNonScalingStroke(renderer, computedSpaceTransform);
- }
- return computedSpaceTransform;
-}
-
-bool SVGRenderSupport::updateGraphicsContext(GraphicsContextStateSaver& stateSaver, RenderStyle* style, RenderObject& renderer, unsigned resourceModeFlags)
+bool SVGRenderSupport::updateGraphicsContext(GraphicsContextStateSaver& stateSaver, RenderStyle* style, RenderObject& renderer, RenderSVGResourceMode resourceMode, const AffineTransform* additionalPaintServerTransform)
{
ASSERT(style);
- RenderSVGResourceMode resourceMode = static_cast<RenderSVGResourceMode>(resourceModeFlags & (ApplyToFillMode | ApplyToStrokeMode));
- ASSERT(resourceMode == ApplyToFillMode || resourceMode == ApplyToStrokeMode);
-
GraphicsContext* context = stateSaver.context();
if (isRenderingClipPathAsMaskImage(renderer)) {
if (resourceMode == ApplyToStrokeMode)
@@ -458,13 +410,13 @@ bool SVGRenderSupport::updateGraphicsContext(GraphicsContextStateSaver& stateSav
if (!paintServer.isValid())
return false;
- const SVGRenderStyle& svgStyle = style->svgStyle();
-
- if (paintServer.isTransformDependent())
- paintServer.prependTransform(computeResourceSpaceTransform(renderer, svgStyle, resourceModeFlags));
+ if (additionalPaintServerTransform && paintServer.isTransformDependent())
+ paintServer.prependTransform(*additionalPaintServerTransform);
paintServer.apply(*context, resourceMode, &stateSaver);
+ const SVGRenderStyle& svgStyle = style->svgStyle();
+
if (resourceMode == ApplyToFillMode) {
context->setAlphaAsFloat(svgStyle.fillOpacity());
context->setFillRule(svgStyle.fillRule());
« Source/core/paint/SVGInlineTextBoxPainter.cpp ('K') | « Source/core/rendering/svg/SVGRenderSupport.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698