Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
flutter::testing::MockLayer Class Reference

#include <mock_layer.h>

Inheritance diagram for flutter::testing::MockLayer:
flutter::Layer flutter::testing::MockCacheableLayer

Public Member Functions

 MockLayer (const SkPath &path, DlPaint paint=DlPaint())
 
void Preroll (PrerollContext *context) override
 
void Paint (PaintContext &context) const override
 
const MutatorsStackparent_mutators ()
 
const SkMatrixparent_matrix ()
 
const SkRectparent_cull_rect ()
 
bool IsReplacing (DiffContext *context, const Layer *layer) const override
 
void Diff (DiffContext *context, const Layer *old_layer) override
 
const MockLayeras_mock_layer () const override
 
bool parent_has_platform_view ()
 
bool parent_has_texture_layer ()
 
bool fake_has_platform_view ()
 
bool fake_reads_surface ()
 
bool fake_opacity_compatible ()
 
bool fake_has_texture_layer ()
 
MockLayerset_parent_has_platform_view (bool flag)
 
MockLayerset_parent_has_texture_layer (bool flag)
 
MockLayerset_fake_has_platform_view (bool flag)
 
MockLayerset_fake_reads_surface (bool flag)
 
MockLayerset_fake_opacity_compatible (bool flag)
 
MockLayerset_fake_has_texture_layer (bool flag)
 
void set_expected_paint_matrix (const SkMatrix &matrix)
 
- Public Member Functions inherited from flutter::Layer
 Layer ()
 
virtual ~Layer ()
 
void AssignOldLayer (Layer *old_layer)
 
virtual void PreservePaintRegion (DiffContext *context)
 
virtual void PaintChildren (PaintContext &context) const
 
bool subtree_has_platform_view () const
 
void set_subtree_has_platform_view (bool value)
 
const SkRectpaint_bounds () const
 
void set_paint_bounds (const SkRect &paint_bounds)
 
bool is_empty () const
 
bool needs_painting (PaintContext &context) const
 
uint64_t original_layer_id () const
 
uint64_t unique_id () const
 
virtual RasterCacheKeyID caching_key_id () const
 
virtual const ContainerLayeras_container_layer () const
 
virtual const DisplayListLayeras_display_list_layer () const
 
virtual const TextureLayeras_texture_layer () const
 
virtual const PerformanceOverlayLayeras_performance_overlay_layer () const
 

Static Public Member Functions

static std::shared_ptr< MockLayerMake (const SkPath &path, DlPaint paint=DlPaint())
 
static std::shared_ptr< MockLayerMakeOpacityCompatible (const SkPath &path)
 

Additional Inherited Members

- Static Public Attributes inherited from flutter::Layer
static constexpr int kSaveLayerRenderFlags
 
static constexpr int kRasterCacheRenderFlags
 

Detailed Description

Definition at line 26 of file mock_layer.h.

Constructor & Destructor Documentation

◆ MockLayer()

flutter::testing::MockLayer::MockLayer ( const SkPath path,
DlPaint  paint = DlPaint() 
)
explicit

Definition at line 15 of file mock_layer.cc.

16 : fake_paint_path_(path), fake_paint_(std::move(paint)) {}
const Paint & paint
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition switches.h:57

Member Function Documentation

◆ as_mock_layer()

const MockLayer * flutter::testing::MockLayer::as_mock_layer ( ) const
inlineoverridevirtual

Reimplemented from flutter::Layer.

Definition at line 50 of file mock_layer.h.

50{ return this; }

◆ Diff()

void flutter::testing::MockLayer::Diff ( DiffContext context,
const Layer old_layer 
)
overridevirtual

Reimplemented from flutter::Layer.

Definition at line 27 of file mock_layer.cc.

27 {
28 DiffContext::AutoSubtreeRestore subtree(context);
29 context->AddLayerBounds(fake_paint_path_.getBounds());
30 context->SetLayerPaintRegion(this, context->CurrentSubtreeRegion());
31}
const SkRect & getBounds() const
Definition SkPath.cpp:420

