#ifndef SkiaImageFilterBuilder_h
#define SkiaImageFilterBuilder_h
#include "platform/PlatformExport.h"
#include "platform/geometry/FloatSize.h"
#include "platform/graphics/ColorSpace.h"
#include "public/platform/WebFilterOperations.h"
#include "wtf/HashMap.h"
class SkImageFilter;
namespace WebCore {
class AffineTransform;
class FilterEffect;
class FilterOperations;
class GraphicsContext;
class PLATFORM_EXPORT SkiaImageFilterBuilder {
public:
SkiaImageFilterBuilder();
explicit SkiaImageFilterBuilder(GraphicsContext*);
~SkiaImageFilterBuilder();
PassRefPtr<SkImageFilter> build(FilterEffect*, ColorSpace);
bool buildFilterOperations(const FilterOperations&, blink::WebFilterOperations*);
PassRefPtr<SkImageFilter> buildTransform(const AffineTransform&, SkImageFilter* input);
PassRefPtr<SkImageFilter> transformColorSpace(
SkImageFilter* input, ColorSpace srcColorSpace, ColorSpace dstColorSpace);
void setCropOffset(const FloatSize& cropOffset) { m_cropOffset = cropOffset; };
FloatSize cropOffset() { return m_cropOffset; }
GraphicsContext* context() { return m_context; }
private:
typedef std::pair<FilterEffect*, ColorSpace> FilterColorSpacePair;
typedef HashMap<FilterColorSpacePair, RefPtr<SkImageFilter> > FilterBuilderHashMap;
FilterBuilderHashMap m_map;
FloatSize m_cropOffset;
GraphicsContext* m_context;
};
}
namespace WTF {
template<> struct DefaultHash<WebCore::ColorSpace> {
typedef IntHash<unsigned> Hash;
};
}
#endif