image.h 1.2 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 "lib/tonic/dart_wrappable.h"
A
Adam Barth 已提交
9
#include "third_party/skia/include/core/SkImage.h"
10

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

namespace blink {
16

17 18
class CanvasImage final : public ftl::RefCountedThreadSafe<CanvasImage>,
                          public tonic::DartWrappable {
19
  DEFINE_WRAPPERTYPEINFO();
20 21
  FRIEND_MAKE_REF_COUNTED(CanvasImage);

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

28 29
  int width() { return image_->width(); }
  int height() { return image_->height(); }
30
  void dispose();
31

32 33
  const sk_sp<SkImage>& image() const { return image_; }
  void set_image(sk_sp<SkImage> image) { image_ = std::move(image); }
34

35
  static void RegisterNatives(tonic::DartLibraryNatives* natives);
36

37 38 39
 private:
  CanvasImage();

A
Adam Barth 已提交
40
  sk_sp<SkImage> image_;
41 42 43 44
};

}  // namespace blink

45
#endif  // FLUTTER_LIB_UI_PAINTING_IMAGE_H_