Flutter Engine
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 
24 #if defined(LEGACY_FUCHSIA_EMBEDDER)
25 #include "flutter/lib/ui/compositing/scene_host.h" // nogncheck
26 #endif
27 
28 namespace flutter {
29 
30 class SceneBuilder : public RefCountedDartWrappable<SceneBuilder> {
31  DEFINE_WRAPPERTYPEINFO();
32  FML_FRIEND_MAKE_REF_COUNTED(SceneBuilder);
33 
34  public:
36  return fml::MakeRefCounted<SceneBuilder>();
37  }
38  ~SceneBuilder() override;
39 
40  void pushTransform(Dart_Handle layer_handle, tonic::Float64List& matrix4);
41  void pushOffset(Dart_Handle layer_handle, double dx, double dy);
42  void pushClipRect(Dart_Handle layer_handle,
43  double left,
44  double right,
45  double top,
46  double bottom,
47  int clipBehavior);
48  void pushClipRRect(Dart_Handle layer_handle,
49  const RRect& rrect,
50  int clipBehavior);
51  void pushClipPath(Dart_Handle layer_handle,
52  const CanvasPath* path,
53  int clipBehavior);
54  void pushOpacity(Dart_Handle layer_handle,
55  int alpha,
56  double dx = 0,
57  double dy = 0);
58  void pushColorFilter(Dart_Handle layer_handle,
59  const ColorFilter* color_filter);
60  void pushImageFilter(Dart_Handle layer_handle,
61  const ImageFilter* image_filter);
62  void pushBackdropFilter(Dart_Handle layer_handle, ImageFilter* filter);
63  void pushShaderMask(Dart_Handle layer_handle,
64  Shader* shader,
65  double maskRectLeft,
66  double maskRectRight,
67  double maskRectTop,
68  double maskRectBottom,
69  int blendMode);
70  void pushPhysicalShape(Dart_Handle layer_handle,
71  const CanvasPath* path,
72  double elevation,
73  int color,
74  int shadowColor,
75  int clipBehavior);
76 
77  void addRetained(fml::RefPtr<EngineLayer> retainedLayer);
78 
79  void pop();
80 
81  void addPerformanceOverlay(uint64_t enabledOptions,
82  double left,
83  double right,
84  double top,
85  double bottom);
86 
87  void addPicture(double dx, double dy, Picture* picture, int hints);
88 
89  void addTexture(double dx,
90  double dy,
91  double width,
92  double height,
93  int64_t textureId,
94  bool freeze,
95  int filterQuality);
96 
97  void addPlatformView(double dx,
98  double dy,
99  double width,
100  double height,
101  int64_t viewId);
102 
103 #if defined(LEGACY_FUCHSIA_EMBEDDER)
104  void addChildScene(double dx,
105  double dy,
106  double width,
107  double height,
108  SceneHost* sceneHost,
109  bool hitTestable);
110 #endif
111 
112  void setRasterizerTracingThreshold(uint32_t frameInterval);
113  void setCheckerboardRasterCacheImages(bool checkerboard);
114  void setCheckerboardOffscreenLayers(bool checkerboard);
115 
116  void build(Dart_Handle scene_handle);
117 
118  static void RegisterNatives(tonic::DartLibraryNatives* natives);
119 
120  private:
121  SceneBuilder();
122 
123  void AddLayer(std::shared_ptr<Layer> layer);
124  void PushLayer(std::shared_ptr<ContainerLayer> layer);
125  void PopLayer();
126 
127  std::vector<std::shared_ptr<ContainerLayer>> layer_stack_;
128  int rasterizer_tracing_threshold_ = 0;
129  bool checkerboard_raster_cache_images_ = false;
130  bool checkerboard_offscreen_layers_ = false;
131 
132  FML_DISALLOW_COPY_AND_ASSIGN(SceneBuilder);
133 };
134 
135 } // namespace flutter
136 
137 #endif // FLUTTER_LIB_UI_COMPOSITING_SCENE_BUILDER_H_
~SceneBuilder() override
DEF_SWITCHES_START snapshot asset path
Definition: switches.h:32
void pushClipRRect(Dart_Handle layer_handle, const RRect &rrect, int clipBehavior)
void pushOpacity(Dart_Handle layer_handle, int alpha, double dx=0, double dy=0)
void setCheckerboardRasterCacheImages(bool checkerboard)
void pushTransform(Dart_Handle layer_handle, tonic::Float64List &matrix4)
void addPlatformView(double dx, double dy, double width, double height, int64_t viewId)
void addRetained(fml::RefPtr< EngineLayer > retainedLayer)
void pushClipRect(Dart_Handle layer_handle, double left, double right, double top, double bottom, int clipBehavior)
void pushOffset(Dart_Handle layer_handle, double dx, double dy)
void pushPhysicalShape(Dart_Handle layer_handle, const CanvasPath *path, double elevation, int color, int shadowColor, int clipBehavior)
void pushShaderMask(Dart_Handle layer_handle, Shader *shader, double maskRectLeft, double maskRectRight, double maskRectTop, double maskRectBottom, int blendMode)
void build(Dart_Handle scene_handle)
static fml::RefPtr< SceneBuilder > create()
Definition: scene_builder.h:35
static void RegisterNatives(tonic::DartLibraryNatives *natives)
void setRasterizerTracingThreshold(uint32_t frameInterval)
void pushImageFilter(Dart_Handle layer_handle, const ImageFilter *image_filter)
void pushClipPath(Dart_Handle layer_handle, const CanvasPath *path, int clipBehavior)
int32_t height
int32_t width
void pushBackdropFilter(Dart_Handle layer_handle, ImageFilter *filter)
void setCheckerboardOffscreenLayers(bool checkerboard)
void addPicture(double dx, double dy, Picture *picture, int hints)
void addPerformanceOverlay(uint64_t enabledOptions, double left, double right, double top, double bottom)
void pushColorFilter(Dart_Handle layer_handle, const ColorFilter *color_filter)
void addTexture(double dx, double dy, double width, double height, int64_t textureId, bool freeze, int filterQuality)