#ifndef ShadowBlur_h
#define ShadowBlur_h
#include "Color.h"
#include "ColorSpace.h"
#include "FloatRect.h"
#include "RoundedRect.h"
#include <wtf/Noncopyable.h>
namespace WebCore {
class AffineTransform;
class GraphicsContext;
class ImageBuffer;
class ShadowBlur {
WTF_MAKE_NONCOPYABLE(ShadowBlur);
public:
enum ShadowType {
NoShadow,
SolidShadow,
BlurShadow
};
ShadowBlur(const FloatSize& radius, const FloatSize& offset, const Color&, ColorSpace);
ShadowBlur();
void setShadowValues(const FloatSize&, const FloatSize& , const Color&, ColorSpace, bool ignoreTransforms = false);
void setShadowsIgnoreTransforms(bool ignoreTransforms) { m_shadowsIgnoreTransforms = ignoreTransforms; }
bool shadowsIgnoreTransforms() const { return m_shadowsIgnoreTransforms; }
GraphicsContext* beginShadowLayer(GraphicsContext*, const FloatRect& layerArea);
void endShadowLayer(GraphicsContext*);
void drawRectShadow(GraphicsContext*, const FloatRect&, const RoundedRect::Radii&);
void drawInsetShadow(GraphicsContext*, const FloatRect&, const FloatRect& holeRect, const RoundedRect::Radii& holeRadii);
void blurLayerImage(unsigned char*, const IntSize&, int stride);
void clear();
ShadowType type() const { return m_type; }
#if PLATFORM(QT) || USE(CAIRO)
bool mustUseShadowBlur(GraphicsContext*) const;
#endif
private:
void updateShadowBlurValues();
void drawShadowBuffer(GraphicsContext*);
void adjustBlurRadius(GraphicsContext*);
enum ShadowDirection {
OuterShadow,
InnerShadow
};
IntRect calculateLayerBoundingRect(GraphicsContext*, const FloatRect& layerArea, const IntRect& clipRect);
IntSize templateSize(const IntSize& blurredEdgeSize, const RoundedRect::Radii&) const;
void drawRectShadowWithoutTiling(GraphicsContext*, const FloatRect&, const RoundedRect::Radii&, const IntRect& layerRect);
void drawRectShadowWithTiling(GraphicsContext*, const FloatRect&, const RoundedRect::Radii&, const IntSize& shadowTemplateSize, const IntSize& blurredEdgeSize);
void drawInsetShadowWithoutTiling(GraphicsContext*, const FloatRect&, const FloatRect& holeRect, const RoundedRect::Radii&, const IntRect& layerRect);
void drawInsetShadowWithTiling(GraphicsContext*, const FloatRect&, const FloatRect& holeRect, const RoundedRect::Radii&, const IntSize& shadowTemplateSize, const IntSize& blurredEdgeSize);
void drawLayerPieces(GraphicsContext*, const FloatRect& shadowBounds, const RoundedRect::Radii&, const IntSize& roundedRadius, const IntSize& templateSize, ShadowDirection);
void blurShadowBuffer(const IntSize& templateSize);
void blurAndColorShadowBuffer(const IntSize& templateSize);
IntSize blurredEdgeSize() const;
ShadowType m_type;
Color m_color;
ColorSpace m_colorSpace;
FloatSize m_blurRadius;
FloatSize m_offset;
ImageBuffer* m_layerImage;
FloatRect m_sourceRect; FloatPoint m_layerOrigin; FloatSize m_layerSize; FloatSize m_layerContextTranslation;
bool m_shadowsIgnoreTransforms;
};
}
#endif // ShadowBlur_h