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

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

Issue 638933002: Introduce SVGPaintServer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Extra sure about manual shadow-restore. 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) 2006 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> 3 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
4 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> 4 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org>
5 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 5 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
11 * 11 *
12 * This library is distributed in the hope that it will be useful, 12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details. 15 * Library General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU Library General Public License 17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to 18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA. 20 * Boston, MA 02110-1301, USA.
21 */ 21 */
22 22
23 #include "config.h" 23 #include "config.h"
24
25 #include "core/rendering/svg/RenderSVGResourceGradient.h" 24 #include "core/rendering/svg/RenderSVGResourceGradient.h"
26 25
27 #include "core/rendering/svg/RenderSVGShape.h" 26 #include "core/paint/SVGPaintServer.h"
28 #include "core/rendering/svg/SVGRenderSupport.h"
29 #include "platform/graphics/GraphicsContext.h"
30 27
31 namespace blink { 28 namespace blink {
32 29
33 RenderSVGResourceGradient::RenderSVGResourceGradient(SVGGradientElement* node) 30 RenderSVGResourceGradient::RenderSVGResourceGradient(SVGGradientElement* node)
34 : RenderSVGResourceContainer(node) 31 : RenderSVGResourceContainer(node)
35 , m_shouldCollectGradientAttributes(true) 32 , m_shouldCollectGradientAttributes(true)
36 { 33 {
37 } 34 }
38 35
39 void RenderSVGResourceGradient::removeAllClientsFromCache(bool markForInvalidati on) 36 void RenderSVGResourceGradient::removeAllClientsFromCache(bool markForInvalidati on)
40 { 37 {
41 m_gradientMap.clear(); 38 m_gradientMap.clear();
42 m_shouldCollectGradientAttributes = true; 39 m_shouldCollectGradientAttributes = true;
43 markAllClientsForInvalidation(markForInvalidation ? PaintInvalidation : Pare ntOnlyInvalidation); 40 markAllClientsForInvalidation(markForInvalidation ? PaintInvalidation : Pare ntOnlyInvalidation);
44 } 41 }
45 42
46 void RenderSVGResourceGradient::removeClientFromCache(RenderObject* client, bool markForInvalidation) 43 void RenderSVGResourceGradient::removeClientFromCache(RenderObject* client, bool markForInvalidation)
47 { 44 {
48 ASSERT(client); 45 ASSERT(client);
49 m_gradientMap.remove(client); 46 m_gradientMap.remove(client);
50 markClientForInvalidation(client, markForInvalidation ? PaintInvalidation : ParentOnlyInvalidation); 47 markClientForInvalidation(client, markForInvalidation ? PaintInvalidation : ParentOnlyInvalidation);
51 } 48 }
52 49
53 bool RenderSVGResourceGradient::applyResource(RenderObject* object, RenderStyle* style, GraphicsContext* context, RenderSVGResourceModeFlags resourceMode) 50 bool RenderSVGResourceGradient::preparePaintServer(RenderObject* object, RenderS tyle* style, RenderSVGResourceModeFlags resourceMode, SVGPaintServer& paintServe r)
54 { 51 {
55 ASSERT(object); 52 ASSERT(object);
56 ASSERT(style); 53 ASSERT(style);
57 ASSERT(context);
58 54
59 clearInvalidationMask(); 55 clearInvalidationMask();
60 56
61 // Be sure to synchronize all SVG properties on the gradientElement _before_ processing any further. 57 // Be sure to synchronize all SVG properties on the gradientElement _before_ processing any further.
62 // Otherwhise the call to collectGradientAttributes() in createTileImage(), may cause the SVG DOM property 58 // Otherwhise the call to collectGradientAttributes() in createTileImage(), may cause the SVG DOM property
63 // synchronization to kick in, which causes removeAllClientsFromCache() to b e called, which in turn deletes our 59 // synchronization to kick in, which causes removeAllClientsFromCache() to b e called, which in turn deletes our
64 // GradientData object! Leaving out the line below will cause svg/dynamic-up dates/SVG*GradientElement-svgdom* to crash. 60 // GradientData object! Leaving out the line below will cause svg/dynamic-up dates/SVG*GradientElement-svgdom* to crash.
65 SVGGradientElement* gradientElement = toSVGGradientElement(element()); 61 SVGGradientElement* gradientElement = toSVGGradientElement(element());
66 if (!gradientElement) 62 if (!gradientElement)
67 return false; 63 return false;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 } 97 }
102 98
103 if (!gradientData->gradient) 99 if (!gradientData->gradient)
104 return false; 100 return false;
105 101
106 const SVGRenderStyle& svgStyle = style->svgStyle(); 102 const SVGRenderStyle& svgStyle = style->svgStyle();
107 103
108 AffineTransform computedGradientSpaceTransform = computeResourceSpaceTransfo rm(object, gradientData->userspaceTransform, svgStyle, resourceMode); 104 AffineTransform computedGradientSpaceTransform = computeResourceSpaceTransfo rm(object, gradientData->userspaceTransform, svgStyle, resourceMode);
109 gradientData->gradient->setGradientSpaceTransform(computedGradientSpaceTrans form); 105 gradientData->gradient->setGradientSpaceTransform(computedGradientSpaceTrans form);
110 106
111 // Draw gradient 107 paintServer.setGradient(gradientData->gradient);
112 context->save();
113
114 if (resourceMode & ApplyToFillMode)
115 context->setFillGradient(gradientData->gradient);
116 else if (resourceMode & ApplyToStrokeMode)
117 context->setStrokeGradient(gradientData->gradient);
118
119 updateGraphicsContext(context, style, *object, resourceMode);
120 return true; 108 return true;
121 } 109 }
122 110
123 void RenderSVGResourceGradient::postApplyResource(GraphicsContext* context)
124 {
125 ASSERT(context);
126 context->restore();
127 }
128
129 void RenderSVGResourceGradient::addStops(GradientData* gradientData, const Vecto r<Gradient::ColorStop>& stops) const 111 void RenderSVGResourceGradient::addStops(GradientData* gradientData, const Vecto r<Gradient::ColorStop>& stops) const
130 { 112 {
131 ASSERT(gradientData->gradient); 113 ASSERT(gradientData->gradient);
132 114
133 const Vector<Gradient::ColorStop>::const_iterator end = stops.end(); 115 const Vector<Gradient::ColorStop>::const_iterator end = stops.end();
134 for (Vector<Gradient::ColorStop>::const_iterator it = stops.begin(); it != e nd; ++it) 116 for (Vector<Gradient::ColorStop>::const_iterator it = stops.begin(); it != e nd; ++it)
135 gradientData->gradient->addColorStop(*it); 117 gradientData->gradient->addColorStop(*it);
136 } 118 }
137 119
138 GradientSpreadMethod RenderSVGResourceGradient::platformSpreadMethodFromSVGType( SVGSpreadMethodType method) const 120 GradientSpreadMethod RenderSVGResourceGradient::platformSpreadMethodFromSVGType( SVGSpreadMethodType method) const
139 { 121 {
140 switch (method) { 122 switch (method) {
141 case SVGSpreadMethodUnknown: 123 case SVGSpreadMethodUnknown:
142 case SVGSpreadMethodPad: 124 case SVGSpreadMethodPad:
143 return SpreadMethodPad; 125 return SpreadMethodPad;
144 case SVGSpreadMethodReflect: 126 case SVGSpreadMethodReflect:
145 return SpreadMethodReflect; 127 return SpreadMethodReflect;
146 case SVGSpreadMethodRepeat: 128 case SVGSpreadMethodRepeat:
147 return SpreadMethodRepeat; 129 return SpreadMethodRepeat;
148 } 130 }
149 131
150 ASSERT_NOT_REACHED(); 132 ASSERT_NOT_REACHED();
151 return SpreadMethodPad; 133 return SpreadMethodPad;
152 } 134 }
153 135
154 } 136 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698