blob: be8924846ef148a67204c70bdedf8caea3d51684 [file] [log] [blame]
commit-bot@chromium.orgc4b21e62014-04-11 18:33:31 +00001/*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +00008#ifndef SkRecorder_DEFINED
9#define SkRecorder_DEFINED
10
11#include "SkCanvas.h"
12#include "SkRecord.h"
13#include "SkRecords.h"
14
15// SkRecorder provides an SkCanvas interface for recording into an SkRecord.
16
17class SkRecorder : public SkCanvas {
18public:
19 // Does not take ownership of the SkRecord.
commit-bot@chromium.orga0950412014-05-29 16:52:40 +000020 SkRecorder(SkRecord*, int width, int height);
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +000021
commit-bot@chromium.org732bd662014-04-24 15:22:55 +000022 // Make SkRecorder forget entirely about its SkRecord*; all calls to SkRecorder will fail.
23 void forgetRecord();
24
commit-bot@chromium.org066a28d2014-04-08 17:31:08 +000025 void clear(SkColor) SK_OVERRIDE;
26 void drawPaint(const SkPaint& paint) SK_OVERRIDE;
27 void drawPoints(PointMode mode,
28 size_t count,
29 const SkPoint pts[],
30 const SkPaint& paint) SK_OVERRIDE;
31 void drawRect(const SkRect& rect, const SkPaint& paint) SK_OVERRIDE;
32 void drawOval(const SkRect& oval, const SkPaint&) SK_OVERRIDE;
33 void drawRRect(const SkRRect& rrect, const SkPaint& paint) SK_OVERRIDE;
34 void drawPath(const SkPath& path, const SkPaint& paint) SK_OVERRIDE;
35 void drawBitmap(const SkBitmap& bitmap,
36 SkScalar left,
37 SkScalar top,
38 const SkPaint* paint = NULL) SK_OVERRIDE;
39 void drawBitmapRectToRect(const SkBitmap& bitmap,
40 const SkRect* src,
41 const SkRect& dst,
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +000042 const SkPaint* paint = NULL,
commit-bot@chromium.org066a28d2014-04-08 17:31:08 +000043 DrawBitmapRectFlags flags = kNone_DrawBitmapRectFlag) SK_OVERRIDE;
44 void drawBitmapMatrix(const SkBitmap& bitmap,
45 const SkMatrix& m,
46 const SkPaint* paint = NULL) SK_OVERRIDE;
47 void drawBitmapNine(const SkBitmap& bitmap,
48 const SkIRect& center,
49 const SkRect& dst,
50 const SkPaint* paint = NULL) SK_OVERRIDE;
51 void drawSprite(const SkBitmap& bitmap,
52 int left,
53 int top,
54 const SkPaint* paint = NULL) SK_OVERRIDE;
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +000055 void drawVertices(VertexMode vmode,
commit-bot@chromium.org066a28d2014-04-08 17:31:08 +000056 int vertexCount,
57 const SkPoint vertices[],
58 const SkPoint texs[],
59 const SkColor colors[],
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +000060 SkXfermode* xmode,
commit-bot@chromium.org066a28d2014-04-08 17:31:08 +000061 const uint16_t indices[],
62 int indexCount,
63 const SkPaint& paint) SK_OVERRIDE;
dandov963137b2014-08-07 07:49:53 -070064 void drawPatch(const SkPatch& patch, const SkPaint& paint) SK_OVERRIDE;
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +000065
Florin Malita5f6102d2014-06-30 10:13:28 -040066 void willSave() SK_OVERRIDE;
commit-bot@chromium.org066a28d2014-04-08 17:31:08 +000067 SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SkCanvas::SaveFlags) SK_OVERRIDE;
68 void willRestore() SK_OVERRIDE;
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +000069
commit-bot@chromium.org066a28d2014-04-08 17:31:08 +000070 void didConcat(const SkMatrix&) SK_OVERRIDE;
71 void didSetMatrix(const SkMatrix&) SK_OVERRIDE;
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +000072
commit-bot@chromium.org066a28d2014-04-08 17:31:08 +000073 void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK_OVERRIDE;
reed@google.come0d9ce82014-04-23 04:00:17 +000074 void onDrawText(const void* text,
75 size_t byteLength,
76 SkScalar x,
77 SkScalar y,
78 const SkPaint& paint) SK_OVERRIDE;
79 void onDrawPosText(const void* text,
80 size_t byteLength,
81 const SkPoint pos[],
82 const SkPaint& paint) SK_OVERRIDE;
83 void onDrawPosTextH(const void* text,
84 size_t byteLength,
85 const SkScalar xpos[],
86 SkScalar constY,
87 const SkPaint& paint) SK_OVERRIDE;
88 void onDrawTextOnPath(const void* text,
89 size_t byteLength,
90 const SkPath& path,
91 const SkMatrix* matrix,
92 const SkPaint& paint) SK_OVERRIDE;
commit-bot@chromium.org066a28d2014-04-08 17:31:08 +000093 void onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) SK_OVERRIDE;
94 void onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) SK_OVERRIDE;
95 void onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) SK_OVERRIDE;
96 void onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) SK_OVERRIDE;
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +000097
reedd5fa1a42014-08-09 11:08:05 -070098 void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) SK_OVERRIDE;
robertphillips9b14f262014-06-04 05:40:44 -070099
commit-bot@chromium.org066a28d2014-04-08 17:31:08 +0000100 void onPushCull(const SkRect& cullRect) SK_OVERRIDE;
101 void onPopCull() SK_OVERRIDE;
commit-bot@chromium.org03a99b82014-04-08 15:17:17 +0000102
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000103private:
104 template <typename T>
105 T* copy(const T*);
106
107 template <typename T>
reed2347b622014-08-07 12:19:50 -0700108 T* copy(const T[], size_t count);
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000109
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000110 SkRecord* fRecord;
111};
112
113#endif//SkRecorder_DEFINED