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

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

Issue 673753004: Move RenderSVGResource into the inheritance hierarchy (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Non-move changes. 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) 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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public License 14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to 15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA. 17 * Boston, MA 02110-1301, USA.
18 */ 18 */
19 19
20 #ifndef RenderSVGResource_h 20 #ifndef RenderSVGResourcePaintServer_h
21 #define RenderSVGResource_h 21 #define RenderSVGResourcePaintServer_h
22 22
23 #include "core/rendering/svg/RenderSVGResourceContainer.h"
23 #include "platform/graphics/Color.h" 24 #include "platform/graphics/Color.h"
24 #include "platform/graphics/Gradient.h" 25 #include "platform/graphics/Gradient.h"
25 #include "platform/graphics/Pattern.h" 26 #include "platform/graphics/Pattern.h"
26 27
27 namespace blink { 28 namespace blink {
28 29
29 enum RenderSVGResourceMode { 30 enum RenderSVGResourceMode {
30 ApplyToFillMode, 31 ApplyToFillMode,
31 ApplyToStrokeMode, 32 ApplyToStrokeMode,
32 }; 33 };
33 34
34 class GraphicsContext; 35 class GraphicsContext;
35 class GraphicsContextStateSaver; 36 class GraphicsContextStateSaver;
36 class RenderObject; 37 class RenderObject;
37 class RenderSVGResource; 38 class RenderSVGResourcePaintServer;
38 class RenderStyle; 39 class RenderStyle;
39 40
40 class SVGPaintServer { 41 class SVGPaintServer {
41 public: 42 public:
42 explicit SVGPaintServer(Color); 43 explicit SVGPaintServer(Color);
43 explicit SVGPaintServer(PassRefPtr<Gradient>); 44 explicit SVGPaintServer(PassRefPtr<Gradient>);
44 explicit SVGPaintServer(PassRefPtr<Pattern>); 45 explicit SVGPaintServer(PassRefPtr<Pattern>);
45 46
46 static SVGPaintServer requestForRenderer(const RenderObject&, const RenderSt yle*, RenderSVGResourceMode); 47 static SVGPaintServer requestForRenderer(const RenderObject&, const RenderSt yle*, RenderSVGResourceMode);
47 static bool existsForRenderer(const RenderObject&, const RenderStyle*, Rende rSVGResourceMode); 48 static bool existsForRenderer(const RenderObject&, const RenderStyle*, Rende rSVGResourceMode);
48 49
49 void apply(GraphicsContext&, RenderSVGResourceMode, GraphicsContextStateSave r* = 0); 50 void apply(GraphicsContext&, RenderSVGResourceMode, GraphicsContextStateSave r* = 0);
50 51
51 static SVGPaintServer invalid() { return SVGPaintServer(Color(Color::transpa rent)); } 52 static SVGPaintServer invalid() { return SVGPaintServer(Color(Color::transpa rent)); }
52 bool isValid() const { return m_color != Color::transparent; } 53 bool isValid() const { return m_color != Color::transparent; }
53 54
54 bool isTransformDependent() const { return m_gradient || m_pattern; } 55 bool isTransformDependent() const { return m_gradient || m_pattern; }
55 void prependTransform(const AffineTransform&); 56 void prependTransform(const AffineTransform&);
56 57
57 private: 58 private:
58 RefPtr<Gradient> m_gradient; 59 RefPtr<Gradient> m_gradient;
59 RefPtr<Pattern> m_pattern; 60 RefPtr<Pattern> m_pattern;
60 Color m_color; 61 Color m_color;
61 }; 62 };
62 63
63 // If |SVGPaintDescription::hasFallback| is true, |SVGPaintDescription::color| i s set to a fallback color. 64 // If |SVGPaintDescription::hasFallback| is true, |SVGPaintDescription::color| i s set to a fallback color.
64 struct SVGPaintDescription { 65 struct SVGPaintDescription {
65 SVGPaintDescription() : resource(nullptr), isValid(false), hasFallback(false ) { } 66 SVGPaintDescription() : resource(nullptr), isValid(false), hasFallback(false ) { }
66 SVGPaintDescription(Color color) : resource(nullptr), color(color), isValid( true), hasFallback(false) { } 67 SVGPaintDescription(Color color) : resource(nullptr), color(color), isValid( true), hasFallback(false) { }
67 SVGPaintDescription(RenderSVGResource* resource) : resource(resource), isVal id(true), hasFallback(false) { ASSERT(resource); } 68 SVGPaintDescription(RenderSVGResourcePaintServer* resource) : resource(resou rce), isValid(true), hasFallback(false) { ASSERT(resource); }
68 SVGPaintDescription(RenderSVGResource* resource, Color fallbackColor) : reso urce(resource), color(fallbackColor), isValid(true), hasFallback(true) { ASSERT( resource); } 69 SVGPaintDescription(RenderSVGResourcePaintServer* resource, Color fallbackCo lor) : resource(resource), color(fallbackColor), isValid(true), hasFallback(true ) { ASSERT(resource); }
69 70
70 RenderSVGResource* resource; 71 RenderSVGResourcePaintServer* resource;
71 Color color; 72 Color color;
72 bool isValid; 73 bool isValid;
73 bool hasFallback; 74 bool hasFallback;
74 }; 75 };
75 76
76 class RenderSVGResource { 77 class RenderSVGResourcePaintServer : public RenderSVGResourceContainer {
77 public: 78 public:
78 RenderSVGResource() { } 79 RenderSVGResourcePaintServer(SVGElement*);
79 virtual ~RenderSVGResource() { } 80 virtual ~RenderSVGResourcePaintServer();
80 81
81 virtual SVGPaintServer preparePaintServer(const RenderObject&); 82 virtual SVGPaintServer preparePaintServer(const RenderObject&) = 0;
82 83
83 // Helper utilities used in to access the underlying resources for DRT. 84 // Helper utilities used in to access the underlying resources for DRT.
84 static SVGPaintDescription requestPaintDescription(const RenderObject&, cons t RenderStyle*, RenderSVGResourceMode); 85 static SVGPaintDescription requestPaintDescription(const RenderObject&, cons t RenderStyle*, RenderSVGResourceMode);
85 }; 86 };
86 87
88 DEFINE_TYPE_CASTS(RenderSVGResourcePaintServer, RenderSVGResourceContainer, reso urce, resource->isSVGPaintServer(), resource.isSVGPaintServer());
89
87 } 90 }
88 91
89 #endif 92 #endif
OLDNEW
« no previous file with comments | « Source/core/rendering/svg/RenderSVGResourceGradient.cpp ('k') | Source/core/rendering/svg/RenderSVGResourcePaintServer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698