Flutter Engine
flutter::SceneBuilder Class Reference

#include <scene_builder.h>

Inheritance diagram for flutter::SceneBuilder:
flutter::RefCountedDartWrappable< SceneBuilder > fml::RefCountedThreadSafe< SceneBuilder > tonic::DartWrappable fml::internal::RefCountedThreadSafeBase

Public Member Functions

 ~SceneBuilder () override
 
void pushTransform (Dart_Handle layer_handle, tonic::Float64List &matrix4)
 
void pushOffset (Dart_Handle layer_handle, double dx, double dy)
 
void pushClipRect (Dart_Handle layer_handle, double left, double right, double top, double bottom, int clipBehavior)
 
void pushClipRRect (Dart_Handle layer_handle, const RRect &rrect, int clipBehavior)
 
void pushClipPath (Dart_Handle layer_handle, const CanvasPath *path, int clipBehavior)
 
void pushOpacity (Dart_Handle layer_handle, int alpha, double dx=0, double dy=0)
 
void pushColorFilter (Dart_Handle layer_handle, const ColorFilter *color_filter)
 
void pushImageFilter (Dart_Handle layer_handle, const ImageFilter *image_filter)
 
void pushBackdropFilter (Dart_Handle layer_handle, ImageFilter *filter)
 
void pushShaderMask (Dart_Handle layer_handle, Shader *shader, double maskRectLeft, double maskRectRight, double maskRectTop, double maskRectBottom, int blendMode)
 
void pushPhysicalShape (Dart_Handle layer_handle, const CanvasPath *path, double elevation, int color, int shadowColor, int clipBehavior)
 
void addRetained (fml::RefPtr< EngineLayer > retainedLayer)
 
void pop ()
 
void addPerformanceOverlay (uint64_t enabledOptions, double left, double right, double top, double bottom)
 
void addPicture (double dx, double dy, Picture *picture, int hints)
 
void addTexture (double dx, double dy, double width, double height, int64_t textureId, bool freeze, int filterQuality)
 
void addPlatformView (double dx, double dy, double width, double height, int64_t viewId)
 
void setRasterizerTracingThreshold (uint32_t frameInterval)
 
void setCheckerboardRasterCacheImages (bool checkerboard)
 
void setCheckerboardOffscreenLayers (bool checkerboard)
 
void build (Dart_Handle scene_handle)
 
- Public Member Functions inherited from flutter::RefCountedDartWrappable< SceneBuilder >
virtual void RetainDartWrappableReference () const override
 
virtual void ReleaseDartWrappableReference () const override
 
- Public Member Functions inherited from fml::RefCountedThreadSafe< SceneBuilder >
void Release () const
 
- Public Member Functions inherited from fml::internal::RefCountedThreadSafeBase
void AddRef () const
 
bool HasOneRef () const
 
void AssertHasOneRef () const
 
- Public Member Functions inherited from tonic::DartWrappable
 DartWrappable ()
 
virtual const DartWrapperInfoGetDartWrapperInfo () const =0
 
virtual size_t GetAllocationSize () const
 
Dart_Handle CreateDartWrapper (DartState *dart_state)
 
void AssociateWithDartWrapper (Dart_Handle wrappable)
 
void ClearDartWrapper ()
 
Dart_WeakPersistentHandle dart_wrapper () const
 

Static Public Member Functions

static fml::RefPtr< SceneBuildercreate ()
 
static void RegisterNatives (tonic::DartLibraryNatives *natives)
 

Additional Inherited Members

- Public Types inherited from tonic::DartWrappable
enum  DartNativeFields {
  kPeerIndex,
  kWrapperInfoIndex,
  kNumberOfNativeFields
}
 
- Protected Member Functions inherited from fml::RefCountedThreadSafe< SceneBuilder >
 RefCountedThreadSafe ()
 
 ~RefCountedThreadSafe ()
 
- Protected Member Functions inherited from fml::internal::RefCountedThreadSafeBase
 RefCountedThreadSafeBase ()
 
 ~RefCountedThreadSafeBase ()
 
