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, fml::RefPtr< EngineLayer > oldLayer)
 
void pushOffset (Dart_Handle layer_handle, double dx, double dy, fml::RefPtr< EngineLayer > oldLayer)
 
void pushClipRect (Dart_Handle layer_handle, double left, double right, double top, double bottom, int clipBehavior, fml::RefPtr< EngineLayer > oldLayer)
 
void pushClipRRect (Dart_Handle layer_handle, const RRect &rrect, int clipBehavior, fml::RefPtr< EngineLayer > oldLayer)
 
void pushClipPath (Dart_Handle layer_handle, const CanvasPath *path, int clipBehavior, fml::RefPtr< EngineLayer > oldLayer)
 
void pushOpacity (Dart_Handle layer_handle, int alpha, double dx, double dy, fml::RefPtr< EngineLayer > oldLayer)
 
void pushColorFilter (Dart_Handle layer_handle, const ColorFilter *color_filter, fml::RefPtr< EngineLayer > oldLayer)
 
void pushImageFilter (Dart_Handle layer_handle, const ImageFilter *image_filter, fml::RefPtr< EngineLayer > oldLayer)
 
void pushBackdropFilter (Dart_Handle layer_handle, ImageFilter *filter, int blendMode, fml::RefPtr< EngineLayer > oldLayer)
 
void pushShaderMask (Dart_Handle layer_handle, Shader *shader, double maskRectLeft, double maskRectRight, double maskRectTop, double maskRectBottom, int blendMode, int filterQualityIndex, fml::RefPtr< EngineLayer > oldLayer)
 
void pushPhysicalShape (Dart_Handle layer_handle, const CanvasPath *path, double elevation, int color, int shadowColor, int clipBehavior, fml::RefPtr< EngineLayer > oldLayer)
 
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)
 
const std::vector< std::shared_ptr< ContainerLayer > > & layer_stack ()
 
- 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,
  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 26 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 307 of file scene_builder.cc.

Referenced by create().

311  {
312  SkRect rect = SkRect::MakeLTRB(left, top, right, bottom);
313  auto layer =
314  std::make_unique<flutter::PerformanceOverlayLayer>(enabledOptions);
315  layer->set_paint_bounds(rect);
316  AddLayer(std::move(layer));
317 }

◆ addPicture()

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

Definition at line 265 of file scene_builder.cc.

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

Referenced by create().

268  {
269  if (picture->picture()) {
270  auto layer = std::make_unique<flutter::PictureLayer>(
271  SkPoint::Make(dx, dy), UIDartState::CreateGPUObject(picture->picture()),
272  !!(hints & 1), !!(hints & 2));
273  AddLayer(std::move(layer));
274  } else {
275  auto layer = std::make_unique<flutter::DisplayListLayer>(
276  SkPoint::Make(dx, dy),
277  UIDartState::CreateGPUObject(picture->display_list()), !!(hints & 1),
278  !!(hints & 2));
279  AddLayer(std::move(layer));
280  }
281 }
static flutter::SkiaGPUObject< T > CreateGPUObject(sk_sp< T > object)

◆ addPlatformView()

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

Definition at line 297 of file scene_builder.cc.

Referenced by create().

301  {
302  auto layer = std::make_unique<flutter::PlatformViewLayer>(
303  SkPoint::Make(dx, dy), SkSize::Make(width, height), viewId);
304  AddLayer(std::move(layer));
305 }
int32_t width
int32_t height

◆ addRetained()

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

Definition at line 257 of file scene_builder.cc.

Referenced by create().

257  {
258  AddLayer(retainedLayer->Layer());
259 }

◆ addTexture()

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

Definition at line 283 of file scene_builder.cc.

References flutter::ImageFilter::SamplingFromIndex().

Referenced by create().

289  {
290  auto sampling = ImageFilter::SamplingFromIndex(filterQualityIndex);
291  auto layer = std::make_unique<flutter::TextureLayer>(
292  SkPoint::Make(dx, dy), SkSize::Make(width, height), textureId, freeze,
293  sampling);
294  AddLayer(std::move(layer));
295 }
int32_t width
static SkSamplingOptions SamplingFromIndex(int filterQualityIndex)
Definition: image_filter.cc:50
int32_t height

◆ build()

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

Definition at line 331 of file scene_builder.cc.

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

Referenced by create().

331  {
332  FML_DCHECK(layer_stack_.size() >= 1);
333 
335  scene_handle, std::move(layer_stack_[0]), rasterizer_tracing_threshold_,
336  checkerboard_raster_cache_images_, checkerboard_offscreen_layers_);
337  layer_stack_.clear();
338  ClearDartWrapper(); // may delete this object.
339 }
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()

◆ layer_stack()

