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

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

Issue 630903003: Move common GC state update code out of paint-server application (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Move updateGraphicsContext. 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.
(...skipping 13 matching lines...) Expand all
24 24
25 #include "core/rendering/svg/RenderSVGResource.h" 25 #include "core/rendering/svg/RenderSVGResource.h"
26 26
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" 31 #include "core/rendering/svg/SVGRenderSupport.h"
32 #include "core/rendering/svg/SVGResources.h" 32 #include "core/rendering/svg/SVGResources.h"
33 #include "core/rendering/svg/SVGResourcesCache.h" 33 #include "core/rendering/svg/SVGResourcesCache.h"
34 #include "platform/graphics/GraphicsContext.h"
34 35
35 namespace blink { 36 namespace blink {
36 37
37 bool RenderSVGResource::applyResource(RenderObject*, RenderStyle*, GraphicsConte xt*, RenderSVGResourceModeFlags) 38 bool RenderSVGResource::applyResource(RenderObject*, RenderStyle*, GraphicsConte xt*, RenderSVGResourceModeFlags)
38 { 39 {
39 ASSERT_NOT_REACHED(); 40 ASSERT_NOT_REACHED();
40 return false; 41 return false;
41 } 42 }
42 43
43 RenderSVGResource* RenderSVGResource::requestPaintingResource(RenderSVGResourceM ode mode, RenderObject* object, const RenderStyle* style, bool& hasFallback) 44 RenderSVGResource* RenderSVGResource::requestPaintingResource(RenderSVGResourceM ode mode, RenderObject* object, const RenderStyle* style, bool& hasFallback)
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 123
123 // The paint server resource exists, though it may be invalid (pattern with width/height=0). Pass the fallback color to our caller 124 // The paint server resource exists, though it may be invalid (pattern with width/height=0). Pass the fallback color to our caller
124 // via sharedSolidPaintingResource so it can use the solid color painting re source, if applyResource() on the URI resource failed. 125 // via sharedSolidPaintingResource so it can use the solid color painting re source, if applyResource() on the URI resource failed.
125 if (hasColor) { 126 if (hasColor) {
126 colorResource->setColor(color); 127 colorResource->setColor(color);
127 hasFallback = true; 128 hasFallback = true;
128 } 129 }
129 return uriResource; 130 return uriResource;
130 } 131 }
131 132
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 if (resourceModeFlags & ApplyToTextMode)
146 context->setTextDrawingMode(TextModeFill);
147 return;
148 }
149
150 const SVGRenderStyle& svgStyle = style->svgStyle();
151
152 if (resourceMode == ApplyToFillMode) {
153 context->setAlphaAsFloat(svgStyle.fillOpacity());
154 context->setFillRule(svgStyle.fillRule());
155 } else {
156 context->setAlphaAsFloat(svgStyle.strokeOpacity());
157 SVGRenderSupport::applyStrokeStyleToContext(context, style, &renderer);
158 }
159
160 if (resourceModeFlags & ApplyToTextMode)
161 context->setTextDrawingMode(resourceMode == ApplyToFillMode ? TextModeFi ll : TextModeStroke);
162 }
163
132 RenderSVGResourceSolidColor* RenderSVGResource::sharedSolidPaintingResource() 164 RenderSVGResourceSolidColor* RenderSVGResource::sharedSolidPaintingResource()
133 { 165 {
134 static RenderSVGResourceSolidColor* s_sharedSolidPaintingResource = 0; 166 static RenderSVGResourceSolidColor* s_sharedSolidPaintingResource = 0;
135 if (!s_sharedSolidPaintingResource) 167 if (!s_sharedSolidPaintingResource)
136 s_sharedSolidPaintingResource = new RenderSVGResourceSolidColor; 168 s_sharedSolidPaintingResource = new RenderSVGResourceSolidColor;
137 return s_sharedSolidPaintingResource; 169 return s_sharedSolidPaintingResource;
138 } 170 }
139 171
140 static inline void removeFromCacheAndInvalidateDependencies(RenderObject* object , bool needsLayout) 172 static inline void removeFromCacheAndInvalidateDependencies(RenderObject* object , bool needsLayout)
141 { 173 {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 // This will process the rest of the ancestors. 229 // This will process the rest of the ancestors.
198 toRenderSVGResourceContainer(current)->removeAllClientsFromCache(); 230 toRenderSVGResourceContainer(current)->removeAllClientsFromCache();
199 break; 231 break;
200 } 232 }
201 233
202 current = current->parent(); 234 current = current->parent();
203 } 235 }
204 } 236 }
205 237
206 } 238 }
OLDNEW
« no previous file with comments | « Source/core/rendering/svg/RenderSVGResource.h ('k') | Source/core/rendering/svg/RenderSVGResourceGradient.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698