Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions flow/layers/backdrop_filter_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ BackdropFilterLayer::BackdropFilterLayer(sk_sp<SkImageFilter> filter)
: filter_(std::move(filter)) {}

void BackdropFilterLayer::Preroll(PrerollContext* context,
const SkMatrix& matrix) {
const SkMatrix& matrix,
bool parent_need_cached) {
Layer::AutoPrerollSaveLayerState save =
Layer::AutoPrerollSaveLayerState::Create(context, true, bool(filter_));
ContainerLayer::Preroll(context, matrix);
ContainerLayer::Preroll(context, matrix, parent_need_cached);
}

void BackdropFilterLayer::Paint(PaintContext& context) const {
Expand Down
2 changes: 1 addition & 1 deletion flow/layers/backdrop_filter_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class BackdropFilterLayer : public ContainerLayer {
public:
BackdropFilterLayer(sk_sp<SkImageFilter> filter);

void Preroll(PrerollContext* context, const SkMatrix& matrix) override;
void Preroll(PrerollContext* context, const SkMatrix& matrix, bool parent_need_cached) override;

void Paint(PaintContext& context) const override;

Expand Down
18 changes: 9 additions & 9 deletions flow/layers/backdrop_filter_layer_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ using BackdropFilterLayerTest = LayerTest;
TEST_F(BackdropFilterLayerTest, PaintingEmptyLayerDies) {
auto layer = std::make_shared<BackdropFilterLayer>(sk_sp<SkImageFilter>());

layer->Preroll(preroll_context(), SkMatrix());
layer->Preroll(preroll_context(), SkMatrix(), false);
EXPECT_EQ(layer->paint_bounds(), kEmptyRect);
EXPECT_FALSE(layer->needs_painting());
EXPECT_FALSE(layer->needs_system_composite());
Expand Down Expand Up @@ -51,7 +51,7 @@ TEST_F(BackdropFilterLayerTest, EmptyFilter) {
auto layer = std::make_shared<BackdropFilterLayer>(nullptr);
layer->Add(mock_layer);

layer->Preroll(preroll_context(), initial_transform);
layer->Preroll(preroll_context(), initial_transform, false);
EXPECT_EQ(layer->paint_bounds(), child_bounds);
EXPECT_TRUE(layer->needs_painting());
EXPECT_EQ(mock_layer->parent_matrix(), initial_transform);
Expand All @@ -77,7 +77,7 @@ TEST_F(BackdropFilterLayerTest, SimpleFilter) {
auto layer = std::make_shared<BackdropFilterLayer>(layer_filter);
layer->Add(mock_layer);

layer->Preroll(preroll_context(), initial_transform);
layer->Preroll(preroll_context(), initial_transform, false);
EXPECT_EQ(layer->paint_bounds(), child_bounds);
EXPECT_TRUE(layer->needs_painting());
EXPECT_EQ(mock_layer->parent_matrix(), initial_transform);
Expand Down Expand Up @@ -110,7 +110,7 @@ TEST_F(BackdropFilterLayerTest, MultipleChildren) {

SkRect children_bounds = child_path1.getBounds();
children_bounds.join(child_path2.getBounds());
layer->Preroll(preroll_context(), initial_transform);
layer->Preroll(preroll_context(), initial_transform, false);
EXPECT_EQ(mock_layer1->paint_bounds(), child_path1.getBounds());
EXPECT_EQ(mock_layer2->paint_bounds(), child_path2.getBounds());
EXPECT_EQ(layer->paint_bounds(), children_bounds);
Expand Down Expand Up @@ -153,7 +153,7 @@ TEST_F(BackdropFilterLayerTest, Nested) {

SkRect children_bounds = child_path1.getBounds();
children_bounds.join(child_path2.getBounds());
layer1->Preroll(preroll_context(), initial_transform);
layer1->Preroll(preroll_context(), initial_transform, false);
EXPECT_EQ(mock_layer1->paint_bounds(), child_path1.getBounds());
EXPECT_EQ(mock_layer2->paint_bounds(), child_path2.getBounds());
EXPECT_EQ(layer1->paint_bounds(), children_bounds);
Expand Down Expand Up @@ -190,26 +190,26 @@ TEST_F(BackdropFilterLayerTest, Readback) {
// BDF with filter always reads from surface
auto layer1 = std::make_shared<BackdropFilterLayer>(layer_filter);
preroll_context()->surface_needs_readback = false;
layer1->Preroll(preroll_context(), initial_transform);
layer1->Preroll(preroll_context(), initial_transform, false);
EXPECT_TRUE(preroll_context()->surface_needs_readback);

// BDF with no filter does not read from surface itself
auto layer2 = std::make_shared<BackdropFilterLayer>(no_filter);
preroll_context()->surface_needs_readback = false;
layer2->Preroll(preroll_context(), initial_transform);
layer2->Preroll(preroll_context(), initial_transform, false);
EXPECT_FALSE(preroll_context()->surface_needs_readback);

// BDF with no filter does not block prior readback value
preroll_context()->surface_needs_readback = true;
layer2->Preroll(preroll_context(), initial_transform);
layer2->Preroll(preroll_context(), initial_transform, false);
EXPECT_TRUE(preroll_context()->surface_needs_readback);

// BDF with no filter blocks child with readback
auto mock_layer =
std::make_shared<MockLayer>(SkPath(), SkPaint(), false, false, true);
layer2->Add(mock_layer);
preroll_context()->surface_needs_readback = false;
layer2->Preroll(preroll_context(), initial_transform);
layer2->Preroll(preroll_context(), initial_transform, false);
EXPECT_FALSE(preroll_context()->surface_needs_readback);
}

Expand Down
2 changes: 1 addition & 1 deletion flow/layers/child_scene_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ChildSceneLayer::ChildSceneLayer(zx_koid_t layer_id,
size_(size),
hit_testable_(hit_testable) {}

void ChildSceneLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
void ChildSceneLayer::Preroll(PrerollContext* context, const SkMatrix& matrix, bool parent_need_cached) {
TRACE_EVENT0("flutter", "ChildSceneLayer::Preroll");

context->child_scene_layer_exists_below = true;
Expand Down
2 changes: 1 addition & 1 deletion flow/layers/child_scene_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ChildSceneLayer : public Layer {
bool hit_testable);
~ChildSceneLayer() override = default;

void Preroll(PrerollContext* context, const SkMatrix& matrix) override;
void Preroll(PrerollContext* context, const SkMatrix& matrix, bool parent_need_cached) override;

void Paint(PaintContext& context) const override;

Expand Down
12 changes: 8 additions & 4 deletions flow/layers/clip_path_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,26 @@ ClipPathLayer::ClipPathLayer(const SkPath& clip_path, Clip clip_behavior)
FML_DCHECK(clip_behavior != Clip::none);
}

void ClipPathLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
void ClipPathLayer::Preroll(PrerollContext* context, const SkMatrix& matrix, bool parent_need_cached) {
TRACE_EVENT0("flutter", "ClipPathLayer::Preroll");

SkRect previous_cull_rect = context->cull_rect;
SkRect clip_path_bounds = clip_path_.getBounds();
children_inside_clip_ = context->cull_rect.intersect(clip_path_bounds);
if (parent_need_cached) {
children_inside_clip_ = true;
} else {
children_inside_clip_ = context->cull_rect.intersect(clip_path_bounds);
}
if (children_inside_clip_) {
TRACE_EVENT_INSTANT0("flutter", "children inside clip rect");

Layer::AutoPrerollSaveLayerState save =
Layer::AutoPrerollSaveLayerState::Create(context, UsesSaveLayer());
context->mutators_stack.PushClipPath(clip_path_);
SkRect child_paint_bounds = SkRect::MakeEmpty();
PrerollChildren(context, matrix, &child_paint_bounds);
PrerollChildren(context, matrix, &child_paint_bounds,parent_need_cached);

if (child_paint_bounds.intersect(clip_path_bounds)) {
if (child_paint_bounds.intersect(clip_path_bounds) || parent_need_cached) {
set_paint_bounds(child_paint_bounds);
}
context->mutators_stack.Pop();
Expand Down
2 changes: 1 addition & 1 deletion flow/layers/clip_path_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ClipPathLayer : public ContainerLayer {
public:
ClipPathLayer(const SkPath& clip_path, Clip clip_behavior = Clip::antiAlias);

void Preroll(PrerollContext* context, const SkMatrix& matrix) override;
void Preroll(PrerollContext* context, const SkMatrix& matrix, bool parent_need_cached) override;

void Paint(PaintContext& context) const override;

Expand Down
12 changes: 6 additions & 6 deletions flow/layers/clip_path_layer_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ TEST_F(ClipPathLayerTest, ClipNoneBehaviorDies) {
TEST_F(ClipPathLayerTest, PaintingEmptyLayerDies) {
auto layer = std::make_shared<ClipPathLayer>(SkPath(), Clip::hardEdge);

layer->Preroll(preroll_context(), SkMatrix());
layer->Preroll(preroll_context(), SkMatrix(), false);
EXPECT_EQ(preroll_context()->cull_rect, kGiantRect); // Untouched
EXPECT_TRUE(preroll_context()->mutators_stack.is_empty()); // Untouched
EXPECT_EQ(layer->paint_bounds(), kEmptyRect);
Expand Down Expand Up @@ -57,7 +57,7 @@ TEST_F(ClipPathLayerTest, PaintingCulledLayerDies) {

preroll_context()->cull_rect = kEmptyRect; // Cull everything

layer->Preroll(preroll_context(), initial_matrix);
layer->Preroll(preroll_context(), initial_matrix, false);
EXPECT_EQ(preroll_context()->cull_rect, kEmptyRect); // Untouched
EXPECT_TRUE(preroll_context()->mutators_stack.is_empty()); // Untouched
EXPECT_EQ(mock_layer->paint_bounds(), kEmptyRect);
Expand Down Expand Up @@ -91,7 +91,7 @@ TEST_F(ClipPathLayerTest, ChildOutsideBounds) {
child_intersect_bounds.intersect(child_bounds);
preroll_context()->cull_rect = cull_bounds; // Cull child

layer->Preroll(preroll_context(), initial_matrix);
layer->Preroll(preroll_context(), initial_matrix, false);
EXPECT_EQ(preroll_context()->cull_rect, cull_bounds); // Untouched
EXPECT_TRUE(preroll_context()->mutators_stack.is_empty()); // Untouched
EXPECT_EQ(mock_layer->paint_bounds(), child_bounds);
Expand Down Expand Up @@ -126,7 +126,7 @@ TEST_F(ClipPathLayerTest, FullyContainedChild) {
auto layer = std::make_shared<ClipPathLayer>(layer_path, Clip::hardEdge);
layer->Add(mock_layer);

layer->Preroll(preroll_context(), initial_matrix);
layer->Preroll(preroll_context(), initial_matrix, false);
EXPECT_EQ(preroll_context()->cull_rect, kGiantRect); // Untouched
EXPECT_TRUE(preroll_context()->mutators_stack.is_empty()); // Untouched
EXPECT_EQ(mock_layer->paint_bounds(), child_bounds);
Expand Down Expand Up @@ -168,7 +168,7 @@ TEST_F(ClipPathLayerTest, PartiallyContainedChild) {
child_intersect_bounds.intersect(child_bounds);
preroll_context()->cull_rect = cull_bounds; // Cull child

layer->Preroll(preroll_context(), initial_matrix);
layer->Preroll(preroll_context(), initial_matrix, false);
EXPECT_EQ(preroll_context()->cull_rect, cull_bounds); // Untouched
EXPECT_TRUE(preroll_context()->mutators_stack.is_empty()); // Untouched
EXPECT_EQ(mock_layer->paint_bounds(), child_bounds);
Expand Down Expand Up @@ -204,7 +204,7 @@ static bool ReadbackResult(PrerollContext* context,
layer->Add(child);
}
context->surface_needs_readback = before;
layer->Preroll(context, initial_matrix);
layer->Preroll(context, initial_matrix, false);
return context->surface_needs_readback;
}

Expand Down
12 changes: 8 additions & 4 deletions flow/layers/clip_rect_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,25 @@ ClipRectLayer::ClipRectLayer(const SkRect& clip_rect, Clip clip_behavior)
FML_DCHECK(clip_behavior != Clip::none);
}

void ClipRectLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
void ClipRectLayer::Preroll(PrerollContext* context, const SkMatrix& matrix, bool parent_need_cached) {
TRACE_EVENT0("flutter", "ClipRectLayer::Preroll");

SkRect previous_cull_rect = context->cull_rect;
children_inside_clip_ = context->cull_rect.intersect(clip_rect_);
if (parent_need_cached) {
children_inside_clip_ = true;
} else {
children_inside_clip_ = context->cull_rect.intersect(clip_rect_);
}
if (children_inside_clip_) {
TRACE_EVENT_INSTANT0("flutter", "children inside clip rect");

Layer::AutoPrerollSaveLayerState save =
Layer::AutoPrerollSaveLayerState::Create(context, UsesSaveLayer());
context->mutators_stack.PushClipRect(clip_rect_);
SkRect child_paint_bounds = SkRect::MakeEmpty();
PrerollChildren(context, matrix, &child_paint_bounds);
PrerollChildren(context, matrix, &child_paint_bounds, parent_need_cached);

if (child_paint_bounds.intersect(clip_rect_)) {
if (child_paint_bounds.intersect(clip_rect_) || parent_need_cached) {
set_paint_bounds(child_paint_bounds);
}
context->mutators_stack.Pop();
Expand Down
2 changes: 1 addition & 1 deletion flow/layers/clip_rect_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ClipRectLayer : public ContainerLayer {
public:
ClipRectLayer(const SkRect& clip_rect, Clip clip_behavior);

void Preroll(PrerollContext* context, const SkMatrix& matrix) override;
void Preroll(PrerollContext* context, const SkMatrix& matrix, bool parent_need_cached) override;
void Paint(PaintContext& context) const override;

bool UsesSaveLayer() const {
Expand Down
12 changes: 6 additions & 6 deletions flow/layers/clip_rect_layer_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ TEST_F(ClipRectLayerTest, ClipNoneBehaviorDies) {
TEST_F(ClipRectLayerTest, PaintingEmptyLayerDies) {
auto layer = std::make_shared<ClipRectLayer>(kEmptyRect, Clip::hardEdge);

layer->Preroll(preroll_context(), SkMatrix());
layer->Preroll(preroll_context(), SkMatrix(), false);
EXPECT_EQ(preroll_context()->cull_rect, kGiantRect); // Untouched
EXPECT_TRUE(preroll_context()->mutators_stack.is_empty()); // Untouched
EXPECT_EQ(layer->paint_bounds(), kEmptyRect);
Expand Down Expand Up @@ -55,7 +55,7 @@ TEST_F(ClipRectLayerTest, PaintingCulledLayerDies) {

preroll_context()->cull_rect = kEmptyRect; // Cull everything

layer->Preroll(preroll_context(), initial_matrix);
layer->Preroll(preroll_context(), initial_matrix, false);
EXPECT_EQ(preroll_context()->cull_rect, kEmptyRect); // Untouched
EXPECT_TRUE(preroll_context()->mutators_stack.is_empty()); // Untouched
EXPECT_EQ(mock_layer->paint_bounds(), kEmptyRect);
Expand Down Expand Up @@ -88,7 +88,7 @@ TEST_F(ClipRectLayerTest, ChildOutsideBounds) {
child_intersect_bounds.intersect(child_bounds);
preroll_context()->cull_rect = cull_bounds; // Cull child

layer->Preroll(preroll_context(), initial_matrix);
layer->Preroll(preroll_context(), initial_matrix, false);
EXPECT_EQ(preroll_context()->cull_rect, cull_bounds); // Untouched
EXPECT_TRUE(preroll_context()->mutators_stack.is_empty()); // Untouched
EXPECT_EQ(mock_layer->paint_bounds(), child_bounds);
Expand Down Expand Up @@ -123,7 +123,7 @@ TEST_F(ClipRectLayerTest, FullyContainedChild) {
auto layer = std::make_shared<ClipRectLayer>(layer_bounds, Clip::hardEdge);
layer->Add(mock_layer);

layer->Preroll(preroll_context(), initial_matrix);
layer->Preroll(preroll_context(), initial_matrix, false);
EXPECT_EQ(preroll_context()->cull_rect, kGiantRect); // Untouched
EXPECT_TRUE(preroll_context()->mutators_stack.is_empty()); // Untouched
EXPECT_EQ(mock_layer->paint_bounds(), child_bounds);
Expand Down Expand Up @@ -165,7 +165,7 @@ TEST_F(ClipRectLayerTest, PartiallyContainedChild) {
child_intersect_bounds.intersect(child_bounds);
preroll_context()->cull_rect = cull_bounds; // Cull child

layer->Preroll(preroll_context(), initial_matrix);
layer->Preroll(preroll_context(), initial_matrix, false);
EXPECT_EQ(preroll_context()->cull_rect, cull_bounds); // Untouched
EXPECT_TRUE(preroll_context()->mutators_stack.is_empty()); // Untouched
EXPECT_EQ(mock_layer->paint_bounds(), child_bounds);
Expand Down Expand Up @@ -201,7 +201,7 @@ static bool ReadbackResult(PrerollContext* context,
layer->Add(child);
}
context->surface_needs_readback = before;
layer->Preroll(context, initial_matrix);
layer->Preroll(context, initial_matrix, false);
return context->surface_needs_readback;
}

Expand Down
12 changes: 8 additions & 4 deletions flow/layers/clip_rrect_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,26 @@ ClipRRectLayer::ClipRRectLayer(const SkRRect& clip_rrect, Clip clip_behavior)
FML_DCHECK(clip_behavior != Clip::none);
}

void ClipRRectLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
void ClipRRectLayer::Preroll(PrerollContext* context, const SkMatrix& matrix, bool parent_need_cached) {
TRACE_EVENT0("flutter", "ClipRRectLayer::Preroll");

SkRect previous_cull_rect = context->cull_rect;
SkRect clip_rrect_bounds = clip_rrect_.getBounds();
children_inside_clip_ = context->cull_rect.intersect(clip_rrect_bounds);
if (parent_need_cached) {
children_inside_clip_ = true;
} else {
children_inside_clip_ = context->cull_rect.intersect(clip_rrect_bounds);
}
if (children_inside_clip_) {
TRACE_EVENT_INSTANT0("flutter", "children inside clip rect");

Layer::AutoPrerollSaveLayerState save =
Layer::AutoPrerollSaveLayerState::Create(context, UsesSaveLayer());
context->mutators_stack.PushClipRRect(clip_rrect_);
SkRect child_paint_bounds = SkRect::MakeEmpty();
PrerollChildren(context, matrix, &child_paint_bounds);
PrerollChildren(context, matrix, &child_paint_bounds, parent_need_cached);

if (child_paint_bounds.intersect(clip_rrect_bounds)) {
if (child_paint_bounds.intersect(clip_rrect_bounds) || parent_need_cached) {
set_paint_bounds(child_paint_bounds);
}
context->mutators_stack.Pop();
Expand Down
2 changes: 1 addition & 1 deletion flow/layers/clip_rrect_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ClipRRectLayer : public ContainerLayer {
public:
ClipRRectLayer(const SkRRect& clip_rrect, Clip clip_behavior);

void Preroll(PrerollContext* context, const SkMatrix& matrix) override;
void Preroll(PrerollContext* context, const SkMatrix& matrix, bool parent_need_cached) override;

void Paint(PaintContext& context) const override;

Expand Down
12 changes: 6 additions & 6 deletions flow/layers/clip_rrect_layer_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ TEST_F(ClipRRectLayerTest, PaintingEmptyLayerDies) {
const SkRRect layer_rrect = SkRRect::MakeEmpty();
auto layer = std::make_shared<ClipRRectLayer>(layer_rrect, Clip::hardEdge);

layer->Preroll(preroll_context(), SkMatrix());
layer->Preroll(preroll_context(), SkMatrix(), false);
EXPECT_EQ(preroll_context()->cull_rect, kGiantRect); // Untouched
EXPECT_TRUE(preroll_context()->mutators_stack.is_empty()); // Untouched
EXPECT_EQ(layer->paint_bounds(), kEmptyRect);
Expand Down Expand Up @@ -60,7 +60,7 @@ TEST_F(ClipRRectLayerTest, PaintingCulledLayerDies) {

preroll_context()->cull_rect = kEmptyRect; // Cull everything

layer->Preroll(preroll_context(), initial_matrix);
layer->Preroll(preroll_context(), initial_matrix, false);
EXPECT_EQ(preroll_context()->cull_rect, kEmptyRect); // Untouched
EXPECT_TRUE(preroll_context()->mutators_stack.is_empty()); // Untouched
EXPECT_EQ(mock_layer->paint_bounds(), kEmptyRect);
Expand Down Expand Up @@ -94,7 +94,7 @@ TEST_F(ClipRRectLayerTest, ChildOutsideBounds) {
child_intersect_bounds.intersect(child_bounds);
preroll_context()->cull_rect = cull_bounds; // Cull child

layer->Preroll(preroll_context(), initial_matrix);
layer->Preroll(preroll_context(), initial_matrix, false);
EXPECT_EQ(preroll_context()->cull_rect, cull_bounds); // Untouched
EXPECT_TRUE(preroll_context()->mutators_stack.is_empty()); // Untouched
EXPECT_EQ(mock_layer->paint_bounds(), child_bounds);
Expand Down Expand Up @@ -129,7 +129,7 @@ TEST_F(ClipRRectLayerTest, FullyContainedChild) {
auto layer = std::make_shared<ClipRRectLayer>(layer_rrect, Clip::hardEdge);
layer->Add(mock_layer);

layer->Preroll(preroll_context(), initial_matrix);
layer->Preroll(preroll_context(), initial_matrix, false);
EXPECT_EQ(preroll_context()->cull_rect, kGiantRect); // Untouched
EXPECT_TRUE(preroll_context()->mutators_stack.is_empty()); // Untouched
EXPECT_EQ(mock_layer->paint_bounds(), child_bounds);
Expand Down Expand Up @@ -171,7 +171,7 @@ TEST_F(ClipRRectLayerTest, PartiallyContainedChild) {
child_intersect_bounds.intersect(child_bounds);
preroll_context()->cull_rect = cull_bounds; // Cull child

layer->Preroll(preroll_context(), initial_matrix);
layer->Preroll(preroll_context(), initial_matrix, false);
EXPECT_EQ(preroll_context()->cull_rect, cull_bounds); // Untouched
EXPECT_TRUE(preroll_context()->mutators_stack.is_empty()); // Untouched
EXPECT_EQ(mock_layer->paint_bounds(), child_bounds);
Expand Down Expand Up @@ -207,7 +207,7 @@ static bool ReadbackResult(PrerollContext* context,
layer->Add(child);
}
context->surface_needs_readback = before;
layer->Preroll(context, initial_matrix);
layer->Preroll(context, initial_matrix, false);
return context->surface_needs_readback;
}

Expand Down
Loading