| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/ozone/platform/drm/gpu/drm_window.h" | 5 #include "ui/ozone/platform/drm/gpu/drm_window.h" |
| 6 | 6 |
| 7 #include "base/trace_event/trace_event.h" | 7 #include "base/trace_event/trace_event.h" |
| 8 #include "third_party/skia/include/core/SkBitmap.h" | 8 #include "third_party/skia/include/core/SkBitmap.h" |
| 9 #include "third_party/skia/include/core/SkDevice.h" | 9 #include "third_party/skia/include/core/SkDevice.h" |
| 10 #include "third_party/skia/include/core/SkSurface.h" | 10 #include "third_party/skia/include/core/SkSurface.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 if (controller_) | 119 if (controller_) |
| 120 controller_->MoveCursor(location); | 120 controller_->MoveCursor(location); |
| 121 } | 121 } |
| 122 | 122 |
| 123 void DrmWindow::QueueOverlayPlane(const OverlayPlane& plane) { | 123 void DrmWindow::QueueOverlayPlane(const OverlayPlane& plane) { |
| 124 pending_planes_.push_back(plane); | 124 pending_planes_.push_back(plane); |
| 125 } | 125 } |
| 126 | 126 |
| 127 bool DrmWindow::SchedulePageFlip(bool is_sync, | 127 bool DrmWindow::SchedulePageFlip(bool is_sync, |
| 128 const SwapCompletionCallback& callback) { | 128 const SwapCompletionCallback& callback) { |
| 129 if (force_buffer_reallocation_) { |
| 130 // Clear pending planes otherwise the next call to queue planes will just |
| 131 // add on top. |
| 132 pending_planes_.clear(); |
| 133 force_buffer_reallocation_ = false; |
| 134 callback.Run(gfx::SwapResult::SWAP_NAK_RECREATE_BUFFERS); |
| 135 return true; |
| 136 } |
| 137 |
| 129 last_submitted_planes_.clear(); | 138 last_submitted_planes_.clear(); |
| 130 last_submitted_planes_.swap(pending_planes_); | 139 last_submitted_planes_.swap(pending_planes_); |
| 131 last_swap_sync_ = is_sync; | 140 last_swap_sync_ = is_sync; |
| 132 | 141 |
| 133 if (controller_) { | 142 if (controller_) { |
| 134 return controller_->SchedulePageFlip(last_submitted_planes_, is_sync, false, | 143 return controller_->SchedulePageFlip(last_submitted_planes_, is_sync, false, |
| 135 callback); | 144 callback); |
| 136 } | 145 } |
| 137 | 146 |
| 138 callback.Run(gfx::SwapResult::SWAP_ACK); | 147 callback.Run(gfx::SwapResult::SWAP_ACK); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 cursor_frame_++; | 206 cursor_frame_++; |
| 198 cursor_frame_ %= cursor_bitmaps_.size(); | 207 cursor_frame_ %= cursor_bitmaps_.size(); |
| 199 | 208 |
| 200 ResetCursor(true); | 209 ResetCursor(true); |
| 201 } | 210 } |
| 202 | 211 |
| 203 void DrmWindow::SetController(HardwareDisplayController* controller) { | 212 void DrmWindow::SetController(HardwareDisplayController* controller) { |
| 204 if (controller_ == controller) | 213 if (controller_ == controller) |
| 205 return; | 214 return; |
| 206 | 215 |
| 216 // Force buffer reallocation since the window moved to a different controller. |
| 217 // This is required otherwise the GPU will eventually try to render into the |
| 218 // buffer currently showing on the old controller (there is no guarantee that |
| 219 // the old controller has been updated in the meantime). |
| 220 force_buffer_reallocation_ = true; |
| 221 |
| 207 controller_ = controller; | 222 controller_ = controller; |
| 208 device_manager_->UpdateDrmDevice( | 223 device_manager_->UpdateDrmDevice( |
| 209 widget_, controller ? controller->GetAllocationDrmDevice() : nullptr); | 224 widget_, controller ? controller->GetAllocationDrmDevice() : nullptr); |
| 210 | 225 |
| 211 UpdateCursorBuffers(); | 226 UpdateCursorBuffers(); |
| 212 // We changed displays, so we want to update the cursor as well. | 227 // We changed displays, so we want to update the cursor as well. |
| 213 ResetCursor(false /* bitmap_only */); | 228 ResetCursor(false /* bitmap_only */); |
| 214 } | 229 } |
| 215 | 230 |
| 216 void DrmWindow::UpdateCursorBuffers() { | 231 void DrmWindow::UpdateCursorBuffers() { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 235 if (!cursor_buffers_[i]->Initialize( | 250 if (!cursor_buffers_[i]->Initialize( |
| 236 info, false /* should_register_framebuffer */)) { | 251 info, false /* should_register_framebuffer */)) { |
| 237 LOG(FATAL) << "Failed to initialize cursor buffer"; | 252 LOG(FATAL) << "Failed to initialize cursor buffer"; |
| 238 return; | 253 return; |
| 239 } | 254 } |
| 240 } | 255 } |
| 241 } | 256 } |
| 242 } | 257 } |
| 243 | 258 |
| 244 } // namespace ui | 259 } // namespace ui |
| OLD | NEW |