bool Release () const
 
void Adopt ()
 
- Protected Member Functions inherited from tonic::DartWrappable
virtual ~DartWrappable ()
 
- Static Protected Member Functions inherited from tonic::DartWrappable
static Dart_PersistentHandle GetTypeForWrapper (tonic::DartState *dart_state, const tonic::DartWrapperInfo &wrapper_info)
 

Detailed Description

Definition at line 30 of file scene_builder.h.

Constructor & Destructor Documentation

◆ ~SceneBuilder()

flutter::SceneBuilder::~SceneBuilder ( )
overridedefault

Referenced by create(), and RegisterNatives().

Member Function Documentation

◆ addPerformanceOverlay()

void flutter::SceneBuilder::addPerformanceOverlay ( uint64_t  enabledOptions,
double  left,
double  right,
double  top,
double  bottom 
)

Definition at line 264 of file scene_builder.cc.

Referenced by create().

268  {
269  SkRect rect = SkRect::MakeLTRB(left, top, right, bottom);
270  auto layer =
271  std::make_unique<flutter::PerformanceOverlayLayer>(enabledOptions);
272  layer->set_paint_bounds(rect);
273  AddLayer(std::move(layer));
274 }

◆ addPicture()

void flutter::SceneBuilder::addPicture ( double  dx,
double  dy,
Picture picture,
int  hints 
)

Definition at line 214 of file scene_builder.cc.

References flutter::UIDartState::CreateGPUObject(), and flutter::Picture::picture().

Referenced by create().

217  {
218  SkPoint offset = SkPoint::Make(dx, dy);
219  SkRect pictureRect = picture->picture()->cullRect();
220  pictureRect.offset(offset.x(), offset.y());
221  auto layer = std::make_unique<flutter::PictureLayer>(
222  offset, UIDartState::CreateGPUObject(picture->picture()), !!(hints & 1),
223  !!(hints & 2));
224  AddLayer(std::move(layer));
225 }
static flutter::SkiaGPUObject< T > CreateGPUObject(sk_sp< T > object)
Definition: ui_dart_state.h:78

◆ addPlatformView()

void flutter::SceneBuilder::addPlatformView ( double  dx,
double  dy,
double  width,
double  height,
int64_t  viewId 
)

Definition at line 240 of file scene_builder.cc.

References height, flutter::SceneHost::id(), and width.

Referenced by create().

244  {
245  auto layer = std::make_unique<flutter::PlatformViewLayer>(
246  SkPoint::Make(dx, dy), SkSize::Make(width, height), viewId);
247  AddLayer(std::move(layer));
248 }
int32_t height
int32_t width

◆ addRetained()

void flutter::SceneBuilder::addRetained ( fml::RefPtr< EngineLayer retainedLayer)

Definition at line 206 of file scene_builder.cc.

Referenced by create().

206  {
207  AddLayer(retainedLayer->Layer());
208 }

◆ addTexture()

void flutter::SceneBuilder::addTexture ( double  dx,
double  dy,
double  width,
double  height,
int64_t  textureId,
bool  freeze,
int  filterQuality 
)

Definition at line 227 of file scene_builder.cc.

Referenced by create().

233  {
234  auto layer = std::make_unique<flutter::TextureLayer>(
235  SkPoint::Make(dx, dy), SkSize::Make(width, height), textureId, freeze,
236  static_cast<SkFilterQuality>(filterQuality));
237  AddLayer(std::move(layer));
238 }
int32_t height
int32_t width

◆ build()

void flutter::SceneBuilder::build ( Dart_Handle  scene_handle)

Definition at line 288 of file scene_builder.cc.

References tonic::DartWrappable::ClearDartWrapper(), flutter::Scene::create(), and FML_DCHECK.

Referenced by create().

