5#include "flutter/lib/ui/painting/picture.h"
10#include "flutter/fml/make_copyable.h"
11#include "flutter/lib/ui/painting/canvas.h"
12#include "flutter/lib/ui/painting/display_list_deferred_image_gpu_skia.h"
13#include "flutter/lib/ui/ui_dart_state.h"
14#if IMPELLER_SUPPORTS_RENDERING
15#include "flutter/lib/ui/painting/display_list_deferred_image_gpu_impeller.h"
17#include "flutter/lib/ui/painting/display_list_image_gpu.h"
33 auto canvas_picture = fml::MakeRefCounted<Picture>(std::move(
display_list));
34 canvas_picture->AssociateWithDartWrapper(dart_handle);
38 : display_list_(
std::move(display_list)) {}
66#if IMPELLER_SUPPORTS_RENDERING
70 std::move(snapshot_delegate), std::move(raster_task_runner));
81 image_info, std::move(display_list), std::move(snapshot_delegate),
82 raster_task_runner, std::move(unref_queue));
95 auto unref_queue = dart_state->GetSkiaUnrefQueue();
96 auto snapshot_delegate = dart_state->GetSnapshotDelegate();
97 auto raster_task_runner = dart_state->GetTaskRunners().GetRasterTaskRunner();
102 std::move(snapshot_delegate), std::move(raster_task_runner),
103 std::move(unref_queue));
104 image->set_image(dl_image);
105 image->AssociateWithDartWrapper(raw_image_handle);
109 display_list_.reset();
115 return display_list_->bytes() +
sizeof(
Picture);
130 std::unique_ptr<LayerTree> layer_tree,
133 auto frame_size = layer_tree->frame_size();
135 frame_size.height(), raw_image_callback);
139 std::unique_ptr<LayerTree> layer_tree,
151 return tonic::ToDart(
"Image dimensions for scene were invalid.");
155 auto image_callback = std::make_unique<tonic::DartPersistentValue>(
156 dart_state, raw_image_callback);
157 auto unref_queue = dart_state->GetSkiaUnrefQueue();
158 auto ui_task_runner = dart_state->GetTaskRunners().GetUITaskRunner();
159 auto raster_task_runner = dart_state->GetTaskRunners().GetRasterTaskRunner();
160 auto snapshot_delegate = dart_state->GetSnapshotDelegate();
172 auto dart_state = image_callback->dart_state().lock();
184 if (!
image->isUIThreadSafe()) {
192 dart_image->set_image(
image);
200 image_callback.reset();
208 layer_tree = std::move(layer_tree)]()
mutable {
213 FML_DCHECK(picture_bounds == layer_tree->frame_size());
214 snapshot_display_list =
216 snapshot_delegate->GetTextureRegistry(),
217 snapshot_delegate->GetGrContext());
219 snapshot_delegate->MakeRasterSnapshot(
220 snapshot_display_list, picture_bounds,
223 ui_task_runner, [ui_task,
image]() { ui_task(
image); });
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
static fml::RefPtr< CanvasImage > Create()
static sk_sp< DlDeferredImageGPUImpeller > Make(std::unique_ptr< LayerTree > layer_tree, fml::TaskRunnerAffineWeakPtr< SnapshotDelegate > snapshot_delegate, fml::RefPtr< fml::TaskRunner > raster_task_runner)
static sk_sp< DlDeferredImageGPUSkia > Make(const SkImageInfo &image_info, sk_sp< DisplayList > display_list, fml::TaskRunnerAffineWeakPtr< SnapshotDelegate > snapshot_delegate, const fml::RefPtr< fml::TaskRunner > &raster_task_runner, fml::RefPtr< SkiaUnrefQueue > unref_queue)
static sk_sp< DlImageGPU > Make(SkiaGPUObject< SkImage > image)
sk_sp< DisplayList > display_list() const
static void CreateAndAssociateWithDartWrapper(Dart_Handle dart_handle, sk_sp< DisplayList > display_list)
Dart_Handle toImage(uint32_t width, uint32_t height, Dart_Handle raw_image_callback)
static Dart_Handle RasterizeLayerTreeToImage(std::unique_ptr< LayerTree > layer_tree, Dart_Handle raw_image_callback)
size_t GetAllocationSize() const
void toImageSync(uint32_t width, uint32_t height, Dart_Handle raw_image_handle)
static Dart_Handle DoRasterizeToImage(const sk_sp< DisplayList > &display_list, std::unique_ptr< LayerTree > layer_tree, uint32_t width, uint32_t height, Dart_Handle raw_image_callback)
static Dart_Handle RasterizeToImage(const sk_sp< DisplayList > &display_list, uint32_t width, uint32_t height, Dart_Handle raw_image_callback)
static void RasterizeToImageSync(sk_sp< DisplayList > display_list, uint32_t width, uint32_t height, Dart_Handle raw_image_handle)
static UIDartState * Current()
static void RunNowOrPostTask(const fml::RefPtr< fml::TaskRunner > &runner, const fml::closure &task)
struct _Dart_Handle * Dart_Handle
DART_EXPORT Dart_Handle Dart_Null(void)
DART_EXPORT bool Dart_IsNull(Dart_Handle object)
DART_EXPORT bool Dart_IsClosure(Dart_Handle object)
#define FML_LOG(severity)
#define FML_DCHECK(condition)
sk_sp< const SkImage > image
IMPLEMENT_WRAPPERTYPEINFO(flutter_gpu, FlutterGpuTestClass)
static sk_sp< DlImage > CreateDeferredImage(bool impeller, std::unique_ptr< LayerTree > layer_tree, fml::TaskRunnerAffineWeakPtr< SnapshotDelegate > snapshot_delegate, fml::RefPtr< fml::TaskRunner > raster_task_runner, fml::RefPtr< SkiaUnrefQueue > unref_queue)
internal::CopyableLambda< T > MakeCopyable(T lambda)
Dart_Handle ToDart(const T &object)
Dart_Handle DartInvoke(Dart_Handle closure, std::initializer_list< Dart_Handle > args)
static constexpr SkISize Make(int32_t w, int32_t h)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
static constexpr SkRect MakeWH(float w, float h)