const std::vector<std::shared_ptr<ContainerLayer> >& flutter::SceneBuilder::layer_stack ( )
inline

Definition at line 122 of file scene_builder.h.

References RegisterNatives().

Referenced by flutter::testing::TEST_F().

122  {
123  return layer_stack_;
124  }

◆ pop()

void flutter::SceneBuilder::pop ( )

Definition at line 261 of file scene_builder.cc.

Referenced by create().

261  {
262  PopLayer();
263 }

◆ pushBackdropFilter()

void flutter::SceneBuilder::pushBackdropFilter ( Dart_Handle  layer_handle,
ImageFilter filter,
int  blendMode,
fml::RefPtr< EngineLayer oldLayer 
)

Definition at line 202 of file scene_builder.cc.

References flutter::ImageFilter::filter(), fml::RefPtr< T >::get(), and flutter::EngineLayer::MakeRetained().

Referenced by create().

205  {
206  auto layer = std::make_shared<flutter::BackdropFilterLayer>(
207  filter->filter(), static_cast<SkBlendMode>(blendMode));
208  PushLayer(layer);
209  EngineLayer::MakeRetained(layer_handle, layer);
210 
211  if (oldLayer && oldLayer->Layer()) {
212  layer->AssignOldLayer(oldLayer->Layer().get());
213  }
214 }
T * get() const
Definition: ref_ptr.h:112
static void MakeRetained(Dart_Handle dart_handle, std::shared_ptr< flutter::ContainerLayer > layer)
Definition: engine_layer.h:25

◆ pushClipPath()

void flutter::SceneBuilder::pushClipPath ( Dart_Handle  layer_handle,
const CanvasPath path,
int  clipBehavior,
fml::RefPtr< EngineLayer oldLayer 
)

Definition at line 145 of file scene_builder.cc.

References FML_DCHECK, fml::RefPtr< T >::get(), flutter::EngineLayer::MakeRetained(), flutter::none, and flutter::CanvasPath::path().

Referenced by create().

148  {
149  flutter::Clip clip_behavior = static_cast<flutter::Clip>(clipBehavior);
150  FML_DCHECK(clip_behavior != flutter::Clip::none);
151  auto layer =
152  std::make_shared<flutter::ClipPathLayer>(path->path(), clip_behavior);
153  PushLayer(layer);
154  EngineLayer::MakeRetained(layer_handle, layer);
155 
156  if (oldLayer && oldLayer->Layer()) {
157  layer->AssignOldLayer(oldLayer->Layer().get());
158  }
159 }
DEF_SWITCHES_START snapshot asset path
Definition: switches.h:32
#define FML_DCHECK(condition)
Definition: logging.h:86
T * get() const
Definition: ref_ptr.h:112
static void MakeRetained(Dart_Handle dart_handle, std::shared_ptr< flutter::ContainerLayer > layer)
Definition: engine_layer.h:25
Clip
Definition: layer.h:40

◆ pushClipRect()

void flutter::SceneBuilder::pushClipRect ( Dart_Handle  layer_handle,
double  left,
double  right,
double  top,
double  bottom,
int  clipBehavior,
fml::RefPtr< EngineLayer oldLayer 
)

Definition at line 111 of file scene_builder.cc.

References fml::RefPtr< T >::get(), and flutter::EngineLayer::MakeRetained().

Referenced by create().

117  {
118  SkRect clipRect = SkRect::MakeLTRB(left, top, right, bottom);
119  flutter::Clip clip_behavior = static_cast<flutter::Clip>(clipBehavior);
120  auto layer =
121  std::make_shared<flutter::ClipRectLayer>(clipRect, clip_behavior);
122  PushLayer(layer);
123  EngineLayer::MakeRetained(layer_handle, layer);
124 
125  if (oldLayer && oldLayer->Layer()) {
126  layer->AssignOldLayer(oldLayer->Layer().get());
127  }
128 }
T * get() const
Definition: ref_ptr.h:112
static void MakeRetained(Dart_Handle dart_handle, std::shared_ptr< flutter::ContainerLayer > layer)
Definition: engine_layer.h:25
Clip
Definition: layer.h:40

◆ pushClipRRect()

void flutter::SceneBuilder::pushClipRRect ( Dart_Handle  layer_handle,
const RRect rrect,
int  clipBehavior,
fml::RefPtr< EngineLayer oldLayer 
)

Definition at line 130 of file scene_builder.cc.

References fml::RefPtr< T >::get(), flutter::EngineLayer::MakeRetained(), and flutter::RRect::sk_rrect.

Referenced by create().

