#ifndef SVGRenderingContext_h
#define SVGRenderingContext_h
#include "core/rendering/PaintInfo.h"
#include "core/rendering/svg/RenderSVGResourceClipper.h"
#include "platform/graphics/ImageBuffer.h"
namespace WebCore {
class AffineTransform;
class RenderObject;
class FloatRect;
class RenderSVGResourceFilter;
class RenderSVGResourceMasker;
class SVGRenderingContext {
public:
enum NeedsGraphicsContextSave {
SaveGraphicsContext,
DontSaveGraphicsContext,
};
SVGRenderingContext()
: m_renderingFlags(0)
, m_object(0)
, m_paintInfo(0)
, m_savedContext(0)
, m_filter(0)
, m_clipper(0)
, m_masker(0)
{
}
SVGRenderingContext(RenderObject* object, PaintInfo& paintinfo, NeedsGraphicsContextSave needsGraphicsContextSave = DontSaveGraphicsContext)
: m_renderingFlags(0)
, m_object(0)
, m_paintInfo(0)
, m_savedContext(0)
, m_filter(0)
, m_clipper(0)
, m_masker(0)
{
prepareToRenderSVGContent(object, paintinfo, needsGraphicsContextSave);
}
~SVGRenderingContext();
void prepareToRenderSVGContent(RenderObject*, PaintInfo&, NeedsGraphicsContextSave = DontSaveGraphicsContext);
bool isRenderingPrepared() const { return m_renderingFlags & RenderingPrepared; }
static void renderSubtree(GraphicsContext*, RenderObject*, const AffineTransform&);
static float calculateScreenFontSizeScalingFactor(const RenderObject*);
static void calculateDeviceSpaceTransformation(const RenderObject*, AffineTransform& absoluteTransform);
static FloatRect clampedAbsoluteTargetRect(const FloatRect& absoluteTargetRect);
static void clear2DRotation(AffineTransform&);
static IntRect calculateImageBufferRect(const FloatRect& targetRect, const AffineTransform& absoluteTransform)
{
return enclosingIntRect(absoluteTransform.mapRect(targetRect));
}
bool bufferForeground(OwnPtr<ImageBuffer>&);
private:
enum RenderingFlags {
RenderingPrepared = 1,
RestoreGraphicsContext = 1 << 1,
EndOpacityLayer = 1 << 2,
PostApplyResources = 1 << 3,
PrepareToRenderSVGContentWasCalled = 1 << 4
};
const static int ActionsNeeded = RestoreGraphicsContext | EndOpacityLayer | PostApplyResources;
int m_renderingFlags;
RenderObject* m_object;
PaintInfo* m_paintInfo;
GraphicsContext* m_savedContext;
IntRect m_savedPaintRect;
RenderSVGResourceFilter* m_filter;
RenderSVGResourceClipper* m_clipper;
ClipperContext m_clipperContext;
RenderSVGResourceMasker* m_masker;
};
}
#endif