Flutter Engine
The Flutter Engine
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. More...
 
void use_mock_raster_cache ()
 Use a mock raster cache in the preroll_context() and paint_context() structures. More...
 
void use_skia_raster_cache ()
 Use a normal raster cache in the preroll_context() and paint_context() structures. More...
 
std::vector< RasterCacheItem * > & cacheable_items ()
 
std::shared_ptr< TextureRegistrytexture_registry ()
 
RasterCacheraster_cache ()
 
PrerollContextpreroll_context ()
 
PaintContextpaint_context ()
 
PaintContextdisplay_list_paint_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 } {
91 preroll_state_stack_.set_preroll_delegate(kGiantRect, SkMatrix::I());
92 paint_state_stack_.set_delegate(&TestT::mock_canvas());
93 display_list_state_stack_.set_delegate(&display_list_builder_);
94 }
static const SkMatrix & I()
Definition: SkMatrix.cpp:1544
void set_preroll_delegate(const SkRect &cull_rect, const SkMatrix &matrix)
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:107
static constexpr SkRect kGiantRect
Definition: layer.h:50
LayerStateStack & state_stack
Definition: layer.h:101
GrDirectContext * gr_context
Definition: layer.h:57

Member Function Documentation

◆ cacheable_items()

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

Definition at line 145 of file layer_test.h.

145{ return cacheable_items_; }

◆ disable_leaf_layer_tracing()

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

Definition at line 178 of file layer_test.h.

178 {
179 paint_context_.enable_leaf_layer_tracing = false;
180 paint_context_.layer_snapshot_store = nullptr;
181 }
bool enable_leaf_layer_tracing
Definition: layer.h:120
LayerSnapshotStore * layer_snapshot_store
Definition: layer.h:119

◆ display_list()

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

Definition at line 158 of file layer_test.h.

158 {
159 if (display_list_ == nullptr) {
160 display_list_ = display_list_builder_.Build();
161 }
162 return display_list_;
163 }
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 153 of file layer_test.h.

153 {
154 return display_list_paint_context_;
155 }

◆ enable_leaf_layer_tracing()

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

Definition at line 173 of file layer_test.h.

173 {
174 paint_context_.enable_leaf_layer_tracing = true;
175 paint_context_.layer_snapshot_store = &snapshot_store_;
176 }

◆ layer_snapshot_store()

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

Definition at line 156 of file layer_test.h.

156{ return snapshot_store_; }

◆ paint_context()

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

Definition at line 152 of file layer_test.h.

152{ return paint_context_; }

◆ preroll_context()

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

Definition at line 151 of file layer_test.h.

151{ return &preroll_context_; }

◆ raster_cache()

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

Definition at line 150 of file layer_test.h.

150{ return raster_cache_.get(); }

◆ reset_display_list()

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

Definition at line 165 of file layer_test.h.

165 {
166 display_list_ = nullptr;
167 // Build() will leave the builder in a state to start recording a new DL
168 display_list_builder_.Build();
169 // Make sure we are starting from a fresh state stack
170 FML_DCHECK(display_list_state_stack_.is_empty());
171 }
#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 147 of file layer_test.h.

147 {
148 return texture_registry_;
149 }

◆ 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 123 of file layer_test.h.

123 {
124 set_raster_cache_(std::make_unique<MockRasterCache>());
125 }

◆ 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 107 of file layer_test.h.

107{ 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 141 of file layer_test.h.

141 {
142 set_raster_cache_(std::make_unique<RasterCache>());
143 }

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