image.h 1.3 KB
Newer Older
1 2 3 4
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6
#ifndef FLUTTER_LIB_UI_PAINTING_IMAGE_H_
#define FLUTTER_LIB_UI_PAINTING_IMAGE_H_
7

8
#include "flutter/flow/skia_gpu_object.h"
9
#include "flutter/lib/ui/dart_wrapper.h"
10
#include "flutter/lib/ui/ui_dart_state.h"
A
Adam Barth 已提交
11
#include "third_party/skia/include/core/SkImage.h"
12

13
namespace tonic {
14
class DartLibraryNatives;
15 16 17
}  // namespace tonic

namespace blink {
18

19
class CanvasImage final : public RefCountedDartWrappable<CanvasImage> {
20
  DEFINE_WRAPPERTYPEINFO();
21
  FML_FRIEND_MAKE_REF_COUNTED(CanvasImage);
22

23 24
 public:
  ~CanvasImage() override;
25 26
  static fml::RefPtr<CanvasImage> Create() {
    return fml::MakeRefCounted<CanvasImage>();
27
  }
28

29 30 31 32
  int width() { return image_.get()->width(); }

  int height() { return image_.get()->height(); }

33
  Dart_Handle toByteData(int format, Dart_Handle callback);
34

35
  void dispose();
36

37 38 39 40
  sk_sp<SkImage> image() const { return image_.get(); }
  void set_image(flow::SkiaGPUObject<SkImage> image) {
    image_ = std::move(image);
  }
41

42 43
  virtual size_t GetAllocationSize() override;

44
  static void RegisterNatives(tonic::DartLibraryNatives* natives);
45

46 47 48
 private:
  CanvasImage();

49
  flow::SkiaGPUObject<SkImage> image_;
50 51 52 53
};

}  // namespace blink

54
#endif  // FLUTTER_LIB_UI_PAINTING_IMAGE_H_