2 * Copyright 2014 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef SkRecorder_DEFINED
9 #define SkRecorder_DEFINED
13 #include "SkRecords.h"
14 #include "SkTDArray.h"
16 // SkRecorder provides an SkCanvas interface for recording into an SkRecord.
18 class SkRecorder : public SkCanvas {
20 // Does not take ownership of the SkRecord.
21 SkRecorder(SkRecord*, int width, int height);
23 // Make SkRecorder forget entirely about its SkRecord*; all calls to SkRecorder will fail.
26 void clear(SkColor) SK_OVERRIDE;
27 void drawPaint(const SkPaint& paint) SK_OVERRIDE;
28 void drawPoints(PointMode mode,
31 const SkPaint& paint) SK_OVERRIDE;
32 void drawRect(const SkRect& rect, const SkPaint& paint) SK_OVERRIDE;
33 void drawOval(const SkRect& oval, const SkPaint&) SK_OVERRIDE;
34 void drawRRect(const SkRRect& rrect, const SkPaint& paint) SK_OVERRIDE;
35 void drawPath(const SkPath& path, const SkPaint& paint) SK_OVERRIDE;
36 void drawBitmap(const SkBitmap& bitmap,
39 const SkPaint* paint = NULL) SK_OVERRIDE;
40 void drawBitmapRectToRect(const SkBitmap& bitmap,
43 const SkPaint* paint = NULL,
44 DrawBitmapRectFlags flags = kNone_DrawBitmapRectFlag) SK_OVERRIDE;
45 void drawBitmapMatrix(const SkBitmap& bitmap,
47 const SkPaint* paint = NULL) SK_OVERRIDE;
48 void drawBitmapNine(const SkBitmap& bitmap,
49 const SkIRect& center,
51 const SkPaint* paint = NULL) SK_OVERRIDE;
52 void drawSprite(const SkBitmap& bitmap,
55 const SkPaint* paint = NULL) SK_OVERRIDE;
56 void drawVertices(VertexMode vmode,
58 const SkPoint vertices[],
60 const SkColor colors[],
62 const uint16_t indices[],
64 const SkPaint& paint) SK_OVERRIDE;
66 void willSave() SK_OVERRIDE;
67 SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SkCanvas::SaveFlags) SK_OVERRIDE;
68 void willRestore() SK_OVERRIDE {}
69 void didRestore() SK_OVERRIDE;
71 void didConcat(const SkMatrix&) SK_OVERRIDE;
72 void didSetMatrix(const SkMatrix&) SK_OVERRIDE;
74 void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK_OVERRIDE;
75 void onDrawText(const void* text,
79 const SkPaint& paint) SK_OVERRIDE;
80 void onDrawPosText(const void* text,
83 const SkPaint& paint) SK_OVERRIDE;
84 void onDrawPosTextH(const void* text,
86 const SkScalar xpos[],
88 const SkPaint& paint) SK_OVERRIDE;
89 void onDrawTextOnPath(const void* text,
92 const SkMatrix* matrix,
93 const SkPaint& paint) SK_OVERRIDE;
94 void onDrawTextBlob(const SkTextBlob* blob,
97 const SkPaint& paint) SK_OVERRIDE;
98 void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
99 const SkPoint texCoords[4], SkXfermode* xmode,
100 const SkPaint& paint) SK_OVERRIDE;
102 void onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) SK_OVERRIDE;
103 void onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) SK_OVERRIDE;
104 void onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) SK_OVERRIDE;
105 void onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) SK_OVERRIDE;
107 void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) SK_OVERRIDE;
109 void onPushCull(const SkRect& cullRect) SK_OVERRIDE;
110 void onPopCull() SK_OVERRIDE;
112 void beginCommentGroup(const char*) SK_OVERRIDE;
113 void addComment(const char*, const char*) SK_OVERRIDE;
114 void endCommentGroup() SK_OVERRIDE;
115 void drawData(const void*, size_t) SK_OVERRIDE;
117 bool isDrawingToLayer() const SK_OVERRIDE;
118 SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&) SK_OVERRIDE { return NULL; }
121 template <typename T>
124 template <typename T>
125 T* copy(const T[], size_t count);
127 SkIRect devBounds() const {
129 this->getClipDeviceBounds(&devBounds);
136 SkTDArray<SkBool8> fSaveIsSaveLayer;
139 #endif//SkRecorder_DEFINED