OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> | 2 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> |
3 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 3 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
4 * Copyright (C) 2013 Google Inc. All rights reserved. | 4 * Copyright (C) 2013 Google Inc. All rights reserved. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
11 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 * Library General Public License for more details. | 14 * Library General Public License for more details. |
15 * | 15 * |
16 * You should have received a copy of the GNU Library General Public License | 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 | 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, | 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 * Boston, MA 02110-1301, USA. | 19 * Boston, MA 02110-1301, USA. |
20 */ | 20 */ |
21 | 21 |
22 #include "config.h" | 22 #include "config.h" |
23 | |
24 #include "core/svg/graphics/filters/SVGFilter.h" | 23 #include "core/svg/graphics/filters/SVGFilter.h" |
25 | 24 |
26 namespace blink { | 25 namespace blink { |
27 | 26 |
28 SVGFilter::SVGFilter(const IntRect& absoluteSourceDrawingRegion, const FloatRect
& targetBoundingBox, const FloatRect& filterRegion, bool effectBBoxMode) | 27 SVGFilter::SVGFilter(const IntRect& absoluteSourceDrawingRegion, const FloatRect
& referenceBox, const FloatRect& filterRegion, bool effectBBoxMode) |
29 : Filter(targetBoundingBox, filterRegion, 1.0f) | 28 : Filter(referenceBox, filterRegion, 1.0f) |
30 , m_absoluteSourceDrawingRegion(absoluteSourceDrawingRegion) | 29 , m_absoluteSourceDrawingRegion(absoluteSourceDrawingRegion) |
31 , m_effectBBoxMode(effectBBoxMode) | 30 , m_effectBBoxMode(effectBBoxMode) |
32 { | 31 { |
33 } | 32 } |
34 | 33 |
35 float SVGFilter::applyHorizontalScale(float value) const | 34 float SVGFilter::applyHorizontalScale(float value) const |
36 { | 35 { |
37 if (m_effectBBoxMode) | 36 if (m_effectBBoxMode) |
38 value *= targetBoundingBox().width(); | 37 value *= referenceBox().width(); |
39 return Filter::applyHorizontalScale(value); | 38 return Filter::applyHorizontalScale(value); |
40 } | 39 } |
41 | 40 |
42 float SVGFilter::applyVerticalScale(float value) const | 41 float SVGFilter::applyVerticalScale(float value) const |
43 { | 42 { |
44 if (m_effectBBoxMode) | 43 if (m_effectBBoxMode) |
45 value *= targetBoundingBox().height(); | 44 value *= referenceBox().height(); |
46 return Filter::applyVerticalScale(value); | 45 return Filter::applyVerticalScale(value); |
47 } | 46 } |
48 | 47 |
49 FloatPoint3D SVGFilter::resolve3dPoint(const FloatPoint3D& point) const | 48 FloatPoint3D SVGFilter::resolve3dPoint(const FloatPoint3D& point) const |
50 { | 49 { |
51 if (!m_effectBBoxMode) | 50 if (!m_effectBBoxMode) |
52 return point; | 51 return point; |
53 return FloatPoint3D(point.x() * targetBoundingBox().width() + targetBounding
Box().x(), | 52 return FloatPoint3D(point.x() * referenceBox().width() + referenceBox().x(), |
54 point.y() * targetBoundingBox().height() + targetBoundingBox().y(), | 53 point.y() * referenceBox().height() + referenceBox().y(), |
55 point.z() * sqrtf(targetBoundingBox().size().diagonalLengthSquared() / 2
)); | 54 point.z() * sqrtf(referenceBox().size().diagonalLengthSquared() / 2)); |
56 } | 55 } |
57 | 56 |
58 PassRefPtrWillBeRawPtr<SVGFilter> SVGFilter::create(const IntRect& absoluteSourc
eDrawingRegion, const FloatRect& targetBoundingBox, const FloatRect& filterRegio
n, bool effectBBoxMode) | 57 PassRefPtrWillBeRawPtr<SVGFilter> SVGFilter::create(const IntRect& absoluteSourc
eDrawingRegion, const FloatRect& referenceBox, const FloatRect& filterRegion, bo
ol effectBBoxMode) |
59 { | 58 { |
60 return adoptRefWillBeNoop(new SVGFilter(absoluteSourceDrawingRegion, targetB
oundingBox, filterRegion, effectBBoxMode)); | 59 return adoptRefWillBeNoop(new SVGFilter(absoluteSourceDrawingRegion, referen
ceBox, filterRegion, effectBBoxMode)); |
61 } | 60 } |
62 | 61 |
63 } // namespace blink | 62 } // namespace blink |
OLD | NEW |