288  {
289  FML_DCHECK(layer_stack_.size() >= 1);
290 
291  Scene::create(scene_handle, layer_stack_[0], rasterizer_tracing_threshold_,
292  checkerboard_raster_cache_images_,
293  checkerboard_offscreen_layers_);
294  ClearDartWrapper(); // may delete this object.
295 }
static void create(Dart_Handle scene_handle, std::shared_ptr< flutter::Layer > rootLayer, uint32_t rasterizerTracingThreshold, bool checkerboardRasterCacheImages, bool checkerboardOffscreenLayers)
Definition: scene.cc:30
#define FML_DCHECK(condition)
Definition: logging.h:86

◆ create()

◆ pop()

void flutter::SceneBuilder::pop ( )

Definition at line 210 of file scene_builder.cc.

Referenced by create().

210  {
211  PopLayer();
212 }

◆ pushBackdropFilter()

void flutter::SceneBuilder::pushBackdropFilter ( Dart_Handle  layer_handle,
ImageFilter filter 
)

Definition at line 170 of file scene_builder.cc.

References flutter::ImageFilter::filter(), and flutter::EngineLayer::MakeRetained().

Referenced by create().

171  {
172  auto layer = std::make_shared<flutter::BackdropFilterLayer>(filter->filter());
173  PushLayer(layer);
174  EngineLayer::MakeRetained(layer_handle, layer);
175 }
static fml::RefPtr< EngineLayer > MakeRetained(std::shared_ptr< flutter::ContainerLayer > layer)
Definition: engine_layer.h:27

◆ pushClipPath()

void flutter::SceneBuilder::pushClipPath ( Dart_Handle  layer_handle,
const CanvasPath path,
int  clipBehavior 
)

Definition at line 133 of file scene_builder.cc.

References FML_DCHECK, flutter::EngineLayer::MakeRetained(), flutter::none, and flutter::CanvasPath::path().

Referenced by create().

135  {
136  flutter::Clip clip_behavior = static_cast<flutter::Clip>(clipBehavior);
137  FML_DCHECK(clip_behavior != flutter::Clip::none);
138  auto layer =
139  std::make_shared<flutter::ClipPathLayer>(path->path(), clip_behavior);
140  PushLayer(layer);
141  EngineLayer::MakeRetained(layer_handle, layer);
142 }
DEF_SWITCHES_START snapshot asset path
Definition: switches.h:32
#define FML_DCHECK(condition)
Definition: logging.h:86
static fml::RefPtr< EngineLayer > MakeRetained(std::shared_ptr< flutter::ContainerLayer > layer)
Definition: engine_layer.h:27
Clip
Definition: layer.h:41

◆ pushClipRect()

void flutter::SceneBuilder::pushClipRect ( Dart_Handle  layer_handle,
double  left,
double  right,
double  top,
double  bottom,
int  clipBehavior 
)

Definition at line 109 of file scene_builder.cc.

References flutter::EngineLayer::MakeRetained().

Referenced by create().

114  {
115  SkRect clipRect = SkRect::MakeLTRB(left, top, right, bottom);
116  flutter::Clip clip_behavior = static_cast<flutter::Clip>(clipBehavior);
117  auto layer =
118  std::make_shared<flutter::ClipRectLayer>(clipRect, clip_behavior);
119  PushLayer(layer);
120  EngineLayer::MakeRetained(layer_handle, layer);
121 }
static fml::RefPtr< EngineLayer > MakeRetained(std::shared_ptr< flutter::ContainerLayer > layer)
Definition: engine_layer.h:27
Clip
Definition: layer.h:41

◆ pushClipRRect()

void flutter::SceneBuilder::pushClipRRect ( Dart_Handle  layer_handle,
const RRect rrect,
int  clipBehavior 
)

Definition at line 123 of file scene_builder.cc.

References flutter::EngineLayer::MakeRetained(), and flutter::RRect::sk_rrect.

Referenced by create().

125  {
126  flutter::Clip clip_behavior = static_cast<flutter::Clip>(clipBehavior);
127  auto layer =
128  std::make_shared<flutter::ClipRRectLayer>(rrect.sk_rrect, clip_behavior);
129  PushLayer(layer);
130  EngineLayer::MakeRetained(layer_handle, layer);
131 }
static fml::RefPtr< EngineLayer > MakeRetained(std::shared_ptr< flutter::ContainerLayer > layer)
Definition: engine_layer.h:27
Clip
Definition: layer.h:41

