5#include "flutter/lib/ui/compositing/scene.h"
7#include "flutter/fml/trace_event.h"
8#include "flutter/lib/ui/painting/display_list_deferred_image_gpu_skia.h"
9#include "flutter/lib/ui/painting/image.h"
10#include "flutter/lib/ui/painting/picture.h"
11#include "flutter/lib/ui/ui_dart_state.h"
12#include "flutter/lib/ui/window/platform_configuration.h"
13#if IMPELLER_SUPPORTS_RENDERING
14#include "flutter/lib/ui/painting/display_list_deferred_image_gpu_impeller.h"
28 std::shared_ptr<flutter::Layer> rootLayer) {
29 auto scene = fml::MakeRefCounted<Scene>(std::move(rootLayer));
30 scene->AssociateWithDartWrapper(scene_handle);
33Scene::Scene(std::shared_ptr<flutter::Layer> rootLayer) {
34 layer_tree_root_layer_ = std::move(rootLayer);
40 return layer_tree_root_layer_ !=
nullptr;
44 layer_tree_root_layer_.reset();
57 Scene::RasterizeToImage(
width,
height, raw_image_handle);
76 std::unique_ptr<LayerTree> layer_tree,
80#if IMPELLER_SUPPORTS_RENDERING
83 std::move(snapshot_delegate),
84 std::move(raster_task_runner));
92 const auto& frame_size = layer_tree->frame_size();
97 image_info, std::move(layer_tree), std::move(snapshot_delegate),
98 raster_task_runner, std::move(unref_queue));
102void Scene::RasterizeToImage(uint32_t
width,
109 auto unref_queue = dart_state->GetSkiaUnrefQueue();
110 auto snapshot_delegate = dart_state->GetSnapshotDelegate();
111 auto raster_task_runner = dart_state->GetTaskRunners().GetRasterTaskRunner();
115 dart_state->IsImpellerEnabled(), BuildLayerTree(
width,
height),
116 std::move(snapshot_delegate), std::move(raster_task_runner),
117 std::move(unref_queue));
118 image->set_image(dl_image);
119 image->AssociateWithDartWrapper(raw_image_handle);
127std::unique_ptr<LayerTree> Scene::BuildLayerTree(uint32_t
width,
132 return std::make_unique<LayerTree>(layer_tree_root_layer_,
@ 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 > MakeFromLayerTree(const SkImageInfo &image_info, std::unique_ptr< LayerTree > layer_tree, fml::TaskRunnerAffineWeakPtr< SnapshotDelegate > snapshot_delegate, const fml::RefPtr< fml::TaskRunner > &raster_task_runner, fml::RefPtr< SkiaUnrefQueue > unref_queue)
static Dart_Handle RasterizeLayerTreeToImage(std::unique_ptr< LayerTree > layer_tree, Dart_Handle raw_image_callback)
std::unique_ptr< flutter::LayerTree > takeLayerTree(uint64_t width, uint64_t height)
Dart_Handle toImage(uint32_t width, uint32_t height, Dart_Handle raw_image_handle)
static void create(Dart_Handle scene_handle, std::shared_ptr< flutter::Layer > rootLayer)
Dart_Handle toImageSync(uint32_t width, uint32_t height, Dart_Handle raw_image_handle)
static UIDartState * Current()
struct _Dart_Handle * Dart_Handle
DART_EXPORT Dart_Handle Dart_Null(void)
#define FML_LOG(severity)
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)
Dart_Handle ToDart(const T &object)
static constexpr SkISize Make(int32_t w, int32_t h)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
#define TRACE_EVENT0(category_group, name)