| 1 | /* |
| 2 | * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> |
| 3 | * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 4 | * |
| 5 | * This library is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU Library General Public |
| 7 | * License as published by the Free Software Foundation; either |
| 8 | * version 2 of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This library is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * Library General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU Library General Public License |
| 16 | * along with this library; see the file COPYING.LIB. If not, write to |
| 17 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 | * Boston, MA 02110-1301, USA. |
| 19 | */ |
| 20 | |
| 21 | #pragma once |
| 22 | |
| 23 | #include "RadialGradientAttributes.h" |
| 24 | #include "RenderSVGResourceGradient.h" |
| 25 | #include "SVGRadialGradientElement.h" |
| 26 | |
| 27 | namespace WebCore { |
| 28 | |
| 29 | class SVGRadialGradientElement; |
| 30 | |
| 31 | class RenderSVGResourceRadialGradient final : public RenderSVGResourceGradient { |
| 32 | WTF_MAKE_ISO_ALLOCATED(RenderSVGResourceRadialGradient); |
| 33 | public: |
| 34 | RenderSVGResourceRadialGradient(SVGRadialGradientElement&, RenderStyle&&); |
| 35 | virtual ~RenderSVGResourceRadialGradient(); |
| 36 | |
| 37 | SVGRadialGradientElement& radialGradientElement() const { return downcast<SVGRadialGradientElement>(RenderSVGResourceGradient::gradientElement()); } |
| 38 | |
| 39 | RenderSVGResourceType resourceType() const override { return RadialGradientResourceType; } |
| 40 | |
| 41 | SVGUnitTypes::SVGUnitType gradientUnits() const override { return m_attributes.gradientUnits(); } |
| 42 | void calculateGradientTransform(AffineTransform& transform) override { transform = m_attributes.gradientTransform(); } |
| 43 | void buildGradient(GradientData*, const RenderStyle&) const override; |
| 44 | |
| 45 | FloatPoint centerPoint(const RadialGradientAttributes&) const; |
| 46 | FloatPoint focalPoint(const RadialGradientAttributes&) const; |
| 47 | float radius(const RadialGradientAttributes&) const; |
| 48 | float focalRadius(const RadialGradientAttributes&) const; |
| 49 | |
| 50 | private: |
| 51 | void gradientElement() const = delete; |
| 52 | |
| 53 | const char* renderName() const override { return "RenderSVGResourceRadialGradient" ; } |
| 54 | bool collectGradientAttributes() override; |
| 55 | |
| 56 | RadialGradientAttributes m_attributes; |
| 57 | }; |
| 58 | |
| 59 | } // namespace WebCore |
| 60 | |
| 61 | SPECIALIZE_TYPE_TRAITS_RENDER_SVG_RESOURCE(RenderSVGResourceRadialGradient, RadialGradientResourceType) |
| 62 | |