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#ifndef GradientAttributes_h 21#define GradientAttributes_h 22 23#include "SVGGradientElement.h" 24#include "SVGUnitTypes.h" 25 26namespace WebCore { 27 28struct GradientAttributes { 29 GradientAttributes() 30 : m_spreadMethod(SVGSpreadMethodPad) 31 , m_gradientUnits(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) 32 , m_spreadMethodSet(false) 33 , m_gradientUnitsSet(false) 34 , m_gradientTransformSet(false) 35 , m_stopsSet(false) 36 { 37 } 38 39 SVGSpreadMethodType spreadMethod() const { return static_cast<SVGSpreadMethodType>(m_spreadMethod); } 40 SVGUnitTypes::SVGUnitType gradientUnits() const { return static_cast<SVGUnitTypes::SVGUnitType>(m_gradientUnits); } 41 AffineTransform gradientTransform() const { return m_gradientTransform; } 42 const Vector<Gradient::ColorStop>& stops() const { return m_stops; } 43 44 void setSpreadMethod(SVGSpreadMethodType value) 45 { 46 m_spreadMethod = value; 47 m_spreadMethodSet = true; 48 } 49 50 void setGradientUnits(SVGUnitTypes::SVGUnitType unitType) 51 { 52 m_gradientUnits = unitType; 53 m_gradientUnitsSet = true; 54 } 55 56 void setGradientTransform(const AffineTransform& value) 57 { 58 m_gradientTransform = value; 59 m_gradientTransformSet = true; 60 } 61 62 void setStops(const Vector<Gradient::ColorStop>& value) 63 { 64 m_stops = value; 65 m_stopsSet = true; 66 } 67 68 bool hasSpreadMethod() const { return m_spreadMethodSet; } 69 bool hasGradientUnits() const { return m_gradientUnitsSet; } 70 bool hasGradientTransform() const { return m_gradientTransformSet; } 71 bool hasStops() const { return m_stopsSet; } 72 73private: 74 // Properties 75 AffineTransform m_gradientTransform; 76 Vector<Gradient::ColorStop> m_stops; 77 78 unsigned m_spreadMethod : 2; 79 unsigned m_gradientUnits : 2; 80 81 // Property states 82 unsigned m_spreadMethodSet : 1; 83 unsigned m_gradientUnitsSet : 1; 84 unsigned m_gradientTransformSet : 1; 85 unsigned m_stopsSet : 1; 86}; 87 88struct SameSizeAsGradientAttributes { 89 AffineTransform a; 90 Vector<Gradient::ColorStop> b; 91 unsigned c : 8; 92}; 93 94COMPILE_ASSERT(sizeof(GradientAttributes) == sizeof(SameSizeAsGradientAttributes), GradientAttributes_size_guard); 95 96} // namespace WebCore 97 98#endif 99