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

Side by Side Diff: third_party/WebKit/Source/core/layout/svg/LayoutSVGResourcePaintServer.h

Issue 2007553002: Retire setGradientSpaceTransform, setPatternSpaceTransform (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fmalita discovers SkMatrix::I() Created 4 years, 6 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
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 LayoutSVGResourcePaintServer_h 20 #ifndef LayoutSVGResourcePaintServer_h
21 #define LayoutSVGResourcePaintServer_h 21 #define LayoutSVGResourcePaintServer_h
22 22
23 #include "core/layout/svg/LayoutSVGResourceContainer.h" 23 #include "core/layout/svg/LayoutSVGResourceContainer.h"
24 #include "platform/graphics/Color.h" 24 #include "platform/graphics/Color.h"
25 #include "platform/graphics/Gradient.h" 25 #include "platform/graphics/Gradient.h"
26 #include "platform/graphics/Pattern.h" 26 #include "platform/graphics/Pattern.h"
27 #include "platform/transforms/AffineTransform.h"
27 #include "wtf/Allocator.h" 28 #include "wtf/Allocator.h"
28 29
29 class SkPaint; 30 class SkPaint;
30 31
31 namespace blink { 32 namespace blink {
32 33
33 enum LayoutSVGResourceMode { 34 enum LayoutSVGResourceMode {
34 ApplyToFillMode, 35 ApplyToFillMode,
35 ApplyToStrokeMode, 36 ApplyToStrokeMode,
36 }; 37 };
37 38
38 class LayoutObject; 39 class LayoutObject;
39 class LayoutSVGResourcePaintServer; 40 class LayoutSVGResourcePaintServer;
40 class ComputedStyle; 41 class ComputedStyle;
41 42
42 class SVGPaintServer { 43 class SVGPaintServer {
43 STACK_ALLOCATED(); 44 STACK_ALLOCATED();
44 public: 45 public:
45 explicit SVGPaintServer(Color); 46 explicit SVGPaintServer(Color);
46 explicit SVGPaintServer(PassRefPtr<Gradient>); 47 SVGPaintServer(PassRefPtr<Gradient>, const AffineTransform&);
47 explicit SVGPaintServer(PassRefPtr<Pattern>); 48 SVGPaintServer(PassRefPtr<Pattern>, const AffineTransform&);
48 49
49 static SVGPaintServer requestForLayoutObject(const LayoutObject&, const Comp utedStyle&, LayoutSVGResourceMode); 50 static SVGPaintServer requestForLayoutObject(const LayoutObject&, const Comp utedStyle&, LayoutSVGResourceMode);
50 static bool existsForLayoutObject(const LayoutObject&, const ComputedStyle&, LayoutSVGResourceMode); 51 static bool existsForLayoutObject(const LayoutObject&, const ComputedStyle&, LayoutSVGResourceMode);
51 52
52 void applyToSkPaint(SkPaint&, float paintAlpha); 53 void applyToSkPaint(SkPaint&, float paintAlpha);
53 54
54 static SVGPaintServer invalid() { return SVGPaintServer(Color(Color::transpa rent)); } 55 static SVGPaintServer invalid() { return SVGPaintServer(Color(Color::transpa rent)); }
55 bool isValid() const { return m_color != Color::transparent; } 56 bool isValid() const { return m_color != Color::transparent; }
56 57
57 bool isTransformDependent() const { return m_gradient || m_pattern; } 58 bool isTransformDependent() const { return m_gradient || m_pattern; }
58 void prependTransform(const AffineTransform&); 59 void prependTransform(const AffineTransform&);
59 60
60 private: 61 private:
61 RefPtr<Gradient> m_gradient; 62 RefPtr<Gradient> m_gradient;
62 RefPtr<Pattern> m_pattern; 63 RefPtr<Pattern> m_pattern;
64 AffineTransform m_transform; // Used for gradient/pattern shaders.
63 Color m_color; 65 Color m_color;
64 }; 66 };
65 67
66 // If |SVGPaintDescription::hasFallback| is true, |SVGPaintDescription::color| i s set to a fallback color. 68 // If |SVGPaintDescription::hasFallback| is true, |SVGPaintDescription::color| i s set to a fallback color.
67 struct SVGPaintDescription { 69 struct SVGPaintDescription {
68 STACK_ALLOCATED(); 70 STACK_ALLOCATED();
69 SVGPaintDescription() : resource(nullptr), isValid(false), hasFallback(false ) { } 71 SVGPaintDescription() : resource(nullptr), isValid(false), hasFallback(false ) { }
70 SVGPaintDescription(Color color) : resource(nullptr), color(color), isValid( true), hasFallback(false) { } 72 SVGPaintDescription(Color color) : resource(nullptr), color(color), isValid( true), hasFallback(false) { }
71 SVGPaintDescription(LayoutSVGResourcePaintServer* resource) : resource(resou rce), isValid(true), hasFallback(false) { ASSERT(resource); } 73 SVGPaintDescription(LayoutSVGResourcePaintServer* resource) : resource(resou rce), isValid(true), hasFallback(false) { ASSERT(resource); }
72 SVGPaintDescription(LayoutSVGResourcePaintServer* resource, Color fallbackCo lor) : resource(resource), color(fallbackColor), isValid(true), hasFallback(true ) { ASSERT(resource); } 74 SVGPaintDescription(LayoutSVGResourcePaintServer* resource, Color fallbackCo lor) : resource(resource), color(fallbackColor), isValid(true), hasFallback(true ) { ASSERT(resource); }
(...skipping 13 matching lines...) Expand all
86 88
87 // Helper utilities used in to access the underlying resources for DRT. 89 // Helper utilities used in to access the underlying resources for DRT.
88 static SVGPaintDescription requestPaintDescription(const LayoutObject&, cons t ComputedStyle&, LayoutSVGResourceMode); 90 static SVGPaintDescription requestPaintDescription(const LayoutObject&, cons t ComputedStyle&, LayoutSVGResourceMode);
89 }; 91 };
90 92
91 DEFINE_TYPE_CASTS(LayoutSVGResourcePaintServer, LayoutSVGResourceContainer, reso urce, resource->isSVGPaintServer(), resource.isSVGPaintServer()); 93 DEFINE_TYPE_CASTS(LayoutSVGResourcePaintServer, LayoutSVGResourceContainer, reso urce, resource->isSVGPaintServer(), resource.isSVGPaintServer());
92 94
93 } // namespace blink 95 } // namespace blink
94 96
95 #endif 97 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698