Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
flutter::testing::LayerTestBase< BaseT > Class Template Reference

#include <layer_test.h>

Inheritance diagram for flutter::testing::LayerTestBase< BaseT >:
flutter::testing::CanvasTestBase< BaseT > flutter::testing::DiffContextTest

Public Member Functions

 LayerTestBase ()
 
void use_null_raster_cache ()
 Use no raster cache in the preroll_context() and paint_context() structures.
 
void use_mock_raster_cache ()
 Use a mock raster cache in the preroll_context() and paint_context() structures.
 
void use_skia_raster_cache ()
 Use a normal raster cache in the preroll_context() and paint_context() structures.
 
std::vector< RasterCacheItem * > & cacheable_items ()
 
std::shared_ptr< TextureRegistrytexture_registry ()
 
RasterCacheraster_cache ()
 
PrerollContextpreroll_context ()
 
PaintContextpaint_context ()
 
PaintContextdisplay_list_paint_context ()
 
const DlPaintcheckerboard_paint ()
 
PaintContextcheckerboard_context ()
 
LayerSnapshotStorelayer_snapshot_store ()
 
sk_sp< DisplayListdisplay_list ()
 
void reset_display_list ()
 
void enable_leaf_layer_tracing ()
 
void disable_leaf_layer_tracing ()
 
- Public Member Functions inherited from flutter::testing::CanvasTestBase< BaseT >
 CanvasTestBase ()=default
 
MockCanvasmock_canvas ()
 
sk_sp< SkColorSpacemock_color_space ()
 

Detailed Description

template<typename BaseT>
class flutter::testing::LayerTestBase< BaseT >

Definition at line 42 of file layer_test.h.

Constructor & Destructor Documentation

◆ LayerTestBase()

template<typename BaseT >
flutter::testing::LayerTestBase< BaseT >::LayerTestBase ( )
inline

Definition at line 48 of file layer_test.h.

49 : texture_registry_(std::make_shared<TextureRegistry>()),
50 preroll_context_{
51 // clang-format off
52 .raster_cache = nullptr,
53 .gr_context = nullptr,
54 .view_embedder = nullptr,
55 .state_stack = preroll_state_stack_,
56 .dst_color_space = TestT::mock_color_space(),
57 .surface_needs_readback = false,
58 .raster_time = raster_time_,
59 .ui_time = ui_time_,
60 .texture_registry = texture_registry_,
61 .has_platform_view = false,
62 .raster_cached_entries = &cacheable_items_,
63 // clang-format on
64 },
65 paint_context_{
66 // clang-format off
67 .state_stack = paint_state_stack_,
68 .canvas = &TestT::mock_canvas(),
69 .gr_context = nullptr,
70 .view_embedder = nullptr,
71 .raster_time = raster_time_,
72 .ui_time = ui_time_,
73 .texture_registry = texture_registry_,
74 .raster_cache = nullptr,
75 // clang-format on
76 },
77 display_list_builder_(k_dl_bounds_),
78 display_list_paint_context_{
79 // clang-format off
80 .state_stack = display_list_state_stack_,
81 .canvas = &display_list_builder_,
82 .gr_context = nullptr,
83 .view_embedder = nullptr,
84 .raster_time = raster_time_,
85 .ui_time = ui_time_,
86 .texture_registry = texture_registry_,
87 .raster_cache = nullptr,
88 // clang-format on
89 },
90 checkerboard_context_{
91 // clang-format off
92 .state_stack = checkerboard_state_stack_,
93 .canvas = &display_list_builder_,
94 .gr_context = nullptr,
95 .view_embedder = nullptr,
96 .raster_time = raster_time_,
97 .ui_time = ui_time_,
98 .texture_registry = texture_registry_,
99 .raster_cache = nullptr,
100 // clang-format on
101 } {
103 preroll_state_stack_.set_preroll_delegate(kGiantRect, SkMatrix::I());
104 paint_state_stack_.set_delegate(&TestT::mock_canvas());
105 display_list_state_stack_.set_delegate(&display_list_builder_);
106 checkerboard_state_stack_.set_delegate(&display_list_builder_);
107 checkerboard_state_stack_.set_checkerboard_func(draw_checkerboard);
108 checkerboard_paint_.setColor(kCheckerboardColor);
109 }
static const SkMatrix & I()
DlPaint & setColor(DlColor color)
Definition dl_paint.h:71
void set_preroll_delegate(const SkRect &cull_rect, const SkMatrix &matrix)
void set_checkerboard_func(CheckerboardFunc checkerboard_func)
void set_delegate(DlCanvas *canvas)
sk_sp< SkColorSpace > mock_color_space()
Definition canvas_test.h:23
void use_null_raster_cache()
Use no raster cache in the preroll_context() and paint_context() structures.
Definition layer_test.h:122
static constexpr SkRect kGiantRect
Definition layer.h:49
LayerStateStack & state_stack
Definition layer.h:100
RasterCache * raster_cache
Definition layer.h:55

Member Function Documentation

◆ cacheable_items()

template<typename BaseT >
std::vector< RasterCacheItem * > & flutter::testing::LayerTestBase< BaseT >::cacheable_items ( )
inline

Definition at line 160 of file layer_test.h.

160{ return cacheable_items_; }

◆ checkerboard_context()

template<typename BaseT >
PaintContext & flutter::testing::LayerTestBase< BaseT >::checkerboard_context ( )
inline

Definition at line 172 of file layer_test.h.

172{ return checkerboard_context_; }

