|
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 |
|
22 #include "config.h" |
|
23 |
|
24 #if ENABLE(SVG) |
|
25 #include "RenderSVGResourceRadialGradient.h" |
|
26 |
|
27 #include "RadialGradientAttributes.h" |
|
28 #include "SVGRadialGradientElement.h" |
|
29 |
|
30 namespace WebCore { |
|
31 |
|
32 RenderSVGResourceType RenderSVGResourceRadialGradient::s_resourceType = RadialGradientResourceType; |
|
33 |
|
34 RenderSVGResourceRadialGradient::RenderSVGResourceRadialGradient(SVGRadialGradientElement* node) |
|
35 : RenderSVGResourceGradient(node) |
|
36 { |
|
37 } |
|
38 |
|
39 RenderSVGResourceRadialGradient::~RenderSVGResourceRadialGradient() |
|
40 { |
|
41 } |
|
42 |
|
43 void RenderSVGResourceRadialGradient::buildGradient(GradientData* gradientData, SVGGradientElement* gradientElement) const |
|
44 { |
|
45 SVGRadialGradientElement* radialGradientElement = static_cast<SVGRadialGradientElement*>(gradientElement); |
|
46 RadialGradientAttributes attributes = radialGradientElement->collectGradientProperties(); |
|
47 |
|
48 // Determine gradient focal/center points and radius |
|
49 FloatPoint focalPoint; |
|
50 FloatPoint centerPoint; |
|
51 float radius; |
|
52 radialGradientElement->calculateFocalCenterPointsAndRadius(attributes, focalPoint, centerPoint, radius); |
|
53 |
|
54 gradientData->gradient = Gradient::create(focalPoint, |
|
55 0.0f, // SVG does not support a "focus radius" |
|
56 centerPoint, |
|
57 radius); |
|
58 |
|
59 gradientData->gradient->setSpreadMethod(attributes.spreadMethod()); |
|
60 |
|
61 // Record current gradient transform |
|
62 gradientData->transform = attributes.gradientTransform(); |
|
63 gradientData->boundingBoxMode = attributes.boundingBoxMode(); |
|
64 |
|
65 // Add stops |
|
66 addStops(gradientData, attributes.stops()); |
|
67 } |
|
68 |
|
69 } |
|
70 |
|
71 #endif |