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#if ENABLE(FILTERS) 25#include "FloatRect.h" 26#include "FloatSize.h" 27#include "ImageBuffer.h" 28#include <wtf/RefCounted.h> 29 30namespace WebCore { 31 32class FilterEffect; 33 34class Filter : public RefCounted<Filter> { 35public: 36 Filter(const AffineTransform& absoluteTransform) 37 : m_absoluteTransform(absoluteTransform) 38 , m_renderingMode(Unaccelerated) 39 { } 40 virtual ~Filter() { } 41 42 void setSourceImage(PassOwnPtr<ImageBuffer> sourceImage) { m_sourceImage = sourceImage; } 43 ImageBuffer* sourceImage() { return m_sourceImage.get(); } 44 45 FloatSize filterResolution() const { return m_filterResolution; } 46 void setFilterResolution(const FloatSize& filterResolution) { m_filterResolution = filterResolution; } 47 48 const AffineTransform& absoluteTransform() const { return m_absoluteTransform; } 49 FloatPoint mapAbsolutePointToLocalPoint(const FloatPoint& point) const { return m_absoluteTransform.inverse().mapPoint(point); } 50 51 RenderingMode renderingMode() const { return m_renderingMode; } 52 void setRenderingMode(RenderingMode renderingMode) { m_renderingMode = renderingMode; } 53 54 virtual float applyHorizontalScale(float value) const { return value * m_filterResolution.width(); } 55 virtual float applyVerticalScale(float value) const { return value * m_filterResolution.height(); } 56 57 virtual FloatRect sourceImageRect() const = 0; 58 virtual FloatRect filterRegion() const = 0; 59 60private: 61 OwnPtr<ImageBuffer> m_sourceImage; 62 FloatSize m_filterResolution; 63 AffineTransform m_absoluteTransform; 64 RenderingMode m_renderingMode; 65}; 66 67} // namespace WebCore 68 69#endif // ENABLE(FILTERS) 70 71#endif // Filter_h 72