Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 4246f15

Browse files
authored
Revert "Reland: Partial repaint platform views" (#54537)
Reverts #54231 Speculatively reverting for flutter/flutter#153335
1 parent 2f8c752 commit 4246f15

9 files changed

+26
-81
lines changed

flow/diff_context.cc

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void DiffContext::BeginSubtree() {
2727
bool had_integral_transform = state_.integral_transform;
2828
state_.rect_index = rects_->size();
2929
state_.has_filter_bounds_adjustment = false;
30-
state_.has_volatile_layer = false;
30+
state_.has_texture = false;
3131
state_.integral_transform = false;
3232

3333
if (had_integral_transform) {
@@ -203,20 +203,14 @@ void DiffContext::AddLayerBounds(const SkRect& rect) {
203203
}
204204
}
205205

206-
void DiffContext::RepaintEntireFrame() {
207-
auto frame_rect = SkRect::MakeIWH(frame_size_.width(), frame_size_.height());
208-
rects_->push_back(frame_rect);
209-
AddDamage(frame_rect);
210-
}
211-
212-
void DiffContext::MarkSubtreeHasVolatileLayer() {
206+
void DiffContext::MarkSubtreeHasTextureLayer() {
213207
// Set the has_texture flag on current state and all parent states. That
214208
// way we'll know that we can't skip diff for retained layers because
215209
// they contain a TextureLayer.
216210
for (auto& state : state_stack_) {
217-
state.has_volatile_layer = true;
211+
state.has_texture = true;
218212
}
219-
state_.has_volatile_layer = true;
213+
state_.has_texture = true;
220214
}
221215

222216
void DiffContext::AddExistingPaintRegion(const PaintRegion& region) {
@@ -244,7 +238,7 @@ PaintRegion DiffContext::CurrentSubtreeRegion() const {
244238
readbacks_.begin(), readbacks_.end(),
245239
[&](const Readback& r) { return r.position >= state_.rect_index; });
246240
return PaintRegion(rects_, state_.rect_index, rects_->size(), has_readback,
247-
state_.has_volatile_layer);
241+
state_.has_texture);
248242
}
249243

250244
void DiffContext::AddDamage(const PaintRegion& damage) {

flow/diff_context.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,18 +107,14 @@ class DiffContext {
107107

108108
bool IsSubtreeDirty() const { return state_.dirty; }
109109

110-
// Marks that current subtree contains a volatile layer. A volatile layer will
111-
// do diffing even if it is a retained subtree. Necessary for TextureLayer
112-
// and PlatformViewLayer.
113-
void MarkSubtreeHasVolatileLayer();
110+
// Marks that current subtree contains a TextureLayer. This is needed to
111+
// ensure that we'll Diff the TextureLayer even if inside retained layer.
112+
void MarkSubtreeHasTextureLayer();
114113

115114
// Add layer bounds to current paint region; rect is in "local" (layer)
116115
// coordinates.
117116
void AddLayerBounds(const SkRect& rect);
118117

119-
// Marks entire frame as dirty.
120-
void RepaintEntireFrame();
121-
122118
// Add entire paint region of retained layer for current subtree. This can
123119
// only be used in subtrees that are not dirty, otherwise ancestor transforms
124120
// or clips may result in different paint region.
@@ -235,7 +231,7 @@ class DiffContext {
235231
bool has_filter_bounds_adjustment = false;
236232

237233
// Whether there is a texture layer in this subtree.
238-
bool has_volatile_layer = false;
234+
bool has_texture = false;
239235
};
240236

241237
void MakeTransformIntegral(DisplayListMatrixClipState& matrix_clip);

flow/layers/container_layer.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void ContainerLayer::DiffChildren(DiffContext* context,
7878
auto prev_layer = prev_layers[i_prev];
7979
auto paint_region = context->GetOldLayerPaintRegion(prev_layer.get());
8080
if (layer == prev_layer && !paint_region.has_readback() &&
81-
!paint_region.has_volatile_layer()) {
81+
!paint_region.has_texture()) {
8282
// for retained layers, stop processing the subtree and add existing
8383
// region; We know current subtree is not dirty (every ancestor up to
8484
// here matches) so the retained subtree will render identically to

flow/layers/platform_view_layer.cc

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,6 @@ PlatformViewLayer::PlatformViewLayer(const SkPoint& offset,
1313
int64_t view_id)
1414
: offset_(offset), size_(size), view_id_(view_id) {}
1515

16-
void PlatformViewLayer::Diff(DiffContext* context, const Layer* old_layer) {
17-
DiffContext::AutoSubtreeRestore subtree(context);
18-
// Ensure that Diff is called again even if this layer is in retained subtree.
19-
context->MarkSubtreeHasVolatileLayer();
20-
// Partial repaint is disabled when platform view is present. This will also
21-
// set whole frame as the layer paint region, which will ensure full repaint
22-
// when the layer is removed.
23-
context->RepaintEntireFrame();
24-
context->SetLayerPaintRegion(this, context->CurrentSubtreeRegion());
25-
}
26-
2716
void PlatformViewLayer::Preroll(PrerollContext* context) {
2817
set_paint_bounds(SkRect::MakeXYWH(offset_.x(), offset_.y(), size_.width(),
2918
size_.height()));

flow/layers/platform_view_layer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ class PlatformViewLayer : public Layer {
1616
public:
1717
PlatformViewLayer(const SkPoint& offset, const SkSize& size, int64_t view_id);
1818

19-
void Diff(DiffContext* context, const Layer* old_layer) override;
2019
void Preroll(PrerollContext* context) override;
2120
void Paint(PaintContext& context) const override;
2221

flow/layers/platform_view_layer_unittests.cc

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include "flutter/flow/layers/platform_view_layer.h"
77
#include "flutter/flow/layers/transform_layer.h"
88

9-
#include "flutter/flow/testing/diff_context_test.h"
109
#include "flutter/flow/testing/layer_test.h"
1110
#include "flutter/flow/testing/mock_embedder.h"
1211
#include "flutter/flow/testing/mock_layer.h"
@@ -140,45 +139,5 @@ TEST_F(PlatformViewLayerTest, StateTransfer) {
140139
transform_layer1->Paint(paint_ctx);
141140
}
142141

143-
using PlatformViewLayerDiffTest = DiffContextTest;
144-
145-
TEST_F(PlatformViewLayerDiffTest, PlatformViewRetainedLayer) {
146-
MockLayerTree tree1(SkISize::Make(800, 600));
147-
auto container = std::make_shared<ContainerLayer>();
148-
tree1.root()->Add(container);
149-
auto layer = std::make_shared<PlatformViewLayer>(SkPoint::Make(100, 100),
150-
SkSize::Make(100, 100), 0);
151-
container->Add(layer);
152-
153-
MockLayerTree tree2(SkISize::Make(800, 600));
154-
tree2.root()->Add(container); // retained layer
155-
156-
auto damage = DiffLayerTree(tree1, MockLayerTree(SkISize::Make(800, 600)));
157-
EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(0, 0, 800, 600));
158-
159-
damage = DiffLayerTree(tree2, tree1);
160-
EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(0, 0, 800, 600));
161-
}
162-
163-
TEST_F(PlatformViewLayerDiffTest, FullRepaintAfterRemovingLayer) {
164-
MockLayerTree tree1(SkISize::Make(800, 600));
165-
auto container = std::make_shared<ContainerLayer>();
166-
tree1.root()->Add(container);
167-
auto layer = std::make_shared<PlatformViewLayer>(SkPoint::Make(100, 100),
168-
SkSize::Make(100, 100), 0);
169-
container->Add(layer);
170-
171-
auto damage = DiffLayerTree(tree1, MockLayerTree(SkISize::Make(800, 600)));
172-
EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(0, 0, 800, 600));
173-
174-
// Second layer tree with the PlatformViewLayer removed.
175-
MockLayerTree tree2(SkISize::Make(800, 600));
176-
auto container2 = std::make_shared<ContainerLayer>();
177-
tree2.root()->Add(container2);
178-
179-
damage = DiffLayerTree(tree2, tree1);
180-
EXPECT_EQ(damage.frame_damage, SkIRect::MakeLTRB(0, 0, 800, 600));
181-
}
182-
183142
} // namespace testing
184143
} // namespace flutter

flow/layers/texture_layer.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void TextureLayer::Diff(DiffContext* context, const Layer* old_layer) {
3434
// TextureLayer is inside retained layer.
3535
// See ContainerLayer::DiffChildren
3636
// https://github.com/flutter/flutter/issues/92925
37-
context->MarkSubtreeHasVolatileLayer();
37+
context->MarkSubtreeHasTextureLayer();
3838
context->AddLayerBounds(SkRect::MakeXYWH(offset_.x(), offset_.y(),
3939
size_.width(), size_.height()));
4040
context->SetLayerPaintRegion(this, context->CurrentSubtreeRegion());

flow/paint_region.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ class PaintRegion {
3030
size_t from,
3131
size_t to,
3232
bool has_readback,
33-
bool has_volatile_layer)
33+
bool has_texture)
3434
: rects_(std::move(rects)),
3535
from_(from),
3636
to_(to),
3737
has_readback_(has_readback),
38-
has_volatile_layer_(has_volatile_layer) {}
38+
has_texture_(has_texture) {}
3939

4040
std::vector<SkRect>::const_iterator begin() const {
4141
FML_DCHECK(is_valid());
@@ -56,16 +56,16 @@ class PaintRegion {
5656
// that performs readback
5757
bool has_readback() const { return has_readback_; }
5858

59-
// Returns whether there is a TextureLayer or PlatformViewLayer in subtree
60-
// represented by this region.
61-
bool has_volatile_layer() const { return has_volatile_layer_; }
59+
// Returns whether there is a TextureLayer in subtree represented by this
60+
// region.
61+
bool has_texture() const { return has_texture_; }
6262

6363
private:
6464
std::shared_ptr<std::vector<SkRect>> rects_;
6565
size_t from_ = 0;
6666
size_t to_ = 0;
6767
bool has_readback_ = false;
68-
bool has_volatile_layer_ = false;
68+
bool has_texture_ = false;
6969
};
7070

7171
} // namespace flutter

shell/common/rasterizer.cc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,9 +743,17 @@ DrawSurfaceStatus Rasterizer::DrawToSurfaceUnsafe(
743743
// when leaf layer tracing is enabled we wish to repaint the whole frame
744744
// for accurate performance metrics.
745745
if (frame->framebuffer_info().supports_partial_repaint) {
746+
// Disable partial repaint if external_view_embedder_ SubmitFlutterView is
747+
// involved - ExternalViewEmbedder unconditionally clears the entire
748+
// surface and also partial repaint with platform view present is
749+
// something that still need to be figured out.
750+
bool force_full_repaint =
751+
external_view_embedder_ &&
752+
(!raster_thread_merger_ || raster_thread_merger_->IsMerged());
753+
746754
damage = std::make_unique<FrameDamage>();
747755
auto existing_damage = frame->framebuffer_info().existing_damage;
748-
if (existing_damage.has_value()) {
756+
if (existing_damage.has_value() && !force_full_repaint) {
749757
damage->SetPreviousLayerTree(GetLastLayerTree(view_id));
750758
damage->AddAdditionalDamage(existing_damage.value());
751759
damage->SetClipAlignment(

0 commit comments

Comments
 (0)