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" |
| 14 | |
| 15 | // SkRecorder provides an SkCanvas interface for recording into an SkRecord. |
| 16 | |
| 17 | class SkRecorder : public SkCanvas { |
| 18 | public: |
| 19 | // Does not take ownership of the SkRecord. |
commit-bot@chromium.org | a095041 | 2014-05-29 16:52:40 +0000 | [diff] [blame] | 20 | SkRecorder(SkRecord*, int width, int height); |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 21 | |
commit-bot@chromium.org | 732bd66 | 2014-04-24 15:22:55 +0000 | [diff] [blame] | 22 | // Make SkRecorder forget entirely about its SkRecord*; all calls to SkRecorder will fail. |
| 23 | void forgetRecord(); |
| 24 | |
commit-bot@chromium.org | 066a28d | 2014-04-08 17:31:08 +0000 | [diff] [blame] | 25 | 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.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 42 | const SkPaint* paint = NULL, |
commit-bot@chromium.org | 066a28d | 2014-04-08 17:31:08 +0000 | [diff] [blame] | 43 | 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.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 55 | void drawVertices(VertexMode vmode, |
commit-bot@chromium.org | 066a28d | 2014-04-08 17:31:08 +0000 | [diff] [blame] | 56 | int vertexCount, |
| 57 | const SkPoint vertices[], |
| 58 | const SkPoint texs[], |
| 59 | const SkColor colors[], |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 60 | SkXfermode* xmode, |
commit-bot@chromium.org | 066a28d | 2014-04-08 17:31:08 +0000 | [diff] [blame] | 61 | const uint16_t indices[], |
| 62 | int indexCount, |
| 63 | const SkPaint& paint) SK_OVERRIDE; |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 64 | |
Florin Malita | 5f6102d | 2014-06-30 10:13:28 -0400 | [diff] [blame] | 65 | void willSave() SK_OVERRIDE; |
commit-bot@chromium.org | 066a28d | 2014-04-08 17:31:08 +0000 | [diff] [blame] | 66 | SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SkCanvas::SaveFlags) SK_OVERRIDE; |
mtklein | 6cfa73a | 2014-08-13 13:33:49 -0700 | [diff] [blame] | 67 | void didRestore() SK_OVERRIDE; |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 68 | |
commit-bot@chromium.org | 066a28d | 2014-04-08 17:31:08 +0000 | [diff] [blame] | 69 | void didConcat(const SkMatrix&) SK_OVERRIDE; |
| 70 | void didSetMatrix(const SkMatrix&) SK_OVERRIDE; |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 71 | |
commit-bot@chromium.org | 066a28d | 2014-04-08 17:31:08 +0000 | [diff] [blame] | 72 | void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK_OVERRIDE; |
reed@google.com | e0d9ce8 | 2014-04-23 04:00:17 +0000 | [diff] [blame] | 73 | void onDrawText(const void* text, |
| 74 | size_t byteLength, |
| 75 | SkScalar x, |
| 76 | SkScalar y, |
| 77 | const SkPaint& paint) SK_OVERRIDE; |
| 78 | void onDrawPosText(const void* text, |
| 79 | size_t byteLength, |
| 80 | const SkPoint pos[], |
| 81 | const SkPaint& paint) SK_OVERRIDE; |
| 82 | void onDrawPosTextH(const void* text, |
| 83 | size_t byteLength, |
| 84 | const SkScalar xpos[], |
| 85 | SkScalar constY, |
| 86 | const SkPaint& paint) SK_OVERRIDE; |
| 87 | void onDrawTextOnPath(const void* text, |
| 88 | size_t byteLength, |
| 89 | const SkPath& path, |
| 90 | const SkMatrix* matrix, |
| 91 | const SkPaint& paint) SK_OVERRIDE; |
fmalita | 00d5c2c | 2014-08-21 08:53:26 -0700 | [diff] [blame] | 92 | void onDrawTextBlob(const SkTextBlob* blob, |
| 93 | SkScalar x, |
| 94 | SkScalar y, |
| 95 | const SkPaint& paint); |
dandov | b3c9d1c | 2014-08-12 08:34:29 -0700 | [diff] [blame] | 96 | void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], |
| 97 | const SkPoint texCoords[4], SkXfermode* xmode, |
| 98 | const SkPaint& paint) SK_OVERRIDE; |
mtklein | 6cfa73a | 2014-08-13 13:33:49 -0700 | [diff] [blame] | 99 | |
commit-bot@chromium.org | 066a28d | 2014-04-08 17:31:08 +0000 | [diff] [blame] | 100 | void onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) SK_OVERRIDE; |
| 101 | void onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) SK_OVERRIDE; |
| 102 | void onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) SK_OVERRIDE; |
| 103 | void onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) SK_OVERRIDE; |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 104 | |
reed | d5fa1a4 | 2014-08-09 11:08:05 -0700 | [diff] [blame] | 105 | void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) SK_OVERRIDE; |
robertphillips | 9b14f26 | 2014-06-04 05:40:44 -0700 | [diff] [blame] | 106 | |
commit-bot@chromium.org | 066a28d | 2014-04-08 17:31:08 +0000 | [diff] [blame] | 107 | void onPushCull(const SkRect& cullRect) SK_OVERRIDE; |
| 108 | void onPopCull() SK_OVERRIDE; |
commit-bot@chromium.org | 03a99b8 | 2014-04-08 15:17:17 +0000 | [diff] [blame] | 109 | |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 110 | private: |
| 111 | template <typename T> |
| 112 | T* copy(const T*); |
| 113 | |
| 114 | template <typename T> |
reed | 2347b62 | 2014-08-07 12:19:50 -0700 | [diff] [blame] | 115 | T* copy(const T[], size_t count); |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 116 | |
mtklein | a723b57 | 2014-08-15 11:49:49 -0700 | [diff] [blame] | 117 | SkIRect devBounds() const { |
| 118 | SkIRect devBounds; |
| 119 | this->getClipDeviceBounds(&devBounds); |
| 120 | return devBounds; |
| 121 | } |
| 122 | |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 123 | SkRecord* fRecord; |
| 124 | }; |
| 125 | |
| 126 | #endif//SkRecorder_DEFINED |