commit-bot@chromium.org | c4b21e6 | 2014-04-11 18:33:31 +0000 | [diff] [blame] | 1 | /* |
| 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.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 8 | #ifndef SkRecorder_DEFINED |
| 9 | #define SkRecorder_DEFINED |
| 10 | |
| 11 | #include "SkCanvas.h" |
| 12 | #include "SkRecord.h" |
| 13 | #include "SkRecords.h" |
mtklein | 29dfaa8 | 2014-09-04 14:12:44 -0700 | [diff] [blame] | 14 | #include "SkTDArray.h" |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 15 | |
| 16 | // SkRecorder provides an SkCanvas interface for recording into an SkRecord. |
| 17 | |
| 18 | class SkRecorder : public SkCanvas { |
| 19 | public: |
| 20 | // Does not take ownership of the SkRecord. |
commit-bot@chromium.org | a095041 | 2014-05-29 16:52:40 +0000 | [diff] [blame] | 21 | SkRecorder(SkRecord*, int width, int height); |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 22 | |
commit-bot@chromium.org | 732bd66 | 2014-04-24 15:22:55 +0000 | [diff] [blame] | 23 | // Make SkRecorder forget entirely about its SkRecord*; all calls to SkRecorder will fail. |
| 24 | void forgetRecord(); |
| 25 | |
commit-bot@chromium.org | 066a28d | 2014-04-08 17:31:08 +0000 | [diff] [blame] | 26 | void clear(SkColor) SK_OVERRIDE; |
| 27 | void drawPaint(const SkPaint& paint) SK_OVERRIDE; |
| 28 | void drawPoints(PointMode mode, |
| 29 | size_t count, |
| 30 | const SkPoint pts[], |
| 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, |
| 37 | SkScalar left, |
| 38 | SkScalar top, |
| 39 | const SkPaint* paint = NULL) SK_OVERRIDE; |
| 40 | void drawBitmapRectToRect(const SkBitmap& bitmap, |
| 41 | const SkRect* src, |
| 42 | const SkRect& dst, |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 43 | const SkPaint* paint = NULL, |
commit-bot@chromium.org | 066a28d | 2014-04-08 17:31:08 +0000 | [diff] [blame] | 44 | DrawBitmapRectFlags flags = kNone_DrawBitmapRectFlag) SK_OVERRIDE; |
| 45 | void drawBitmapMatrix(const SkBitmap& bitmap, |
| 46 | const SkMatrix& m, |
| 47 | const SkPaint* paint = NULL) SK_OVERRIDE; |
| 48 | void drawBitmapNine(const SkBitmap& bitmap, |
| 49 | const SkIRect& center, |
| 50 | const SkRect& dst, |
| 51 | const SkPaint* paint = NULL) SK_OVERRIDE; |
piotaixr | 6515175 | 2014-10-16 11:58:39 -0700 | [diff] [blame] | 52 | virtual void drawImage(const SkImage* image, SkScalar left, SkScalar top, |
| 53 | const SkPaint* paint = NULL) SK_OVERRIDE; |
| 54 | virtual void drawImageRect(const SkImage* image, const SkRect* src, |
| 55 | const SkRect& dst, |
| 56 | const SkPaint* paint = NULL) SK_OVERRIDE; |
commit-bot@chromium.org | 066a28d | 2014-04-08 17:31:08 +0000 | [diff] [blame] | 57 | void drawSprite(const SkBitmap& bitmap, |
| 58 | int left, |
| 59 | int top, |
| 60 | const SkPaint* paint = NULL) SK_OVERRIDE; |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 61 | void drawVertices(VertexMode vmode, |
commit-bot@chromium.org | 066a28d | 2014-04-08 17:31:08 +0000 | [diff] [blame] | 62 | int vertexCount, |
| 63 | const SkPoint vertices[], |
| 64 | const SkPoint texs[], |
| 65 | const SkColor colors[], |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 66 | SkXfermode* xmode, |
commit-bot@chromium.org | 066a28d | 2014-04-08 17:31:08 +0000 | [diff] [blame] | 67 | const uint16_t indices[], |
| 68 | int indexCount, |
| 69 | const SkPaint& paint) SK_OVERRIDE; |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 70 | |
Florin Malita | 5f6102d | 2014-06-30 10:13:28 -0400 | [diff] [blame] | 71 | void willSave() SK_OVERRIDE; |
commit-bot@chromium.org | 066a28d | 2014-04-08 17:31:08 +0000 | [diff] [blame] | 72 | SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SkCanvas::SaveFlags) SK_OVERRIDE; |
mtklein | 29dfaa8 | 2014-09-04 14:12:44 -0700 | [diff] [blame] | 73 | void willRestore() SK_OVERRIDE {} |
mtklein | 6cfa73a | 2014-08-13 13:33:49 -0700 | [diff] [blame] | 74 | void didRestore() SK_OVERRIDE; |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 75 | |
commit-bot@chromium.org | 066a28d | 2014-04-08 17:31:08 +0000 | [diff] [blame] | 76 | void didConcat(const SkMatrix&) SK_OVERRIDE; |
| 77 | void didSetMatrix(const SkMatrix&) SK_OVERRIDE; |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 78 | |
commit-bot@chromium.org | 066a28d | 2014-04-08 17:31:08 +0000 | [diff] [blame] | 79 | void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK_OVERRIDE; |
reed@google.com | e0d9ce8 | 2014-04-23 04:00:17 +0000 | [diff] [blame] | 80 | void onDrawText(const void* text, |
| 81 | size_t byteLength, |
| 82 | SkScalar x, |
| 83 | SkScalar y, |
| 84 | const SkPaint& paint) SK_OVERRIDE; |
| 85 | void onDrawPosText(const void* text, |
| 86 | size_t byteLength, |
| 87 | const SkPoint pos[], |
| 88 | const SkPaint& paint) SK_OVERRIDE; |
| 89 | void onDrawPosTextH(const void* text, |
| 90 | size_t byteLength, |
| 91 | const SkScalar xpos[], |
| 92 | SkScalar constY, |
| 93 | const SkPaint& paint) SK_OVERRIDE; |
| 94 | void onDrawTextOnPath(const void* text, |
| 95 | size_t byteLength, |
| 96 | const SkPath& path, |
| 97 | const SkMatrix* matrix, |
| 98 | const SkPaint& paint) SK_OVERRIDE; |
fmalita | 00d5c2c | 2014-08-21 08:53:26 -0700 | [diff] [blame] | 99 | void onDrawTextBlob(const SkTextBlob* blob, |
| 100 | SkScalar x, |
| 101 | SkScalar y, |
fmalita | b742517 | 2014-08-26 07:56:44 -0700 | [diff] [blame] | 102 | const SkPaint& paint) SK_OVERRIDE; |
dandov | b3c9d1c | 2014-08-12 08:34:29 -0700 | [diff] [blame] | 103 | void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], |
| 104 | const SkPoint texCoords[4], SkXfermode* xmode, |
| 105 | const SkPaint& paint) SK_OVERRIDE; |
mtklein | 6cfa73a | 2014-08-13 13:33:49 -0700 | [diff] [blame] | 106 | |
commit-bot@chromium.org | 066a28d | 2014-04-08 17:31:08 +0000 | [diff] [blame] | 107 | void onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) SK_OVERRIDE; |
| 108 | void onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) SK_OVERRIDE; |
| 109 | void onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) SK_OVERRIDE; |
| 110 | void onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) SK_OVERRIDE; |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 111 | |
reed | d5fa1a4 | 2014-08-09 11:08:05 -0700 | [diff] [blame] | 112 | void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) SK_OVERRIDE; |
robertphillips | 9b14f26 | 2014-06-04 05:40:44 -0700 | [diff] [blame] | 113 | |
commit-bot@chromium.org | 066a28d | 2014-04-08 17:31:08 +0000 | [diff] [blame] | 114 | void onPushCull(const SkRect& cullRect) SK_OVERRIDE; |
| 115 | void onPopCull() SK_OVERRIDE; |
commit-bot@chromium.org | 03a99b8 | 2014-04-08 15:17:17 +0000 | [diff] [blame] | 116 | |
mtklein | 5f0e822 | 2014-08-22 11:44:26 -0700 | [diff] [blame] | 117 | void beginCommentGroup(const char*) SK_OVERRIDE; |
| 118 | void addComment(const char*, const char*) SK_OVERRIDE; |
| 119 | void endCommentGroup() SK_OVERRIDE; |
mtklein | 29dfaa8 | 2014-09-04 14:12:44 -0700 | [diff] [blame] | 120 | void drawData(const void*, size_t) SK_OVERRIDE; |
| 121 | |
| 122 | bool isDrawingToLayer() const SK_OVERRIDE; |
reed | 4a8126e | 2014-09-22 07:29:03 -0700 | [diff] [blame] | 123 | SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&) SK_OVERRIDE { return NULL; } |
mtklein | 5f0e822 | 2014-08-22 11:44:26 -0700 | [diff] [blame] | 124 | |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 125 | private: |
| 126 | template <typename T> |
| 127 | T* copy(const T*); |
| 128 | |
| 129 | template <typename T> |
reed | 2347b62 | 2014-08-07 12:19:50 -0700 | [diff] [blame] | 130 | T* copy(const T[], size_t count); |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 131 | |
mtklein | a723b57 | 2014-08-15 11:49:49 -0700 | [diff] [blame] | 132 | SkIRect devBounds() const { |
| 133 | SkIRect devBounds; |
| 134 | this->getClipDeviceBounds(&devBounds); |
| 135 | return devBounds; |
| 136 | } |
| 137 | |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 138 | SkRecord* fRecord; |
mtklein | 29dfaa8 | 2014-09-04 14:12:44 -0700 | [diff] [blame] | 139 | |
| 140 | int fSaveLayerCount; |
| 141 | SkTDArray<SkBool8> fSaveIsSaveLayer; |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 142 | }; |
| 143 | |
| 144 | #endif//SkRecorder_DEFINED |