1 | /* |
2 | * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> |
3 | * |
4 | * This library is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU Library General Public |
6 | * License as published by the Free Software Foundation; either |
7 | * version 2 of the License, or (at your option) any later version. |
8 | * |
9 | * This library is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | * Library General Public License for more details. |
13 | * |
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 |
16 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 | * Boston, MA 02110-1301, USA. |
18 | */ |
19 | |
20 | #pragma once |
21 | |
22 | #include "SVGGradientElement.h" |
23 | #include "SVGUnitTypes.h" |
24 | |
25 | namespace WebCore { |
26 | |
27 | struct GradientAttributes { |
28 | GradientAttributes() |
29 | : m_spreadMethod(SVGSpreadMethodPad) |
30 | , m_gradientUnits(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) |
31 | , m_spreadMethodSet(false) |
32 | , m_gradientUnitsSet(false) |
33 | , m_gradientTransformSet(false) |
34 | , m_stopsSet(false) |
35 | { |
36 | } |
37 | |
38 | SVGSpreadMethodType spreadMethod() const { return static_cast<SVGSpreadMethodType>(m_spreadMethod); } |
39 | SVGUnitTypes::SVGUnitType gradientUnits() const { return static_cast<SVGUnitTypes::SVGUnitType>(m_gradientUnits); } |
40 | AffineTransform gradientTransform() const { return m_gradientTransform; } |
41 | const Vector<Gradient::ColorStop>& stops() const { return m_stops; } |
42 | |
43 | void setSpreadMethod(SVGSpreadMethodType value) |
44 | { |
45 | m_spreadMethod = value; |
46 | m_spreadMethodSet = true; |
47 | } |
48 | |
49 | void setGradientUnits(SVGUnitTypes::SVGUnitType unitType) |
50 | { |
51 | m_gradientUnits = unitType; |
52 | m_gradientUnitsSet = true; |
53 | } |
54 | |
55 | void setGradientTransform(const AffineTransform& value) |
56 | { |
57 | m_gradientTransform = value; |
58 | m_gradientTransformSet = true; |
59 | } |
60 | |
61 | void setStops(const Vector<Gradient::ColorStop>& value) |
62 | { |
63 | m_stops = value; |
64 | m_stopsSet = true; |
65 | } |
66 | |
67 | bool hasSpreadMethod() const { return m_spreadMethodSet; } |
68 | bool hasGradientUnits() const { return m_gradientUnitsSet; } |
69 | bool hasGradientTransform() const { return m_gradientTransformSet; } |
70 | bool hasStops() const { return m_stopsSet; } |
71 | |
72 | private: |
73 | // Properties |
74 | AffineTransform m_gradientTransform; |
75 | Vector<Gradient::ColorStop> m_stops; |
76 | |
77 | unsigned m_spreadMethod : 2; |
78 | unsigned m_gradientUnits : 2; |
79 | |
80 | // Property states |
81 | unsigned m_spreadMethodSet : 1; |
82 | unsigned m_gradientUnitsSet : 1; |
83 | unsigned m_gradientTransformSet : 1; |
84 | unsigned m_stopsSet : 1; |
85 | }; |
86 | |
87 | struct SameSizeAsGradientAttributes { |
88 | AffineTransform a; |
89 | Vector<Gradient::ColorStop> b; |
90 | unsigned c : 8; |
91 | }; |
92 | |
93 | COMPILE_ASSERT(sizeof(GradientAttributes) == sizeof(SameSizeAsGradientAttributes), GradientAttributes_size_guard); |
94 | |
95 | } // namespace WebCore |
96 | |