| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
| 7 #include "third_party/skia/include/core/SkCanvas.h" | 7 #include "third_party/skia/include/core/SkCanvas.h" |
| 8 #include "ui/ozone/platform/drm/gpu/crtc_controller.h" | 8 #include "ui/ozone/platform/drm/gpu/crtc_controller.h" |
| 9 #include "ui/ozone/platform/drm/gpu/drm_buffer.h" | 9 #include "ui/ozone/platform/drm/gpu/drm_buffer.h" |
| 10 #include "ui/ozone/platform/drm/gpu/drm_device.h" | 10 #include "ui/ozone/platform/drm/gpu/drm_device.h" |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, | 266 base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
| 267 base::Unretained(this)))); | 267 base::Unretained(this)))); |
| 268 drm_->RunCallbacks(); | 268 drm_->RunCallbacks(); |
| 269 | 269 |
| 270 const ui::HardwareDisplayPlane* owned_plane = nullptr; | 270 const ui::HardwareDisplayPlane* owned_plane = nullptr; |
| 271 for (const auto& plane : drm_->plane_manager()->planes()) | 271 for (const auto& plane : drm_->plane_manager()->planes()) |
| 272 if (plane->in_use()) | 272 if (plane->in_use()) |
| 273 owned_plane = plane; | 273 owned_plane = plane; |
| 274 ASSERT_TRUE(owned_plane != nullptr); | 274 ASSERT_TRUE(owned_plane != nullptr); |
| 275 EXPECT_EQ(kPrimaryCrtc, owned_plane->owning_crtc()); | 275 EXPECT_EQ(kPrimaryCrtc, owned_plane->owning_crtc()); |
| 276 // Removing the crtc should free the plane. | 276 // Removing the crtc should not free the plane or change ownership. |
| 277 scoped_ptr<ui::CrtcController> crtc = | 277 scoped_ptr<ui::CrtcController> crtc = |
| 278 controller_->RemoveCrtc(drm_, kPrimaryCrtc); | 278 controller_->RemoveCrtc(drm_, kPrimaryCrtc); |
| 279 EXPECT_TRUE(owned_plane->in_use()); |
| 280 EXPECT_EQ(kPrimaryCrtc, owned_plane->owning_crtc()); |
| 281 // Check that controller doesn't effect the state of removed plane in |
| 282 // subsequent page flip. |
| 283 EXPECT_TRUE(controller_->SchedulePageFlip( |
| 284 planes, false, false, |
| 285 base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
| 286 base::Unretained(this)))); |
| 287 drm_->RunCallbacks(); |
| 288 EXPECT_TRUE(owned_plane->in_use()); |
| 289 EXPECT_EQ(kPrimaryCrtc, owned_plane->owning_crtc()); |
| 290 } |
| 291 |
| 292 TEST_F(HardwareDisplayControllerTest, PlaneStateAfterDestroyingCrtc) { |
| 293 ui::OverlayPlane plane1(scoped_refptr<ui::ScanoutBuffer>( |
| 294 new MockScanoutBuffer(kDefaultModeSize))); |
| 295 EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode)); |
| 296 std::vector<ui::OverlayPlane> planes = |
| 297 std::vector<ui::OverlayPlane>(1, plane1); |
| 298 EXPECT_TRUE(controller_->SchedulePageFlip( |
| 299 planes, false, false, |
| 300 base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
| 301 base::Unretained(this)))); |
| 302 drm_->RunCallbacks(); |
| 303 |
| 304 const ui::HardwareDisplayPlane* owned_plane = nullptr; |
| 305 for (const auto& plane : drm_->plane_manager()->planes()) |
| 306 if (plane->in_use()) |
| 307 owned_plane = plane; |
| 308 ASSERT_TRUE(owned_plane != nullptr); |
| 309 EXPECT_EQ(kPrimaryCrtc, owned_plane->owning_crtc()); |
| 310 scoped_ptr<ui::CrtcController> crtc = |
| 311 controller_->RemoveCrtc(drm_, kPrimaryCrtc); |
| 312 // Destroying crtc should free the plane. |
| 313 crtc.reset(); |
| 314 uint32_t crtc_nullid = 0; |
| 279 EXPECT_FALSE(owned_plane->in_use()); | 315 EXPECT_FALSE(owned_plane->in_use()); |
| 316 EXPECT_EQ(crtc_nullid, owned_plane->owning_crtc()); |
| 317 } |
| 318 |
| 319 TEST_F(HardwareDisplayControllerTest, PlaneStateAfterAddCrtc) { |
| 320 ui::OverlayPlane plane1(scoped_refptr<ui::ScanoutBuffer>( |
| 321 new MockScanoutBuffer(kDefaultModeSize))); |
| 322 EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode)); |
| 323 std::vector<ui::OverlayPlane> planes = |
| 324 std::vector<ui::OverlayPlane>(1, plane1); |
| 325 EXPECT_TRUE(controller_->SchedulePageFlip( |
| 326 planes, false, false, |
| 327 base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
| 328 base::Unretained(this)))); |
| 329 drm_->RunCallbacks(); |
| 330 |
| 331 ui::HardwareDisplayPlane* primary_crtc_plane = nullptr; |
| 332 for (const auto& plane : drm_->plane_manager()->planes()) { |
| 333 if (plane->in_use() && kPrimaryCrtc == plane->owning_crtc()) |
| 334 primary_crtc_plane = plane; |
| 335 } |
| 336 |
| 337 ASSERT_TRUE(primary_crtc_plane != nullptr); |
| 338 |
| 339 scoped_ptr<ui::HardwareDisplayController> hdc_controller; |
| 340 hdc_controller.reset(new ui::HardwareDisplayController( |
| 341 controller_->RemoveCrtc(drm_, kPrimaryCrtc), controller_->origin())); |
| 342 EXPECT_TRUE(controller_->SchedulePageFlip( |
| 343 planes, false, false, |
| 344 base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
| 345 base::Unretained(this)))); |
| 346 drm_->RunCallbacks(); |
| 347 EXPECT_TRUE(primary_crtc_plane->in_use()); |
| 348 EXPECT_EQ(kPrimaryCrtc, primary_crtc_plane->owning_crtc()); |
| 349 |
| 350 // We reset state of plane here to test that the plane was actually added to |
| 351 // hdc_controller. In which case, the right state should be set to plane |
| 352 // after page flip call is handled by the controller. |
| 353 primary_crtc_plane->set_in_use(false); |
| 354 primary_crtc_plane->set_owning_crtc(0); |
| 355 EXPECT_TRUE(hdc_controller->SchedulePageFlip( |
| 356 planes, false, false, |
| 357 base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
| 358 base::Unretained(this)))); |
| 359 drm_->RunCallbacks(); |
| 360 EXPECT_TRUE(primary_crtc_plane->in_use()); |
| 361 EXPECT_EQ(kPrimaryCrtc, primary_crtc_plane->owning_crtc()); |
| 280 } | 362 } |
| 281 | 363 |
| 282 TEST_F(HardwareDisplayControllerTest, ModesetWhilePageFlipping) { | 364 TEST_F(HardwareDisplayControllerTest, ModesetWhilePageFlipping) { |
| 283 ui::OverlayPlane plane1(scoped_refptr<ui::ScanoutBuffer>( | 365 ui::OverlayPlane plane1(scoped_refptr<ui::ScanoutBuffer>( |
| 284 new MockScanoutBuffer(kDefaultModeSize))); | 366 new MockScanoutBuffer(kDefaultModeSize))); |
| 285 EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode)); | 367 EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode)); |
| 286 std::vector<ui::OverlayPlane> planes = | 368 std::vector<ui::OverlayPlane> planes = |
| 287 std::vector<ui::OverlayPlane>(1, plane1); | 369 std::vector<ui::OverlayPlane>(1, plane1); |
| 288 EXPECT_TRUE(controller_->SchedulePageFlip( | 370 EXPECT_TRUE(controller_->SchedulePageFlip( |
| 289 planes, false, false, | 371 planes, false, false, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 planes, false, false, | 405 planes, false, false, |
| 324 base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, | 406 base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
| 325 base::Unretained(this)))); | 407 base::Unretained(this)))); |
| 326 | 408 |
| 327 controller_->RemoveCrtc(drm_, kPrimaryCrtc); | 409 controller_->RemoveCrtc(drm_, kPrimaryCrtc); |
| 328 | 410 |
| 329 EXPECT_EQ(1, page_flips_); | 411 EXPECT_EQ(1, page_flips_); |
| 330 drm_->RunCallbacks(); | 412 drm_->RunCallbacks(); |
| 331 EXPECT_EQ(1, page_flips_); | 413 EXPECT_EQ(1, page_flips_); |
| 332 } | 414 } |
| OLD | NEW |