Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
flutter::TransformLayer Class Reference

#include <transform_layer.h>

Inheritance diagram for flutter::TransformLayer:
flutter::ContainerLayer flutter::Layer

Public Member Functions

 TransformLayer (const SkMatrix &transform)
 
 TransformLayer (const SkM44 &transform)
 
void Diff (DiffContext *context, const Layer *old_layer) override
 
void Preroll (PrerollContext *context) override
 
void Paint (PaintContext &context) const override
 
- Public Member Functions inherited from flutter::ContainerLayer
 ContainerLayer ()
 
void Diff (DiffContext *context, const Layer *old_layer) override
 
void PreservePaintRegion (DiffContext *context) override
 
virtual void Add (std::shared_ptr< Layer > layer)
 
void Preroll (PrerollContext *context) override
 
void Paint (PaintContext &context) const override
 
const std::vector< std::shared_ptr< Layer > > & layers () const
 
virtual void DiffChildren (DiffContext *context, const ContainerLayer *old_layer)
 
void PaintChildren (PaintContext &context) const override
 
const ContainerLayeras_container_layer () const override
 
const SkRectchild_paint_bounds () const
 
void set_child_paint_bounds (const SkRect &bounds)
 
int children_renderable_state_flags () const
 
void set_children_renderable_state_flags (int flags)
 
- Public Member Functions inherited from flutter::Layer
 Layer ()
 
virtual ~Layer ()
 
void AssignOldLayer (Layer *old_layer)
 
virtual bool IsReplacing (DiffContext *context, const Layer *old_layer) const
 
virtual void Diff (DiffContext *context, const Layer *old_layer)
 
virtual void PreservePaintRegion (DiffContext *context)
 
virtual void Preroll (PrerollContext *context)=0
 
virtual void Paint (PaintContext &context) const =0
 
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
 
virtual const testing::MockLayeras_mock_layer () const
 

Additional Inherited Members

- Static Public Attributes inherited from flutter::Layer
static constexpr int kSaveLayerRenderFlags
 
static constexpr int kRasterCacheRenderFlags
 
- Protected Member Functions inherited from flutter::ContainerLayer
void PrerollChildren (PrerollContext *context, SkRect *child_paint_bounds)
 

Detailed Description

Definition at line 14 of file transform_layer.h.

Constructor & Destructor Documentation

◆ TransformLayer() [1/2]

flutter::TransformLayer::TransformLayer ( const SkMatrix transform)
inlineexplicit

Definition at line 16 of file transform_layer.h.

Definition: SkM44.h:150
TransformLayer(const SkMatrix &transform)
static SkColor4f transform(SkColor4f c, SkColorSpace *src, SkColorSpace *dst)
Definition: p3.cpp:47

◆ TransformLayer() [2/2]

flutter::TransformLayer::TransformLayer ( const SkM44 transform)
explicit

Definition at line 11 of file transform_layer.cc.

11 : transform_(transform) {
12 // Checks (in some degree) that SkM44 transform_ is valid and initialized.
13 //
14 // If transform_ is uninitialized, this assert may look flaky as it doesn't
15 // fail all the time, and some rerun may make it pass. But don't ignore it and
16 // just rerun the test if this is triggered, since even a flaky failure here
17 // may signify a potentially big problem in the code.
18 //
19 // We have to write this flaky test because there is no reliable way to test
20 // whether a variable is initialized or not in C++.
21 FML_DCHECK(transform_.isFinite());
22 if (!transform_.isFinite()) {
23 FML_LOG(ERROR) << "TransformLayer is constructed with an invalid matrix.";
24 transform_.setIdentity();
25 }
26}
bool isFinite() const
Definition: SkM44.h:378
SkM44 & setIdentity()
Definition: SkM44.h:293
#define FML_LOG(severity)
Definition: logging.h:82
#define FML_DCHECK(condition)
Definition: logging.h:103
#define ERROR(message)
Definition: elf_loader.cc:260

Member Function Documentation

◆ Diff()

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

Reimplemented from flutter::ContainerLayer.

Definition at line 28 of file transform_layer.cc.

28 {
29 DiffContext::AutoSubtreeRestore subtree(context);
30 auto* prev = static_cast<const TransformLayer*>(old_layer);
31 if (!context->IsSubtreeDirty()) {
33 if (transform_ != prev->transform_) {
34 context->MarkSubtreeDirty(context->GetOldLayerPaintRegion(old_layer));
35 }
36 }
37 context->PushTransform(transform_);
38 DiffChildren(context, prev);
39 context->SetLayerPaintRegion(this, context->CurrentSubtreeRegion());
40}
static float prev(float f)
virtual void DiffChildren(DiffContext *context, const ContainerLayer *old_layer)

◆ Paint()

void flutter::TransformLayer::Paint ( PaintContext context) const
overridevirtual

Reimplemented from flutter::ContainerLayer.

Definition at line 68 of file transform_layer.cc.

68 {
69 FML_DCHECK(needs_painting(context));
70
71 auto mutator = context.state_stack.save();
72 mutator.transform(transform_);
73
74 PaintChildren(context);
75}
void PaintChildren(PaintContext &context) const override
bool needs_painting(PaintContext &context) const
Definition: layer.h:232

◆ Preroll()

void flutter::TransformLayer::Preroll ( PrerollContext context)
overridevirtual

Reimplemented from flutter::ContainerLayer.

Definition at line 42 of file transform_layer.cc.

42 {
43 auto mutator = context->state_stack.save();
44 mutator.transform(transform_);
45
48
49 // We convert to a 3x3 matrix here primarily because the SkM44 object
50 // does not support a mapRect operation.
51 // https://bugs.chromium.org/p/skia/issues/detail?id=11720&q=mapRect&can=2
52 //
53 // All geometry is X,Y only which means the 3rd row of the 4x4 matrix
54 // is ignored and the output of the 3rd column is also ignored.
55 // So we can transform the rectangle using just the 3x3 SkMatrix
56 // equivalent without any loss of information.
57 //
58 // Performance consideration:
59 // Skia has an internal mapRect for their SkM44 object that is faster
60 // than what SkMatrix does when it has perspective elements. But SkMatrix
61 // is otherwise optimal for non-perspective matrices. If SkM44 ever exposes
62 // a mapRect operation, or if SkMatrix ever optimizes its handling of
63 // the perspective elements, this issue will become moot.
64 transform_.asM33().mapRect(&child_paint_bounds);
66}
SkMatrix asM33() const
Definition: SkM44.h:409
bool mapRect(SkRect *dst, const SkRect &src, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes) const
Definition: SkMatrix.cpp:1141
void PrerollChildren(PrerollContext *context, SkRect *child_paint_bounds)
const SkRect & child_paint_bounds() const
void set_paint_bounds(const SkRect &paint_bounds)
Definition: layer.h:223
static constexpr SkRect MakeEmpty()
Definition: SkRect.h:595

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