Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Side by Side Diff: include/core/SkPictureRecorder.h

Issue 318763004: First pass at splitting out SkPictureRecord from SkPicture (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Make dtor non-virtual Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/core/SkPicture.h ('k') | src/core/SkPicture.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include "SkBBHFactory.h" 11 #include "SkBBHFactory.h"
12 #include "SkPicture.h" 12 #include "SkPicture.h"
13 #include "SkRefCnt.h" 13 #include "SkRefCnt.h"
14 14
15 class SkCanvas; 15 class SkCanvas;
16 class SkPictureRecord;
16 17
17 class SK_API SkPictureRecorder : SkNoncopyable { 18 class SK_API SkPictureRecorder : SkNoncopyable {
18 public: 19 public:
20 SkPictureRecorder() : fCanvas(NULL) { }
21 ~SkPictureRecorder();
22
19 /** Returns the canvas that records the drawing commands. 23 /** Returns the canvas that records the drawing commands.
20 @param width the base width for the picture, as if the recording 24 @param width the base width for the picture, as if the recording
21 canvas' bitmap had this width. 25 canvas' bitmap had this width.
22 @param height the base width for the picture, as if the recording 26 @param height the base width for the picture, as if the recording
23 canvas' bitmap had this height. 27 canvas' bitmap had this height.
24 @param bbhFactory factory to create desired acceleration structure 28 @param bbhFactory factory to create desired acceleration structure
25 @param recordFlags optional flags that control recording. 29 @param recordFlags optional flags that control recording.
26 @return the canvas. 30 @return the canvas.
27 */ 31 */
28 // TODO: allow default parameters once the other beginRecoding entry point i s gone 32 // TODO: allow default parameters once the other beginRecoding entry point i s gone
29 SkCanvas* beginRecording(int width, int height, 33 SkCanvas* beginRecording(int width, int height,
30 SkBBHFactory* bbhFactory /* = NULL */, 34 SkBBHFactory* bbhFactory /* = NULL */,
31 uint32_t recordFlags /* = 0 */); 35 uint32_t recordFlags /* = 0 */);
32 36
33 /** Returns the recording canvas if one is active, or NULL if recording is 37 /** Returns the recording canvas if one is active, or NULL if recording is
34 not active. This does not alter the refcnt on the canvas (if present). 38 not active. This does not alter the refcnt on the canvas (if present).
35 */ 39 */
36 SkCanvas* getRecordingCanvas() { 40 SkCanvas* getRecordingCanvas();
37 if (NULL != fPicture.get()) {
38 return fPicture->getRecordingCanvas();
39 }
40 return NULL;
41 }
42 41
43 /** Signal that the caller is done recording. This invalidates the canvas 42 /** Signal that the caller is done recording. This invalidates the canvas
44 returned by beginRecording/getRecordingCanvas, and returns the 43 returned by beginRecording/getRecordingCanvas, and returns the
45 created SkPicture. Note that the returned picture has its creation 44 created SkPicture. Note that the returned picture has its creation
46 ref which the caller must take ownership of. 45 ref which the caller must take ownership of.
47 */ 46 */
48 SkPicture* endRecording() { 47 SkPicture* endRecording();
49 if (NULL != fPicture.get()) {
50 fPicture->endRecording();
51 return fPicture.detach();
52 }
53 return NULL;
54 }
55 48
56 /** Enable/disable all the picture recording optimizations (i.e., 49 /** Enable/disable all the picture recording optimizations (i.e.,
57 those in SkPictureRecord). It is mainly intended for testing the 50 those in SkPictureRecord). It is mainly intended for testing the
58 existing optimizations (i.e., to actually have the pattern 51 existing optimizations (i.e., to actually have the pattern
59 appear in an .skp we have to disable the optimization). Call right 52 appear in an .skp we have to disable the optimization). Call right
60 after 'beginRecording'. 53 after 'beginRecording'.
61 */ 54 */
62 void internalOnly_EnableOpts(bool enableOpts) { 55 void internalOnly_EnableOpts(bool enableOpts);
63 if (NULL != fPicture.get()) {
64 fPicture->internalOnly_EnableOpts(enableOpts);
65 }
66 }
67 56
68 private: 57 private:
69 #ifdef SK_BUILD_FOR_ANDROID 58 #ifdef SK_BUILD_FOR_ANDROID
70 /** Replay the current (partially recorded) operation stream into 59 /** Replay the current (partially recorded) operation stream into
71 canvas. This call doesn't close the current recording. 60 canvas. This call doesn't close the current recording.
72 */ 61 */
73 friend class AndroidPicture; 62 friend class AndroidPicture;
74 friend class SkPictureRecorderReplayTester; // for unit testing 63 friend class SkPictureRecorderReplayTester; // for unit testing
75 void partialReplay(SkCanvas* canvas) const; 64 void partialReplay(SkCanvas* canvas) const;
76 #endif 65 #endif
77 66
78 SkAutoTUnref<SkPicture> fPicture; 67 SkAutoTUnref<SkPicture> fPicture;
68 SkPictureRecord* fCanvas; // ref counted
79 69
80 typedef SkNoncopyable INHERITED; 70 typedef SkNoncopyable INHERITED;
81 }; 71 };
82 72
83 #endif 73 #endif
OLDNEW
« no previous file with comments | « include/core/SkPicture.h ('k') | src/core/SkPicture.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698