133  {
134  flutter::Clip clip_behavior = static_cast<flutter::Clip>(clipBehavior);
135  auto layer =
136  std::make_shared<flutter::ClipRRectLayer>(rrect.sk_rrect, clip_behavior);
137  PushLayer(layer);
138  EngineLayer::MakeRetained(layer_handle, layer);
139 
140  if (oldLayer && oldLayer->Layer()) {
141  layer->AssignOldLayer(oldLayer->Layer().get());
142  }
143 }
T * get() const
Definition: ref_ptr.h:112
static void MakeRetained(Dart_Handle dart_handle, std::shared_ptr< flutter::ContainerLayer > layer)
Definition: engine_layer.h:25
Clip
Definition: layer.h:40

◆ pushColorFilter()

void flutter::SceneBuilder::pushColorFilter ( Dart_Handle  layer_handle,
const ColorFilter color_filter,
fml::RefPtr< EngineLayer oldLayer 
)

Definition at line 176 of file scene_builder.cc.

References flutter::ColorFilter::filter(), fml::RefPtr< T >::get(), and flutter::EngineLayer::MakeRetained().

Referenced by create().

178  {
179  auto layer =
180  std::make_shared<flutter::ColorFilterLayer>(color_filter->filter());
181  PushLayer(layer);
182  EngineLayer::MakeRetained(layer_handle, layer);
183 
184  if (oldLayer && oldLayer->Layer()) {
185  layer->AssignOldLayer(oldLayer->Layer().get());
186  }
187 }
T * get() const
Definition: ref_ptr.h:112
static void MakeRetained(Dart_Handle dart_handle, std::shared_ptr< flutter::ContainerLayer > layer)
Definition: engine_layer.h:25

◆ pushImageFilter()

void flutter::SceneBuilder::pushImageFilter ( Dart_Handle  layer_handle,
const ImageFilter image_filter,
fml::RefPtr< EngineLayer oldLayer 
)

Definition at line 189 of file scene_builder.cc.

References flutter::ImageFilter::filter(), fml::RefPtr< T >::get(), and flutter::EngineLayer::MakeRetained().

Referenced by create().

191  {
192  auto layer =
193  std::make_shared<flutter::ImageFilterLayer>(image_filter->filter());
194  PushLayer(layer);
195  EngineLayer::MakeRetained(layer_handle, layer);
196 
197  if (oldLayer && oldLayer->Layer()) {
198  layer->AssignOldLayer(oldLayer->Layer().get());
199  }
200 }
T * get() const
Definition: ref_ptr.h:112
static void MakeRetained(Dart_Handle dart_handle, std::shared_ptr< flutter::ContainerLayer > layer)
Definition: engine_layer.h:25

◆ pushOffset()

void flutter::SceneBuilder::pushOffset ( Dart_Handle  layer_handle,
double  dx,
double  dy,
fml::RefPtr< EngineLayer oldLayer 
)

Definition at line 97 of file scene_builder.cc.

References fml::RefPtr< T >::get(), and flutter::EngineLayer::MakeRetained().

Referenced by create().

100  {
101  SkMatrix sk_matrix = SkMatrix::Translate(dx, dy);
102  auto layer = std::make_shared<flutter::TransformLayer>(sk_matrix);
103  PushLayer(layer);
104  EngineLayer::MakeRetained(layer_handle, layer);
105 
106  if (oldLayer && oldLayer->Layer()) {
107  layer->AssignOldLayer(oldLayer->Layer().get());
108  }
109 }
T * get() const
Definition: ref_ptr.h:112
static void MakeRetained(Dart_Handle dart_handle, std::shared_ptr< flutter::ContainerLayer > layer)
Definition: engine_layer.h:25

◆ pushOpacity()

void flutter::SceneBuilder::pushOpacity ( Dart_Handle  layer_handle,
int  alpha,
double  dx,
double  dy,
fml::RefPtr< EngineLayer oldLayer 
)

Definition at line 161 of file scene_builder.cc.

References fml::RefPtr< T >::get(), and flutter::EngineLayer::MakeRetained().

Referenced by create().

165  {
166  auto layer =
167  std::make_shared<flutter::OpacityLayer>(alpha, SkPoint::Make(dx, dy));
168  PushLayer(layer);
169  EngineLayer::MakeRetained(layer_handle, layer);
170 
171  if (oldLayer && oldLayer->Layer()) {
172  layer->AssignOldLayer(oldLayer->Layer().get());
173  }
174 }
T * get() const
Definition: ref_ptr.h:112
static void MakeRetained(Dart_Handle dart_handle, std::shared_ptr< flutter::ContainerLayer > layer)
Definition: engine_layer.h:25

◆ pushPhysicalShape()

void flutter::SceneBuilder::pushPhysicalShape ( Dart_Handle  layer_handle,
const CanvasPath path,
double  elevation,
int  color,
int  shadowColor,
int  clipBehavior,
fml::RefPtr< EngineLayer oldLayer 
)