◆ pushColorFilter()

void flutter::SceneBuilder::pushColorFilter ( Dart_Handle  layer_handle,
const ColorFilter color_filter 
)

Definition at line 154 of file scene_builder.cc.

References flutter::ColorFilter::filter(), and flutter::EngineLayer::MakeRetained().

Referenced by create().

155  {
156  auto layer =
157  std::make_shared<flutter::ColorFilterLayer>(color_filter->filter());
158  PushLayer(layer);
159  EngineLayer::MakeRetained(layer_handle, layer);
160 }
static fml::RefPtr< EngineLayer > MakeRetained(std::shared_ptr< flutter::ContainerLayer > layer)
Definition: engine_layer.h:27

◆ pushImageFilter()

void flutter::SceneBuilder::pushImageFilter ( Dart_Handle  layer_handle,
const ImageFilter image_filter 
)

Definition at line 162 of file scene_builder.cc.

References flutter::ImageFilter::filter(), and flutter::EngineLayer::MakeRetained().

Referenced by create().

163  {
164  auto layer =
165  std::make_shared<flutter::ImageFilterLayer>(image_filter->filter());
166  PushLayer(layer);
167  EngineLayer::MakeRetained(layer_handle, layer);
168 }
static fml::RefPtr< EngineLayer > MakeRetained(std::shared_ptr< flutter::ContainerLayer > layer)
Definition: engine_layer.h:27

◆ pushOffset()

void flutter::SceneBuilder::pushOffset ( Dart_Handle  layer_handle,
double  dx,
double  dy 
)

Definition at line 102 of file scene_builder.cc.

References flutter::EngineLayer::MakeRetained().

Referenced by create().

102  {
103  SkMatrix sk_matrix = SkMatrix::Translate(dx, dy);
104  auto layer = std::make_shared<flutter::TransformLayer>(sk_matrix);
105  PushLayer(layer);
106  EngineLayer::MakeRetained(layer_handle, layer);
107 }
static fml::RefPtr< EngineLayer > MakeRetained(std::shared_ptr< flutter::ContainerLayer > layer)
Definition: engine_layer.h:27

◆ pushOpacity()

void flutter::SceneBuilder::pushOpacity ( Dart_Handle  layer_handle,
int  alpha,
double  dx = 0,
double  dy = 0 
)

Definition at line 144 of file scene_builder.cc.

References flutter::EngineLayer::MakeRetained().

Referenced by create().

147  {
148  auto layer =
149  std::make_shared<flutter::OpacityLayer>(alpha, SkPoint::Make(dx, dy));
150  PushLayer(layer);
151  EngineLayer::MakeRetained(layer_handle, layer);
152 }
static fml::RefPtr< EngineLayer > MakeRetained(std::shared_ptr< flutter::ContainerLayer > layer)
Definition: engine_layer.h:27

◆ pushPhysicalShape()

void flutter::SceneBuilder::pushPhysicalShape ( Dart_Handle  layer_handle,
const CanvasPath path,
double  elevation,
int  color,
int  shadowColor,
int  clipBehavior 
)

Definition at line 192 of file scene_builder.cc.

References flutter::EngineLayer::MakeRetained(), and flutter::CanvasPath::path().

Referenced by create().

197  {
198  auto layer = std::make_shared<flutter::PhysicalShapeLayer>(
199  static_cast<SkColor>(color), static_cast<SkColor>(shadow_color),
200  static_cast<float>(elevation), path->path(),
201  static_cast<flutter::Clip>(clipBehavior));
202  PushLayer(layer);
203  EngineLayer::MakeRetained(layer_handle, layer);
204 }
DEF_SWITCHES_START snapshot asset path
Definition: switches.h:32
static fml::RefPtr< EngineLayer > MakeRetained(std::shared_ptr< flutter::ContainerLayer > layer)
Definition: engine_layer.h:27
Clip
Definition: layer.h:41

