Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: ui/ozone/platform/drm/gpu/drm_overlay_validator.cc

Issue 2686903003: ozone: prefer YUYV format for overlay.
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ui/ozone/platform/drm/gpu/drm_overlay_validator_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_overlay_validator.h" 5 #include "ui/ozone/platform/drm/gpu/drm_overlay_validator.h"
6 6
7 #include <drm_fourcc.h> 7 #include <drm_fourcc.h>
8 8
9 #include "ui/gfx/geometry/size_conversions.h" 9 #include "ui/gfx/geometry/size_conversions.h"
10 #include "ui/ozone/platform/drm/common/drm_util.h" 10 #include "ui/ozone/platform/drm/common/drm_util.h"
11 #include "ui/ozone/platform/drm/gpu/drm_device.h" 11 #include "ui/ozone/platform/drm/gpu/drm_device.h"
12 #include "ui/ozone/platform/drm/gpu/drm_window.h" 12 #include "ui/ozone/platform/drm/gpu/drm_window.h"
13 #include "ui/ozone/platform/drm/gpu/hardware_display_controller.h" 13 #include "ui/ozone/platform/drm/gpu/hardware_display_controller.h"
14 #include "ui/ozone/platform/drm/gpu/scanout_buffer.h" 14 #include "ui/ozone/platform/drm/gpu/scanout_buffer.h"
15 15
16 namespace ui { 16 namespace ui {
17 17
18 namespace { 18 namespace {
19 19
20 const size_t kMaxCacheSize = 200; 20 const size_t kMaxCacheSize = 200;
21 21
22 bool NeedsAlphaComposition(uint32_t format) { 22 bool NeedsAlphaComposition(uint32_t format) {
23 switch (format) { 23 switch (format) {
24 case DRM_FORMAT_XRGB8888: 24 case DRM_FORMAT_XRGB8888:
25 case DRM_FORMAT_UYVY: 25 case DRM_FORMAT_UYVY:
26 case DRM_FORMAT_YUYV:
26 return false; 27 return false;
27 default: 28 default:
28 return true; 29 return true;
29 } 30 }
30 } 31 }
31 32
32 scoped_refptr<ScanoutBuffer> GetBufferForPageFlipTest( 33 scoped_refptr<ScanoutBuffer> GetBufferForPageFlipTest(
33 const scoped_refptr<DrmDevice>& drm_device, 34 const scoped_refptr<DrmDevice>& drm_device,
34 const gfx::Size& size, 35 const gfx::Size& size,
35 uint32_t format, 36 uint32_t format,
(...skipping 19 matching lines...) Expand all
55 const gfx::RectF crop_rect) { 56 const gfx::RectF crop_rect) {
56 if (!crop_rect.IsEmpty()) { 57 if (!crop_rect.IsEmpty()) {
57 return gfx::ToCeiledSize( 58 return gfx::ToCeiledSize(
58 gfx::SizeF(display_rect.width() / crop_rect.width(), 59 gfx::SizeF(display_rect.width() / crop_rect.width(),
59 display_rect.height() / crop_rect.height())); 60 display_rect.height() / crop_rect.height()));
60 } 61 }
61 62
62 return original_size; 63 return original_size;
63 } 64 }
64 65
65 uint32_t FindOptimalBufferFormat(uint32_t original_format, 66 uint32_t FindOptimalBufferFormat(uint32_t original_format,
Daniele Castagna 2017/02/27 23:10:55 Is any device actually using this code path? I thi
dshwang 2017/02/28 02:14:28 This code is used by both legacy page flip and nuc
Daniele Castagna 2017/02/28 02:56:08 We're not using overlays on Intel ATM. So, this is
dshwang 2017/02/28 04:01:59 Correct. production code never use it. To test th
66 uint32_t plane_z_order, 67 uint32_t plane_z_order,
67 const gfx::Rect& plane_bounds, 68 const gfx::Rect& plane_bounds,
68 const gfx::Rect& window_bounds, 69 const gfx::Rect& window_bounds,
69 HardwareDisplayController* controller) { 70 HardwareDisplayController* controller) {
70 uint32_t z_order = plane_z_order; 71 uint32_t z_order = plane_z_order;
71 // If Overlay completely covers primary and isn't transparent, try to find 72 // If Overlay completely covers primary and isn't transparent, try to find
72 // optimal format w.r.t primary plane. This guarantees that optimal format 73 // optimal format w.r.t primary plane. This guarantees that optimal format
73 // would not fail page flip when plane manager/CC collapses planes. 74 // would not fail page flip when plane manager/CC collapses planes.
74 if (plane_bounds == window_bounds && 75 if (plane_bounds == window_bounds &&
75 !NeedsAlphaComposition(original_format)) { 76 !NeedsAlphaComposition(original_format)) {
76 z_order = 0; 77 z_order = 0;
77 } 78 }
78 79
79 // YUV is preferable format if supported. 80 // YUV is preferable format if supported.
80 if (controller->IsFormatSupported(DRM_FORMAT_UYVY, z_order)) { 81 if (controller->IsFormatSupported(DRM_FORMAT_YUYV, z_order)) {
81 return DRM_FORMAT_UYVY; 82 return DRM_FORMAT_YUYV;
82 } else if (controller->IsFormatSupported(DRM_FORMAT_XRGB8888, z_order)) { 83 } else if (controller->IsFormatSupported(DRM_FORMAT_XRGB8888, z_order)) {
83 return DRM_FORMAT_XRGB8888; 84 return DRM_FORMAT_XRGB8888;
84 } 85 }
85 86
86 return original_format; 87 return original_format;
87 } 88 }
88 89
89 } // namespace 90 } // namespace
90 91
91 DrmOverlayValidator::OverlayHints::OverlayHints(uint32_t format, 92 DrmOverlayValidator::OverlayHints::OverlayHints(uint32_t format,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 overlay.display_rect, overlay.crop_rect); 141 overlay.display_rect, overlay.crop_rect);
141 test_list.push_back(plane); 142 test_list.push_back(plane);
142 143
143 if (controller->TestPageFlip(test_list)) { 144 if (controller->TestPageFlip(test_list)) {
144 overlay.is_overlay_candidate = true; 145 overlay.is_overlay_candidate = true;
145 146
146 // If size scaling is needed, find an optimal format. 147 // If size scaling is needed, find an optimal format.
147 if (overlay.plane_z_order && scaled_buffer_size != overlay.buffer_size) { 148 if (overlay.plane_z_order && scaled_buffer_size != overlay.buffer_size) {
148 uint32_t optimal_format = FindOptimalBufferFormat( 149 uint32_t optimal_format = FindOptimalBufferFormat(
149 original_format, overlay.plane_z_order, overlay.display_rect, 150 original_format, overlay.plane_z_order, overlay.display_rect,
150 window_->bounds(), controller); 151 window_->bounds(), controller);
dshwang 2017/02/28 02:14:28 When display size and video size are different, we
151 152
152 if (original_format != optimal_format) { 153 if (original_format != optimal_format) {
153 OverlayPlane original_plain = test_list.back(); 154 OverlayPlane original_plain = test_list.back();
154 test_list.pop_back(); 155 test_list.pop_back();
155 scoped_refptr<ScanoutBuffer> optimal_buffer = 156 scoped_refptr<ScanoutBuffer> optimal_buffer =
156 GetBufferForPageFlipTest(drm, scaled_buffer_size, optimal_format, 157 GetBufferForPageFlipTest(drm, scaled_buffer_size, optimal_format,
157 buffer_generator_, &reusable_buffers); 158 buffer_generator_, &reusable_buffers);
158 DCHECK(optimal_buffer); 159 DCHECK(optimal_buffer);
159 160
160 OverlayPlane optimal_plane(optimal_buffer, overlay.plane_z_order, 161 OverlayPlane optimal_plane(optimal_buffer, overlay.plane_z_order,
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 263
263 // Make sure we dont hold reference to buffer when caching this plane list. 264 // Make sure we dont hold reference to buffer when caching this plane list.
264 plane.buffer = nullptr; 265 plane.buffer = nullptr;
265 } 266 }
266 267
267 DCHECK(hints_plane_list.size() == overlay_hints.size()); 268 DCHECK(hints_plane_list.size() == overlay_hints.size());
268 overlay_hints_cache_.Put(hints_plane_list, overlay_hints); 269 overlay_hints_cache_.Put(hints_plane_list, overlay_hints);
269 } 270 }
270 271
271 } // namespace ui 272 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | ui/ozone/platform/drm/gpu/drm_overlay_validator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698