Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / platform / graphics / filters / Filter.h
1 /*
2  * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
3  * Copyright (C) 2013 Google Inc. 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 #ifndef Filter_h
22 #define Filter_h
23
24 #include "platform/PlatformExport.h"
25 #include "platform/geometry/FloatPoint3D.h"
26 #include "platform/geometry/FloatRect.h"
27 #include "platform/geometry/IntRect.h"
28 #include "wtf/RefCounted.h"
29
30 namespace blink {
31
32 class PLATFORM_EXPORT Filter : public RefCounted<Filter> {
33 public:
34     Filter(float scale)
35     : m_scale(scale) { }
36     virtual ~Filter() { }
37
38     float scale() const { return m_scale; }
39     FloatRect mapLocalRectToAbsoluteRect(const FloatRect& rect) const { FloatRect result(rect); result.scale(m_scale); return result; }
40     FloatRect mapAbsoluteRectToLocalRect(const FloatRect& rect) const { FloatRect result(rect); result.scale(1.0f / m_scale); return result; }
41     virtual float applyHorizontalScale(float value) const { return m_scale * value; }
42     virtual float applyVerticalScale(float value) const { return m_scale * value; }
43
44     virtual FloatPoint3D resolve3dPoint(const FloatPoint3D& point) const { return point; }
45
46     virtual IntRect sourceImageRect() const = 0;
47
48     FloatRect absoluteFilterRegion() const { return m_absoluteFilterRegion; }
49
50     FloatRect filterRegion() const { return m_filterRegion; }
51     void setFilterRegion(const FloatRect& rect)
52     {
53         m_filterRegion = rect;
54         m_absoluteFilterRegion = rect;
55         m_absoluteFilterRegion.scale(m_scale);
56     }
57
58 private:
59     float m_scale;
60     FloatRect m_absoluteFilterRegion;
61     FloatRect m_filterRegion;
62 };
63
64 } // namespace blink
65
66 #endif // Filter_h