picture_recorder.h 1.2 KB
Newer Older
M
Michael Goderbauer 已提交
1
// Copyright 2013 The Flutter Authors. All rights reserved.
2 3 4 5 6 7
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef FLUTTER_LIB_UI_PAINTING_PICTURE_RECORDER_H_
#define FLUTTER_LIB_UI_PAINTING_PICTURE_RECORDER_H_

8
#include "flutter/lib/ui/dart_wrapper.h"
9 10
#include "third_party/skia/include/core/SkPictureRecorder.h"

11 12 13 14
namespace tonic {
class DartLibraryNatives;
}  // namespace tonic

15 16 17 18
namespace blink {
class Canvas;
class Picture;

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 31
  bool isRecording();

32
  void set_canvas(fml::RefPtr<Canvas> canvas) { canvas_ = std::move(canvas); }
33

34
  static void RegisterNatives(tonic::DartLibraryNatives* natives);
35 36 37 38 39 40

 private:
  PictureRecorder();

  SkRTreeFactory rtree_factory_;
  SkPictureRecorder picture_recorder_;
41
  fml::RefPtr<Canvas> canvas_;
42 43
};

44
}  // namespace blink
45 46

#endif  // FLUTTER_LIB_UI_PAINTING_PICTURE_RECORDER_H_