| OLD | NEW |
| 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 <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 EXPECT_TRUE(validated_params.front().is_overlay_candidate); | 184 EXPECT_TRUE(validated_params.front().is_overlay_candidate); |
| 185 EXPECT_FALSE(validated_params.back().is_overlay_candidate); | 185 EXPECT_FALSE(validated_params.back().is_overlay_candidate); |
| 186 } | 186 } |
| 187 | 187 |
| 188 TEST_F(DrmOverlayValidatorTest, ClearCacheOnReset) { | 188 TEST_F(DrmOverlayValidatorTest, ClearCacheOnReset) { |
| 189 // This test checks if we invalidate cache when Reset is called. | 189 // This test checks if we invalidate cache when Reset is called. |
| 190 overlay_params_.back().buffer_size = overlay_rect_.size(); | 190 overlay_params_.back().buffer_size = overlay_rect_.size(); |
| 191 overlay_params_.back().display_rect = overlay_rect_; | 191 overlay_params_.back().display_rect = overlay_rect_; |
| 192 plane_list_.back().display_bounds = overlay_rect_; | 192 plane_list_.back().display_bounds = overlay_rect_; |
| 193 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, | 193 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, |
| 194 DRM_FORMAT_UYVY}; | 194 DRM_FORMAT_YUYV}; |
| 195 | 195 |
| 196 ui::FakePlaneInfo primary_plane_info( | 196 ui::FakePlaneInfo primary_plane_info( |
| 197 100, 1 << 0, std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888)); | 197 100, 1 << 0, std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888)); |
| 198 ui::FakePlaneInfo overlay_info(101, 1 << 0, xrgb_yuv_packed_formats); | 198 ui::FakePlaneInfo overlay_info(101, 1 << 0, xrgb_yuv_packed_formats); |
| 199 std::vector<ui::FakePlaneInfo> planes_info{primary_plane_info, overlay_info}; | 199 std::vector<ui::FakePlaneInfo> planes_info{primary_plane_info, overlay_info}; |
| 200 plane_manager_->SetPlaneProperties(planes_info); | 200 plane_manager_->SetPlaneProperties(planes_info); |
| 201 overlay_validator_->ClearCache(); | 201 overlay_validator_->ClearCache(); |
| 202 | 202 |
| 203 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList()); | 203 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList()); |
| 204 | 204 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 217 | 217 |
| 218 TEST_F(DrmOverlayValidatorTest, ClearCacheOnResetWithScaling) { | 218 TEST_F(DrmOverlayValidatorTest, ClearCacheOnResetWithScaling) { |
| 219 // This test checks if we invalidate cache when Reset is called. | 219 // This test checks if we invalidate cache when Reset is called. |
| 220 gfx::RectF crop_rect = gfx::RectF(0, 0, 0.5, 0.5); | 220 gfx::RectF crop_rect = gfx::RectF(0, 0, 0.5, 0.5); |
| 221 overlay_params_.back().buffer_size = overlay_rect_.size(); | 221 overlay_params_.back().buffer_size = overlay_rect_.size(); |
| 222 overlay_params_.back().display_rect = overlay_rect_; | 222 overlay_params_.back().display_rect = overlay_rect_; |
| 223 overlay_params_.back().crop_rect = crop_rect; | 223 overlay_params_.back().crop_rect = crop_rect; |
| 224 plane_list_.back().display_bounds = overlay_rect_; | 224 plane_list_.back().display_bounds = overlay_rect_; |
| 225 plane_list_.back().crop_rect = crop_rect; | 225 plane_list_.back().crop_rect = crop_rect; |
| 226 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, | 226 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, |
| 227 DRM_FORMAT_UYVY}; | 227 DRM_FORMAT_YUYV}; |
| 228 | 228 |
| 229 ui::FakePlaneInfo primary_plane_info( | 229 ui::FakePlaneInfo primary_plane_info( |
| 230 100, 1 << 0, std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888)); | 230 100, 1 << 0, std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888)); |
| 231 ui::FakePlaneInfo overlay_info(101, 1 << 0, xrgb_yuv_packed_formats); | 231 ui::FakePlaneInfo overlay_info(101, 1 << 0, xrgb_yuv_packed_formats); |
| 232 std::vector<ui::FakePlaneInfo> planes_info{primary_plane_info, overlay_info}; | 232 std::vector<ui::FakePlaneInfo> planes_info{primary_plane_info, overlay_info}; |
| 233 plane_manager_->SetPlaneProperties(planes_info); | 233 plane_manager_->SetPlaneProperties(planes_info); |
| 234 overlay_validator_->ClearCache(); | 234 overlay_validator_->ClearCache(); |
| 235 | 235 |
| 236 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList()); | 236 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList()); |
| 237 | 237 |
| 238 ui::OverlayPlaneList plane_list = | 238 ui::OverlayPlaneList plane_list = |
| 239 overlay_validator_->PrepareBuffersForPageFlip(plane_list_); | 239 overlay_validator_->PrepareBuffersForPageFlip(plane_list_); |
| 240 // Scaling allows format conversion. | 240 // Scaling allows format conversion. |
| 241 EXPECT_EQ(DRM_FORMAT_UYVY, | 241 EXPECT_EQ(DRM_FORMAT_YUYV, |
| 242 plane_list.back().buffer->GetFramebufferPixelFormat()); | 242 plane_list.back().buffer->GetFramebufferPixelFormat()); |
| 243 // Check if ClearCache actually clears the cache. | 243 // Check if ClearCache actually clears the cache. |
| 244 overlay_validator_->ClearCache(); | 244 overlay_validator_->ClearCache(); |
| 245 plane_list = overlay_validator_->PrepareBuffersForPageFlip(plane_list_); | 245 plane_list = overlay_validator_->PrepareBuffersForPageFlip(plane_list_); |
| 246 // There should be no entry in cache for this configuration and should return | 246 // There should be no entry in cache for this configuration and should return |
| 247 // default value of DRM_FORMAT_XRGB8888. | 247 // default value of DRM_FORMAT_XRGB8888. |
| 248 EXPECT_EQ(DRM_FORMAT_XRGB8888, | 248 EXPECT_EQ(DRM_FORMAT_XRGB8888, |
| 249 plane_list.back().buffer->GetFramebufferPixelFormat()); | 249 plane_list.back().buffer->GetFramebufferPixelFormat()); |
| 250 } | 250 } |
| 251 | 251 |
| 252 TEST_F(DrmOverlayValidatorTest, OptimalFormatForOverlayInFullScreen_XRGB) { | 252 TEST_F(DrmOverlayValidatorTest, OptimalFormatForOverlayInFullScreen_XRGB) { |
| 253 // Optimal format for Overlay configuration should be XRGB, when primary plane | 253 // Optimal format for Overlay configuration should be XRGB, when primary plane |
| 254 // supports only XRGB and overlay obscures primary. | 254 // supports only XRGB and overlay obscures primary. |
| 255 overlay_params_.back().buffer_size = primary_rect_.size(); | 255 overlay_params_.back().buffer_size = primary_rect_.size(); |
| 256 overlay_params_.back().display_rect = primary_rect_; | 256 overlay_params_.back().display_rect = primary_rect_; |
| 257 plane_list_.back().display_bounds = primary_rect_; | 257 plane_list_.back().display_bounds = primary_rect_; |
| 258 | 258 |
| 259 // Check optimal format for Overlay. | 259 // Check optimal format for Overlay. |
| 260 ui::FakePlaneInfo primary_plane_info( | 260 ui::FakePlaneInfo primary_plane_info( |
| 261 100, 1 << 0, std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888)); | 261 100, 1 << 0, std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888)); |
| 262 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, | 262 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, |
| 263 DRM_FORMAT_UYVY}; | 263 DRM_FORMAT_YUYV}; |
| 264 ui::FakePlaneInfo plane_info(101, 1 << 0, xrgb_yuv_packed_formats); | 264 ui::FakePlaneInfo plane_info(101, 1 << 0, xrgb_yuv_packed_formats); |
| 265 | 265 |
| 266 std::vector<ui::FakePlaneInfo> planes{primary_plane_info, plane_info}; | 266 std::vector<ui::FakePlaneInfo> planes{primary_plane_info, plane_info}; |
| 267 plane_manager_->SetPlaneProperties(planes); | 267 plane_manager_->SetPlaneProperties(planes); |
| 268 overlay_validator_->ClearCache(); | 268 overlay_validator_->ClearCache(); |
| 269 | 269 |
| 270 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList()); | 270 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList()); |
| 271 ui::OverlayPlaneList plane_list = | 271 ui::OverlayPlaneList plane_list = |
| 272 overlay_validator_->PrepareBuffersForPageFlip(plane_list_); | 272 overlay_validator_->PrepareBuffersForPageFlip(plane_list_); |
| 273 EXPECT_EQ(DRM_FORMAT_XRGB8888, | 273 EXPECT_EQ(DRM_FORMAT_XRGB8888, |
| 274 plane_list.back().buffer->GetFramebufferPixelFormat()); | 274 plane_list.back().buffer->GetFramebufferPixelFormat()); |
| 275 } | 275 } |
| 276 | 276 |
| 277 TEST_F(DrmOverlayValidatorTest, OptimalFormatForOverlayInFullScreen_YUV) { | 277 TEST_F(DrmOverlayValidatorTest, OptimalFormatForOverlayInFullScreen_YUV) { |
| 278 overlay_params_.back().buffer_size = primary_rect_.size(); | 278 overlay_params_.back().buffer_size = primary_rect_.size(); |
| 279 overlay_params_.back().display_rect = primary_rect_; | 279 overlay_params_.back().display_rect = primary_rect_; |
| 280 plane_list_.back().display_bounds = primary_rect_; | 280 plane_list_.back().display_bounds = primary_rect_; |
| 281 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, | 281 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, |
| 282 DRM_FORMAT_UYVY}; | 282 DRM_FORMAT_YUYV}; |
| 283 | 283 |
| 284 // We should prefer YUV when primary can support it. | 284 // We should prefer YUV when primary can support it. |
| 285 ui::FakePlaneInfo primary_plane_info(100, 1 << 0, xrgb_yuv_packed_formats); | 285 ui::FakePlaneInfo primary_plane_info(100, 1 << 0, xrgb_yuv_packed_formats); |
| 286 ui::FakePlaneInfo plane_info(101, 1 << 0, xrgb_yuv_packed_formats); | 286 ui::FakePlaneInfo plane_info(101, 1 << 0, xrgb_yuv_packed_formats); |
| 287 | 287 |
| 288 std::vector<ui::FakePlaneInfo> planes{primary_plane_info, plane_info}; | 288 std::vector<ui::FakePlaneInfo> planes{primary_plane_info, plane_info}; |
| 289 plane_manager_->SetPlaneProperties(planes); | 289 plane_manager_->SetPlaneProperties(planes); |
| 290 overlay_validator_->ClearCache(); | 290 overlay_validator_->ClearCache(); |
| 291 | 291 |
| 292 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList()); | 292 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList()); |
| 293 ui::OverlayPlaneList plane_list = | 293 ui::OverlayPlaneList plane_list = |
| 294 overlay_validator_->PrepareBuffersForPageFlip(plane_list_); | 294 overlay_validator_->PrepareBuffersForPageFlip(plane_list_); |
| 295 // TODO(dcastagna): If Atomic support is enabled, a packed format (UYVY) might | 295 // TODO(dcastagna): If Atomic support is enabled, a packed format (YUYV) might |
| 296 // be the optimal one and should be preferred. | 296 // be the optimal one and should be preferred. |
| 297 EXPECT_EQ(DRM_FORMAT_XRGB8888, | 297 EXPECT_EQ(DRM_FORMAT_XRGB8888, |
| 298 plane_list.back().buffer->GetFramebufferPixelFormat()); | 298 plane_list.back().buffer->GetFramebufferPixelFormat()); |
| 299 } | 299 } |
| 300 | 300 |
| 301 TEST_F(DrmOverlayValidatorTest, OverlayPreferredFormat) { | 301 TEST_F(DrmOverlayValidatorTest, OverlayPreferredFormat) { |
| 302 plane_manager_->ResetPlaneCount(); | 302 plane_manager_->ResetPlaneCount(); |
| 303 // This test checks for optimal format in case of non full screen video case. | 303 // This test checks for optimal format in case of non full screen video case. |
| 304 overlay_params_.back().buffer_size = overlay_rect_.size(); | 304 overlay_params_.back().buffer_size = overlay_rect_.size(); |
| 305 overlay_params_.back().display_rect = overlay_rect_; | 305 overlay_params_.back().display_rect = overlay_rect_; |
| 306 plane_list_.back().display_bounds = overlay_rect_; | 306 plane_list_.back().display_bounds = overlay_rect_; |
| 307 | 307 |
| 308 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, | 308 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, |
| 309 DRM_FORMAT_UYVY}; | 309 DRM_FORMAT_YUYV}; |
| 310 ui::FakePlaneInfo primary_plane_info( | 310 ui::FakePlaneInfo primary_plane_info( |
| 311 100, 1 << 0, std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888)); | 311 100, 1 << 0, std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888)); |
| 312 ui::FakePlaneInfo overlay_info(101, 1 << 0, xrgb_yuv_packed_formats); | 312 ui::FakePlaneInfo overlay_info(101, 1 << 0, xrgb_yuv_packed_formats); |
| 313 std::vector<ui::FakePlaneInfo> planes_info{primary_plane_info, overlay_info}; | 313 std::vector<ui::FakePlaneInfo> planes_info{primary_plane_info, overlay_info}; |
| 314 plane_manager_->SetPlaneProperties(planes_info); | 314 plane_manager_->SetPlaneProperties(planes_info); |
| 315 overlay_validator_->ClearCache(); | 315 overlay_validator_->ClearCache(); |
| 316 | 316 |
| 317 std::vector<ui::OverlayCheck_Params> validated_params = | 317 std::vector<ui::OverlayCheck_Params> validated_params = |
| 318 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList()); | 318 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList()); |
| 319 | 319 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 334 // Prefer YUV as optimal format when Overlay supports it and scaling is | 334 // Prefer YUV as optimal format when Overlay supports it and scaling is |
| 335 // needed. | 335 // needed. |
| 336 gfx::RectF crop_rect = gfx::RectF(0, 0, 0.5, 0.5); | 336 gfx::RectF crop_rect = gfx::RectF(0, 0, 0.5, 0.5); |
| 337 overlay_params_.back().buffer_size = overlay_rect_.size(); | 337 overlay_params_.back().buffer_size = overlay_rect_.size(); |
| 338 overlay_params_.back().display_rect = overlay_rect_; | 338 overlay_params_.back().display_rect = overlay_rect_; |
| 339 overlay_params_.back().crop_rect = crop_rect; | 339 overlay_params_.back().crop_rect = crop_rect; |
| 340 plane_list_.back().display_bounds = overlay_rect_; | 340 plane_list_.back().display_bounds = overlay_rect_; |
| 341 plane_list_.back().crop_rect = crop_rect; | 341 plane_list_.back().crop_rect = crop_rect; |
| 342 | 342 |
| 343 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, | 343 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, |
| 344 DRM_FORMAT_UYVY}; | 344 DRM_FORMAT_YUYV}; |
| 345 ui::FakePlaneInfo primary_plane_info( | 345 ui::FakePlaneInfo primary_plane_info( |
| 346 100, 1 << 0, std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888)); | 346 100, 1 << 0, std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888)); |
| 347 ui::FakePlaneInfo overlay_info(101, 1 << 0, xrgb_yuv_packed_formats); | 347 ui::FakePlaneInfo overlay_info(101, 1 << 0, xrgb_yuv_packed_formats); |
| 348 std::vector<ui::FakePlaneInfo> planes_info{primary_plane_info, overlay_info}; | 348 std::vector<ui::FakePlaneInfo> planes_info{primary_plane_info, overlay_info}; |
| 349 plane_manager_->SetPlaneProperties(planes_info); | 349 plane_manager_->SetPlaneProperties(planes_info); |
| 350 overlay_validator_->ClearCache(); | 350 overlay_validator_->ClearCache(); |
| 351 | 351 |
| 352 std::vector<ui::OverlayCheck_Params> validated_params = | 352 std::vector<ui::OverlayCheck_Params> validated_params = |
| 353 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList()); | 353 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList()); |
| 354 | 354 |
| 355 for (const auto& param : validated_params) | 355 for (const auto& param : validated_params) |
| 356 EXPECT_TRUE(param.is_overlay_candidate); | 356 EXPECT_TRUE(param.is_overlay_candidate); |
| 357 | 357 |
| 358 EXPECT_EQ(5, plane_manager_->plane_count()); | 358 EXPECT_EQ(5, plane_manager_->plane_count()); |
| 359 | 359 |
| 360 ui::OverlayPlaneList plane_list = | 360 ui::OverlayPlaneList plane_list = |
| 361 overlay_validator_->PrepareBuffersForPageFlip(plane_list_); | 361 overlay_validator_->PrepareBuffersForPageFlip(plane_list_); |
| 362 EXPECT_EQ(DRM_FORMAT_UYVY, | 362 EXPECT_EQ(DRM_FORMAT_YUYV, |
| 363 plane_list.back().buffer->GetFramebufferPixelFormat()); | 363 plane_list.back().buffer->GetFramebufferPixelFormat()); |
| 364 } | 364 } |
| 365 | 365 |
| 366 TEST_F(DrmOverlayValidatorTest, OverlayPreferredFormat_XRGB) { | 366 TEST_F(DrmOverlayValidatorTest, OverlayPreferredFormat_XRGB) { |
| 367 plane_manager_->ResetPlaneCount(); | 367 plane_manager_->ResetPlaneCount(); |
| 368 // This test checks for optimal format in case of non full screen video case. | 368 // This test checks for optimal format in case of non full screen video case. |
| 369 // This should be XRGB when overlay doesn't support YUV. | 369 // This should be XRGB when overlay doesn't support YUV. |
| 370 overlay_params_.back().buffer_size = overlay_rect_.size(); | 370 overlay_params_.back().buffer_size = overlay_rect_.size(); |
| 371 overlay_params_.back().display_rect = overlay_rect_; | 371 overlay_params_.back().display_rect = overlay_rect_; |
| 372 plane_list_.back().display_bounds = overlay_rect_; | 372 plane_list_.back().display_bounds = overlay_rect_; |
| 373 | 373 |
| 374 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, | 374 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, |
| 375 DRM_FORMAT_UYVY}; | 375 DRM_FORMAT_YUYV}; |
| 376 ui::FakePlaneInfo primary_plane_info(100, 1 << 0, xrgb_yuv_packed_formats); | 376 ui::FakePlaneInfo primary_plane_info(100, 1 << 0, xrgb_yuv_packed_formats); |
| 377 ui::FakePlaneInfo overlay_info(101, 1 << 0, | 377 ui::FakePlaneInfo overlay_info(101, 1 << 0, |
| 378 std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888)); | 378 std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888)); |
| 379 std::vector<ui::FakePlaneInfo> planes_info{primary_plane_info, overlay_info}; | 379 std::vector<ui::FakePlaneInfo> planes_info{primary_plane_info, overlay_info}; |
| 380 plane_manager_->SetPlaneProperties(planes_info); | 380 plane_manager_->SetPlaneProperties(planes_info); |
| 381 overlay_validator_->ClearCache(); | 381 overlay_validator_->ClearCache(); |
| 382 | 382 |
| 383 std::vector<ui::OverlayCheck_Params> validated_params = | 383 std::vector<ui::OverlayCheck_Params> validated_params = |
| 384 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList()); | 384 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList()); |
| 385 ui::OverlayPlaneList plane_list = | 385 ui::OverlayPlaneList plane_list = |
| 386 overlay_validator_->PrepareBuffersForPageFlip(plane_list_); | 386 overlay_validator_->PrepareBuffersForPageFlip(plane_list_); |
| 387 EXPECT_EQ(DRM_FORMAT_XRGB8888, | 387 EXPECT_EQ(DRM_FORMAT_XRGB8888, |
| 388 plane_list.back().buffer->GetFramebufferPixelFormat()); | 388 plane_list.back().buffer->GetFramebufferPixelFormat()); |
| 389 EXPECT_EQ(3, plane_manager_->plane_count()); | 389 EXPECT_EQ(3, plane_manager_->plane_count()); |
| 390 for (const auto& param : validated_params) | 390 for (const auto& param : validated_params) |
| 391 EXPECT_TRUE(param.is_overlay_candidate); | 391 EXPECT_TRUE(param.is_overlay_candidate); |
| 392 } | 392 } |
| 393 | 393 |
| 394 TEST_F(DrmOverlayValidatorTest, RejectYUVBuffersIfNotSupported) { | 394 TEST_F(DrmOverlayValidatorTest, RejectYUVBuffersIfNotSupported) { |
| 395 plane_manager_->ResetPlaneCount(); | 395 plane_manager_->ResetPlaneCount(); |
| 396 // Check case where buffer storage format is already UYVY but planes dont | 396 // Check case where buffer storage format is already YUYV but planes dont |
| 397 // support it. | 397 // support it. |
| 398 overlay_params_.back().buffer_size = overlay_rect_.size(); | 398 overlay_params_.back().buffer_size = overlay_rect_.size(); |
| 399 overlay_params_.back().display_rect = overlay_rect_; | 399 overlay_params_.back().display_rect = overlay_rect_; |
| 400 plane_list_.back().display_bounds = overlay_rect_; | 400 plane_list_.back().display_bounds = overlay_rect_; |
| 401 | 401 |
| 402 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, | 402 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, |
| 403 DRM_FORMAT_UYVY}; | 403 DRM_FORMAT_YUYV}; |
| 404 ui::FakePlaneInfo primary_plane_info(100, 1 << 0, xrgb_yuv_packed_formats); | 404 ui::FakePlaneInfo primary_plane_info(100, 1 << 0, xrgb_yuv_packed_formats); |
| 405 ui::FakePlaneInfo overlay_info(101, 1 << 0, | 405 ui::FakePlaneInfo overlay_info(101, 1 << 0, |
| 406 std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888)); | 406 std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888)); |
| 407 std::vector<ui::FakePlaneInfo> planes_info{primary_plane_info, overlay_info}; | 407 std::vector<ui::FakePlaneInfo> planes_info{primary_plane_info, overlay_info}; |
| 408 plane_manager_->SetPlaneProperties(planes_info); | 408 plane_manager_->SetPlaneProperties(planes_info); |
| 409 overlay_validator_->ClearCache(); | 409 overlay_validator_->ClearCache(); |
| 410 | 410 |
| 411 std::vector<ui::OverlayCheck_Params> validated_params = overlay_params_; | 411 std::vector<ui::OverlayCheck_Params> validated_params = overlay_params_; |
| 412 validated_params.back().format = gfx::BufferFormat::UYVY_422; | 412 validated_params.back().format = gfx::BufferFormat::YUYV_422; |
| 413 plane_manager_->ResetPlaneCount(); | 413 plane_manager_->ResetPlaneCount(); |
| 414 validated_params = overlay_validator_->TestPageFlip(validated_params, | 414 validated_params = overlay_validator_->TestPageFlip(validated_params, |
| 415 ui::OverlayPlaneList()); | 415 ui::OverlayPlaneList()); |
| 416 | 416 |
| 417 EXPECT_FALSE(validated_params.back().is_overlay_candidate); | 417 EXPECT_FALSE(validated_params.back().is_overlay_candidate); |
| 418 } | 418 } |
| 419 | 419 |
| 420 TEST_F(DrmOverlayValidatorTest, | 420 TEST_F(DrmOverlayValidatorTest, |
| 421 RejectYUVBuffersIfNotSupported_MirroredControllers) { | 421 RejectYUVBuffersIfNotSupported_MirroredControllers) { |
| 422 std::vector<uint32_t> crtcs{kDefaultCrtc, kSecondaryCrtc}; | 422 std::vector<uint32_t> crtcs{kDefaultCrtc, kSecondaryCrtc}; |
| 423 plane_manager_->SetCrtcInfo(crtcs); | 423 plane_manager_->SetCrtcInfo(crtcs); |
| 424 | 424 |
| 425 std::vector<uint32_t> only_rgb_format{DRM_FORMAT_XRGB8888}; | 425 std::vector<uint32_t> only_rgb_format{DRM_FORMAT_XRGB8888}; |
| 426 std::vector<uint32_t> xrgb_yuv_packed_formats{DRM_FORMAT_XRGB8888, | 426 std::vector<uint32_t> xrgb_yuv_packed_formats{DRM_FORMAT_XRGB8888, |
| 427 DRM_FORMAT_UYVY}; | 427 DRM_FORMAT_YUYV}; |
| 428 ui::HardwareDisplayController* controller = window_->GetController(); | 428 ui::HardwareDisplayController* controller = window_->GetController(); |
| 429 controller->AddCrtc(std::unique_ptr<ui::CrtcController>( | 429 controller->AddCrtc(std::unique_ptr<ui::CrtcController>( |
| 430 new ui::CrtcController(drm_.get(), kSecondaryCrtc, kSecondaryConnector))); | 430 new ui::CrtcController(drm_.get(), kSecondaryCrtc, kSecondaryConnector))); |
| 431 ui::OverlayPlane plane1(scoped_refptr<ui::ScanoutBuffer>( | 431 ui::OverlayPlane plane1(scoped_refptr<ui::ScanoutBuffer>( |
| 432 new ui::MockScanoutBuffer(primary_rect_.size()))); | 432 new ui::MockScanoutBuffer(primary_rect_.size()))); |
| 433 EXPECT_TRUE(controller->Modeset(plane1, kDefaultMode)); | 433 EXPECT_TRUE(controller->Modeset(plane1, kDefaultMode)); |
| 434 | 434 |
| 435 gfx::RectF crop_rect = gfx::RectF(0, 0, 0.5, 0.5); | 435 gfx::RectF crop_rect = gfx::RectF(0, 0, 0.5, 0.5); |
| 436 overlay_params_.back().buffer_size = overlay_rect_.size(); | 436 overlay_params_.back().buffer_size = overlay_rect_.size(); |
| 437 overlay_params_.back().display_rect = overlay_rect_; | 437 overlay_params_.back().display_rect = overlay_rect_; |
| 438 overlay_params_.back().crop_rect = crop_rect; | 438 overlay_params_.back().crop_rect = crop_rect; |
| 439 plane_list_.back().display_bounds = overlay_rect_; | 439 plane_list_.back().display_bounds = overlay_rect_; |
| 440 plane_list_.back().crop_rect = crop_rect; | 440 plane_list_.back().crop_rect = crop_rect; |
| 441 | 441 |
| 442 ui::FakePlaneInfo primary_crtc_primary_plane(100, 1 << 0, only_rgb_format); | 442 ui::FakePlaneInfo primary_crtc_primary_plane(100, 1 << 0, only_rgb_format); |
| 443 ui::FakePlaneInfo primary_crtc_overlay(101, 1 << 0, xrgb_yuv_packed_formats); | 443 ui::FakePlaneInfo primary_crtc_overlay(101, 1 << 0, xrgb_yuv_packed_formats); |
| 444 ui::FakePlaneInfo secondary_crtc_primary_plane(102, 1 << 1, only_rgb_format); | 444 ui::FakePlaneInfo secondary_crtc_primary_plane(102, 1 << 1, only_rgb_format); |
| 445 ui::FakePlaneInfo secondary_crtc_overlay(103, 1 << 1, | 445 ui::FakePlaneInfo secondary_crtc_overlay(103, 1 << 1, |
| 446 xrgb_yuv_packed_formats); | 446 xrgb_yuv_packed_formats); |
| 447 | 447 |
| 448 std::vector<ui::FakePlaneInfo> planes_info{ | 448 std::vector<ui::FakePlaneInfo> planes_info{ |
| 449 primary_crtc_primary_plane, primary_crtc_overlay, | 449 primary_crtc_primary_plane, primary_crtc_overlay, |
| 450 secondary_crtc_primary_plane, secondary_crtc_overlay}; | 450 secondary_crtc_primary_plane, secondary_crtc_overlay}; |
| 451 plane_manager_->SetPlaneProperties(planes_info); | 451 plane_manager_->SetPlaneProperties(planes_info); |
| 452 overlay_validator_->ClearCache(); | 452 overlay_validator_->ClearCache(); |
| 453 | 453 |
| 454 std::vector<ui::OverlayCheck_Params> validated_params = overlay_params_; | 454 std::vector<ui::OverlayCheck_Params> validated_params = overlay_params_; |
| 455 validated_params.back().format = gfx::BufferFormat::UYVY_422; | 455 validated_params.back().format = gfx::BufferFormat::YUYV_422; |
| 456 plane_manager_->ResetPlaneCount(); | 456 plane_manager_->ResetPlaneCount(); |
| 457 validated_params = overlay_validator_->TestPageFlip(validated_params, | 457 validated_params = overlay_validator_->TestPageFlip(validated_params, |
| 458 ui::OverlayPlaneList()); | 458 ui::OverlayPlaneList()); |
| 459 | 459 |
| 460 EXPECT_TRUE(validated_params.back().is_overlay_candidate); | 460 EXPECT_TRUE(validated_params.back().is_overlay_candidate); |
| 461 | 461 |
| 462 // Both controllers have Overlay which support DRM_FORMAT_UYVY, and scaling is | 462 // Both controllers have Overlay which support DRM_FORMAT_YUYV, and scaling is |
| 463 // needed, hence this should be picked as the optimal format. | 463 // needed, hence this should be picked as the optimal format. |
| 464 ui::OverlayPlaneList plane_list = | 464 ui::OverlayPlaneList plane_list = |
| 465 overlay_validator_->PrepareBuffersForPageFlip(plane_list_); | 465 overlay_validator_->PrepareBuffersForPageFlip(plane_list_); |
| 466 EXPECT_EQ(DRM_FORMAT_UYVY, | 466 EXPECT_EQ(DRM_FORMAT_YUYV, |
| 467 plane_list.back().buffer->GetFramebufferPixelFormat()); | 467 plane_list.back().buffer->GetFramebufferPixelFormat()); |
| 468 | 468 |
| 469 // This configuration should not be promoted to Overlay when either of the | 469 // This configuration should not be promoted to Overlay when either of the |
| 470 // controllers dont support UYVY format. | 470 // controllers dont support YUYV format. |
| 471 | 471 |
| 472 // Check case where we dont have support for packed formats in Mirrored CRTC. | 472 // Check case where we dont have support for packed formats in Mirrored CRTC. |
| 473 planes_info.back().allowed_formats = only_rgb_format; | 473 planes_info.back().allowed_formats = only_rgb_format; |
| 474 plane_manager_->SetPlaneProperties(planes_info); | 474 plane_manager_->SetPlaneProperties(planes_info); |
| 475 overlay_validator_->ClearCache(); | 475 overlay_validator_->ClearCache(); |
| 476 | 476 |
| 477 validated_params = overlay_validator_->TestPageFlip(validated_params, | 477 validated_params = overlay_validator_->TestPageFlip(validated_params, |
| 478 ui::OverlayPlaneList()); | 478 ui::OverlayPlaneList()); |
| 479 EXPECT_FALSE(validated_params.back().is_overlay_candidate); | 479 EXPECT_FALSE(validated_params.back().is_overlay_candidate); |
| 480 | 480 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 501 new ui::CrtcController(drm_.get(), kSecondaryCrtc, kSecondaryConnector))); | 501 new ui::CrtcController(drm_.get(), kSecondaryCrtc, kSecondaryConnector))); |
| 502 ui::OverlayPlane plane1(scoped_refptr<ui::ScanoutBuffer>( | 502 ui::OverlayPlane plane1(scoped_refptr<ui::ScanoutBuffer>( |
| 503 new ui::MockScanoutBuffer(primary_rect_.size()))); | 503 new ui::MockScanoutBuffer(primary_rect_.size()))); |
| 504 EXPECT_TRUE(controller->Modeset(plane1, kDefaultMode)); | 504 EXPECT_TRUE(controller->Modeset(plane1, kDefaultMode)); |
| 505 | 505 |
| 506 overlay_params_.back().buffer_size = overlay_rect_.size(); | 506 overlay_params_.back().buffer_size = overlay_rect_.size(); |
| 507 overlay_params_.back().display_rect = overlay_rect_; | 507 overlay_params_.back().display_rect = overlay_rect_; |
| 508 plane_list_.back().display_bounds = overlay_rect_; | 508 plane_list_.back().display_bounds = overlay_rect_; |
| 509 std::vector<uint32_t> only_rgb_format = {DRM_FORMAT_XRGB8888}; | 509 std::vector<uint32_t> only_rgb_format = {DRM_FORMAT_XRGB8888}; |
| 510 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, | 510 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, |
| 511 DRM_FORMAT_UYVY}; | 511 DRM_FORMAT_YUYV}; |
| 512 | 512 |
| 513 ui::FakePlaneInfo primary_crtc_primary_plane(100, 1 << 0, only_rgb_format); | 513 ui::FakePlaneInfo primary_crtc_primary_plane(100, 1 << 0, only_rgb_format); |
| 514 ui::FakePlaneInfo primary_crtc_overlay(101, 1 << 0, xrgb_yuv_packed_formats); | 514 ui::FakePlaneInfo primary_crtc_overlay(101, 1 << 0, xrgb_yuv_packed_formats); |
| 515 ui::FakePlaneInfo secondary_crtc_primary_plane(102, 1 << 1, only_rgb_format); | 515 ui::FakePlaneInfo secondary_crtc_primary_plane(102, 1 << 1, only_rgb_format); |
| 516 ui::FakePlaneInfo secondary_crtc_overlay(103, 1 << 1, | 516 ui::FakePlaneInfo secondary_crtc_overlay(103, 1 << 1, |
| 517 xrgb_yuv_packed_formats); | 517 xrgb_yuv_packed_formats); |
| 518 | 518 |
| 519 std::vector<ui::FakePlaneInfo> planes_info{ | 519 std::vector<ui::FakePlaneInfo> planes_info{ |
| 520 primary_crtc_primary_plane, primary_crtc_overlay, | 520 primary_crtc_primary_plane, primary_crtc_overlay, |
| 521 secondary_crtc_primary_plane, secondary_crtc_overlay}; | 521 secondary_crtc_primary_plane, secondary_crtc_overlay}; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 TEST_F(DrmOverlayValidatorTest, OptimizeOnlyIfProcessingCallbackPresent) { | 565 TEST_F(DrmOverlayValidatorTest, OptimizeOnlyIfProcessingCallbackPresent) { |
| 566 // This test checks that we dont manipulate overlay buffers in case Processing | 566 // This test checks that we dont manipulate overlay buffers in case Processing |
| 567 // callback is not present. | 567 // callback is not present. |
| 568 gfx::RectF crop_rect = gfx::RectF(0, 0, 0.5, 0.5); | 568 gfx::RectF crop_rect = gfx::RectF(0, 0, 0.5, 0.5); |
| 569 overlay_params_.back().buffer_size = overlay_rect_.size(); | 569 overlay_params_.back().buffer_size = overlay_rect_.size(); |
| 570 overlay_params_.back().display_rect = overlay_rect_; | 570 overlay_params_.back().display_rect = overlay_rect_; |
| 571 overlay_params_.back().crop_rect = crop_rect; | 571 overlay_params_.back().crop_rect = crop_rect; |
| 572 plane_list_.back().display_bounds = overlay_rect_; | 572 plane_list_.back().display_bounds = overlay_rect_; |
| 573 plane_list_.back().crop_rect = crop_rect; | 573 plane_list_.back().crop_rect = crop_rect; |
| 574 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, | 574 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, |
| 575 DRM_FORMAT_UYVY}; | 575 DRM_FORMAT_YUYV}; |
| 576 | 576 |
| 577 ui::FakePlaneInfo primary_plane_info( | 577 ui::FakePlaneInfo primary_plane_info( |
| 578 100, 1 << 0, std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888)); | 578 100, 1 << 0, std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888)); |
| 579 ui::FakePlaneInfo overlay_info(101, 1 << 0, xrgb_yuv_packed_formats); | 579 ui::FakePlaneInfo overlay_info(101, 1 << 0, xrgb_yuv_packed_formats); |
| 580 std::vector<ui::FakePlaneInfo> planes_info{primary_plane_info, overlay_info}; | 580 std::vector<ui::FakePlaneInfo> planes_info{primary_plane_info, overlay_info}; |
| 581 plane_manager_->SetPlaneProperties(planes_info); | 581 plane_manager_->SetPlaneProperties(planes_info); |
| 582 overlay_validator_->ClearCache(); | 582 overlay_validator_->ClearCache(); |
| 583 | 583 |
| 584 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList()); | 584 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList()); |
| 585 | 585 |
| 586 ui::OverlayPlaneList plane_list = | 586 ui::OverlayPlaneList plane_list = |
| 587 overlay_validator_->PrepareBuffersForPageFlip(plane_list_); | 587 overlay_validator_->PrepareBuffersForPageFlip(plane_list_); |
| 588 // Scaling allows format conversion. | 588 // Scaling allows format conversion. |
| 589 EXPECT_EQ(DRM_FORMAT_UYVY, | 589 EXPECT_EQ(DRM_FORMAT_YUYV, |
| 590 plane_list.back().buffer->GetFramebufferPixelFormat()); | 590 plane_list.back().buffer->GetFramebufferPixelFormat()); |
| 591 plane_list_.back().processing_callback.Reset(); | 591 plane_list_.back().processing_callback.Reset(); |
| 592 plane_list = overlay_validator_->PrepareBuffersForPageFlip(plane_list_); | 592 plane_list = overlay_validator_->PrepareBuffersForPageFlip(plane_list_); |
| 593 EXPECT_EQ(plane_list_.back().buffer->GetFramebufferPixelFormat(), | 593 EXPECT_EQ(plane_list_.back().buffer->GetFramebufferPixelFormat(), |
| 594 plane_list.back().buffer->GetFramebufferPixelFormat()); | 594 plane_list.back().buffer->GetFramebufferPixelFormat()); |
| 595 plane_list_.back().processing_callback = process_buffer_handler_; | 595 plane_list_.back().processing_callback = process_buffer_handler_; |
| 596 } | 596 } |
| 597 | 597 |
| 598 TEST_F(DrmOverlayValidatorTest, DontResetOriginalBufferIfProcessedIsInvalid) { | 598 TEST_F(DrmOverlayValidatorTest, DontResetOriginalBufferIfProcessedIsInvalid) { |
| 599 // This test checks that we dont manipulate overlay buffers in case Processing | 599 // This test checks that we dont manipulate overlay buffers in case Processing |
| 600 // callback is not present. | 600 // callback is not present. |
| 601 gfx::RectF crop_rect = gfx::RectF(0, 0, 0.5, 0.5); | 601 gfx::RectF crop_rect = gfx::RectF(0, 0, 0.5, 0.5); |
| 602 overlay_params_.back().buffer_size = overlay_rect_.size(); | 602 overlay_params_.back().buffer_size = overlay_rect_.size(); |
| 603 overlay_params_.back().display_rect = overlay_rect_; | 603 overlay_params_.back().display_rect = overlay_rect_; |
| 604 overlay_params_.back().crop_rect = crop_rect; | 604 overlay_params_.back().crop_rect = crop_rect; |
| 605 plane_list_.back().display_bounds = overlay_rect_; | 605 plane_list_.back().display_bounds = overlay_rect_; |
| 606 plane_list_.back().crop_rect = crop_rect; | 606 plane_list_.back().crop_rect = crop_rect; |
| 607 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, | 607 std::vector<uint32_t> xrgb_yuv_packed_formats = {DRM_FORMAT_XRGB8888, |
| 608 DRM_FORMAT_UYVY}; | 608 DRM_FORMAT_YUYV}; |
| 609 | 609 |
| 610 ui::FakePlaneInfo primary_plane_info( | 610 ui::FakePlaneInfo primary_plane_info( |
| 611 100, 1 << 0, std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888)); | 611 100, 1 << 0, std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888)); |
| 612 ui::FakePlaneInfo overlay_info(101, 1 << 0, xrgb_yuv_packed_formats); | 612 ui::FakePlaneInfo overlay_info(101, 1 << 0, xrgb_yuv_packed_formats); |
| 613 std::vector<ui::FakePlaneInfo> planes_info{primary_plane_info, overlay_info}; | 613 std::vector<ui::FakePlaneInfo> planes_info{primary_plane_info, overlay_info}; |
| 614 plane_manager_->SetPlaneProperties(planes_info); | 614 plane_manager_->SetPlaneProperties(planes_info); |
| 615 overlay_validator_->ClearCache(); | 615 overlay_validator_->ClearCache(); |
| 616 | 616 |
| 617 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList()); | 617 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList()); |
| 618 | 618 |
| 619 ui::OverlayPlaneList plane_list = | 619 ui::OverlayPlaneList plane_list = |
| 620 overlay_validator_->PrepareBuffersForPageFlip(plane_list_); | 620 overlay_validator_->PrepareBuffersForPageFlip(plane_list_); |
| 621 // Scaling allows format conversion. | 621 // Scaling allows format conversion. |
| 622 EXPECT_EQ(DRM_FORMAT_UYVY, | 622 EXPECT_EQ(DRM_FORMAT_YUYV, |
| 623 plane_list.back().buffer->GetFramebufferPixelFormat()); | 623 plane_list.back().buffer->GetFramebufferPixelFormat()); |
| 624 plane_list_.back().processing_callback = base::Bind( | 624 plane_list_.back().processing_callback = base::Bind( |
| 625 &DrmOverlayValidatorTest::ReturnNullBuffer, base::Unretained(this)); | 625 &DrmOverlayValidatorTest::ReturnNullBuffer, base::Unretained(this)); |
| 626 | 626 |
| 627 plane_list = overlay_validator_->PrepareBuffersForPageFlip(plane_list_); | 627 plane_list = overlay_validator_->PrepareBuffersForPageFlip(plane_list_); |
| 628 EXPECT_EQ(plane_list_.back().buffer->GetFramebufferPixelFormat(), | 628 EXPECT_EQ(plane_list_.back().buffer->GetFramebufferPixelFormat(), |
| 629 plane_list.back().buffer->GetFramebufferPixelFormat()); | 629 plane_list.back().buffer->GetFramebufferPixelFormat()); |
| 630 plane_list_.back().processing_callback = base::Bind( | 630 plane_list_.back().processing_callback = base::Bind( |
| 631 &DrmOverlayValidatorTest::ProcessBuffer, base::Unretained(this)); | 631 &DrmOverlayValidatorTest::ProcessBuffer, base::Unretained(this)); |
| 632 } | 632 } |
| 633 | 633 |
| 634 TEST_F(DrmOverlayValidatorTest, RejectBufferAllocationFail) { | 634 TEST_F(DrmOverlayValidatorTest, RejectBufferAllocationFail) { |
| 635 // Buffer allocation for scanout might fail. | 635 // Buffer allocation for scanout might fail. |
| 636 // In that case we should reject the overlay candidate. | 636 // In that case we should reject the overlay candidate. |
| 637 buffer_generator_->set_allocation_failure(true); | 637 buffer_generator_->set_allocation_failure(true); |
| 638 | 638 |
| 639 std::vector<ui::OverlayCheck_Params> validated_params = | 639 std::vector<ui::OverlayCheck_Params> validated_params = |
| 640 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList()); | 640 overlay_validator_->TestPageFlip(overlay_params_, ui::OverlayPlaneList()); |
| 641 EXPECT_FALSE(validated_params.front().is_overlay_candidate); | 641 EXPECT_FALSE(validated_params.front().is_overlay_candidate); |
| 642 } | 642 } |
| OLD | NEW |