namespace {
// The maximum number of damage rects to cache for outstanding frame requests
// (for OnAcceleratedPaint).
const size_t kMaxDamageRects = 10;
compositor_->SetRootLayer(root_layer_.get());
compositor_->AddChildFrameSink(GetFrameSinkId());
#else
LOG(INFO) << "compositor construct, widget = " << static_cast<uint32_t>(browser_impl_->GetAcceleratedWidget());
ui::Compositor* compositor = CefRenderWidgetHostViewOSR::GetCompositor(
browser_impl_->GetAcceleratedWidget());
accelerate_widget_map_[browser_impl_->GetAcceleratedWidget()]++;
if (!compositor) {
compositor = new ui::Compositor(
context_factory->AllocateFrameSinkId(), context_factory,
if (!compositor_) {
return; // already released
}
#else
if (!browser_impl_) {
return;
}
auto it = accelerate_widget_map_.find(browser_impl_->GetAcceleratedWidget());
if (it == accelerate_widget_map_.end()) {
return;
}
#endif
// Marking the DelegatedFrameHost as removed from the window hierarchy is
// necessary to remove all connections to its old ui::Compositor.
if (delegated_frame_host_) {
if (is_showing_) {
delegated_frame_host_->WasHidden(content:elegatedFrameHost::HiddenCause::kOther);
}
delegated_frame_host_->DetachFromCompositor();
delegated_frame_host_.reset(nullptr);
}
#ifdef DISABLE_GPU
compositor_.reset(nullptr);
#else
LOG(INFO) << "ReleaseCompositor";
if(--accelerate_widget_map_[browser_impl_->GetAcceleratedWidget()] == 0) {
if (!browser_impl_) {
return;
}
LOG(INFO) << "ReleaseCompositor, widget = " << static_cast<uint32_t>(browser_impl_->GetAcceleratedWidget());
auto it = compositor_map_.find(browser_impl_->GetAcceleratedWidget());
if (it != compositor_map_.end()) {
if (it->second != nullptr) {
delete it->second;
}
compositor_map_.erase(it);
}
accelerate_widget_map_.erase(browser_impl_->GetAcceleratedWidget());
}
#endif
}
```