SVGRenderingContext.h [plain text]
#ifndef SVGRenderingContext_h
#define SVGRenderingContext_h
#if ENABLE(SVG)
#include "ImageBuffer.h"
#include "LayoutTypes.h"
#include "PaintInfo.h"
namespace WebCore {
class AffineTransform;
class RenderObject;
class FloatRect;
class RenderSVGResourceFilter;
class SVGRenderingContext {
public:
enum NeedsGraphicsContextSave {
SaveGraphicsContext,
DontSaveGraphicsContext,
};
SVGRenderingContext()
: m_renderingFlags(0)
, m_object(0)
, m_paintInfo(0)
, m_savedContext(0)
#if ENABLE(FILTERS)
, m_filter(0)
#endif
{
}
SVGRenderingContext(RenderObject* object, PaintInfo& paintinfo, NeedsGraphicsContextSave needsGraphicsContextSave = DontSaveGraphicsContext)
: m_renderingFlags(0)
, m_object(0)
, m_paintInfo(0)
, m_savedContext(0)
#if ENABLE(FILTERS)
, m_filter(0)
#endif
{
prepareToRenderSVGContent(object, paintinfo, needsGraphicsContextSave);
}
~SVGRenderingContext();
void prepareToRenderSVGContent(RenderObject*, PaintInfo&, NeedsGraphicsContextSave = DontSaveGraphicsContext);
bool isRenderingPrepared() const { return m_renderingFlags & RenderingPrepared; }
static bool createImageBuffer(const FloatRect& paintRect, const AffineTransform& absoluteTransform, OwnPtr<ImageBuffer>&, ColorSpace, RenderingMode);
static bool createImageBufferForPattern(const FloatRect& absoluteTargetRect, const FloatRect& clampedAbsoluteTargetRect, OwnPtr<ImageBuffer>&, ColorSpace, RenderingMode);
static void renderSubtreeToImageBuffer(ImageBuffer*, RenderObject*, const AffineTransform&);
static void clipToImageBuffer(GraphicsContext*, const AffineTransform& absoluteTransform, const FloatRect& targetRect, OwnPtr<ImageBuffer>&, bool safeToClear);
static void calculateTransformationToOutermostSVGCoordinateSystem(const RenderObject*, AffineTransform& absoluteTransform);
static IntSize clampedAbsoluteSize(const IntSize&);
static FloatRect clampedAbsoluteTargetRect(const FloatRect& absoluteTargetRect);
static void clear2DRotation(AffineTransform&);
static IntRect calculateImageBufferRect(const FloatRect& targetRect, const AffineTransform& absoluteTransform)
{
return enclosingIntRect(absoluteTransform.mapRect(targetRect));
}
private:
enum RenderingFlags {
RenderingPrepared = 1,
RestoreGraphicsContext = 1 << 1,
EndOpacityLayer = 1 << 2,
EndShadowLayer = 1 << 3,
EndFilterLayer = 1 << 4,
PrepareToRenderSVGContentWasCalled = 1 << 5
};
const static int ActionsNeeded = RestoreGraphicsContext | EndOpacityLayer | EndShadowLayer | EndFilterLayer;
int m_renderingFlags;
RenderObject* m_object;
PaintInfo* m_paintInfo;
GraphicsContext* m_savedContext;
#if ENABLE(FILTERS)
RenderSVGResourceFilter* m_filter;
#endif
};
}
#endif // ENABLE(SVG)
#endif // SVGRenderingContext_h