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

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

Issue 1426993003: Ozone: Dont hardcode format to YUV when using Overlay Composition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove obsolete code Created 4 years, 11 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
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 <drm_fourcc.h> 5 #include <drm_fourcc.h>
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 DrmOverlayValidatorTest() {} 44 DrmOverlayValidatorTest() {}
45 45
46 void SetUp() override; 46 void SetUp() override;
47 void TearDown() override; 47 void TearDown() override;
48 48
49 void OnSwapBuffers(gfx::SwapResult result) { 49 void OnSwapBuffers(gfx::SwapResult result) {
50 on_swap_buffers_count_++; 50 on_swap_buffers_count_++;
51 last_swap_buffers_result_ = result; 51 last_swap_buffers_result_ = result;
52 } 52 }
53 53
54 bool CopyBuffer(const scoped_refptr<ui::ScanoutBuffer>& source_buffer,
55 scoped_refptr<ui::ScanoutBuffer>& target_buffer) {
56 return true;
57 }
58
54 protected: 59 protected:
55 scoped_ptr<base::MessageLoop> message_loop_; 60 scoped_ptr<base::MessageLoop> message_loop_;
56 scoped_refptr<ui::MockDrmDevice> drm_; 61 scoped_refptr<ui::MockDrmDevice> drm_;
57 scoped_ptr<ui::MockScanoutBufferGenerator> buffer_generator_; 62 scoped_ptr<ui::MockScanoutBufferGenerator> buffer_generator_;
58 scoped_ptr<ui::ScreenManager> screen_manager_; 63 scoped_ptr<ui::ScreenManager> screen_manager_;
59 scoped_ptr<ui::DrmDeviceManager> drm_device_manager_; 64 scoped_ptr<ui::DrmDeviceManager> drm_device_manager_;
60 ui::MockHardwareDisplayPlaneManager* plane_manager_; 65 ui::MockHardwareDisplayPlaneManager* plane_manager_;
61 ui::DrmWindow* window_; 66 ui::DrmWindow* window_;
62 scoped_ptr<ui::DrmOverlayValidator> overlay_validator_; 67 scoped_ptr<ui::DrmOverlayValidator> overlay_validator_;
63 std::vector<ui::OverlayCheck_Params> overlay_params_; 68 std::vector<ui::OverlayCheck_Params> overlay_params_;
64 ui::OverlayPlaneList plane_list_; 69 ui::OverlayPlaneList plane_list_;
70 ui::OverlayPlane::CopyBufferCallback copy_buffer_handler_;
65 71
66 int on_swap_buffers_count_; 72 int on_swap_buffers_count_;
67 gfx::SwapResult last_swap_buffers_result_; 73 gfx::SwapResult last_swap_buffers_result_;
68 gfx::Rect overlay_rect_; 74 gfx::Rect overlay_rect_;
69 gfx::Rect primary_rect_; 75 gfx::Rect primary_rect_;
70 76
71 private: 77 private:
72 DISALLOW_COPY_AND_ASSIGN(DrmOverlayValidatorTest); 78 DISALLOW_COPY_AND_ASSIGN(DrmOverlayValidatorTest);
73 }; 79 };
74 80
75 void DrmOverlayValidatorTest::SetUp() { 81 void DrmOverlayValidatorTest::SetUp() {
76 on_swap_buffers_count_ = 0; 82 on_swap_buffers_count_ = 0;
77 last_swap_buffers_result_ = gfx::SwapResult::SWAP_FAILED; 83 last_swap_buffers_result_ = gfx::SwapResult::SWAP_FAILED;
84 copy_buffer_handler_ =
85 base::Bind(&DrmOverlayValidatorTest::CopyBuffer, base::Unretained(this));
78 86
79 message_loop_.reset(new base::MessageLoopForUI); 87 message_loop_.reset(new base::MessageLoopForUI);
80 std::vector<uint32_t> crtcs; 88 std::vector<uint32_t> crtcs;
81 crtcs.push_back(kDefaultCrtc); 89 crtcs.push_back(kDefaultCrtc);
82 drm_ = new ui::MockDrmDevice(false, crtcs, kPlanesPerCrtc); 90 drm_ = new ui::MockDrmDevice(false, crtcs, kPlanesPerCrtc);
83 buffer_generator_.reset(new ui::MockScanoutBufferGenerator()); 91 buffer_generator_.reset(new ui::MockScanoutBufferGenerator());
84 screen_manager_.reset(new ui::ScreenManager(buffer_generator_.get())); 92 screen_manager_.reset(new ui::ScreenManager(buffer_generator_.get()));
85 screen_manager_->AddDisplayController(drm_, kDefaultCrtc, kDefaultConnector); 93 screen_manager_->AddDisplayController(drm_, kDefaultCrtc, kDefaultConnector);
86 screen_manager_->ConfigureDisplayController( 94 screen_manager_->ConfigureDisplayController(
87 drm_, kDefaultCrtc, kDefaultConnector, gfx::Point(), kDefaultMode); 95 drm_, kDefaultCrtc, kDefaultConnector, gfx::Point(), kDefaultMode);
(...skipping 20 matching lines...) Expand all
108 primary_candidate.buffer_size = primary_rect_.size(); 116 primary_candidate.buffer_size = primary_rect_.size();
109 primary_candidate.display_rect = primary_rect_; 117 primary_candidate.display_rect = primary_rect_;
110 overlay_params_.push_back(primary_candidate); 118 overlay_params_.push_back(primary_candidate);
111 119
112 ui::OverlayCheck_Params overlay_candidate; 120 ui::OverlayCheck_Params overlay_candidate;
113 overlay_candidate.buffer_size = overlay_rect_.size(); 121 overlay_candidate.buffer_size = overlay_rect_.size();
114 overlay_candidate.display_rect = overlay_rect_; 122 overlay_candidate.display_rect = overlay_rect_;
115 overlay_candidate.plane_z_order = 1; 123 overlay_candidate.plane_z_order = 1;
116 overlay_params_.push_back(overlay_candidate); 124 overlay_params_.push_back(overlay_candidate);
117 125
126 scoped_refptr<ui::DrmDevice> drm =
127 window_->GetController()->GetAllocationDrmDevice();
118 for (const auto& param : overlay_params_) { 128 for (const auto& param : overlay_params_) {
119 ui::OverlayPlane plane(nullptr, param.plane_z_order, param.transform, 129 scoped_refptr<ui::ScanoutBuffer> scanout_buffer =
120 param.display_rect, param.crop_rect); 130 buffer_generator_->Create(drm, param.format, param.buffer_size);
131 ui::OverlayPlane plane(std::move(scanout_buffer), param.plane_z_order,
132 param.transform, param.display_rect, param.crop_rect,
133 copy_buffer_handler_);
121 plane_list_.push_back(plane); 134 plane_list_.push_back(plane);
122 } 135 }
123 } 136 }
124 137
125 void DrmOverlayValidatorTest::TearDown() { 138 void DrmOverlayValidatorTest::TearDown() {
126 scoped_ptr<ui::DrmWindow> window = 139 scoped_ptr<ui::DrmWindow> window =
127 screen_manager_->RemoveWindow(kDefaultWidgetHandle); 140 screen_manager_->RemoveWindow(kDefaultWidgetHandle);
128 window->Shutdown(); 141 window->Shutdown();
129 message_loop_.reset(); 142 message_loop_.reset();
130 } 143 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 ui::FakePlaneInfo primary_plane_info( 189 ui::FakePlaneInfo primary_plane_info(
177 100, 1 << 0, std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888)); 190 100, 1 << 0, std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888));
178 ui::FakePlaneInfo overlay_info(101, 1 << 0, xrgb_yuv_packed_formats); 191 ui::FakePlaneInfo overlay_info(101, 1 << 0, xrgb_yuv_packed_formats);
179 std::vector<ui::FakePlaneInfo> planes_info{primary_plane_info, overlay_info}; 192 std::vector<ui::FakePlaneInfo> planes_info{primary_plane_info, overlay_info};
180 plane_manager_->SetPlaneProperties(planes_info); 193 plane_manager_->SetPlaneProperties(planes_info);
181 overlay_validator_->ClearCache(); 194 overlay_validator_->ClearCache();
182 195
183 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList(), 196 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList(),
184 buffer_generator_.get()); 197 buffer_generator_.get());
185 198
186 uint32_t optimal_format = overlay_validator_->GetOptimalBufferFormat( 199 ui::OverlayPlaneList plane_list =
187 plane_list_.back(), plane_list_); 200 overlay_validator_->ValidatePlanesForPageFlip(plane_list_,
188 EXPECT_EQ(DRM_FORMAT_UYVY, optimal_format); 201 buffer_generator_.get());
202 EXPECT_EQ(DRM_FORMAT_UYVY,
203 plane_list.back().buffer->GetFramebufferPixelFormat());
189 // Check if ClearCache actually clears the cache. 204 // Check if ClearCache actually clears the cache.
190 overlay_validator_->ClearCache(); 205 overlay_validator_->ClearCache();
191 optimal_format = overlay_validator_->GetOptimalBufferFormat( 206 plane_list = overlay_validator_->ValidatePlanesForPageFlip(
192 plane_list_.back(), plane_list_); 207 plane_list_, buffer_generator_.get());
193 // There should be no entry in cache for this configuration and should return 208 // There should be no entry in cache for this configuration and should return
194 // default value of DRM_FORMAT_XRGB8888. 209 // default value of DRM_FORMAT_XRGB8888.
195 EXPECT_EQ(DRM_FORMAT_XRGB8888, optimal_format); 210 EXPECT_EQ(DRM_FORMAT_XRGB8888,
211 plane_list.back().buffer->GetFramebufferPixelFormat());
196 } 212 }
197 213
198 TEST_F(DrmOverlayValidatorTest, OptimalFormatForOverlayInFullScreen_XRGB) { 214 TEST_F(DrmOverlayValidatorTest, OptimalFormatForOverlayInFullScreen_XRGB) {
199 // Optimal format for Overlay configuration should be XRGB, when primary plane 215 // Optimal format for Overlay configuration should be XRGB, when primary plane
200 // supports only XRGB and overlay obscures primary. 216 // supports only XRGB and overlay obscures primary.
201 overlay_params_.back().buffer_size = primary_rect_.size(); 217 overlay_params_.back().buffer_size = primary_rect_.size();
202 overlay_params_.back().display_rect = primary_rect_; 218 overlay_params_.back().display_rect = primary_rect_;
203 plane_list_.back().display_bounds = primary_rect_; 219 plane_list_.back().display_bounds = primary_rect_;
204 220
205 // Check optimal format for Overlay. 221 // Check optimal format for Overlay.
206 ui::FakePlaneInfo primary_plane_info( 222 ui::FakePlaneInfo primary_plane_info(
207 100, 1 << 0, std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888)); 223 100, 1 << 0, std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888));
208 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, 224 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888,
209 DRM_FORMAT_UYVY}; 225 DRM_FORMAT_UYVY};
210 ui::FakePlaneInfo plane_info(101, 1 << 0, xrgb_yuv_packed_formats); 226 ui::FakePlaneInfo plane_info(101, 1 << 0, xrgb_yuv_packed_formats);
211 227
212 std::vector<ui::FakePlaneInfo> planes{primary_plane_info, plane_info}; 228 std::vector<ui::FakePlaneInfo> planes{primary_plane_info, plane_info};
213 plane_manager_->SetPlaneProperties(planes); 229 plane_manager_->SetPlaneProperties(planes);
214 overlay_validator_->ClearCache(); 230 overlay_validator_->ClearCache();
215 231
216 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList(), 232 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList(),
217 buffer_generator_.get()); 233 buffer_generator_.get());
218 uint32_t optimal_format = overlay_validator_->GetOptimalBufferFormat( 234 ui::OverlayPlaneList plane_list =
219 plane_list_.back(), plane_list_); 235 overlay_validator_->ValidatePlanesForPageFlip(plane_list_,
220 EXPECT_EQ(DRM_FORMAT_XRGB8888, optimal_format); 236 buffer_generator_.get());
237 EXPECT_EQ(DRM_FORMAT_XRGB8888,
238 plane_list.back().buffer->GetFramebufferPixelFormat());
221 } 239 }
222 240
223 TEST_F(DrmOverlayValidatorTest, OptimalFormatForOverlayInFullScreen_YUV) { 241 TEST_F(DrmOverlayValidatorTest, OptimalFormatForOverlayInFullScreen_YUV) {
224 overlay_params_.back().buffer_size = primary_rect_.size(); 242 overlay_params_.back().buffer_size = primary_rect_.size();
225 overlay_params_.back().display_rect = primary_rect_; 243 overlay_params_.back().display_rect = primary_rect_;
226 plane_list_.back().display_bounds = primary_rect_; 244 plane_list_.back().display_bounds = primary_rect_;
227 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, 245 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888,
228 DRM_FORMAT_UYVY}; 246 DRM_FORMAT_UYVY};
229 247
230 // We should prefer YUV when primary can support it. 248 // We should prefer YUV when primary can support it.
231 ui::FakePlaneInfo primary_plane_info(100, 1 << 0, xrgb_yuv_packed_formats); 249 ui::FakePlaneInfo primary_plane_info(100, 1 << 0, xrgb_yuv_packed_formats);
232 ui::FakePlaneInfo plane_info(101, 1 << 0, xrgb_yuv_packed_formats); 250 ui::FakePlaneInfo plane_info(101, 1 << 0, xrgb_yuv_packed_formats);
233 251
234 std::vector<ui::FakePlaneInfo> planes{primary_plane_info, plane_info}; 252 std::vector<ui::FakePlaneInfo> planes{primary_plane_info, plane_info};
235 plane_manager_->SetPlaneProperties(planes); 253 plane_manager_->SetPlaneProperties(planes);
236 overlay_validator_->ClearCache(); 254 overlay_validator_->ClearCache();
237 255
238 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList(), 256 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList(),
239 buffer_generator_.get()); 257 buffer_generator_.get());
240 uint32_t optimal_format = overlay_validator_->GetOptimalBufferFormat( 258 ui::OverlayPlaneList plane_list =
241 plane_list_.back(), plane_list_); 259 overlay_validator_->ValidatePlanesForPageFlip(plane_list_,
260 buffer_generator_.get());
242 #if defined(USE_DRM_ATOMIC) 261 #if defined(USE_DRM_ATOMIC)
243 EXPECT_EQ(DRM_FORMAT_UYVY, optimal_format); 262 EXPECT_EQ(DRM_FORMAT_UYVY,
263 plane_list.back().buffer->GetFramebufferPixelFormat());
244 #else 264 #else
245 // If Atomic support is disabled, ensure we choose DRM_FORMAT_XRGB8888 as the 265 // If Atomic support is disabled, ensure we choose DRM_FORMAT_XRGB8888 as the
246 // optimal format even if other packed formats are supported by Primary. 266 // optimal format even if other packed formats are supported by Primary.
247 EXPECT_EQ(DRM_FORMAT_XRGB8888, optimal_format); 267 EXPECT_EQ(DRM_FORMAT_XRGB8888,
268 plane_list.back().buffer->GetFramebufferPixelFormat());
248 #endif 269 #endif
249 } 270 }
250 271
251 TEST_F(DrmOverlayValidatorTest, OverlayPreferredFormat_YUV) { 272 TEST_F(DrmOverlayValidatorTest, OverlayPreferredFormat_YUV) {
252 plane_manager_->ResetPlaneCount(); 273 plane_manager_->ResetPlaneCount();
253 // This test checks for optimal format in case of non full screen video case. 274 // This test checks for optimal format in case of non full screen video case.
254 // Prefer YUV as optimal format when Overlay supports it. 275 // Prefer YUV as optimal format when Overlay supports it.
255 overlay_params_.back().buffer_size = overlay_rect_.size(); 276 overlay_params_.back().buffer_size = overlay_rect_.size();
256 overlay_params_.back().display_rect = overlay_rect_; 277 overlay_params_.back().display_rect = overlay_rect_;
257 plane_list_.back().display_bounds = overlay_rect_; 278 plane_list_.back().display_bounds = overlay_rect_;
258 279
259 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, 280 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888,
260 DRM_FORMAT_UYVY}; 281 DRM_FORMAT_UYVY};
261 ui::FakePlaneInfo primary_plane_info( 282 ui::FakePlaneInfo primary_plane_info(
262 100, 1 << 0, std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888)); 283 100, 1 << 0, std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888));
263 ui::FakePlaneInfo overlay_info(101, 1 << 0, xrgb_yuv_packed_formats); 284 ui::FakePlaneInfo overlay_info(101, 1 << 0, xrgb_yuv_packed_formats);
264 std::vector<ui::FakePlaneInfo> planes_info{primary_plane_info, overlay_info}; 285 std::vector<ui::FakePlaneInfo> planes_info{primary_plane_info, overlay_info};
265 plane_manager_->SetPlaneProperties(planes_info); 286 plane_manager_->SetPlaneProperties(planes_info);
266 overlay_validator_->ClearCache(); 287 overlay_validator_->ClearCache();
267 288
268 std::vector<ui::OverlayCheck_Params> validated_params = 289 std::vector<ui::OverlayCheck_Params> validated_params =
269 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList(), 290 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList(),
270 buffer_generator_.get()); 291 buffer_generator_.get());
271 292
272 for (const auto& param : validated_params) 293 for (const auto& param : validated_params)
273 EXPECT_EQ(true, param.is_overlay_candidate); 294 EXPECT_EQ(true, param.is_overlay_candidate);
274 295
275 EXPECT_EQ(5, plane_manager_->plane_count()); 296 EXPECT_EQ(5, plane_manager_->plane_count());
276 297
277 uint32_t optimal_format = overlay_validator_->GetOptimalBufferFormat( 298 ui::OverlayPlaneList plane_list =
278 plane_list_.back(), plane_list_); 299 overlay_validator_->ValidatePlanesForPageFlip(plane_list_,
279 EXPECT_EQ(DRM_FORMAT_UYVY, optimal_format); 300 buffer_generator_.get());
301 EXPECT_EQ(DRM_FORMAT_UYVY,
302 plane_list.back().buffer->GetFramebufferPixelFormat());
280 } 303 }
281 304
282 TEST_F(DrmOverlayValidatorTest, OverlayPreferredFormat_XRGB) { 305 TEST_F(DrmOverlayValidatorTest, OverlayPreferredFormat_XRGB) {
283 plane_manager_->ResetPlaneCount(); 306 plane_manager_->ResetPlaneCount();
284 // This test checks for optimal format in case of non full screen video case. 307 // This test checks for optimal format in case of non full screen video case.
285 // This should be XRGB when overlay doesn't support YUV. 308 // This should be XRGB when overlay doesn't support YUV.
286 overlay_params_.back().buffer_size = overlay_rect_.size(); 309 overlay_params_.back().buffer_size = overlay_rect_.size();
287 overlay_params_.back().display_rect = overlay_rect_; 310 overlay_params_.back().display_rect = overlay_rect_;
288 plane_list_.back().display_bounds = overlay_rect_; 311 plane_list_.back().display_bounds = overlay_rect_;
289 312
290 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, 313 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888,
291 DRM_FORMAT_UYVY}; 314 DRM_FORMAT_UYVY};
292 ui::FakePlaneInfo primary_plane_info(100, 1 << 0, xrgb_yuv_packed_formats); 315 ui::FakePlaneInfo primary_plane_info(100, 1 << 0, xrgb_yuv_packed_formats);
293 ui::FakePlaneInfo overlay_info(101, 1 << 0, 316 ui::FakePlaneInfo overlay_info(101, 1 << 0,
294 std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888)); 317 std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888));
295 std::vector<ui::FakePlaneInfo> planes_info{primary_plane_info, overlay_info}; 318 std::vector<ui::FakePlaneInfo> planes_info{primary_plane_info, overlay_info};
296 plane_manager_->SetPlaneProperties(planes_info); 319 plane_manager_->SetPlaneProperties(planes_info);
297 overlay_validator_->ClearCache(); 320 overlay_validator_->ClearCache();
298 321
299 std::vector<ui::OverlayCheck_Params> validated_params = 322 std::vector<ui::OverlayCheck_Params> validated_params =
300 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList(), 323 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList(),
301 buffer_generator_.get()); 324 buffer_generator_.get());
302 uint32_t optimal_format = overlay_validator_->GetOptimalBufferFormat( 325 ui::OverlayPlaneList plane_list =
303 plane_list_.back(), plane_list_); 326 overlay_validator_->ValidatePlanesForPageFlip(plane_list_,
304 327 buffer_generator_.get());
305 EXPECT_EQ(DRM_FORMAT_XRGB8888, optimal_format); 328 EXPECT_EQ(DRM_FORMAT_XRGB8888,
329 plane_list.back().buffer->GetFramebufferPixelFormat());
306 EXPECT_EQ(3, plane_manager_->plane_count()); 330 EXPECT_EQ(3, plane_manager_->plane_count());
307 for (const auto& param : validated_params) 331 for (const auto& param : validated_params)
308 EXPECT_EQ(true, param.is_overlay_candidate); 332 EXPECT_EQ(true, param.is_overlay_candidate);
309 } 333 }
310 334
311 TEST_F(DrmOverlayValidatorTest, RejectYUVBuffersIfNotSupported) { 335 TEST_F(DrmOverlayValidatorTest, RejectYUVBuffersIfNotSupported) {
312 plane_manager_->ResetPlaneCount(); 336 plane_manager_->ResetPlaneCount();
313 // Check case where buffer storage format is already UYVY but planes dont 337 // Check case where buffer storage format is already UYVY but planes dont
314 // support it. 338 // support it.
315 overlay_params_.back().buffer_size = overlay_rect_.size(); 339 overlay_params_.back().buffer_size = overlay_rect_.size();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 std::vector<ui::OverlayCheck_Params> validated_params = overlay_params_; 392 std::vector<ui::OverlayCheck_Params> validated_params = overlay_params_;
369 validated_params.back().format = gfx::BufferFormat::UYVY_422; 393 validated_params.back().format = gfx::BufferFormat::UYVY_422;
370 plane_manager_->ResetPlaneCount(); 394 plane_manager_->ResetPlaneCount();
371 validated_params = overlay_validator_->TestPageFlip( 395 validated_params = overlay_validator_->TestPageFlip(
372 validated_params, ui::OverlayPlaneList(), buffer_generator_.get()); 396 validated_params, ui::OverlayPlaneList(), buffer_generator_.get());
373 397
374 EXPECT_EQ(true, validated_params.back().is_overlay_candidate); 398 EXPECT_EQ(true, validated_params.back().is_overlay_candidate);
375 399
376 // Both controllers have Overlay which support DRM_FORMAT_UYVY, hence this 400 // Both controllers have Overlay which support DRM_FORMAT_UYVY, hence this
377 // should be picked as the optimal format. 401 // should be picked as the optimal format.
378 uint32_t optimal_format = overlay_validator_->GetOptimalBufferFormat( 402 ui::OverlayPlaneList plane_list =
379 plane_list_.back(), plane_list_); 403 overlay_validator_->ValidatePlanesForPageFlip(plane_list_,
380 EXPECT_EQ(DRM_FORMAT_UYVY, optimal_format); 404 buffer_generator_.get());
405 EXPECT_EQ(DRM_FORMAT_UYVY,
406 plane_list.back().buffer->GetFramebufferPixelFormat());
381 407
382 // This configuration should not be promoted to Overlay when either of the 408 // This configuration should not be promoted to Overlay when either of the
383 // controllers dont support UYVY format. 409 // controllers dont support UYVY format.
384 410
385 // Check case where we dont have support for packed formats in Mirrored CRTC. 411 // Check case where we dont have support for packed formats in Mirrored CRTC.
386 planes_info.back().allowed_formats = only_rgb_format; 412 planes_info.back().allowed_formats = only_rgb_format;
387 plane_manager_->SetPlaneProperties(planes_info); 413 plane_manager_->SetPlaneProperties(planes_info);
388 overlay_validator_->ClearCache(); 414 overlay_validator_->ClearCache();
389 415
390 validated_params = overlay_validator_->TestPageFlip( 416 validated_params = overlay_validator_->TestPageFlip(
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 overlay_validator_->ClearCache(); 462 overlay_validator_->ClearCache();
437 463
438 plane_manager_->ResetPlaneCount(); 464 plane_manager_->ResetPlaneCount();
439 std::vector<ui::OverlayCheck_Params> validated_params = 465 std::vector<ui::OverlayCheck_Params> validated_params =
440 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList(), 466 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList(),
441 buffer_generator_.get()); 467 buffer_generator_.get());
442 468
443 EXPECT_EQ(true, validated_params.back().is_overlay_candidate); 469 EXPECT_EQ(true, validated_params.back().is_overlay_candidate);
444 // Both controllers have Overlay which support DRM_FORMAT_UYVY, hence this 470 // Both controllers have Overlay which support DRM_FORMAT_UYVY, hence this
445 // should be picked as the optimal format. 471 // should be picked as the optimal format.
446 uint32_t optimal_format = overlay_validator_->GetOptimalBufferFormat( 472 ui::OverlayPlaneList plane_list =
447 plane_list_.back(), plane_list_); 473 overlay_validator_->ValidatePlanesForPageFlip(plane_list_,
448 EXPECT_EQ(DRM_FORMAT_UYVY, optimal_format); 474 buffer_generator_.get());
475 EXPECT_EQ(DRM_FORMAT_UYVY,
476 plane_list.back().buffer->GetFramebufferPixelFormat());
449 477
450 // DRM_FORMAT_XRGB8888 should be the preferred format when either of the 478 // DRM_FORMAT_XRGB8888 should be the preferred format when either of the
451 // controllers dont support UYVY format. 479 // controllers dont support UYVY format.
452 480
453 // Check case where we dont have support for packed formats in Mirrored CRTC. 481 // Check case where we dont have support for packed formats in Mirrored CRTC.
454 planes_info.back().allowed_formats = only_rgb_format; 482 planes_info.back().allowed_formats = only_rgb_format;
455 plane_manager_->SetPlaneProperties(planes_info); 483 plane_manager_->SetPlaneProperties(planes_info);
456 overlay_validator_->ClearCache(); 484 overlay_validator_->ClearCache();
457 485
458 validated_params = overlay_validator_->TestPageFlip( 486 validated_params = overlay_validator_->TestPageFlip(
459 overlay_params_, ui::OverlayPlaneList(), buffer_generator_.get()); 487 overlay_params_, ui::OverlayPlaneList(), buffer_generator_.get());
460 EXPECT_EQ(true, validated_params.back().is_overlay_candidate); 488 EXPECT_EQ(true, validated_params.back().is_overlay_candidate);
461 489
462 optimal_format = overlay_validator_->GetOptimalBufferFormat( 490 plane_list = overlay_validator_->ValidatePlanesForPageFlip(
463 plane_list_.back(), plane_list_); 491 plane_list_, buffer_generator_.get());
464 EXPECT_EQ(DRM_FORMAT_XRGB8888, optimal_format); 492 EXPECT_EQ(DRM_FORMAT_XRGB8888,
493 plane_list.back().buffer->GetFramebufferPixelFormat());
465 494
466 // Check case where we dont have support for packed formats in primary 495 // Check case where we dont have support for packed formats in primary
467 // display. 496 // display.
468 planes_info.back().allowed_formats = xrgb_yuv_packed_formats; 497 planes_info.back().allowed_formats = xrgb_yuv_packed_formats;
469 planes_info[1].allowed_formats = only_rgb_format; 498 planes_info[1].allowed_formats = only_rgb_format;
470 plane_manager_->SetPlaneProperties(planes_info); 499 plane_manager_->SetPlaneProperties(planes_info);
471 overlay_validator_->ClearCache(); 500 overlay_validator_->ClearCache();
472 501
473 validated_params = overlay_validator_->TestPageFlip( 502 validated_params = overlay_validator_->TestPageFlip(
474 overlay_params_, ui::OverlayPlaneList(), buffer_generator_.get()); 503 overlay_params_, ui::OverlayPlaneList(), buffer_generator_.get());
475 EXPECT_EQ(true, validated_params.back().is_overlay_candidate); 504 EXPECT_EQ(true, validated_params.back().is_overlay_candidate);
476 505
477 optimal_format = overlay_validator_->GetOptimalBufferFormat( 506 plane_list = overlay_validator_->ValidatePlanesForPageFlip(
478 plane_list_.back(), plane_list_); 507 plane_list_, buffer_generator_.get());
479 EXPECT_EQ(DRM_FORMAT_XRGB8888, optimal_format); 508 EXPECT_EQ(DRM_FORMAT_XRGB8888,
509 plane_list.back().buffer->GetFramebufferPixelFormat());
480 controller->RemoveCrtc(drm_, kSecondaryCrtc); 510 controller->RemoveCrtc(drm_, kSecondaryCrtc);
481 } 511 }
512
513 TEST_F(DrmOverlayValidatorTest, OptimizeOnlyIfProcessingCallbackPresent) {
514 // This test checks that we dont manipulate overlay buffers in case Processing
515 // callback is not present.
516 overlay_params_.back().buffer_size = overlay_rect_.size();
517 overlay_params_.back().display_rect = overlay_rect_;
518 plane_list_.back().display_bounds = overlay_rect_;
519 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888,
520 DRM_FORMAT_UYVY};
521
522 ui::FakePlaneInfo primary_plane_info(
523 100, 1 << 0, std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888));
524 ui::FakePlaneInfo overlay_info(101, 1 << 0, xrgb_yuv_packed_formats);
525 std::vector<ui::FakePlaneInfo> planes_info{primary_plane_info, overlay_info};
526 plane_manager_->SetPlaneProperties(planes_info);
527 overlay_validator_->ClearCache();
528
529 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList(),
530 buffer_generator_.get());
531
532 ui::OverlayPlaneList plane_list =
533 overlay_validator_->ValidatePlanesForPageFlip(plane_list_,
534 buffer_generator_.get());
535 EXPECT_EQ(DRM_FORMAT_UYVY,
536 plane_list.back().buffer->GetFramebufferPixelFormat());
537 plane_list_.back().processing_callback.Reset();
538 plane_list = overlay_validator_->ValidatePlanesForPageFlip(
539 plane_list_, buffer_generator_.get());
540 EXPECT_EQ(plane_list_.back().buffer->GetFramebufferPixelFormat(),
541 plane_list.back().buffer->GetFramebufferPixelFormat());
542 plane_list_.back().processing_callback = copy_buffer_handler_;
543 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698