DisplayListRecorder.h [plain text]
#ifndef DisplayListRecorder_h
#define DisplayListRecorder_h
#include "DisplayList.h"
#include "GraphicsContext.h" // For InterpolationQuality.
#include "Image.h" // For Image::TileRule.
#include "TextFlags.h"
#include <wtf/Noncopyable.h>
namespace WebCore {
class FloatPoint;
class FloatRect;
class GlyphBuffer;
class FloatPoint;
class Font;
class Image;
struct GraphicsContextState;
struct ImagePaintingOptions;
namespace DisplayList {
class DrawingItem;
class Recorder {
WTF_MAKE_NONCOPYABLE(Recorder);
public:
Recorder(GraphicsContext&, DisplayList&, const FloatRect& initialClip, const AffineTransform&);
~Recorder();
void updateState(const GraphicsContextState&, GraphicsContextState::StateChangeFlags);
void clearShadow();
void setLineCap(LineCap);
void setLineDash(const DashArray&, float dashOffset);
void setLineJoin(LineJoin);
void setMiterLimit(float);
void fillRect(const FloatRect&);
void fillRect(const FloatRect&, const Color&);
void fillRect(const FloatRect&, Gradient&);
void fillRect(const FloatRect&, const Color&, CompositeOperator, BlendMode);
void fillRoundedRect(const FloatRoundedRect&, const Color&, BlendMode);
void fillRectWithRoundedHole(const FloatRect&, const FloatRoundedRect& roundedHoleRect, const Color&);
void fillPath(const Path&);
void fillEllipse(const FloatRect&);
void strokeRect(const FloatRect&, float lineWidth);
void strokePath(const Path&);
void strokeEllipse(const FloatRect&);
void clearRect(const FloatRect&);
#if USE(CG)
void applyStrokePattern();
void applyFillPattern();
#endif
void drawGlyphs(const Font&, const GlyphBuffer&, int from, int numGlyphs, const FloatPoint& anchorPoint, FontSmoothingMode);
void drawImage(Image&, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions&);
void drawTiledImage(Image&, const FloatRect& destination, const FloatPoint& source, const FloatSize& tileSize, const FloatSize& spacing, const ImagePaintingOptions&);
void drawTiledImage(Image&, const FloatRect& destination, const FloatRect& source, const FloatSize& tileScaleFactor, Image::TileRule hRule, Image::TileRule vRule, const ImagePaintingOptions&);
#if USE(CG) || USE(CAIRO)
void drawNativeImage(const NativeImagePtr&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator, BlendMode, ImageOrientation);
#endif
void drawPattern(Image&, const FloatRect& srcRect, const AffineTransform&, const FloatPoint& phase, const FloatSize& spacing, CompositeOperator, const FloatRect& destRect, BlendMode = BlendModeNormal);
void drawRect(const FloatRect&, float borderThickness);
void drawLine(const FloatPoint&, const FloatPoint&);
void drawLinesForText(const FloatPoint&, const DashArray& widths, bool printing, bool doubleLines, float strokeThickness);
void drawLineForDocumentMarker(const FloatPoint&, float width, GraphicsContext::DocumentMarkerLineStyle);
void drawEllipse(const FloatRect&);
void drawPath(const Path&);
void drawFocusRing(const Path&, int width, int offset, const Color&);
void drawFocusRing(const Vector<FloatRect>&, int width, int offset, const Color&);
void save();
void restore();
void translate(float x, float y);
void rotate(float angleInRadians);
void scale(const FloatSize&);
void concatCTM(const AffineTransform&);
void beginTransparencyLayer(float opacity);
void endTransparencyLayer();
void clip(const FloatRect&);
void clipOut(const FloatRect&);
void clipOut(const Path&);
void clipPath(const Path&, WindRule);
void applyDeviceScaleFactor(float);
size_t itemCount() const { return m_displayList.itemCount(); }
private:
Item& appendItem(Ref<Item>&&);
void willAppendItem(const Item&);
FloatRect extentFromLocalBounds(const FloatRect&) const;
void updateItemExtent(DrawingItem&) const;
const AffineTransform& ctm() const;
const FloatRect& clipBounds() const;
struct ContextState {
AffineTransform ctm;
FloatRect clipBounds;
GraphicsContextStateChange stateChange;
GraphicsContextState lastDrawingState;
bool wasUsedForDrawing { false };
size_t saveItemIndex { 0 };
ContextState(const AffineTransform& transform, const FloatRect& clip)
: ctm(transform)
, clipBounds(clip)
{
}
ContextState cloneForSave(size_t saveIndex) const
{
ContextState state(ctm, clipBounds);
state.stateChange = stateChange;
state.lastDrawingState = lastDrawingState;
state.saveItemIndex = saveIndex;
return state;
}
void translate(float x, float y);
void rotate(float angleInRadians);
void scale(const FloatSize&);
void concatCTM(const AffineTransform&);
};
const ContextState& currentState() const;
ContextState& currentState();
GraphicsContext& m_graphicsContext;
DisplayList& m_displayList;
Vector<ContextState, 32> m_stateStack;
};
}
}
#endif // DisplayListRecorder_h