Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / rendering / svg / RenderSVGResourceRadialGradient.cpp
1 /*
2  * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
3  * Copyright (C) Research In Motion Limited 2010. All rights reserved.
4  * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public License
17  * along with this library; see the file COPYING.LIB.  If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21
22 #include "config.h"
23
24 #include "core/rendering/svg/RenderSVGResourceRadialGradient.h"
25
26 #include "core/svg/SVGRadialGradientElement.h"
27
28 namespace blink {
29
30 RenderSVGResourceRadialGradient::RenderSVGResourceRadialGradient(SVGRadialGradientElement* node)
31     : RenderSVGResourceGradient(node)
32 {
33 }
34
35 RenderSVGResourceRadialGradient::~RenderSVGResourceRadialGradient()
36 {
37 }
38
39 bool RenderSVGResourceRadialGradient::collectGradientAttributes(SVGGradientElement* gradientElement)
40 {
41     m_attributes = RadialGradientAttributes();
42     return toSVGRadialGradientElement(gradientElement)->collectGradientAttributes(m_attributes);
43 }
44
45 FloatPoint RenderSVGResourceRadialGradient::centerPoint(const RadialGradientAttributes& attributes) const
46 {
47     return SVGLengthContext::resolvePoint(element(), attributes.gradientUnits(), attributes.cx(), attributes.cy());
48 }
49
50 FloatPoint RenderSVGResourceRadialGradient::focalPoint(const RadialGradientAttributes& attributes) const
51 {
52     return SVGLengthContext::resolvePoint(element(), attributes.gradientUnits(), attributes.fx(), attributes.fy());
53 }
54
55 float RenderSVGResourceRadialGradient::radius(const RadialGradientAttributes& attributes) const
56 {
57     return SVGLengthContext::resolveLength(element(), attributes.gradientUnits(), attributes.r());
58 }
59
60 float RenderSVGResourceRadialGradient::focalRadius(const RadialGradientAttributes& attributes) const
61 {
62     return SVGLengthContext::resolveLength(element(), attributes.gradientUnits(), attributes.fr());
63 }
64
65 void RenderSVGResourceRadialGradient::buildGradient(GradientData* gradientData) const
66 {
67     gradientData->gradient = Gradient::create(this->focalPoint(m_attributes),
68         this->focalRadius(m_attributes),
69         this->centerPoint(m_attributes),
70         this->radius(m_attributes));
71
72     gradientData->gradient->setSpreadMethod(platformSpreadMethodFromSVGType(m_attributes.spreadMethod()));
73
74     addStops(gradientData, m_attributes.stops());
75 }
76
77 }