◆ pushShaderMask()

void flutter::SceneBuilder::pushShaderMask ( Dart_Handle  layer_handle,
Shader shader,
double  maskRectLeft,
double  maskRectRight,
double  maskRectTop,
double  maskRectBottom,
int  blendMode 
)

Definition at line 177 of file scene_builder.cc.

References flutter::EngineLayer::MakeRetained(), and flutter::Shader::shader().

Referenced by create().

183  {
184  SkRect rect = SkRect::MakeLTRB(maskRectLeft, maskRectTop, maskRectRight,
185  maskRectBottom);
186  auto layer = std::make_shared<flutter::ShaderMaskLayer>(
187  shader->shader(), rect, static_cast<SkBlendMode>(blendMode));
188  PushLayer(layer);
189  EngineLayer::MakeRetained(layer_handle, layer);
190 }
static fml::RefPtr< EngineLayer > MakeRetained(std::shared_ptr< flutter::ContainerLayer > layer)
Definition: engine_layer.h:27

◆ pushTransform()

void flutter::SceneBuilder::pushTransform ( Dart_Handle  layer_handle,
tonic::Float64List &  matrix4 
)

Definition at line 92 of file scene_builder.cc.

References flutter::EngineLayer::MakeRetained(), and flutter::ToSkMatrix().

Referenced by create().

93  {
94  SkMatrix sk_matrix = ToSkMatrix(matrix4);
95  auto layer = std::make_shared<flutter::TransformLayer>(sk_matrix);
96  PushLayer(layer);
97  // matrix4 has to be released before we can return another Dart object
98  matrix4.Release();
99  EngineLayer::MakeRetained(layer_handle, layer);
100 }
static fml::RefPtr< EngineLayer > MakeRetained(std::shared_ptr< flutter::ContainerLayer > layer)
Definition: engine_layer.h:27
SkMatrix ToSkMatrix(const tonic::Float64List &matrix4)
Definition: matrix.cc:20

◆ RegisterNatives()

void flutter::SceneBuilder::RegisterNatives ( tonic::DartLibraryNatives natives)
static

Definition at line 74 of file scene_builder.cc.

References DART_REGISTER_NATIVE, FOR_EACH_BINDING, tonic::DartLibraryNatives::Register(), flutter::SceneBuilder_constructor(), and ~SceneBuilder().

Referenced by create(), and flutter::DartUI::InitForGlobal().

74  {
75  natives->Register({
76  {"SceneBuilder_constructor", SceneBuilder_constructor, 1, true},
78 #if defined(LEGACY_FUCHSIA_EMBEDDER)
79  DART_REGISTER_NATIVE(SceneBuilder, addChildScene)
80 #endif
81  });
82 }
void Register(std::initializer_list< Entry > entries)
static void SceneBuilder_constructor(Dart_NativeArguments args)
#define FOR_EACH_BINDING(V)
#define DART_REGISTER_NATIVE(CLASS, METHOD)

◆ setCheckerboardOffscreenLayers()

void flutter::SceneBuilder::setCheckerboardOffscreenLayers ( bool  checkerboard)

Definition at line 284 of file scene_builder.cc.

Referenced by create().

284  {
285  checkerboard_offscreen_layers_ = checkerboard;
286 }

◆ setCheckerboardRasterCacheImages()

void flutter::SceneBuilder::setCheckerboardRasterCacheImages ( bool  checkerboard)

Definition at line 280 of file scene_builder.cc.

Referenced by create().

280  {
281  checkerboard_raster_cache_images_ = checkerboard;
282 }

◆ setRasterizerTracingThreshold()

void flutter::SceneBuilder::setRasterizerTracingThreshold ( uint32_t  frameInterval)

Definition at line 276 of file scene_builder.cc.

Referenced by create().

276  {
277  rasterizer_tracing_threshold_ = frameInterval;
278 }

The documentation for this class was generated from the following files: