Flutter Engine
 
Loading...
Searching...
No Matches
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 ()
 
sk_sp< DisplayListdisplay_list ()
 
void reset_display_list ()
 
- Public Member Functions inherited from flutter::testing::CanvasTestBase< BaseT >
 CanvasTestBase ()=default
 
sk_sp< SkColorSpace > mock_color_space ()
 

Detailed Description

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

Definition at line 37 of file layer_test.h.

Constructor & Destructor Documentation

◆ LayerTestBase()

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

Definition at line 43 of file layer_test.h.

44 : texture_registry_(std::make_shared<TextureRegistry>()),
45 preroll_context_{
46 // clang-format off
47 .raster_cache = nullptr,
48 .gr_context = nullptr,
49 .view_embedder = nullptr,
50 .state_stack = preroll_state_stack_,
51 .dst_color_space = TestT::mock_color_space(),
52 .surface_needs_readback = false,
53 .raster_time = raster_time_,
54 .ui_time = ui_time_,
55 .texture_registry = texture_registry_,
56 .has_platform_view = false,
57 .raster_cached_entries = &cacheable_items_,
58 // clang-format on
59 },
60 display_list_builder_(k_dl_bounds_),
61 display_list_paint_context_{
62 // clang-format off
63 .state_stack = display_list_state_stack_,
64 .canvas = &display_list_builder_,
65 .gr_context = nullptr,
66 .view_embedder = nullptr,
67 .raster_time = raster_time_,
68 .ui_time = ui_time_,
69 .texture_registry = texture_registry_,
70 .raster_cache = nullptr,
71 // clang-format on
72 } {
74 preroll_state_stack_.set_preroll_delegate(kGiantRect, DlMatrix());
75 display_list_state_stack_.set_delegate(&display_list_builder_);
76 }
void set_delegate(DlCanvas *canvas)
void set_preroll_delegate(const DlRect &cull_rect, const DlMatrix &matrix)
void use_null_raster_cache()
Use no raster cache in the preroll_context() and paint_context() structures.
Definition layer_test.h:89
impeller::Matrix DlMatrix
static constexpr DlRect kGiantRect
Definition layer.h:40
LayerStateStack & state_stack
Definition layer.h:91
GrDirectContext * gr_context
Definition layer.h:47

References flutter::kGiantRect, flutter::LayerStateStack::set_delegate(), flutter::LayerStateStack::set_preroll_delegate(), and flutter::testing::LayerTestBase< BaseT >::use_null_raster_cache().

Member Function Documentation

◆ cacheable_items()

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

Definition at line 127 of file layer_test.h.

127{ return cacheable_items_; }

◆ display_list()

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

Definition at line 139 of file layer_test.h.

139 {
140 if (display_list_ == nullptr) {
141 display_list_ = display_list_builder_.Build();
142 }
143 return display_list_;
144 }
sk_sp< DisplayList > Build()
Definition dl_builder.cc:66

References flutter::DisplayListBuilder::Build().

Referenced by flutter::testing::DiffContextTest::CreateDisplayListLayer().

◆ display_list_paint_context()

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

Definition at line 135 of file layer_test.h.

135 {
136 return display_list_paint_context_;
137 }

◆ paint_context()

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

Definition at line 134 of file layer_test.h.

134{ return display_list_paint_context_; }

◆ preroll_context()

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

Definition at line 133 of file layer_test.h.

133{ return &preroll_context_; }

◆ raster_cache()

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

Definition at line 132 of file layer_test.h.

132{ return raster_cache_.get(); }

◆ reset_display_list()

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

Definition at line 146 of file layer_test.h.

146 {
147 display_list_ = nullptr;
148 // Build() will leave the builder in a state to start recording a new DL
149 display_list_builder_.Build();
150 // Make sure we are starting from a fresh state stack
151 FML_DCHECK(display_list_state_stack_.is_empty());
152 }
#define FML_DCHECK(condition)
Definition logging.h:122

References flutter::DisplayListBuilder::Build(), FML_DCHECK, and flutter::LayerStateStack::is_empty().

◆ texture_registry()

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

Definition at line 129 of file layer_test.h.

129 {
130 return texture_registry_;
131 }

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

105 {
106 set_raster_cache_(std::make_unique<MockRasterCache>());
107 }

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

89{ set_raster_cache_(nullptr); }

Referenced by flutter::testing::LayerTestBase< BaseT >::LayerTestBase().

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

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

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