RenderSVGResourceGradient.h [plain text]
#ifndef RenderSVGResourceGradient_h
#define RenderSVGResourceGradient_h
#if ENABLE(SVG)
#include "AffineTransform.h"
#include "FloatRect.h"
#include "Gradient.h"
#include "ImageBuffer.h"
#include "RenderSVGResourceContainer.h"
#include "SVGGradientElement.h"
#include <wtf/HashMap.h>
namespace WebCore {
struct GradientData {
RefPtr<Gradient> gradient;
AffineTransform userspaceTransform;
};
class GraphicsContext;
class RenderSVGResourceGradient : public RenderSVGResourceContainer {
public:
RenderSVGResourceGradient(SVGGradientElement*);
virtual void removeAllClientsFromCache(bool markForInvalidation = true);
virtual void removeClientFromCache(RenderObject*, bool markForInvalidation = true);
virtual bool applyResource(RenderObject*, RenderStyle*, GraphicsContext*&, unsigned short resourceMode);
virtual void postApplyResource(RenderObject*, GraphicsContext*&, unsigned short resourceMode, const Path*, const RenderSVGShape*);
virtual FloatRect resourceBoundingBox(RenderObject*) { return FloatRect(); }
protected:
void addStops(GradientData*, const Vector<Gradient::ColorStop>&) const;
virtual SVGUnitTypes::SVGUnitType gradientUnits() const = 0;
virtual void calculateGradientTransform(AffineTransform&) = 0;
virtual bool collectGradientAttributes(SVGGradientElement*) = 0;
virtual void buildGradient(GradientData*) const = 0;
GradientSpreadMethod platformSpreadMethodFromSVGType(SVGSpreadMethodType) const;
private:
bool m_shouldCollectGradientAttributes : 1;
HashMap<RenderObject*, OwnPtr<GradientData> > m_gradientMap;
#if USE(CG)
GraphicsContext* m_savedContext;
OwnPtr<ImageBuffer> m_imageBuffer;
#endif
};
}
#endif
#endif