2 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
3 * Copyright (C) 2013 Google Inc. All rights reserved.
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.
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.
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.
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"
32 class PLATFORM_EXPORT Filter : public RefCounted<Filter> {
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; }
44 virtual FloatPoint3D resolve3dPoint(const FloatPoint3D& point) const { return point; }
46 virtual IntRect sourceImageRect() const = 0;
48 FloatRect absoluteFilterRegion() const { return m_absoluteFilterRegion; }
50 FloatRect filterRegion() const { return m_filterRegion; }
51 void setFilterRegion(const FloatRect& rect)
53 m_filterRegion = rect;
54 m_absoluteFilterRegion = rect;
55 m_absoluteFilterRegion.scale(m_scale);
60 FloatRect m_absoluteFilterRegion;
61 FloatRect m_filterRegion;