OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2007 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2007 Rob Buis <buis@kde.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/RenderSVGResource.h" | 24 #include "core/rendering/svg/RenderSVGResource.h" |
26 | 25 |
| 26 #include "core/paint/SVGPaintServer.h" |
27 #include "core/rendering/svg/RenderSVGResourceClipper.h" | 27 #include "core/rendering/svg/RenderSVGResourceClipper.h" |
28 #include "core/rendering/svg/RenderSVGResourceFilter.h" | 28 #include "core/rendering/svg/RenderSVGResourceFilter.h" |
29 #include "core/rendering/svg/RenderSVGResourceMasker.h" | 29 #include "core/rendering/svg/RenderSVGResourceMasker.h" |
30 #include "core/rendering/svg/RenderSVGResourceSolidColor.h" | 30 #include "core/rendering/svg/RenderSVGResourceSolidColor.h" |
31 #include "core/rendering/svg/SVGRenderSupport.h" | |
32 #include "core/rendering/svg/SVGResources.h" | 31 #include "core/rendering/svg/SVGResources.h" |
33 #include "core/rendering/svg/SVGResourcesCache.h" | 32 #include "core/rendering/svg/SVGResourcesCache.h" |
34 #include "platform/graphics/GraphicsContext.h" | |
35 | 33 |
36 namespace blink { | 34 namespace blink { |
37 | 35 |
38 bool RenderSVGResource::applyResource(RenderObject*, RenderStyle*, GraphicsConte
xt*, RenderSVGResourceModeFlags) | 36 PassOwnPtr<SVGPaintServer> RenderSVGResource::preparePaintServer(RenderObject*,
RenderStyle*, RenderSVGResourceModeFlags) |
39 { | 37 { |
40 ASSERT_NOT_REACHED(); | 38 ASSERT_NOT_REACHED(); |
41 return false; | 39 return nullptr; |
42 } | 40 } |
43 | 41 |
44 RenderSVGResource* RenderSVGResource::requestPaintingResource(RenderSVGResourceM
ode mode, RenderObject* object, const RenderStyle* style, bool& hasFallback) | 42 RenderSVGResource* RenderSVGResource::requestPaintingResource(RenderSVGResourceM
ode mode, RenderObject* object, const RenderStyle* style, bool& hasFallback) |
45 { | 43 { |
46 ASSERT(object); | 44 ASSERT(object); |
47 ASSERT(style); | 45 ASSERT(style); |
48 | 46 |
49 hasFallback = false; | 47 hasFallback = false; |
50 | 48 |
51 // If we have no style at all, ignore it. | 49 // If we have no style at all, ignore it. |
52 const SVGRenderStyle& svgStyle = style->svgStyle(); | 50 const SVGRenderStyle& svgStyle = style->svgStyle(); |
53 | 51 |
54 bool isRenderingMask = SVGRenderSupport::isRenderingClipPathAsMaskImage(*obj
ect); | |
55 | |
56 // If we have no fill/stroke, return 0. | 52 // If we have no fill/stroke, return 0. |
57 if (mode == ApplyToFillMode) { | 53 if (mode == ApplyToFillMode) { |
58 // When rendering the mask for a RenderSVGResourceClipper, always use th
e initial fill paint server, and ignore stroke. | |
59 if (isRenderingMask) { | |
60 RenderSVGResourceSolidColor* colorResource = RenderSVGResource::shar
edSolidPaintingResource(); | |
61 colorResource->setColor(SVGRenderStyle::initialFillPaintColor()); | |
62 return colorResource; | |
63 } | |
64 | |
65 if (!svgStyle.hasFill()) | 54 if (!svgStyle.hasFill()) |
66 return 0; | 55 return 0; |
67 } else { | 56 } else { |
68 if (!svgStyle.hasStroke() || isRenderingMask) | 57 if (!svgStyle.hasStroke()) |
69 return 0; | 58 return 0; |
70 } | 59 } |
71 | 60 |
72 bool applyToFill = mode == ApplyToFillMode; | 61 bool applyToFill = mode == ApplyToFillMode; |
73 SVGPaintType paintType = applyToFill ? svgStyle.fillPaintType() : svgStyle.s
trokePaintType(); | 62 SVGPaintType paintType = applyToFill ? svgStyle.fillPaintType() : svgStyle.s
trokePaintType(); |
74 ASSERT(paintType != SVG_PAINTTYPE_NONE); | 63 ASSERT(paintType != SVG_PAINTTYPE_NONE); |
75 | 64 |
76 Color color; | 65 Color color; |
77 bool hasColor = false; | 66 bool hasColor = false; |
78 switch (paintType) { | 67 switch (paintType) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 112 |
124 // The paint server resource exists, though it may be invalid (pattern with
width/height=0). Pass the fallback color to our caller | 113 // The paint server resource exists, though it may be invalid (pattern with
width/height=0). Pass the fallback color to our caller |
125 // via sharedSolidPaintingResource so it can use the solid color painting re
source, if applyResource() on the URI resource failed. | 114 // via sharedSolidPaintingResource so it can use the solid color painting re
source, if applyResource() on the URI resource failed. |
126 if (hasColor) { | 115 if (hasColor) { |
127 colorResource->setColor(color); | 116 colorResource->setColor(color); |
128 hasFallback = true; | 117 hasFallback = true; |
129 } | 118 } |
130 return uriResource; | 119 return uriResource; |
131 } | 120 } |
132 | 121 |
133 void RenderSVGResource::updateGraphicsContext(GraphicsContext* context, const Re
nderStyle* style, const RenderObject& renderer, unsigned resourceModeFlags) | |
134 { | |
135 ASSERT(context); | |
136 ASSERT(style); | |
137 | |
138 RenderSVGResourceMode resourceMode = static_cast<RenderSVGResourceMode>(reso
urceModeFlags & (ApplyToFillMode | ApplyToStrokeMode)); | |
139 ASSERT(resourceMode == ApplyToFillMode || resourceMode == ApplyToStrokeMode)
; | |
140 | |
141 if (SVGRenderSupport::isRenderingClipPathAsMaskImage(renderer)) { | |
142 // When rendering the mask for a RenderSVGResourceClipper, the stroke co
de path is never hit. | |
143 ASSERT(resourceMode == ApplyToFillMode); | |
144 context->setAlphaAsFloat(1); | |
145 return; | |
146 } | |
147 | |
148 const SVGRenderStyle& svgStyle = style->svgStyle(); | |
149 | |
150 if (resourceMode == ApplyToFillMode) { | |
151 context->setAlphaAsFloat(svgStyle.fillOpacity()); | |
152 context->setFillRule(svgStyle.fillRule()); | |
153 } else { | |
154 context->setAlphaAsFloat(svgStyle.strokeOpacity()); | |
155 SVGRenderSupport::applyStrokeStyleToContext(context, style, &renderer); | |
156 } | |
157 } | |
158 | |
159 RenderSVGResourceSolidColor* RenderSVGResource::sharedSolidPaintingResource() | 122 RenderSVGResourceSolidColor* RenderSVGResource::sharedSolidPaintingResource() |
160 { | 123 { |
161 static RenderSVGResourceSolidColor* s_sharedSolidPaintingResource = 0; | 124 static RenderSVGResourceSolidColor* s_sharedSolidPaintingResource = 0; |
162 if (!s_sharedSolidPaintingResource) | 125 if (!s_sharedSolidPaintingResource) |
163 s_sharedSolidPaintingResource = new RenderSVGResourceSolidColor; | 126 s_sharedSolidPaintingResource = new RenderSVGResourceSolidColor; |
164 return s_sharedSolidPaintingResource; | 127 return s_sharedSolidPaintingResource; |
165 } | 128 } |
166 | 129 |
167 static inline void removeFromCacheAndInvalidateDependencies(RenderObject* object
, bool needsLayout) | 130 static inline void removeFromCacheAndInvalidateDependencies(RenderObject* object
, bool needsLayout) |
168 { | 131 { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 // This will process the rest of the ancestors. | 187 // This will process the rest of the ancestors. |
225 toRenderSVGResourceContainer(current)->removeAllClientsFromCache(); | 188 toRenderSVGResourceContainer(current)->removeAllClientsFromCache(); |
226 break; | 189 break; |
227 } | 190 } |
228 | 191 |
229 current = current->parent(); | 192 current = current->parent(); |
230 } | 193 } |
231 } | 194 } |
232 | 195 |
233 } | 196 } |
OLD | NEW |