| 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) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
| 14 * | 14 * |
| 15 * You should have received a copy of the GNU Library General Public License | 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 | 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, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
| 19 */ | 19 */ |
| 20 | 20 |
| 21 #ifndef Filter_h | 21 #ifndef Filter_h |
| 22 #define Filter_h | 22 #define Filter_h |
| 23 | 23 |
| 24 #include "platform/PlatformExport.h" | 24 #include "platform/PlatformExport.h" |
| 25 #include "platform/geometry/FloatPoint3D.h" | 25 #include "platform/geometry/FloatPoint3D.h" |
| 26 #include "platform/geometry/FloatRect.h" | 26 #include "platform/geometry/FloatRect.h" |
| 27 #include "platform/geometry/IntRect.h" | 27 #include "platform/geometry/IntRect.h" |
| 28 #include "platform/heap/Handle.h" |
| 28 #include "wtf/RefCounted.h" | 29 #include "wtf/RefCounted.h" |
| 29 | 30 |
| 30 namespace blink { | 31 namespace blink { |
| 31 | 32 |
| 32 class PLATFORM_EXPORT Filter : public RefCounted<Filter> { | 33 class PLATFORM_EXPORT Filter : public RefCountedWillBeGarbageCollectedFinalized<
Filter> { |
| 33 public: | 34 public: |
| 34 Filter(float scale) | |
| 35 : m_scale(scale) { } | |
| 36 virtual ~Filter() { } | 35 virtual ~Filter() { } |
| 36 virtual void trace(Visitor*) { } |
| 37 | 37 |
| 38 float scale() const { return m_scale; } | 38 float scale() const { return m_scale; } |
| 39 FloatRect mapLocalRectToAbsoluteRect(const FloatRect& rect) const { FloatRec
t result(rect); result.scale(m_scale); return result; } | 39 FloatRect mapLocalRectToAbsoluteRect(const FloatRect& rect) const { FloatRec
t result(rect); result.scale(m_scale); return result; } |
| 40 FloatRect mapAbsoluteRectToLocalRect(const FloatRect& rect) const { FloatRec
t result(rect); result.scale(1.0f / m_scale); return result; } | 40 FloatRect mapAbsoluteRectToLocalRect(const FloatRect& rect) const { FloatRec
t result(rect); result.scale(1.0f / m_scale); return result; } |
| 41 virtual float applyHorizontalScale(float value) const { return m_scale * val
ue; } | 41 virtual float applyHorizontalScale(float value) const { return m_scale * val
ue; } |
| 42 virtual float applyVerticalScale(float value) const { return m_scale * value
; } | 42 virtual float applyVerticalScale(float value) const { return m_scale * value
; } |
| 43 | 43 |
| 44 virtual FloatPoint3D resolve3dPoint(const FloatPoint3D& point) const { retur
n point; } | 44 virtual FloatPoint3D resolve3dPoint(const FloatPoint3D& point) const { retur
n point; } |
| 45 | 45 |
| 46 virtual IntRect sourceImageRect() const = 0; | 46 virtual IntRect sourceImageRect() const = 0; |
| 47 | 47 |
| 48 FloatRect absoluteFilterRegion() const { return m_absoluteFilterRegion; } | 48 FloatRect absoluteFilterRegion() const { return m_absoluteFilterRegion; } |
| 49 | 49 |
| 50 FloatRect filterRegion() const { return m_filterRegion; } | 50 FloatRect filterRegion() const { return m_filterRegion; } |
| 51 void setFilterRegion(const FloatRect& rect) | 51 void setFilterRegion(const FloatRect& rect) |
| 52 { | 52 { |
| 53 m_filterRegion = rect; | 53 m_filterRegion = rect; |
| 54 m_absoluteFilterRegion = rect; | 54 m_absoluteFilterRegion = rect; |
| 55 m_absoluteFilterRegion.scale(m_scale); | 55 m_absoluteFilterRegion.scale(m_scale); |
| 56 } | 56 } |
| 57 | 57 |
| 58 protected: |
| 59 explicit Filter(float scale) |
| 60 : m_scale(scale) |
| 61 { |
| 62 } |
| 63 |
| 58 private: | 64 private: |
| 59 float m_scale; | 65 float m_scale; |
| 60 FloatRect m_absoluteFilterRegion; | 66 FloatRect m_absoluteFilterRegion; |
| 61 FloatRect m_filterRegion; | 67 FloatRect m_filterRegion; |
| 62 }; | 68 }; |
| 63 | 69 |
| 64 } // namespace blink | 70 } // namespace blink |
| 65 | 71 |
| 66 #endif // Filter_h | 72 #endif // Filter_h |
| OLD | NEW |