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

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

Issue 658333003: Make RenderSVGResource::requestPaintingResource an implementation detail (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Revert to earlier. Try to keep some impl-detail-hiding. 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
« no previous file with comments | « Source/core/core.gypi ('k') | Source/core/rendering/svg/RenderSVGResource.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. 2 * Copyright (C) Research In Motion Limited 2009-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
(...skipping 14 matching lines...) Expand all
25 #include "platform/graphics/Pattern.h" 25 #include "platform/graphics/Pattern.h"
26 26
27 namespace blink { 27 namespace blink {
28 28
29 enum RenderSVGResourceType { 29 enum RenderSVGResourceType {
30 MaskerResourceType, 30 MaskerResourceType,
31 MarkerResourceType, 31 MarkerResourceType,
32 PatternResourceType, 32 PatternResourceType,
33 LinearGradientResourceType, 33 LinearGradientResourceType,
34 RadialGradientResourceType, 34 RadialGradientResourceType,
35 SolidColorResourceType,
36 FilterResourceType, 35 FilterResourceType,
37 ClipperResourceType 36 ClipperResourceType
38 }; 37 };
39 38
40 enum RenderSVGResourceMode { 39 enum RenderSVGResourceMode {
41 ApplyToFillMode, 40 ApplyToFillMode,
42 ApplyToStrokeMode, 41 ApplyToStrokeMode,
43 }; 42 };
44 43
45 class GraphicsContext; 44 class GraphicsContext;
46 class GraphicsContextStateSaver; 45 class GraphicsContextStateSaver;
47 class RenderObject; 46 class RenderObject;
47 class RenderSVGResource;
48 class RenderStyle; 48 class RenderStyle;
49 class RenderSVGResourceSolidColor;
50 49
51 class SVGPaintServer { 50 class SVGPaintServer {
52 public: 51 public:
53 explicit SVGPaintServer(Color); 52 explicit SVGPaintServer(Color);
54 explicit SVGPaintServer(PassRefPtr<Gradient>); 53 explicit SVGPaintServer(PassRefPtr<Gradient>);
55 explicit SVGPaintServer(PassRefPtr<Pattern>); 54 explicit SVGPaintServer(PassRefPtr<Pattern>);
56 55
57 static SVGPaintServer requestForRenderer(const RenderObject&, const RenderSt yle*, RenderSVGResourceMode); 56 static SVGPaintServer requestForRenderer(const RenderObject&, const RenderSt yle*, RenderSVGResourceMode);
57 static bool existsForRenderer(const RenderObject&, const RenderStyle*, Rende rSVGResourceMode);
58 58
59 void apply(GraphicsContext&, RenderSVGResourceMode, GraphicsContextStateSave r* = 0); 59 void apply(GraphicsContext&, RenderSVGResourceMode, GraphicsContextStateSave r* = 0);
60 60
61 static SVGPaintServer invalid() { return SVGPaintServer(Color(Color::transpa rent)); } 61 static SVGPaintServer invalid() { return SVGPaintServer(Color(Color::transpa rent)); }
62 bool isValid() const { return m_color != Color::transparent; } 62 bool isValid() const { return m_color != Color::transparent; }
63 63
64 bool isTransformDependent() const { return m_gradient || m_pattern; } 64 bool isTransformDependent() const { return m_gradient || m_pattern; }
65 void prependTransform(const AffineTransform&); 65 void prependTransform(const AffineTransform&);
66 66
67 private: 67 private:
68 RefPtr<Gradient> m_gradient; 68 RefPtr<Gradient> m_gradient;
69 RefPtr<Pattern> m_pattern; 69 RefPtr<Pattern> m_pattern;
70 Color m_color; 70 Color m_color;
71 }; 71 };
72 72
73 // If |SVGPaintDescription::hasFallback| is true, |SVGPaintDescription::color| i s set to a fallback color.
74 struct SVGPaintDescription {
75 SVGPaintDescription() : resource(nullptr), isValid(false), hasFallback(false ) { }
76 SVGPaintDescription(Color color) : resource(nullptr), color(color), isValid( true), hasFallback(false) { }
77 SVGPaintDescription(RenderSVGResource* resource) : resource(resource), isVal id(true), hasFallback(false) { ASSERT(resource); }
78 SVGPaintDescription(RenderSVGResource* resource, Color fallbackColor) : reso urce(resource), color(fallbackColor), isValid(true), hasFallback(true) { ASSERT( resource); }
79
80 RenderSVGResource* resource;
81 Color color;
82 bool isValid;
83 bool hasFallback;
84 };
85
73 class RenderSVGResource { 86 class RenderSVGResource {
74 public: 87 public:
75 RenderSVGResource() { } 88 RenderSVGResource() { }
76 virtual ~RenderSVGResource() { } 89 virtual ~RenderSVGResource() { }
77 90
78 virtual SVGPaintServer preparePaintServer(const RenderObject&); 91 virtual SVGPaintServer preparePaintServer(const RenderObject&);
79 92
80 virtual RenderSVGResourceType resourceType() const = 0; 93 virtual RenderSVGResourceType resourceType() const = 0;
81 94
82 // Helper utilities used in the render tree to access resources used for pai nting shapes/text (gradients & patterns & solid colors only) 95 // Helper utilities used in to access the underlying resources for DRT.
83 // If hasFallback gets set to true, the sharedSolidPaintingResource is set t o a fallback color. 96 static SVGPaintDescription requestPaintForDRT(const RenderObject&, const Ren derStyle*, RenderSVGResourceMode);
f(malita) 2014/10/21 13:57:36 nit: I would prefer not to have DRT-specific metho
84 static RenderSVGResource* requestPaintingResource(RenderSVGResourceMode, con st RenderObject&, const RenderStyle*, bool& hasFallback);
85 static RenderSVGResourceSolidColor* sharedSolidPaintingResource();
86 97
87 static void markForLayoutAndParentResourceInvalidation(RenderObject*, bool n eedsLayout = true); 98 static void markForLayoutAndParentResourceInvalidation(RenderObject*, bool n eedsLayout = true);
88 }; 99 };
89 100
90 #define DEFINE_RENDER_SVG_RESOURCE_TYPE_CASTS(thisType, typeName) \ 101 #define DEFINE_RENDER_SVG_RESOURCE_TYPE_CASTS(thisType, typeName) \
91 DEFINE_TYPE_CASTS(thisType, RenderSVGResource, resource, resource->resourceT ype() == typeName, resource.resourceType() == typeName) 102 DEFINE_TYPE_CASTS(thisType, RenderSVGResource, resource, resource->resourceT ype() == typeName, resource.resourceType() == typeName)
92 103
93 } 104 }
94 105
95 #endif 106 #endif
OLDNEW
« no previous file with comments | « Source/core/core.gypi ('k') | Source/core/rendering/svg/RenderSVGResource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698