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

Side by Side Diff: Source/core/rendering/svg/RenderSVGResourcePattern.cpp

Issue 230443003: Fix application of OBB paint-servers when device scale != 1 (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase. Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 3 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 111
112 // Compute pattern space transformation. 112 // Compute pattern space transformation.
113 const IntSize tileImageSize = tileImage->size(); 113 const IntSize tileImageSize = tileImage->size();
114 patternData->transform.translate(tileBoundaries.x(), tileBoundaries.y()); 114 patternData->transform.translate(tileBoundaries.x(), tileBoundaries.y());
115 patternData->transform.scale(tileBoundaries.width() / tileImageSize.width(), tileBoundaries.height() / tileImageSize.height()); 115 patternData->transform.scale(tileBoundaries.width() / tileImageSize.width(), tileBoundaries.height() / tileImageSize.height());
116 116
117 AffineTransform patternTransform = m_attributes.patternTransform(); 117 AffineTransform patternTransform = m_attributes.patternTransform();
118 if (!patternTransform.isIdentity()) 118 if (!patternTransform.isIdentity())
119 patternData->transform = patternTransform * patternData->transform; 119 patternData->transform = patternTransform * patternData->transform;
120 120
121 // Account for text drawing resetting the context to non-scaled, see SVGInli neTextBox::paintTextWithShadows.
122 if (resourceMode & ApplyToTextMode) {
123 AffineTransform additionalTextTransformation;
124 if (shouldTransformOnTextPainting(object, additionalTextTransformation))
125 patternData->transform *= additionalTextTransformation;
126 }
127 patternData->pattern->setPatternSpaceTransform(patternData->transform);
128
129 // Various calls above may trigger invalidations in some fringe cases (Image Buffer allocation 121 // Various calls above may trigger invalidations in some fringe cases (Image Buffer allocation
130 // failures in the SVG image cache for example). To avoid having our Pattern Data deleted by 122 // failures in the SVG image cache for example). To avoid having our Pattern Data deleted by
131 // removeAllClientsFromCache(), we only make it visible in the cache at the very end. 123 // removeAllClientsFromCache(), we only make it visible in the cache at the very end.
132 return m_patternMap.set(object, patternData.release()).storedValue->value.ge t(); 124 return m_patternMap.set(object, patternData.release()).storedValue->value.ge t();
133 } 125 }
134 126
135 bool RenderSVGResourcePattern::applyResource(RenderObject* object, RenderStyle* style, GraphicsContext*& context, unsigned short resourceMode) 127 bool RenderSVGResourcePattern::applyResource(RenderObject* object, RenderStyle* style, GraphicsContext*& context, unsigned short resourceMode)
136 { 128 {
137 ASSERT(object); 129 ASSERT(object);
138 ASSERT(style); 130 ASSERT(style);
139 ASSERT(context); 131 ASSERT(context);
140 ASSERT(resourceMode != ApplyToDefaultMode); 132 ASSERT(resourceMode != ApplyToDefaultMode);
141 133
142 clearInvalidationMask(); 134 clearInvalidationMask();
143 135
144 // Spec: When the geometry of the applicable element has no width or height and objectBoundingBox is specified, 136 // Spec: When the geometry of the applicable element has no width or height and objectBoundingBox is specified,
145 // then the given effect (e.g. a gradient or a filter) will be ignored. 137 // then the given effect (e.g. a gradient or a filter) will be ignored.
146 FloatRect objectBoundingBox = object->objectBoundingBox(); 138 FloatRect objectBoundingBox = object->objectBoundingBox();
147 if (m_attributes.patternUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDIN GBOX && objectBoundingBox.isEmpty()) 139 if (m_attributes.patternUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDIN GBOX && objectBoundingBox.isEmpty())
148 return false; 140 return false;
149 141
150 PatternData* patternData = buildPattern(object, resourceMode); 142 PatternData* patternData = buildPattern(object, resourceMode);
151 if (!patternData) 143 if (!patternData)
152 return false; 144 return false;
153 145
146 const SVGRenderStyle* svgStyle = style->svgStyle();
147 ASSERT(svgStyle);
148
149 AffineTransform computedPatternSpaceTransform = computeResourceSpaceTransfor m(object, patternData->transform, svgStyle, resourceMode);
150 patternData->pattern->setPatternSpaceTransform(computedPatternSpaceTransform );
151
154 // Draw pattern 152 // Draw pattern
155 context->save(); 153 context->save();
156 154
157 const SVGRenderStyle* svgStyle = style->svgStyle();
158 ASSERT(svgStyle);
159
160 if (resourceMode & ApplyToFillMode) { 155 if (resourceMode & ApplyToFillMode) {
161 context->setAlphaAsFloat(svgStyle->fillOpacity()); 156 context->setAlphaAsFloat(svgStyle->fillOpacity());
162 context->setFillPattern(patternData->pattern); 157 context->setFillPattern(patternData->pattern);
163 context->setFillRule(svgStyle->fillRule()); 158 context->setFillRule(svgStyle->fillRule());
164 } else if (resourceMode & ApplyToStrokeMode) { 159 } else if (resourceMode & ApplyToStrokeMode) {
165 if (svgStyle->vectorEffect() == VE_NON_SCALING_STROKE)
166 patternData->pattern->setPatternSpaceTransform(transformOnNonScaling Stroke(object, patternData->transform));
167 context->setAlphaAsFloat(svgStyle->strokeOpacity()); 160 context->setAlphaAsFloat(svgStyle->strokeOpacity());
168 context->setStrokePattern(patternData->pattern); 161 context->setStrokePattern(patternData->pattern);
169 SVGRenderSupport::applyStrokeStyleToContext(context, style, object); 162 SVGRenderSupport::applyStrokeStyleToContext(context, style, object);
170 } 163 }
171 164
172 if (resourceMode & ApplyToTextMode) { 165 if (resourceMode & ApplyToTextMode) {
173 if (resourceMode & ApplyToFillMode) 166 if (resourceMode & ApplyToFillMode)
174 context->setTextDrawingMode(TextModeFill); 167 context->setTextDrawingMode(TextModeFill);
175 else if (resourceMode & ApplyToStrokeMode) 168 else if (resourceMode & ApplyToStrokeMode)
176 context->setTextDrawingMode(TextModeStroke); 169 context->setTextDrawingMode(TextModeStroke);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 continue; 264 continue;
272 if (element->renderer()->needsLayout()) 265 if (element->renderer()->needsLayout())
273 return nullptr; 266 return nullptr;
274 SVGRenderingContext::renderSubtree(tileImage->context(), element->render er(), contentTransformation); 267 SVGRenderingContext::renderSubtree(tileImage->context(), element->render er(), contentTransformation);
275 } 268 }
276 269
277 return tileImage.release(); 270 return tileImage.release();
278 } 271 }
279 272
280 } 273 }
OLDNEW
« no previous file with comments | « Source/core/rendering/svg/RenderSVGResourceGradient.cpp ('k') | Source/core/rendering/svg/SVGTextRunRenderingContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698