Definition at line 238 of file scene_builder.cc.

References fml::RefPtr< T >::get(), flutter::EngineLayer::MakeRetained(), and flutter::CanvasPath::path().

Referenced by create().

244  {
245  auto layer = std::make_shared<flutter::PhysicalShapeLayer>(
246  static_cast<SkColor>(color), static_cast<SkColor>(shadow_color),
247  static_cast<float>(elevation), path->path(),
248  static_cast<flutter::Clip>(clipBehavior));
249  PushLayer(layer);
250  EngineLayer::MakeRetained(layer_handle, layer);
251 
252  if (oldLayer && oldLayer->Layer()) {
253  layer->AssignOldLayer(oldLayer->Layer().get());
254  }
255 }
DEF_SWITCHES_START snapshot asset path
Definition: switches.h:32
T * get() const
Definition: ref_ptr.h:112
static void MakeRetained(Dart_Handle dart_handle, std::shared_ptr< flutter::ContainerLayer > layer)
Definition: engine_layer.h:25
Clip
Definition: layer.h:40

◆ pushShaderMask()

void flutter::SceneBuilder::pushShaderMask ( Dart_Handle  layer_handle,
Shader shader,
double  maskRectLeft,
double  maskRectRight,
double  maskRectTop,
double  maskRectBottom,
int  blendMode,
int  filterQualityIndex,
fml::RefPtr< EngineLayer oldLayer 
)

Definition at line 216 of file scene_builder.cc.

References fml::RefPtr< T >::get(), flutter::EngineLayer::MakeRetained(), flutter::ImageFilter::SamplingFromIndex(), and flutter::Shader::shader().

Referenced by create().

224  {
225  SkRect rect = SkRect::MakeLTRB(maskRectLeft, maskRectTop, maskRectRight,
226  maskRectBottom);
227  auto sampling = ImageFilter::SamplingFromIndex(filterQualityIndex);
228  auto layer = std::make_shared<flutter::ShaderMaskLayer>(
229  shader->shader(sampling), rect, static_cast<SkBlendMode>(blendMode));
230  PushLayer(layer);
231  EngineLayer::MakeRetained(layer_handle, layer);
232 
233  if (oldLayer && oldLayer->Layer()) {
234  layer->AssignOldLayer(oldLayer->Layer().get());
235  }
236 }
T * get() const
Definition: ref_ptr.h:112
static SkSamplingOptions SamplingFromIndex(int filterQualityIndex)
Definition: image_filter.cc:50
static void MakeRetained(Dart_Handle dart_handle, std::shared_ptr< flutter::ContainerLayer > layer)
Definition: engine_layer.h:25

◆ pushTransform()

void flutter::SceneBuilder::pushTransform ( Dart_Handle  layer_handle,
tonic::Float64List &  matrix4,
fml::RefPtr< EngineLayer oldLayer 
)

Definition at line 82 of file scene_builder.cc.

References fml::RefPtr< T >::get(), flutter::EngineLayer::MakeRetained(), and flutter::ToSkMatrix().

Referenced by create().

84  {
85  SkMatrix sk_matrix = ToSkMatrix(matrix4);
86  auto layer = std::make_shared<flutter::TransformLayer>(sk_matrix);
87  PushLayer(layer);
88  // matrix4 has to be released before we can return another Dart object
89  matrix4.Release();
90  EngineLayer::MakeRetained(layer_handle, layer);
91 
92  if (oldLayer && oldLayer->Layer()) {
93  layer->AssignOldLayer(oldLayer->Layer().get());
94  }
95 }
T * get() const
Definition: ref_ptr.h:112
static void MakeRetained(Dart_Handle dart_handle, std::shared_ptr< flutter::ContainerLayer > layer)
Definition: engine_layer.h:25
SkMatrix ToSkMatrix(const tonic::Float64List &matrix4)
Definition: matrix.cc:20

◆ RegisterNatives()

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

Definition at line 68 of file scene_builder.cc.

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

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

68  {
69  natives->Register(
70  {{"SceneBuilder_constructor", SceneBuilder_constructor, 1, true},
72 }
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 327 of file scene_builder.cc.

Referenced by create().

327  {
328  checkerboard_offscreen_layers_ = checkerboard;
329 }

◆ setCheckerboardRasterCacheImages()

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

Definition at line 323 of file scene_builder.cc.

Referenced by create().

323  {
324  checkerboard_raster_cache_images_ = checkerboard;
325 }

◆ setRasterizerTracingThreshold()

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

Definition at line 319 of file scene_builder.cc.

Referenced by create().

319  {
320  rasterizer_tracing_threshold_ = frameInterval;
321 }

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