◆ checkerboard_paint()

template<typename BaseT >
const DlPaint & flutter::testing::LayerTestBase< BaseT >::checkerboard_paint ( )
inline

Definition at line 171 of file layer_test.h.

171{ return checkerboard_paint_; }

◆ disable_leaf_layer_tracing()

template<typename BaseT >
void flutter::testing::LayerTestBase< BaseT >::disable_leaf_layer_tracing ( )
inline

Definition at line 195 of file layer_test.h.

195 {
196 paint_context_.enable_leaf_layer_tracing = false;
197 paint_context_.layer_snapshot_store = nullptr;
198 }
bool enable_leaf_layer_tracing
Definition layer.h:119
LayerSnapshotStore * layer_snapshot_store
Definition layer.h:118

◆ display_list()

template<typename BaseT >
sk_sp< DisplayList > flutter::testing::LayerTestBase< BaseT >::display_list ( )
inline

Definition at line 175 of file layer_test.h.

175 {
176 if (display_list_ == nullptr) {
177 display_list_ = display_list_builder_.Build();
178 }
179 return display_list_;
180 }
sk_sp< DisplayList > Build()
Definition dl_builder.cc:67

◆ display_list_paint_context()

template<typename BaseT >
PaintContext & flutter::testing::LayerTestBase< BaseT >::display_list_paint_context ( )
inline

Definition at line 168 of file layer_test.h.

168 {
169 return display_list_paint_context_;
170 }

◆ enable_leaf_layer_tracing()

template<typename BaseT >
void flutter::testing::LayerTestBase< BaseT >::enable_leaf_layer_tracing ( )
inline

Definition at line 190 of file layer_test.h.

190 {
191 paint_context_.enable_leaf_layer_tracing = true;
192 paint_context_.layer_snapshot_store = &snapshot_store_;
193 }

◆ layer_snapshot_store()

template<typename BaseT >
LayerSnapshotStore & flutter::testing::LayerTestBase< BaseT >::layer_snapshot_store ( )
inline

Definition at line 173 of file layer_test.h.

173{ return snapshot_store_; }

◆ paint_context()

template<typename BaseT >
PaintContext & flutter::testing::LayerTestBase< BaseT >::paint_context ( )
inline

Definition at line 167 of file layer_test.h.

167{ return paint_context_; }

◆ preroll_context()

template<typename BaseT >
PrerollContext * flutter::testing::LayerTestBase< BaseT >::preroll_context ( )
inline

Definition at line 166 of file layer_test.h.

166{ return &preroll_context_; }

◆ raster_cache()

template<typename BaseT >
RasterCache * flutter::testing::LayerTestBase< BaseT >::raster_cache ( )
inline

Definition at line 165 of file layer_test.h.

165{ return raster_cache_.get(); }

◆ reset_display_list()

template<typename BaseT >
void flutter::testing::LayerTestBase< BaseT >::reset_display_list ( )
inline

Definition at line 182 of file layer_test.h.

182 {
183 display_list_ = nullptr;
184 // Build() will leave the builder in a state to start recording a new DL
185 display_list_builder_.Build();
186 // Make sure we are starting from a fresh state stack
187 FML_DCHECK(display_list_state_stack_.is_empty());
188 }
#define FML_DCHECK(condition)
Definition logging.h:103

◆ texture_registry()

template<typename BaseT >
std::shared_ptr< TextureRegistry > flutter::testing::LayerTestBase< BaseT >::texture_registry ( )
inline

Definition at line 162 of file layer_test.h.

162 {
163 return texture_registry_;
164 }

◆ use_mock_raster_cache()

template<typename BaseT >
void flutter::testing::LayerTestBase< BaseT >::use_mock_raster_cache ( )
inline

Use a mock raster cache in the preroll_context() and paint_context() structures.

This method must be called before using the preroll_context() and paint_context() structures in calls to the Layer::Preroll() and Layer::Paint() methods. The mock raster cache behaves like a normal raster cache with respect to decisions about when layers and pictures should be cached, but it does not incur the overhead of rendering the layers or caching the resulting pixels.

See also
use_null_raster_cache()
use_skia_raster_cache()

Definition at line 138 of file layer_test.h.

138 {
139 set_raster_cache_(std::make_unique<MockRasterCache>());
140 }

◆ use_null_raster_cache()

template<typename BaseT >
void flutter::testing::LayerTestBase< BaseT >::use_null_raster_cache ( )
inline

Use no raster cache in the preroll_context() and paint_context() structures.

This method must be called before using the preroll_context() and paint_context() structures in calls to the Layer::Preroll() and Layer::Paint() methods. This is the default mode of operation.

See also
use_mock_raster_cache()
use_skia_raster_cache()

Definition at line 122 of file layer_test.h.

122{ set_raster_cache_(nullptr); }

◆ use_skia_raster_cache()

template<typename BaseT >
void flutter::testing::LayerTestBase< BaseT >::use_skia_raster_cache ( )
inline

Use a normal raster cache in the preroll_context() and paint_context() structures.

This method must be called before using the preroll_context() and paint_context() structures in calls to the Layer::Preroll() and Layer::Paint() methods. The Skia raster cache will behave identically to the raster cache typically used when handling a frame on a device including rendering the contents of pictures and layers to an SkImage, but using a software rather than a hardware renderer.

See also
use_null_raster_cache()
use_mock_raster_cache()

Definition at line 156 of file layer_test.h.

156 {
157 set_raster_cache_(std::make_unique<RasterCache>());
158 }

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