Skia
2DGraphicsLibrary
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SkPictureRecorder.h
1 /*
2  * Copyright 2014 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef SkPictureRecorder_DEFINED
9 #define SkPictureRecorder_DEFINED
10 
11 #include "SkBBHFactory.h"
12 #include "SkPicture.h"
13 #include "SkRefCnt.h"
14 
15 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
16 namespace android {
17  class Picture;
18 };
19 #endif
20 
21 class GrContext;
22 class SkCanvas;
23 class SkDrawable;
24 class SkMiniRecorder;
25 class SkPictureRecord;
26 class SkRecord;
27 class SkRecorder;
28 
29 class SK_API SkPictureRecorder : SkNoncopyable {
30 public:
33 
34  enum RecordFlags {
35  // If you call drawPicture() or drawDrawable() on the recording canvas, this flag forces
36  // that object to playback its contents immediately rather than reffing the object.
37  kPlaybackDrawPicture_RecordFlag = 1 << 0,
38  };
39 
40  enum FinishFlags {
41  };
42 
50  SkCanvas* beginRecording(const SkRect& bounds,
51  SkBBHFactory* bbhFactory = NULL,
52  uint32_t recordFlags = 0);
53 
54  SkCanvas* beginRecording(SkScalar width, SkScalar height,
55  SkBBHFactory* bbhFactory = NULL,
56  uint32_t recordFlags = 0) {
57  return this->beginRecording(SkRect::MakeWH(width, height), bbhFactory, recordFlags);
58  }
59 
63  SkCanvas* getRecordingCanvas();
64 
75  sk_sp<SkPicture> finishRecordingAsPicture(uint32_t endFlags = 0);
76 
86  sk_sp<SkPicture> finishRecordingAsPictureWithCull(const SkRect& cullRect,
87  uint32_t endFlags = 0);
88 
99  sk_sp<SkDrawable> finishRecordingAsDrawable(uint32_t endFlags = 0);
100 
101 private:
102  void reset();
103 
107 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
108  friend class android::Picture;
109 #endif
110  friend class SkPictureRecorderReplayTester; // for unit testing
111  void partialReplay(SkCanvas* canvas) const;
112 
113  bool fActivelyRecording;
114  uint32_t fFlags;
115  SkRect fCullRect;
117  std::unique_ptr<SkRecorder> fRecorder;
118  sk_sp<SkRecord> fRecord;
119  std::unique_ptr<SkMiniRecorder> fMiniRecorder;
120 
121  typedef SkNoncopyable INHERITED;
122 };
123 
124 #endif
A Canvas encapsulates all of the state about drawing into a device (bitmap).
Definition: SkCanvas.h:59
Definition: SkBBHFactory.h:15
Definition: GrContext.h:47
Base-class for objects that draw into SkCanvas.
Definition: SkDrawable.h:26
Definition: SkRect.h:404
Definition: SkPictureRecorder.h:29