Ensure cc::PictureLayer's client is cleared
cc::PictureLayer is ref counted, so it can live longer than the client,
so for safety, the client should call ClearClient() of the layer when
the client is destructed or is no longer the client of the layer.
Bug: 913464
Change-Id: Id9093a8fba371e3773dd0ae292a0f855ce4f100a
Reviewed-on: https://chromium-review.googlesource.com/c/1427447
Reviewed-by: Philip Rogers <[email protected]>
Reviewed-by: Antoine Labour <[email protected]>
Commit-Queue: Xianzhu Wang <[email protected]>
Cr-Commit-Position: refs/heads/master@{#625478}
diff --git a/content/renderer/child_frame_compositing_helper.cc b/content/renderer/child_frame_compositing_helper.cc
index 6bd5177..fda424e7 100644
--- a/content/renderer/child_frame_compositing_helper.cc
+++ b/content/renderer/child_frame_compositing_helper.cc
@@ -27,24 +27,25 @@
DCHECK(child_frame_compositor_);
}
-ChildFrameCompositingHelper::~ChildFrameCompositingHelper() = default;
+ChildFrameCompositingHelper::~ChildFrameCompositingHelper() {
+ if (crash_ui_layer_)
+ crash_ui_layer_->ClearClient();
+}
void ChildFrameCompositingHelper::ChildFrameGone(
const gfx::Size& frame_size_in_dip,
float device_scale_factor) {
surface_id_ = viz::SurfaceId();
- crashed_ = true;
device_scale_factor_ = device_scale_factor;
- auto crash_ui_layer = cc::PictureLayer::Create(this);
- crash_ui_layer->SetMasksToBounds(true);
+ crash_ui_layer_ = cc::PictureLayer::Create(this);
+ crash_ui_layer_->SetMasksToBounds(true);
+ crash_ui_layer_->SetIsDrawable(true);
bool prevent_contents_opaque_changes = false;
bool is_surface_layer = false;
- child_frame_compositor_->SetLayer(std::move(crash_ui_layer),
- prevent_contents_opaque_changes,
- is_surface_layer);
- UpdateVisibility(true);
+ child_frame_compositor_->SetLayer(
+ crash_ui_layer_, prevent_contents_opaque_changes, is_surface_layer);
}
void ChildFrameCompositingHelper::SetSurfaceId(
@@ -82,15 +83,15 @@
}
gfx::Rect ChildFrameCompositingHelper::PaintableRegion() {
- DCHECK(crashed_);
- return gfx::Rect(child_frame_compositor_->GetLayer()->bounds());
+ DCHECK(crash_ui_layer_);
+ return gfx::Rect(crash_ui_layer_->bounds());
}
scoped_refptr<cc::DisplayItemList>
ChildFrameCompositingHelper::PaintContentsToDisplayList(
PaintingControlSetting) {
- DCHECK(crashed_);
- auto layer_size = child_frame_compositor_->GetLayer()->bounds();
+ DCHECK(crash_ui_layer_);
+ auto layer_size = crash_ui_layer_->bounds();
auto display_list = base::MakeRefCounted<cc::DisplayItemList>();
display_list->StartPaint();
display_list->push<cc::DrawColorOp>(SK_ColorGRAY, SkBlendMode::kSrc);