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
11namespace tonic {
12class DartLibraryNatives;
13} // namespace tonic
14
15namespace flutter {
16class Canvas;
17class Picture;
18
19class 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(Dart_Handle dart_picture);
30
31 void set_canvas(fml::RefPtr<Canvas> canvas) { canvas_ = std::move(canvas); }
32
33 static void RegisterNatives(tonic::DartLibraryNatives* natives);
34
35 private:
36 PictureRecorder();
37
38 SkRTreeFactory rtree_factory_;
39 SkPictureRecorder picture_recorder_;
40 fml::RefPtr<Canvas> canvas_;
41};
42
43} // namespace flutter
44
45#endif // FLUTTER_LIB_UI_PAINTING_PICTURE_RECORDER_H_
46