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

Side by Side Diff: Source/core/rendering/svg/RenderSVGResource.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) 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
27 #include "core/rendering/svg/RenderSVGResourceClipper.h" 26 #include "core/rendering/svg/RenderSVGResourceClipper.h"
28 #include "core/rendering/svg/RenderSVGResourceFilter.h" 27 #include "core/rendering/svg/RenderSVGResourceFilter.h"
29 #include "core/rendering/svg/RenderSVGResourceMasker.h" 28 #include "core/rendering/svg/RenderSVGResourceMasker.h"
30 #include "core/rendering/svg/RenderSVGResourceSolidColor.h" 29 #include "core/rendering/svg/RenderSVGResourceSolidColor.h"
31 #include "core/rendering/svg/SVGRenderSupport.h"
32 #include "core/rendering/svg/SVGResources.h" 30 #include "core/rendering/svg/SVGResources.h"
33 #include "core/rendering/svg/SVGResourcesCache.h" 31 #include "core/rendering/svg/SVGResourcesCache.h"
34 #include "platform/graphics/GraphicsContext.h"
35 32
36 namespace blink { 33 namespace blink {
37 34
38 bool RenderSVGResource::applyResource(RenderObject*, RenderStyle*, GraphicsConte xt*, RenderSVGResourceModeFlags) 35 bool RenderSVGResource::preparePaintServer(RenderObject*, RenderStyle*, RenderSV GResourceModeFlags, SVGPaintServer&)
39 { 36 {
40 ASSERT_NOT_REACHED(); 37 ASSERT_NOT_REACHED();
41 return false; 38 return false;
42 } 39 }
43 40
44 RenderSVGResource* RenderSVGResource::requestPaintingResource(RenderSVGResourceM ode mode, RenderObject* object, const RenderStyle* style, bool& hasFallback) 41 RenderSVGResource* RenderSVGResource::requestPaintingResource(RenderSVGResourceM ode mode, RenderObject* object, const RenderStyle* style, bool& hasFallback)
45 { 42 {
46 ASSERT(object); 43 ASSERT(object);
47 ASSERT(style); 44 ASSERT(style);
48 45
49 hasFallback = false; 46 hasFallback = false;
50 47
51 // If we have no style at all, ignore it. 48 // If we have no style at all, ignore it.
52 const SVGRenderStyle& svgStyle = style->svgStyle(); 49 const SVGRenderStyle& svgStyle = style->svgStyle();
53 50
54 bool isRenderingMask = SVGRenderSupport::isRenderingClipPathAsMaskImage(*obj ect);
55
56 // If we have no fill/stroke, return 0. 51 // If we have no fill/stroke, return 0.
57 if (mode == ApplyToFillMode) { 52 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()) 53 if (!svgStyle.hasFill())
66 return 0; 54 return 0;
67 } else { 55 } else {
68 if (!svgStyle.hasStroke() || isRenderingMask) 56 if (!svgStyle.hasStroke())
69 return 0; 57 return 0;
70 } 58 }
71 59
72 bool applyToFill = mode == ApplyToFillMode; 60 bool applyToFill = mode == ApplyToFillMode;
73 SVGPaintType paintType = applyToFill ? svgStyle.fillPaintType() : svgStyle.s trokePaintType(); 61 SVGPaintType paintType = applyToFill ? svgStyle.fillPaintType() : svgStyle.s trokePaintType();
74 ASSERT(paintType != SVG_PAINTTYPE_NONE); 62 ASSERT(paintType != SVG_PAINTTYPE_NONE);
75 63
76 Color color; 64 Color color;
77 bool hasColor = false; 65 bool hasColor = false;
78 switch (paintType) { 66 switch (paintType) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 111
124 // The paint server resource exists, though it may be invalid (pattern with width/height=0). Pass the fallback color to our caller 112 // 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. 113 // via sharedSolidPaintingResource so it can use the solid color painting re source, if applyResource() on the URI resource failed.
126 if (hasColor) { 114 if (hasColor) {
127 colorResource->setColor(color); 115 colorResource->setColor(color);
128 hasFallback = true; 116 hasFallback = true;
129 } 117 }
130 return uriResource; 118 return uriResource;
131 } 119 }
132 120
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() 121 RenderSVGResourceSolidColor* RenderSVGResource::sharedSolidPaintingResource()
160 { 122 {
161 static RenderSVGResourceSolidColor* s_sharedSolidPaintingResource = 0; 123 static RenderSVGResourceSolidColor* s_sharedSolidPaintingResource = 0;
162 if (!s_sharedSolidPaintingResource) 124 if (!s_sharedSolidPaintingResource)
163 s_sharedSolidPaintingResource = new RenderSVGResourceSolidColor; 125 s_sharedSolidPaintingResource = new RenderSVGResourceSolidColor;
164 return s_sharedSolidPaintingResource; 126 return s_sharedSolidPaintingResource;
165 } 127 }
166 128
167 static inline void removeFromCacheAndInvalidateDependencies(RenderObject* object , bool needsLayout) 129 static inline void removeFromCacheAndInvalidateDependencies(RenderObject* object , bool needsLayout)
168 { 130 {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 // This will process the rest of the ancestors. 186 // This will process the rest of the ancestors.
225 toRenderSVGResourceContainer(current)->removeAllClientsFromCache(); 187 toRenderSVGResourceContainer(current)->removeAllClientsFromCache();
226 break; 188 break;
227 } 189 }
228 190
229 current = current->parent(); 191 current = current->parent();
230 } 192 }
231 } 193 }
232 194
233 } 195 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698