Index: ui/ozone/platform/drm/gpu/drm_window.cc |
diff --git a/ui/ozone/platform/drm/gpu/drm_window.cc b/ui/ozone/platform/drm/gpu/drm_window.cc |
index a777d492c03874b18e01d74b59db41cffb84b980..1b33a1e6419b7bf166900546fdb4e67e59cdd327 100644 |
--- a/ui/ozone/platform/drm/gpu/drm_window.cc |
+++ b/ui/ozone/platform/drm/gpu/drm_window.cc |
@@ -126,6 +126,15 @@ void DrmWindow::QueueOverlayPlane(const OverlayPlane& plane) { |
bool DrmWindow::SchedulePageFlip(bool is_sync, |
const SwapCompletionCallback& callback) { |
+ if (force_buffer_reallocation_) { |
+ // Clear pending planes otherwise the next call to queue planes will just |
+ // add on top. |
+ pending_planes_.clear(); |
+ force_buffer_reallocation_ = false; |
+ callback.Run(gfx::SwapResult::SWAP_NAK_RECREATE_BUFFERS); |
+ return true; |
+ } |
+ |
last_submitted_planes_.clear(); |
last_submitted_planes_.swap(pending_planes_); |
last_swap_sync_ = is_sync; |
@@ -204,6 +213,12 @@ void DrmWindow::SetController(HardwareDisplayController* controller) { |
if (controller_ == controller) |
return; |
+ // Force buffer reallocation since the window moved to a different controller. |
+ // This is required otherwise the GPU will eventually try to render into the |
+ // buffer currently showing on the old controller (there is no guarantee that |
+ // the old controller has been updated in the meantime). |
+ force_buffer_reallocation_ = true; |
+ |
controller_ = controller; |
device_manager_->UpdateDrmDevice( |
widget_, controller ? controller->GetAllocationDrmDevice() : nullptr); |