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