• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef FLUTTER_LIB_UI_PAINTING_PICTURE_RECORDER_H_
6 #define FLUTTER_LIB_UI_PAINTING_PICTURE_RECORDER_H_
7 
8 #include "flutter/lib/ui/dart_wrapper.h"
9 #include "third_party/skia/include/core/SkPictureRecorder.h"
10 
11 namespace tonic {
12 class DartLibraryNatives;
13 }  // namespace tonic
14 
15 namespace flutter {
16 class Canvas;
17 class Picture;
18 
19 class PictureRecorder : public RefCountedDartWrappable<PictureRecorder> {
20   DEFINE_WRAPPERTYPEINFO();
21   FML_FRIEND_MAKE_REF_COUNTED(PictureRecorder);
22 
23  public:
24   static fml::RefPtr<PictureRecorder> Create();
25 
26   ~PictureRecorder() override;
27 
28   SkCanvas* BeginRecording(SkRect bounds);
29   fml::RefPtr<Picture> endRecording();
30   bool isRecording();
31 
set_canvas(fml::RefPtr<Canvas> canvas)32   void set_canvas(fml::RefPtr<Canvas> canvas) { canvas_ = std::move(canvas); }
33 
34   static void RegisterNatives(tonic::DartLibraryNatives* natives);
35 
36  private:
37   PictureRecorder();
38 
39   SkRTreeFactory rtree_factory_;
40   SkPictureRecorder picture_recorder_;
41   fml::RefPtr<Canvas> canvas_;
42 };
43 
44 }  // namespace flutter
45 
46 #endif  // FLUTTER_LIB_UI_PAINTING_PICTURE_RECORDER_H_
47