OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkRecorder_DEFINED | 8 #ifndef SkRecorder_DEFINED |
9 #define SkRecorder_DEFINED | 9 #define SkRecorder_DEFINED |
10 | 10 |
11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
12 #include "SkRecord.h" | 12 #include "SkRecord.h" |
13 #include "SkRecords.h" | 13 #include "SkRecords.h" |
14 | 14 |
15 // SkRecorder provides an SkCanvas interface for recording into an SkRecord. | 15 // SkRecorder provides an SkCanvas interface for recording into an SkRecord. |
16 | 16 |
17 class SkRecorder : public SkCanvas { | 17 class SkRecorder : public SkCanvas { |
18 public: | 18 public: |
19 // SkRecorder can work in two modes: | |
20 // write-only: only a core subset of SkCanvas operations (save/restore, cl
ip, transform, draw) | |
21 // are supported, and all of the readback methods on SkCanvas will probabl
y fail or lie. | |
22 // | |
23 // read-write: all methods should behave with similar semantics to SkCanva
s. | |
24 // | |
25 // Write-only averages 10-20% faster, but you can't sensibly inspect the can
vas while recording. | |
26 enum Mode { kWriteOnly_Mode, kReadWrite_Mode }; | |
27 | |
28 // Does not take ownership of the SkRecord. | 19 // Does not take ownership of the SkRecord. |
29 SkRecorder(Mode mode, SkRecord*, int width, int height); | 20 SkRecorder(SkRecord*, int width, int height); |
30 | 21 |
31 // Make SkRecorder forget entirely about its SkRecord*; all calls to SkRecor
der will fail. | 22 // Make SkRecorder forget entirely about its SkRecord*; all calls to SkRecor
der will fail. |
32 void forgetRecord(); | 23 void forgetRecord(); |
33 | 24 |
34 void clear(SkColor) SK_OVERRIDE; | 25 void clear(SkColor) SK_OVERRIDE; |
35 void drawPaint(const SkPaint& paint) SK_OVERRIDE; | 26 void drawPaint(const SkPaint& paint) SK_OVERRIDE; |
36 void drawPoints(PointMode mode, | 27 void drawPoints(PointMode mode, |
37 size_t count, | 28 size_t count, |
38 const SkPoint pts[], | 29 const SkPoint pts[], |
39 const SkPaint& paint) SK_OVERRIDE; | 30 const SkPaint& paint) SK_OVERRIDE; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 void onPushCull(const SkRect& cullRect) SK_OVERRIDE; | 98 void onPushCull(const SkRect& cullRect) SK_OVERRIDE; |
108 void onPopCull() SK_OVERRIDE; | 99 void onPopCull() SK_OVERRIDE; |
109 | 100 |
110 private: | 101 private: |
111 template <typename T> | 102 template <typename T> |
112 T* copy(const T*); | 103 T* copy(const T*); |
113 | 104 |
114 template <typename T> | 105 template <typename T> |
115 T* copy(const T[], unsigned count); | 106 T* copy(const T[], unsigned count); |
116 | 107 |
117 const Mode fMode; | |
118 SkRecord* fRecord; | 108 SkRecord* fRecord; |
119 }; | 109 }; |
120 | 110 |
121 #endif//SkRecorder_DEFINED | 111 #endif//SkRecorder_DEFINED |
OLD | NEW |