Skia
2D Graphics Library
SkPictureRecorder.h
Go to the documentation of this file.
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 "include/core/SkRect.h"
12 #include "include/core/SkRefCnt.h"
13 #include "include/core/SkScalar.h"
14 #include "include/private/base/SkAPI.h"
15 
16 #include <memory>
17 
18 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
19 namespace android {
20  class Picture;
21 };
22 #endif
23 
24 class SkBBHFactory;
25 class SkBBoxHierarchy;
26 class SkCanvas;
27 class SkDrawable;
28 class SkPicture;
29 class SkRecord;
30 class SkRecorder;
31 
32 class SK_API SkPictureRecorder {
33 public:
36 
45 
46  SkCanvas* beginRecording(const SkRect& bounds, SkBBHFactory* bbhFactory = nullptr);
47 
49  SkBBHFactory* bbhFactory = nullptr) {
50  return this->beginRecording(SkRect::MakeWH(width, height), bbhFactory);
51  }
52 
57 
69 
80 
92 
93 private:
94  void reset();
95 
99 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
100  friend class android::Picture;
101 #endif
102  friend class SkPictureRecorderReplayTester; // for unit testing
103  void partialReplay(SkCanvas* canvas) const;
104 
105  bool fActivelyRecording;
106  SkRect fCullRect;
108  std::unique_ptr<SkRecorder> fRecorder;
109  sk_sp<SkRecord> fRecord;
110 
112  SkPictureRecorder& operator=(SkPictureRecorder&&) = delete;
113 };
114 
115 #endif
float SkScalar
Definition: SkScalar.h:14
Definition: SkBBHFactory.h:48
Definition: SkBBHFactory.h:20
SkCanvas provides an interface for drawing, and how the drawing is clipped and transformed.
Definition: SkCanvas.h:99
Base-class for objects that draw into SkCanvas.
Definition: SkDrawable.h:37
Definition: SkPictureRecorder.h:32
sk_sp< SkDrawable > finishRecordingAsDrawable()
Signal that the caller is done recording.
SkCanvas * getRecordingCanvas()
Returns the recording canvas if one is active, or NULL if recording is not active.
SkCanvas * beginRecording(const SkRect &bounds, SkBBHFactory *bbhFactory=nullptr)
sk_sp< SkPicture > finishRecordingAsPicture()
Signal that the caller is done recording.
SkCanvas * beginRecording(SkScalar width, SkScalar height, SkBBHFactory *bbhFactory=nullptr)
Definition: SkPictureRecorder.h:48
SkCanvas * beginRecording(const SkRect &bounds, sk_sp< SkBBoxHierarchy > bbh)
Returns the canvas that records the drawing commands.
sk_sp< SkPicture > finishRecordingAsPictureWithCull(const SkRect &cullRect)
Signal that the caller is done recording, and update the cull rect to use for bounding box hierarchy ...
SkPicture records drawing commands made to SkCanvas.
Definition: SkPicture.h:44
SkRect holds four float coordinates describing the upper and lower bounds of a rectangle.
Definition: SkRect.h:582
static constexpr SkRect MakeWH(float w, float h)
Returns constructed SkRect set to float values (0, 0, w, h).
Definition: SkRect.h:609