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

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

Issue 2712463002: ozone: Reject overlays when a test buffer can't be allocated. (Closed)
Patch Set: Remove DCHECK that one plane would always succeed. 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"
(...skipping 27 matching lines...) Expand all
38 // Check if we can re-use existing buffers. 38 // Check if we can re-use existing buffers.
39 for (const auto& buffer : *reusable_buffers) { 39 for (const auto& buffer : *reusable_buffers) {
40 if (buffer->GetFramebufferPixelFormat() == format && 40 if (buffer->GetFramebufferPixelFormat() == format &&
41 buffer->GetSize() == size) { 41 buffer->GetSize() == size) {
42 return buffer; 42 return buffer;
43 } 43 }
44 } 44 }
45 45
46 scoped_refptr<ScanoutBuffer> scanout_buffer = 46 scoped_refptr<ScanoutBuffer> scanout_buffer =
47 buffer_generator->Create(drm_device, format, size); 47 buffer_generator->Create(drm_device, format, size);
48 reusable_buffers->push_back(scanout_buffer); 48 if (scanout_buffer)
49 reusable_buffers->push_back(scanout_buffer);
49 50
50 return scanout_buffer; 51 return scanout_buffer;
51 } 52 }
52 53
53 gfx::Size GetScaledSize(const gfx::Size original_size, 54 gfx::Size GetScaledSize(const gfx::Size original_size,
54 const gfx::Rect display_rect, 55 const gfx::Rect display_rect,
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(),
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 126
126 for (auto& overlay : validated_params) { 127 for (auto& overlay : validated_params) {
127 if (!overlay.is_overlay_candidate) 128 if (!overlay.is_overlay_candidate)
128 continue; 129 continue;
129 130
130 gfx::Size scaled_buffer_size = GetScaledSize( 131 gfx::Size scaled_buffer_size = GetScaledSize(
131 overlay.buffer_size, overlay.display_rect, overlay.crop_rect); 132 overlay.buffer_size, overlay.display_rect, overlay.crop_rect);
132 133
133 uint32_t original_format = GetFourCCFormatForFramebuffer(overlay.format); 134 uint32_t original_format = GetFourCCFormatForFramebuffer(overlay.format);
134 scoped_refptr<ScanoutBuffer> buffer = 135 scoped_refptr<ScanoutBuffer> buffer =
135 GetBufferForPageFlipTest(drm, scaled_buffer_size, original_format, 136 GetBufferForPageFlipTest(drm, overlay.buffer_size, original_format,
136 buffer_generator_, &reusable_buffers); 137 buffer_generator_, &reusable_buffers);
137 DCHECK(buffer);
138 138
139 OverlayPlane plane(buffer, overlay.plane_z_order, overlay.transform, 139 OverlayPlane plane(buffer, overlay.plane_z_order, overlay.transform,
140 overlay.display_rect, overlay.crop_rect); 140 overlay.display_rect, overlay.crop_rect);
141 test_list.push_back(plane); 141 test_list.push_back(plane);
142 142
143 if (controller->TestPageFlip(test_list)) { 143 if (buffer && controller->TestPageFlip(test_list)) {
144 overlay.is_overlay_candidate = true; 144 overlay.is_overlay_candidate = true;
145 145
146 // If size scaling is needed, find an optimal format. 146 // If size scaling is needed, find an optimal format.
147 if (overlay.plane_z_order && scaled_buffer_size != overlay.buffer_size) { 147 if (overlay.plane_z_order && scaled_buffer_size != overlay.buffer_size) {
148 uint32_t optimal_format = FindOptimalBufferFormat( 148 uint32_t optimal_format = FindOptimalBufferFormat(
149 original_format, overlay.plane_z_order, overlay.display_rect, 149 original_format, overlay.plane_z_order, overlay.display_rect,
150 window_->bounds(), controller); 150 window_->bounds(), controller);
151 151
152 if (original_format != optimal_format) { 152 if (original_format != optimal_format) {
153 OverlayPlane original_plain = test_list.back(); 153 OverlayPlane original_plain = test_list.back();
(...skipping 19 matching lines...) Expand all
173 } 173 }
174 } 174 }
175 } 175 }
176 } else { 176 } else {
177 // If test failed here, platform cannot support this configuration 177 // If test failed here, platform cannot support this configuration
178 // with current combination of layers. This is usually the case when this 178 // with current combination of layers. This is usually the case when this
179 // plane has requested post processing capability which needs additional 179 // plane has requested post processing capability which needs additional
180 // hardware resources and they might be already in use by other planes. 180 // hardware resources and they might be already in use by other planes.
181 // For example this plane has requested scaling capabilities and all 181 // For example this plane has requested scaling capabilities and all
182 // available scalars are already in use by other planes. 182 // available scalars are already in use by other planes.
183 DCHECK(test_list.size() > 1);
184 overlay.is_overlay_candidate = false; 183 overlay.is_overlay_candidate = false;
185 test_list.pop_back(); 184 test_list.pop_back();
186 } 185 }
187 } 186 }
188 187
189 UpdateOverlayHintsCache(test_list); 188 UpdateOverlayHintsCache(test_list);
190 189
191 return validated_params; 190 return validated_params;
192 } 191 }
193 192
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 261
263 // Make sure we dont hold reference to buffer when caching this plane list. 262 // Make sure we dont hold reference to buffer when caching this plane list.
264 plane.buffer = nullptr; 263 plane.buffer = nullptr;
265 } 264 }
266 265
267 DCHECK(hints_plane_list.size() == overlay_hints.size()); 266 DCHECK(hints_plane_list.size() == overlay_hints.size());
268 overlay_hints_cache_.Put(hints_plane_list, overlay_hints); 267 overlay_hints_cache_.Put(hints_plane_list, overlay_hints);
269 } 268 }
270 269
271 } // namespace ui 270 } // 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