5#include "flutter/lib/ui/compositing/scene_builder.h"
7#include "flutter/flow/layers/backdrop_filter_layer.h"
8#include "flutter/flow/layers/clip_path_layer.h"
9#include "flutter/flow/layers/clip_rect_layer.h"
10#include "flutter/flow/layers/clip_rrect_layer.h"
11#include "flutter/flow/layers/color_filter_layer.h"
12#include "flutter/flow/layers/container_layer.h"
13#include "flutter/flow/layers/display_list_layer.h"
14#include "flutter/flow/layers/image_filter_layer.h"
15#include "flutter/flow/layers/layer.h"
16#include "flutter/flow/layers/layer_tree.h"
17#include "flutter/flow/layers/opacity_layer.h"
18#include "flutter/flow/layers/performance_overlay_layer.h"
19#include "flutter/flow/layers/platform_view_layer.h"
20#include "flutter/flow/layers/shader_mask_layer.h"
21#include "flutter/flow/layers/texture_layer.h"
22#include "flutter/flow/layers/transform_layer.h"
23#include "flutter/fml/build_config.h"
24#include "flutter/lib/ui/floating_point.h"
25#include "flutter/lib/ui/painting/matrix.h"
26#include "flutter/lib/ui/painting/shader.h"
36SceneBuilder::SceneBuilder() {
39 PushLayer(std::make_shared<flutter::ContainerLayer>());
45 tonic::Float64List& matrix4,
48 auto layer = std::make_shared<flutter::TransformLayer>(
sk_matrix);
54 if (oldLayer && oldLayer->Layer()) {
55 layer->AssignOldLayer(oldLayer->Layer().
get());
64 auto layer = std::make_shared<flutter::TransformLayer>(
sk_matrix);
68 if (oldLayer && oldLayer->Layer()) {
69 layer->AssignOldLayer(oldLayer->Layer().
get());
84 std::make_shared<flutter::ClipRectLayer>(clipRect, clip_behavior);
88 if (oldLayer && oldLayer->Layer()) {
89 layer->AssignOldLayer(oldLayer->Layer().
get());
99 std::make_shared<flutter::ClipRRectLayer>(rrect.sk_rrect, clip_behavior);
103 if (oldLayer && oldLayer->Layer()) {
104 layer->AssignOldLayer(oldLayer->Layer().
get());
115 std::make_shared<flutter::ClipPathLayer>(
path->path(), clip_behavior);
119 if (oldLayer && oldLayer->Layer()) {
120 layer->AssignOldLayer(oldLayer->Layer().
get());
129 auto layer = std::make_shared<flutter::OpacityLayer>(
134 if (oldLayer && oldLayer->Layer()) {
135 layer->AssignOldLayer(oldLayer->Layer().
get());
143 std::make_shared<flutter::ColorFilterLayer>(
color_filter->filter());
147 if (oldLayer && oldLayer->Layer()) {
148 layer->AssignOldLayer(oldLayer->Layer().
get());
157 auto layer = std::make_shared<flutter::ImageFilterLayer>(
162 if (oldLayer && oldLayer->Layer()) {
163 layer->AssignOldLayer(oldLayer->Layer().
get());
172 auto layer = std::make_shared<flutter::BackdropFilterLayer>(
177 if (oldLayer && oldLayer->Layer()) {
178 layer->AssignOldLayer(oldLayer->Layer().
get());
185 double maskRectRight,
187 double maskRectBottom,
189 int filterQualityIndex,
195 auto layer = std::make_shared<flutter::ShaderMaskLayer>(
200 if (oldLayer && oldLayer->Layer()) {
201 layer->AssignOldLayer(oldLayer->Layer().
get());
206 AddLayer(retainedLayer->Layer());
224 if (picture->display_list()) {
225 auto layer = std::make_unique<flutter::DisplayListLayer>(
227 !!(hints & 1), !!(hints & 2));
228 AddLayer(std::move(layer));
238 int filterQualityIndex) {
240 auto layer = std::make_unique<flutter::TextureLayer>(
244 AddLayer(std::move(layer));
252 auto layer = std::make_unique<flutter::PlatformViewLayer>(
255 AddLayer(std::move(layer));
266 std::make_unique<flutter::PerformanceOverlayLayer>(enabledOptions);
267 layer->set_paint_bounds(rect);
268 AddLayer(std::move(layer));
272 rasterizer_tracing_threshold_ = frameInterval;
287 scene_handle, std::move(layer_stack_[0]), rasterizer_tracing_threshold_,
288 checkerboard_raster_cache_images_, checkerboard_offscreen_layers_);
289 layer_stack_.clear();
293void SceneBuilder::AddLayer(std::shared_ptr<Layer> layer) {
296 if (!layer_stack_.empty()) {
297 layer_stack_.back()->Add(std::move(layer));
301void SceneBuilder::PushLayer(std::shared_ptr<ContainerLayer> layer) {
303 layer_stack_.push_back(std::move(layer));
306void SceneBuilder::PopLayer() {
308 if (layer_stack_.size() > 1) {
309 layer_stack_.pop_back();
static sk_sp< SkImage > color_filter(const SkImage *image, SkColorFilter *colorFilter)
static bool left(const SkPoint &p0, const SkPoint &p1)
static bool right(const SkPoint &p0, const SkPoint &p1)
static SkMatrix Translate(SkScalar dx, SkScalar dy)
static void MakeRetained(Dart_Handle dart_handle, const std::shared_ptr< flutter::ContainerLayer > &layer)
const std::shared_ptr< const DlImageFilter > filter() const
static DlImageSampling SamplingFromIndex(int filterQualityIndex)
void pushOffset(Dart_Handle layer_handle, double dx, double dy, const fml::RefPtr< EngineLayer > &oldLayer)
void pushBackdropFilter(Dart_Handle layer_handle, ImageFilter *filter, int blendMode, const fml::RefPtr< EngineLayer > &oldLayer)
void addTexture(double dx, double dy, double width, double height, int64_t textureId, bool freeze, int filterQuality)
void setRasterizerTracingThreshold(uint32_t frameInterval)
void build(Dart_Handle scene_handle)
void pushShaderMask(Dart_Handle layer_handle, Shader *shader, double maskRectLeft, double maskRectRight, double maskRectTop, double maskRectBottom, int blendMode, int filterQualityIndex, const fml::RefPtr< EngineLayer > &oldLayer)
void pushClipRect(Dart_Handle layer_handle, double left, double right, double top, double bottom, int clipBehavior, const fml::RefPtr< EngineLayer > &oldLayer)
void setCheckerboardRasterCacheImages(bool checkerboard)
void pushClipPath(Dart_Handle layer_handle, const CanvasPath *path, int clipBehavior, const fml::RefPtr< EngineLayer > &oldLayer)
void addPlatformView(double dx, double dy, double width, double height, int64_t viewId)
void pushClipRRect(Dart_Handle layer_handle, const RRect &rrect, int clipBehavior, const fml::RefPtr< EngineLayer > &oldLayer)
void addRetained(const fml::RefPtr< EngineLayer > &retainedLayer)
void pushImageFilter(Dart_Handle layer_handle, const ImageFilter *image_filter, double dx, double dy, const fml::RefPtr< EngineLayer > &oldLayer)
void addPicture(double dx, double dy, Picture *picture, int hints)
void addPerformanceOverlay(uint64_t enabledOptions, double left, double right, double top, double bottom)
void pushTransform(Dart_Handle layer_handle, tonic::Float64List &matrix4, const fml::RefPtr< EngineLayer > &oldLayer)
void pushColorFilter(Dart_Handle layer_handle, const ColorFilter *color_filter, const fml::RefPtr< EngineLayer > &oldLayer)
void pushOpacity(Dart_Handle layer_handle, int alpha, double dx, double dy, const fml::RefPtr< EngineLayer > &oldLayer)
void setCheckerboardOffscreenLayers(bool checkerboard)
static void create(Dart_Handle scene_handle, std::shared_ptr< flutter::Layer > rootLayer, uint32_t rasterizerTracingThreshold, bool checkerboardRasterCacheImages, bool checkerboardOffscreenLayers)
virtual std::shared_ptr< DlColorSource > shader(DlImageSampling)=0
struct _Dart_Handle * Dart_Handle
#define IMPLEMENT_WRAPPERTYPEINFO(LibraryName, ClassName)
#define FML_DCHECK(condition)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
static float SafeNarrow(double value)
SkM44 ToSkM44(const tonic::Float64List &matrix4)
static constexpr SkPoint Make(float x, float y)
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
static constexpr SkSize Make(SkScalar w, SkScalar h)
static void checkerboard(SkCanvas *canvas, SkColor c1, SkColor c2, int size)