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

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

Issue 331573004: Add EXPERIMENTAL_beginRecording() for SkRecord-based recording. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: put back 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 | « gyp/tools.gyp ('k') | src/core/SkPictureRecorder.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 class SkPictureRecord;
17 class SkRecord;
18 class SkRecorder;
17 19
18 class SK_API SkPictureRecorder : SkNoncopyable { 20 class SK_API SkPictureRecorder : SkNoncopyable {
19 public: 21 public:
20 SkPictureRecorder() : fCanvas(NULL) { } 22 SkPictureRecorder() : fPictureRecord(NULL), fRecorder(NULL), fRecord(NULL) { }
21 ~SkPictureRecorder(); 23 ~SkPictureRecorder();
22 24
23 /** Returns the canvas that records the drawing commands. 25 /** Returns the canvas that records the drawing commands.
24 @param width the base width for the picture, as if the recording 26 @param width the base width for the picture, as if the recording
25 canvas' bitmap had this width. 27 canvas' bitmap had this width.
26 @param height the base width for the picture, as if the recording 28 @param height the base width for the picture, as if the recording
27 canvas' bitmap had this height. 29 canvas' bitmap had this height.
28 @param bbhFactory factory to create desired acceleration structure 30 @param bbhFactory factory to create desired acceleration structure
29 @param recordFlags optional flags that control recording. 31 @param recordFlags optional flags that control recording.
30 @return the canvas. 32 @return the canvas.
31 */ 33 */
32 SkCanvas* beginRecording(int width, int height, 34 SkCanvas* beginRecording(int width, int height,
33 SkBBHFactory* bbhFactory = NULL, 35 SkBBHFactory* bbhFactory = NULL,
34 uint32_t recordFlags = 0); 36 uint32_t recordFlags = 0);
35 37
38 /** Same as beginRecording(), using a new faster backend. */
39 SkCanvas* EXPERIMENTAL_beginRecording(int width, int height,
40 SkBBHFactory* bbhFactory = NULL);
41
36 /** Returns the recording canvas if one is active, or NULL if recording is 42 /** Returns the recording canvas if one is active, or NULL if recording is
37 not active. This does not alter the refcnt on the canvas (if present). 43 not active. This does not alter the refcnt on the canvas (if present).
38 */ 44 */
39 SkCanvas* getRecordingCanvas(); 45 SkCanvas* getRecordingCanvas();
40 46
41 /** Signal that the caller is done recording. This invalidates the canvas 47 /** Signal that the caller is done recording. This invalidates the canvas
42 returned by beginRecording/getRecordingCanvas, and returns the 48 returned by beginRecording/getRecordingCanvas, and returns the
43 created SkPicture. Note that the returned picture has its creation 49 created SkPicture. Note that the returned picture has its creation
44 ref which the caller must take ownership of. 50 ref which the caller must take ownership of.
45 */ 51 */
46 SkPicture* endRecording(); 52 SkPicture* endRecording();
47 53
48 /** Enable/disable all the picture recording optimizations (i.e., 54 /** Enable/disable all the picture recording optimizations (i.e.,
49 those in SkPictureRecord). It is mainly intended for testing the 55 those in SkPictureRecord). It is mainly intended for testing the
50 existing optimizations (i.e., to actually have the pattern 56 existing optimizations (i.e., to actually have the pattern
51 appear in an .skp we have to disable the optimization). Call right 57 appear in an .skp we have to disable the optimization). Call right
52 after 'beginRecording'. 58 after 'beginRecording'.
53 */ 59 */
54 void internalOnly_EnableOpts(bool enableOpts); 60 void internalOnly_EnableOpts(bool enableOpts);
55 61
56 private: 62 private:
63 void reset();
64
57 /** Replay the current (partially recorded) operation stream into 65 /** Replay the current (partially recorded) operation stream into
58 canvas. This call doesn't close the current recording. 66 canvas. This call doesn't close the current recording.
59 */ 67 */
60 friend class AndroidPicture; 68 friend class AndroidPicture;
61 friend class SkPictureRecorderReplayTester; // for unit testing 69 friend class SkPictureRecorderReplayTester; // for unit testing
62 void partialReplay(SkCanvas* canvas) const; 70 void partialReplay(SkCanvas* canvas) const;
63 71
64 int fWidth; 72 int fWidth;
65 int fHeight; 73 int fHeight;
66 SkPictureRecord* fCanvas; // ref counted 74
75 // Both ref counted. One of these two will be non-null:
76 SkPictureRecord* fPictureRecord; // beginRecording()
77 SkRecorder* fRecorder; // EXPERIMENTAL_beginRecording()
78
79 // Not refcounted. Used by EXPERIMENTAL_beginRecording().
80 SkRecord* fRecord;
67 81
68 typedef SkNoncopyable INHERITED; 82 typedef SkNoncopyable INHERITED;
69 }; 83 };
70 84
71 #endif 85 #endif
OLDNEW
« no previous file with comments | « gyp/tools.gyp ('k') | src/core/SkPictureRecorder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698