1 // Copyright 2015 The Chromium 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_H_ 6 #define FLUTTER_LIB_UI_PAINTING_PICTURE_H_ 7 8 #include "flutter/fml/memory/ref_counted.h" 9 #include "flutter/flow/skia_gpu_object.h" 10 #include "flutter/lib/ui/painting/image.h" 11 #include "third_party/skia/include/core/SkPicture.h" 12 13 14 namespace flutter { 15 16 class Canvas; 17 18 class Picture : public fml::RefCountedThreadSafe<Picture> { 19 FML_FRIEND_MAKE_REF_COUNTED(Picture); 20 21 public: 22 virtual ~Picture(); 23 static fml::RefPtr<Picture> Create(SkiaGPUObject<SkPicture> picture); 24 picture()25 sk_sp<SkPicture> picture() const { return picture_.get(); } 26 27 fml::RefPtr<CanvasImage> toImage(int width, int height); 28 static Dart_Handle RasterizeToImage(sk_sp<SkPicture> picture, 29 uint32_t width, 30 uint32_t height, 31 Dart_Handle raw_image_callback); 32 33 void dispose(); 34 35 virtual size_t GetAllocationSize(); 36 37 private: 38 explicit Picture(SkiaGPUObject<SkPicture> picture); 39 40 SkiaGPUObject<SkPicture> picture_; 41 }; 42 43 } // namespace blink 44 45 #endif // FLUTTER_LIB_UI_PAINTING_PICTURE_H_ 46