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

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

Issue 652243002: Hoist paint-server transform adaption out of preparePaintServer (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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public License 14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to 15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA. 17 * Boston, MA 02110-1301, USA.
18 */ 18 */
19 19
20 #include "config.h" 20 #include "config.h"
21
22 #include "core/rendering/svg/RenderSVGResourceContainer.h" 21 #include "core/rendering/svg/RenderSVGResourceContainer.h"
23 22
24 #include "core/rendering/RenderLayer.h" 23 #include "core/rendering/RenderLayer.h"
25 #include "core/rendering/RenderView.h"
26 #include "core/rendering/svg/SVGRenderingContext.h"
27 #include "core/rendering/svg/SVGResourcesCache.h" 24 #include "core/rendering/svg/SVGResourcesCache.h"
28 #include "core/svg/SVGGraphicsElement.h"
29 25
30 #include "wtf/TemporaryChange.h" 26 #include "wtf/TemporaryChange.h"
31 27
32 namespace blink { 28 namespace blink {
33 29
34 static inline SVGDocumentExtensions& svgExtensionsFromElement(SVGElement* elemen t) 30 static inline SVGDocumentExtensions& svgExtensionsFromElement(SVGElement* elemen t)
35 { 31 {
36 ASSERT(element); 32 ASSERT(element);
37 return element->document().accessSVGExtensions(); 33 return element->document().accessSVGExtensions();
38 } 34 }
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 if (!renderer) 219 if (!renderer)
224 continue; 220 continue;
225 221
226 StyleDifference diff; 222 StyleDifference diff;
227 diff.setNeedsFullLayout(); 223 diff.setNeedsFullLayout();
228 SVGResourcesCache::clientStyleChanged(renderer, diff, renderer->style()) ; 224 SVGResourcesCache::clientStyleChanged(renderer, diff, renderer->style()) ;
229 renderer->setNeedsLayoutAndFullPaintInvalidation(); 225 renderer->setNeedsLayoutAndFullPaintInvalidation();
230 } 226 }
231 } 227 }
232 228
233 static bool shouldTransformOnTextPainting(RenderObject* object, AffineTransform& resourceTransform)
234 {
235 ASSERT(object);
236
237 // This method should only be called for RenderObjects that deal with text r endering. Cmp. RenderObject.h's is*() methods.
238 ASSERT(object->isSVGText() || object->isSVGTextPath() || object->isSVGInline ());
239
240 // In text drawing, the scaling part of the graphics context CTM is removed, compare SVGInlineTextBox::paintTextWithShadows.
241 // So, we use that scaling factor here, too, and then push it down to patter n or gradient space
242 // in order to keep the pattern or gradient correctly scaled.
243 float scalingFactor = SVGRenderingContext::calculateScreenFontSizeScalingFac tor(object);
244 if (scalingFactor == 1)
245 return false;
246 resourceTransform.scale(scalingFactor);
247 return true;
248 } 229 }
249
250 AffineTransform RenderSVGResourceContainer::computeResourceSpaceTransform(Render Object* object, const AffineTransform& baseTransform, const SVGRenderStyle& svgS tyle, unsigned short resourceMode)
251 {
252 AffineTransform computedSpaceTransform = baseTransform;
253 if (resourceMode & ApplyToTextMode) {
254 // Depending on the font scaling factor, we may need to apply an
255 // additional transform (scale-factor) the paintserver, since text
256 // painting removes the scale factor from the context. (See
257 // SVGInlineTextBox::paintTextWithShadows.)
258 AffineTransform additionalTextTransformation;
259 if (shouldTransformOnTextPainting(object, additionalTextTransformation))
260 computedSpaceTransform = additionalTextTransformation * computedSpac eTransform;
261 }
262 if (resourceMode & ApplyToStrokeMode) {
263 // Non-scaling stroke needs to reset the transform back to the host tran sform.
264 if (svgStyle.vectorEffect() == VE_NON_SCALING_STROKE)
265 computedSpaceTransform = transformOnNonScalingStroke(object, compute dSpaceTransform);
266 }
267 return computedSpaceTransform;
268 }
269
270 // FIXME: This does not belong here.
271 AffineTransform RenderSVGResourceContainer::transformOnNonScalingStroke(RenderOb ject* object, const AffineTransform& resourceTransform)
272 {
273 if (!object->isSVGShape())
274 return resourceTransform;
275
276 SVGGraphicsElement* element = toSVGGraphicsElement(object->node());
277 AffineTransform transform = element->getScreenCTM(SVGGraphicsElement::Disall owStyleUpdate);
278 transform *= resourceTransform;
279 return transform;
280 }
281
282 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698