Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
scene_builder.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter 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_COMPOSITING_SCENE_BUILDER_H_
6#define FLUTTER_LIB_UI_COMPOSITING_SCENE_BUILDER_H_
7
8#include <cstdint>
9#include <memory>
10#include <vector>
11
12#include "flutter/flow/layers/container_layer.h"
13#include "flutter/lib/ui/compositing/scene.h"
14#include "flutter/lib/ui/dart_wrapper.h"
15#include "flutter/lib/ui/painting/color_filter.h"
16#include "flutter/lib/ui/painting/engine_layer.h"
17#include "flutter/lib/ui/painting/image_filter.h"
18#include "flutter/lib/ui/painting/path.h"
19#include "flutter/lib/ui/painting/picture.h"
20#include "flutter/lib/ui/painting/rrect.h"
21#include "flutter/lib/ui/painting/shader.h"
23
24namespace flutter {
25
26class SceneBuilder : public RefCountedDartWrappable<SceneBuilder> {
27 DEFINE_WRAPPERTYPEINFO();
29
30 public:
31 static void Create(Dart_Handle wrapper) {
33 auto res = fml::MakeRefCounted<SceneBuilder>();
34 res->AssociateWithDartWrapper(wrapper);
35 }
36
37 ~SceneBuilder() override;
38
40 Dart_Handle matrix4_handle,
41 const fml::RefPtr<EngineLayer>& oldLayer) {
42 tonic::Float64List matrix4(matrix4_handle);
43 pushTransform(layer_handle, matrix4, oldLayer);
44 }
45 void pushTransform(Dart_Handle layer_handle,
46 tonic::Float64List& matrix4,
47 const fml::RefPtr<EngineLayer>& oldLayer);
48 void pushOffset(Dart_Handle layer_handle,
49 double dx,
50 double dy,
51 const fml::RefPtr<EngineLayer>& oldLayer);
52 void pushClipRect(Dart_Handle layer_handle,
53 double left,
54 double right,
55 double top,
56 double bottom,
57 int clipBehavior,
58 const fml::RefPtr<EngineLayer>& oldLayer);
59 void pushClipRRect(Dart_Handle layer_handle,
60 const RRect& rrect,
61 int clipBehavior,
62 const fml::RefPtr<EngineLayer>& oldLayer);
63 void pushClipPath(Dart_Handle layer_handle,
64 const CanvasPath* path,
65 int clipBehavior,
66 const fml::RefPtr<EngineLayer>& oldLayer);
67 void pushOpacity(Dart_Handle layer_handle,
68 int alpha,
69 double dx,
70 double dy,
71 const fml::RefPtr<EngineLayer>& oldLayer);
72 void pushColorFilter(Dart_Handle layer_handle,
74 const fml::RefPtr<EngineLayer>& oldLayer);
75 void pushImageFilter(Dart_Handle layer_handle,
76 const ImageFilter* image_filter,
77 double dx,
78 double dy,
79 const fml::RefPtr<EngineLayer>& oldLayer);
80 void pushBackdropFilter(Dart_Handle layer_handle,
81 ImageFilter* filter,
82 int blendMode,
83 const fml::RefPtr<EngineLayer>& oldLayer);
84 void pushShaderMask(Dart_Handle layer_handle,
85 Shader* shader,
86 double maskRectLeft,
87 double maskRectRight,
88 double maskRectTop,
89 double maskRectBottom,
90 int blendMode,
91 int filterQualityIndex,
92 const fml::RefPtr<EngineLayer>& oldLayer);
93
94 void addRetained(const fml::RefPtr<EngineLayer>& retainedLayer);
95
96 void pop();
97
98 void addPerformanceOverlay(uint64_t enabledOptions,
99 double left,
100 double right,
101 double top,
102 double bottom);
103
104 void addPicture(double dx, double dy, Picture* picture, int hints);
105
106 void addTexture(double dx,
107 double dy,
108 double width,
109 double height,
110 int64_t textureId,
111 bool freeze,
112 int filterQuality);
113
114 void addPlatformView(double dx,
115 double dy,
116 double width,
117 double height,
118 int64_t viewId);
119
120 void setRasterizerTracingThreshold(uint32_t frameInterval);
123
124 void build(Dart_Handle scene_handle);
125
126 const std::vector<std::shared_ptr<ContainerLayer>>& layer_stack() {
127 return layer_stack_;
128 }
129
130 private:
131 SceneBuilder();
132
133 void AddLayer(std::shared_ptr<Layer> layer);
134 void PushLayer(std::shared_ptr<ContainerLayer> layer);
135 void PopLayer();
136
137 std::vector<std::shared_ptr<ContainerLayer>> layer_stack_;
138 int rasterizer_tracing_threshold_ = 0;
139 bool checkerboard_raster_cache_images_ = false;
140 bool checkerboard_offscreen_layers_ = false;
141
143};
144
145} // namespace flutter
146
147#endif // FLUTTER_LIB_UI_COMPOSITING_SCENE_BUILDER_H_
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)
void pushOffset(Dart_Handle layer_handle, double dx, double dy, const fml::RefPtr< EngineLayer > &oldLayer)
void pushTransformHandle(Dart_Handle layer_handle, Dart_Handle matrix4_handle, const fml::RefPtr< EngineLayer > &oldLayer)
~SceneBuilder() override
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 pushShaderMask(Dart_Handle layer_handle, Shader *shader, double maskRectLeft, double maskRectRight, double maskRectTop, double maskRectBottom, int blendMode, int filterQualityIndex, const fml::RefPtr< EngineLayer > &oldLayer)
const std::vector< std::shared_ptr< ContainerLayer > > & layer_stack()
static void Create(Dart_Handle wrapper)
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 ThrowIfUIOperationsProhibited()
struct _Dart_Handle * Dart_Handle
Definition dart_api.h:258
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27
Definition build.py:1
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
Definition switches.h:57
#define FML_FRIEND_MAKE_REF_COUNTED(T)
int32_t height
int32_t width
static void checkerboard(SkCanvas *canvas, SkColor c1, SkColor c2, int size)