◆ fake_has_platform_view()

bool flutter::testing::MockLayer::fake_has_platform_view ( )
inline

Definition at line 60 of file mock_layer.h.

60{ return mock_flags_ & kFakeHasPlatformView; }

◆ fake_has_texture_layer()

bool flutter::testing::MockLayer::fake_has_texture_layer ( )
inline

Definition at line 68 of file mock_layer.h.

68{ return mock_flags_ & kFakeHasTextureLayer; }

◆ fake_opacity_compatible()

bool flutter::testing::MockLayer::fake_opacity_compatible ( )
inline

Definition at line 64 of file mock_layer.h.

64 {
65 return mock_flags_ & kFakeOpacityCompatible;
66 }

◆ fake_reads_surface()

bool flutter::testing::MockLayer::fake_reads_surface ( )
inline

Definition at line 62 of file mock_layer.h.

62{ return mock_flags_ & kFakeReadsSurface; }

◆ IsReplacing()

bool flutter::testing::MockLayer::IsReplacing ( DiffContext context,
const Layer layer 
) const
overridevirtual

Reimplemented from flutter::Layer.

Definition at line 18 of file mock_layer.cc.

18 {
19 // Similar to PictureLayer, only return true for identical mock layers;
20 // That way ContainerLayer::DiffChildren can properly detect mock layer
21 // insertion
22 auto mock_layer = layer->as_mock_layer();
23 return mock_layer && mock_layer->fake_paint_ == fake_paint_ &&
24 mock_layer->fake_paint_path_ == fake_paint_path_;
25}

◆ Make()

static std::shared_ptr< MockLayer > flutter::testing::MockLayer::Make ( const SkPath path,
DlPaint  paint = DlPaint() 
)
inlinestatic

Definition at line 30 of file mock_layer.h.

31 {
32 return std::make_shared<MockLayer>(path, std::move(paint));
33 }

◆ MakeOpacityCompatible()

static std::shared_ptr< MockLayer > flutter::testing::MockLayer::MakeOpacityCompatible ( const SkPath path)
inlinestatic

Definition at line 35 of file mock_layer.h.

35 {
36 auto mock_layer = std::make_shared<MockLayer>(path, DlPaint());
37 mock_layer->set_fake_opacity_compatible(true);
38 return mock_layer;
39 }

◆ Paint()

void flutter::testing::MockLayer::Paint ( PaintContext context) const
overridevirtual

Implements flutter::Layer.

Definition at line 52 of file mock_layer.cc.

52 {
53 FML_DCHECK(needs_painting(context));
54
55 if (expected_paint_matrix_.has_value()) {
56 SkMatrix matrix = context.canvas->GetTransform();
57
58 EXPECT_EQ(matrix, expected_paint_matrix_.value());
59 }
60
61 DlPaint paint = fake_paint_;
62 context.state_stack.fill(paint);
63 context.canvas->DrawPath(fake_paint_path_, paint);
64}
bool needs_painting(PaintContext &context) const
Definition layer.h:231
#define FML_DCHECK(condition)
Definition logging.h:103
unsigned useCenter Optional< SkMatrix > matrix
Definition SkRecords.h:258

◆ parent_cull_rect()

const SkRect & flutter::testing::MockLayer::parent_cull_rect ( )
inline

Definition at line 46 of file mock_layer.h.

46{ return parent_cull_rect_; }

◆ parent_has_platform_view()

bool flutter::testing::MockLayer::parent_has_platform_view ( )
inline

Definition at line 52 of file mock_layer.h.

52 {
53 return mock_flags_ & kParentHasPlatformView;
54 }

◆ parent_has_texture_layer()

bool flutter::testing::MockLayer::parent_has_texture_layer ( )
inline

Definition at line 56 of file mock_layer.h.

56 {
57 return mock_flags_ & kParentHasTextureLayer;
58 }

◆ parent_matrix()

const SkMatrix & flutter::testing::MockLayer::parent_matrix ( )
inline

Definition at line 45 of file mock_layer.h.

45{ return parent_matrix_; }

