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 SkPictureRecorder_DEFINED | 8 #ifndef SkPictureRecorder_DEFINED |
9 #define SkPictureRecorder_DEFINED | 9 #define SkPictureRecorder_DEFINED |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 class SkCanvas; | 21 class SkCanvas; |
22 class SkPictureRecord; | 22 class SkPictureRecord; |
23 class SkRecord; | 23 class SkRecord; |
24 class SkRecorder; | 24 class SkRecorder; |
25 | 25 |
26 class SK_API SkPictureRecorder : SkNoncopyable { | 26 class SK_API SkPictureRecorder : SkNoncopyable { |
27 public: | 27 public: |
28 SkPictureRecorder(); | 28 SkPictureRecorder(); |
29 ~SkPictureRecorder(); | 29 ~SkPictureRecorder(); |
30 | 30 |
| 31 #ifdef SK_LEGACY_PICTURE_SIZE_API |
| 32 SkCanvas* beginRecording(int width, int height, |
| 33 SkBBHFactory* bbhFactory = NULL, |
| 34 uint32_t recordFlags = 0) { |
| 35 return this->beginRecording(SkIntToScalar(width), SkIntToScalar(height), |
| 36 bbhFactory, recordFlags); |
| 37 } |
| 38 #endif |
| 39 |
31 /** Returns the canvas that records the drawing commands. | 40 /** Returns the canvas that records the drawing commands. |
32 @param width the base width for the picture, as if the recording | 41 @param width the width of the cull rect used when recording this picture
. |
33 canvas' bitmap had this width. | 42 @param height the height of the cull rect used when recording this pictu
re. |
34 @param height the base width for the picture, as if the recording | |
35 canvas' bitmap had this height. | |
36 @param bbhFactory factory to create desired acceleration structure | 43 @param bbhFactory factory to create desired acceleration structure |
37 @param recordFlags optional flags that control recording. | 44 @param recordFlags optional flags that control recording. |
38 @return the canvas. | 45 @return the canvas. |
39 */ | 46 */ |
40 SkCanvas* beginRecording(int width, int height, | 47 SkCanvas* beginRecording(SkScalar width, SkScalar height, |
41 SkBBHFactory* bbhFactory = NULL, | 48 SkBBHFactory* bbhFactory = NULL, |
42 uint32_t recordFlags = 0); | 49 uint32_t recordFlags = 0); |
43 | 50 |
44 // As usual, we have a deprecated old version and a maybe almost working | 51 // As usual, we have a deprecated old version and a maybe almost working |
45 // new version. We currently point beginRecording() to | 52 // new version. We currently point beginRecording() to |
46 // DEPRECATED_beginRecording() unless SK_PICTURE_USE_SK_RECORD is defined, | 53 // DEPRECATED_beginRecording() unless SK_PICTURE_USE_SK_RECORD is defined, |
47 // then we use EXPERIMENTAL_beginRecording(). | 54 // then we use EXPERIMENTAL_beginRecording(). |
48 | 55 |
49 // Old slower backend. | 56 // Old slower backend. |
50 SkCanvas* DEPRECATED_beginRecording(int width, int height, | 57 SkCanvas* DEPRECATED_beginRecording(SkScalar width, SkScalar height, |
51 SkBBHFactory* bbhFactory = NULL, | 58 SkBBHFactory* bbhFactory = NULL, |
52 uint32_t recordFlags = 0); | 59 uint32_t recordFlags = 0); |
53 | 60 |
54 // New faster backend. | 61 // New faster backend. |
55 SkCanvas* EXPERIMENTAL_beginRecording(int width, int height, | 62 SkCanvas* EXPERIMENTAL_beginRecording(SkScalar width, SkScalar height, |
56 SkBBHFactory* bbhFactory = NULL); | 63 SkBBHFactory* bbhFactory = NULL); |
57 | 64 |
58 /** Returns the recording canvas if one is active, or NULL if recording is | 65 /** Returns the recording canvas if one is active, or NULL if recording is |
59 not active. This does not alter the refcnt on the canvas (if present). | 66 not active. This does not alter the refcnt on the canvas (if present). |
60 */ | 67 */ |
61 SkCanvas* getRecordingCanvas(); | 68 SkCanvas* getRecordingCanvas(); |
62 | 69 |
63 /** Signal that the caller is done recording. This invalidates the canvas | 70 /** Signal that the caller is done recording. This invalidates the canvas |
64 returned by beginRecording/getRecordingCanvas, and returns the | 71 returned by beginRecording/getRecordingCanvas, and returns the |
65 created SkPicture. Note that the returned picture has its creation | 72 created SkPicture. Note that the returned picture has its creation |
(...skipping 14 matching lines...) Expand all Loading... |
80 | 87 |
81 /** Replay the current (partially recorded) operation stream into | 88 /** Replay the current (partially recorded) operation stream into |
82 canvas. This call doesn't close the current recording. | 89 canvas. This call doesn't close the current recording. |
83 */ | 90 */ |
84 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 91 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
85 friend class android::Picture; | 92 friend class android::Picture; |
86 #endif | 93 #endif |
87 friend class SkPictureRecorderReplayTester; // for unit testing | 94 friend class SkPictureRecorderReplayTester; // for unit testing |
88 void partialReplay(SkCanvas* canvas) const; | 95 void partialReplay(SkCanvas* canvas) const; |
89 | 96 |
90 int fWidth; | 97 SkScalar fCullWidth; |
91 int fHeight; | 98 SkScalar fCullHeight; |
92 | |
93 SkAutoTUnref<SkBBoxHierarchy> fBBH; | 99 SkAutoTUnref<SkBBoxHierarchy> fBBH; |
94 | 100 |
95 // One of these two canvases will be non-NULL. | 101 // One of these two canvases will be non-NULL. |
96 SkAutoTUnref<SkPictureRecord> fPictureRecord; // beginRecording() | 102 SkAutoTUnref<SkPictureRecord> fPictureRecord; // beginRecording() |
97 SkAutoTUnref<SkRecorder> fRecorder; // EXPERIMENTAL_beginRecordin
g() | 103 SkAutoTUnref<SkRecorder> fRecorder; // EXPERIMENTAL_beginRecordin
g() |
98 | 104 |
99 // Used by EXPERIMENTAL_beginRecording(). | 105 // Used by EXPERIMENTAL_beginRecording(). |
100 SkAutoTDelete<SkRecord> fRecord; | 106 SkAutoTDelete<SkRecord> fRecord; |
101 | 107 |
102 typedef SkNoncopyable INHERITED; | 108 typedef SkNoncopyable INHERITED; |
103 }; | 109 }; |
104 | 110 |
105 #endif | 111 #endif |
OLD | NEW |