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

Side by Side Diff: include/record/SkRecording.h

Issue 248033002: Rearrange SkRecord public API to fit better with cc/resources/picture (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add forgetRecord() Created 6 years, 8 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 | « dm/DMRecordTask.cpp ('k') | src/record/SkRecorder.h » ('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 SkRecording_DEFINED 8 #ifndef SkRecording_DEFINED
9 #define SkRecording_DEFINED 9 #define SkRecording_DEFINED
10 10
11 #include "SkCanvas.h" // SkCanvas 11 #include "SkCanvas.h" // SkCanvas
12 #include "SkTypes.h" // SkNoncopyable 12 #include "SkRefCnt.h" // SkAutoTUnref
13 #include "SkTemplates.h" // SkAutoTDelete
14 #include "SkTypes.h" // SkNoncopyable
13 15
14 // These are intentionally left opaque. 16 // These are intentionally left opaque.
15 class SkRecord; 17 class SkRecord;
16 class SkRecorder; 18 class SkRecorder;
17 19
18 namespace EXPERIMENTAL { 20 namespace EXPERIMENTAL {
19 21
20 /** Easy mode interface to SkRecord-based SkCanvas recording. 22 /** Easy mode interface to SkRecord-based SkCanvas recording.
21 * 23 *
22 * SkRecording* recording = SkRecording::Create(1920, 1080); 24 * scoped_ptr<SkRecording> recording(new SkRecording(1920, 1080));
reed1 2014/04/23 21:53:30 its not wrong, but I don't think our pseudo code i
mtklein 2014/04/23 22:05:54 It's intended for Chrome readers. Want me to rewr
25 * skia::RefPtr<SkCanvas> canvas(skia::SharePtr(recording->canvas()));
23 * 26 *
24 * SkCanvas* canvas = recording->canvas();
25 * canvas->drawThis(); 27 * canvas->drawThis();
26 * canvas->clipThat(); 28 * canvas->clipThat();
27 * ... 29 * ...
28 * 30 *
29 * scoped_ptr<const SkPlayback> playback(SkRecording::Delete(recording)); 31 * canvas.clear(); // You must deref the canvas before you may call releasePla yback().
32 * scoped_ptr<const SkPlayback> playback(recording->releasePlayback());
30 * playback->draw(&someCanvas); 33 * playback->draw(&someCanvas);
31 * playback->draw(&someOtherCanvas); 34 * playback->draw(&someOtherCanvas);
32 * 35 *
33 * SkPlayback is thread safe; SkRecording is not. 36 * SkPlayback is thread safe; SkRecording is not.
34 */ 37 */
35 38
36 class SkPlayback : SkNoncopyable { 39 class SkPlayback : SkNoncopyable {
37 public: 40 public:
38 // Remember, if you've got an SkPlayback*, you probably own it. Don't forge t to delete it! 41 // Remember, if you've got an SkPlayback*, you probably own it. Don't forge t to delete it!
39 ~SkPlayback(); 42 ~SkPlayback();
40 43
41 // Draw recorded commands into a canvas. 44 // Draw recorded commands into a canvas.
42 void draw(SkCanvas*) const; 45 void draw(SkCanvas*) const;
43 46
44 private: 47 private:
45 explicit SkPlayback(const SkRecord*); 48 explicit SkPlayback(const SkRecord*);
46 49
47 const SkRecord* fRecord; 50 SkAutoTDelete<const SkRecord> fRecord;
48 51
49 friend class SkRecording; 52 friend class SkRecording;
50 }; 53 };
51 54
52 class SkRecording : SkNoncopyable { 55 class SkRecording : SkNoncopyable {
53 public: 56 public:
54 // Result must be returned via SkRecording::Delete.
55 static SkRecording* Create(int width, int height);
56
57 // Caller takes ownership of SkPlayback.
58 static const SkPlayback* Delete(SkRecording*);
59
60 // Draws issued to this canvas will be replayed by SkPlayback::draw().
61 // This pointer is owned by the SkRecording; the caller must not take owners hip.
62 SkCanvas* canvas();
63
64 private:
65 SkRecording(int width, int height); 57 SkRecording(int width, int height);
66 ~SkRecording(); 58 ~SkRecording();
67 59
68 SkRecorder* fRecorder; 60 // Draws issued to this canvas will be replayed by SkPlayback::draw().
69 SkRecord* fRecord; 61 // Any refs held on canvas() must be dropped before you may call releasePlay back().
62 SkCanvas* canvas();
63
64 // Release exclusive ownership of an SkPlayback to the caller.
65 // Any refs held on canvas() must be dropped before you may call releasePlay back().
66 SkPlayback* releasePlayback();
67
68 private:
69 SkAutoTDelete<SkRecord> fRecord;
70 SkAutoTUnref<SkRecorder> fRecorder;
70 }; 71 };
71 72
72 } // namespace EXPERIMENTAL 73 } // namespace EXPERIMENTAL
73 74
74 #endif//SkRecording_DEFINED 75 #endif//SkRecording_DEFINED
OLDNEW
« no previous file with comments | « dm/DMRecordTask.cpp ('k') | src/record/SkRecorder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698