| 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 <drm_fourcc.h> | 7 #include <drm_fourcc.h> |
| 8 | 8 |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 #ifndef DRM_CAP_CURSOR_WIDTH | 27 #ifndef DRM_CAP_CURSOR_WIDTH |
| 28 #define DRM_CAP_CURSOR_WIDTH 0x8 | 28 #define DRM_CAP_CURSOR_WIDTH 0x8 |
| 29 #endif | 29 #endif |
| 30 | 30 |
| 31 #ifndef DRM_CAP_CURSOR_HEIGHT | 31 #ifndef DRM_CAP_CURSOR_HEIGHT |
| 32 #define DRM_CAP_CURSOR_HEIGHT 0x9 | 32 #define DRM_CAP_CURSOR_HEIGHT 0x9 |
| 33 #endif | 33 #endif |
| 34 | 34 |
| 35 void EmptyFlipCallback(gfx::SwapResult) { | |
| 36 } | |
| 37 | |
| 38 void UpdateCursorImage(DrmBuffer* cursor, const SkBitmap& image) { | 35 void UpdateCursorImage(DrmBuffer* cursor, const SkBitmap& image) { |
| 39 SkRect damage; | 36 SkRect damage; |
| 40 image.getBounds(&damage); | 37 image.getBounds(&damage); |
| 41 | 38 |
| 42 // Clear to transparent in case |image| is smaller than the canvas. | 39 // Clear to transparent in case |image| is smaller than the canvas. |
| 43 SkCanvas* canvas = cursor->GetCanvas(); | 40 SkCanvas* canvas = cursor->GetCanvas(); |
| 44 canvas->clear(SK_ColorTRANSPARENT); | 41 canvas->clear(SK_ColorTRANSPARENT); |
| 45 | 42 |
| 46 SkRect clip; | 43 SkRect clip; |
| 47 clip.set(0, 0, canvas->getDeviceSize().width(), | 44 clip.set(0, 0, canvas->getDeviceSize().width(), |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 return; | 130 return; |
| 134 } | 131 } |
| 135 | 132 |
| 136 last_submitted_planes_ = planes; | 133 last_submitted_planes_ = planes; |
| 137 | 134 |
| 138 if (!controller_) { | 135 if (!controller_) { |
| 139 callback.Run(gfx::SwapResult::SWAP_ACK); | 136 callback.Run(gfx::SwapResult::SWAP_ACK); |
| 140 return; | 137 return; |
| 141 } | 138 } |
| 142 | 139 |
| 143 // Controller should call the callback in all cases. | 140 controller_->SchedulePageFlip(last_submitted_planes_, callback); |
| 144 controller_->SchedulePageFlip(last_submitted_planes_, false /* test_only */, | |
| 145 callback); | |
| 146 } | 141 } |
| 147 | 142 |
| 148 std::vector<OverlayCheck_Params> DrmWindow::TestPageFlip( | 143 std::vector<OverlayCheck_Params> DrmWindow::TestPageFlip( |
| 149 const std::vector<OverlayCheck_Params>& overlays, | 144 const std::vector<OverlayCheck_Params>& overlays, |
| 150 ScanoutBufferGenerator* buffer_generator) { | 145 ScanoutBufferGenerator* buffer_generator) { |
| 151 std::vector<OverlayCheck_Params> params; | 146 std::vector<OverlayCheck_Params> params; |
| 152 if (!controller_) { | 147 if (!controller_) { |
| 153 // Nothing much we can do here. | 148 // Nothing much we can do here. |
| 154 return params; | 149 return params; |
| 155 } | 150 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 overlay.display_rect, overlay.crop_rect); | 183 overlay.display_rect, overlay.crop_rect); |
| 189 | 184 |
| 190 // Buffer for Primary plane should always be present for compatibility test. | 185 // Buffer for Primary plane should always be present for compatibility test. |
| 191 if (!compatible_test_list.size() && overlay.plane_z_order != 0) { | 186 if (!compatible_test_list.size() && overlay.plane_z_order != 0) { |
| 192 compatible_test_list.push_back( | 187 compatible_test_list.push_back( |
| 193 *OverlayPlane::GetPrimaryPlane(last_submitted_planes_)); | 188 *OverlayPlane::GetPrimaryPlane(last_submitted_planes_)); |
| 194 } | 189 } |
| 195 | 190 |
| 196 compatible_test_list.push_back(plane); | 191 compatible_test_list.push_back(plane); |
| 197 | 192 |
| 198 bool page_flip_succeeded = controller_->SchedulePageFlip( | 193 if (controller_->TestPageFlip(compatible_test_list)) { |
| 199 compatible_test_list, true /* test_only */, | |
| 200 base::Bind(&EmptyFlipCallback)); | |
| 201 | |
| 202 if (page_flip_succeeded) { | |
| 203 overlay_params.plane_ids = | 194 overlay_params.plane_ids = |
| 204 controller_->GetCompatibleHardwarePlaneIds(plane); | 195 controller_->GetCompatibleHardwarePlaneIds(plane); |
| 205 params.push_back(overlay_params); | 196 params.push_back(overlay_params); |
| 206 } | 197 } |
| 207 | 198 |
| 208 if (compatible_test_list.size() > 1) | 199 if (compatible_test_list.size() > 1) |
| 209 compatible_test_list.pop_back(); | 200 compatible_test_list.pop_back(); |
| 210 } | 201 } |
| 211 | 202 |
| 212 return params; | 203 return params; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 if (!cursor_buffers_[i]->Initialize( | 297 if (!cursor_buffers_[i]->Initialize( |
| 307 info, false /* should_register_framebuffer */)) { | 298 info, false /* should_register_framebuffer */)) { |
| 308 LOG(FATAL) << "Failed to initialize cursor buffer"; | 299 LOG(FATAL) << "Failed to initialize cursor buffer"; |
| 309 return; | 300 return; |
| 310 } | 301 } |
| 311 } | 302 } |
| 312 } | 303 } |
| 313 } | 304 } |
| 314 | 305 |
| 315 } // namespace ui | 306 } // namespace ui |
| OLD | NEW |