Flutter Engine
 
Loading...
Searching...
No Matches
transform_layer.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
7#include <optional>
8
9namespace flutter {
10
12 : transform_(transform) {
13 FML_DCHECK(transform_.IsFinite());
14 if (!transform_.IsFinite()) {
15 FML_LOG(ERROR) << "TransformLayer is constructed with an invalid matrix.";
16 transform_ = {};
17 }
18}
19
20void TransformLayer::Diff(DiffContext* context, const Layer* old_layer) {
21 DiffContext::AutoSubtreeRestore subtree(context);
22 auto* prev = static_cast<const TransformLayer*>(old_layer);
23 if (!context->IsSubtreeDirty()) {
24 FML_DCHECK(prev);
25 if (transform_ != prev->transform_) {
26 context->MarkSubtreeDirty(context->GetOldLayerPaintRegion(old_layer));
27 }
28 }
29 context->PushTransform(transform_);
30 DiffChildren(context, prev);
31 context->SetLayerPaintRegion(this, context->CurrentSubtreeRegion());
32}
33
44
45void TransformLayer::Paint(PaintContext& context) const {
46 FML_DCHECK(needs_painting(context));
47
48 auto mutator = context.state_stack.save();
49 mutator.transform(transform_);
50
51 PaintChildren(context);
52}
53
54} // namespace flutter
const DlRect & child_paint_bounds() const
void PrerollChildren(PrerollContext *context, DlRect *child_paint_bounds)
void PaintChildren(PaintContext &context) const override
virtual void DiffChildren(DiffContext *context, const ContainerLayer *old_layer)
void SetLayerPaintRegion(const Layer *layer, const PaintRegion &region)
void MarkSubtreeDirty(const PaintRegion &previous_paint_region=PaintRegion())
PaintRegion CurrentSubtreeRegion() const
PaintRegion GetOldLayerPaintRegion(const Layer *layer) const
bool IsSubtreeDirty() const
void PushTransform(const DlMatrix &transform)
void set_paint_bounds(const DlRect &paint_bounds)
Definition layer.h:209
bool needs_painting(PaintContext &context) const
Definition layer.h:218
void Diff(DiffContext *context, const Layer *old_layer) override
void Preroll(PrerollContext *context) override
void Paint(PaintContext &context) const override
TransformLayer(const DlMatrix &transform)
#define FML_LOG(severity)
Definition logging.h:101
#define FML_DCHECK(condition)
Definition logging.h:122
LayerStateStack & state_stack
Definition layer.h:91
LayerStateStack & state_stack
Definition layer.h:49
A 4x4 matrix using column-major storage.
Definition matrix.h:37
bool IsFinite() const
Definition matrix.h:404
constexpr TRect TransformAndClipBounds(const Matrix &transform) const
Creates a new bounding box that contains this transformed rectangle, clipped against the near clippin...
Definition rect.h:438