◆ parent_mutators()

const MutatorsStack & flutter::testing::MockLayer::parent_mutators ( )
inline

Definition at line 44 of file mock_layer.h.

44{ return parent_mutators_; }

◆ Preroll()

void flutter::testing::MockLayer::Preroll ( PrerollContext context)
overridevirtual

Implements flutter::Layer.

Definition at line 33 of file mock_layer.cc.

33 {
34 context->state_stack.fill(&parent_mutators_);
35 parent_matrix_ = context->state_stack.transform_3x3();
36 parent_cull_rect_ = context->state_stack.local_cull_rect();
37
38 set_parent_has_platform_view(context->has_platform_view);
39 set_parent_has_texture_layer(context->has_texture_layer);
40
41 context->has_platform_view = fake_has_platform_view();
42 context->has_texture_layer = fake_has_texture_layer();
43 set_paint_bounds(fake_paint_path_.getBounds());
44 if (fake_reads_surface()) {
45 context->surface_needs_readback = true;
46 }
48 context->renderable_state_flags = LayerStateStack::kCallerCanApplyOpacity;
49 }
50}
static constexpr int kCallerCanApplyOpacity
void set_paint_bounds(const SkRect &paint_bounds)
Definition layer.h:222
MockLayer & set_parent_has_platform_view(bool flag)
Definition mock_layer.h:70
MockLayer & set_parent_has_texture_layer(bool flag)
Definition mock_layer.h:76

◆ set_expected_paint_matrix()

void flutter::testing::MockLayer::set_expected_paint_matrix ( const SkMatrix matrix)
inline

Definition at line 106 of file mock_layer.h.

106 {
107 expected_paint_matrix_ = matrix;
108 }

◆ set_fake_has_platform_view()

MockLayer & flutter::testing::MockLayer::set_fake_has_platform_view ( bool  flag)
inline

Definition at line 82 of file mock_layer.h.

82 {
83 flag ? (mock_flags_ |= kFakeHasPlatformView)
84 : (mock_flags_ &= ~(kFakeHasPlatformView));
85 return *this;
86 }
FlutterSemanticsFlag flag

◆ set_fake_has_texture_layer()

MockLayer & flutter::testing::MockLayer::set_fake_has_texture_layer ( bool  flag)
inline

Definition at line 100 of file mock_layer.h.

100 {
101 flag ? (mock_flags_ |= kFakeHasTextureLayer)
102 : (mock_flags_ &= ~(kFakeHasTextureLayer));
103 return *this;
104 }

◆ set_fake_opacity_compatible()

MockLayer & flutter::testing::MockLayer::set_fake_opacity_compatible ( bool  flag)
inline

Definition at line 94 of file mock_layer.h.

94 {
95 flag ? (mock_flags_ |= kFakeOpacityCompatible)
96 : (mock_flags_ &= ~(kFakeOpacityCompatible));
97 return *this;
98 }

◆ set_fake_reads_surface()

MockLayer & flutter::testing::MockLayer::set_fake_reads_surface ( bool  flag)
inline

Definition at line 88 of file mock_layer.h.

88 {
89 flag ? (mock_flags_ |= kFakeReadsSurface)
90 : (mock_flags_ &= ~(kFakeReadsSurface));
91 return *this;
92 }

◆ set_parent_has_platform_view()

MockLayer & flutter::testing::MockLayer::set_parent_has_platform_view ( bool  flag)
inline

Definition at line 70 of file mock_layer.h.

70 {
71 flag ? (mock_flags_ |= kParentHasPlatformView)
72 : (mock_flags_ &= ~(kParentHasPlatformView));
73 return *this;
74 }

◆ set_parent_has_texture_layer()

MockLayer & flutter::testing::MockLayer::set_parent_has_texture_layer ( bool  flag)
inline

Definition at line 76 of file mock_layer.h.

76 {
77 flag ? (mock_flags_ |= kParentHasTextureLayer)
78 : (mock_flags_ &= ~(kParentHasTextureLayer));
79 return *this;
80 }

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