Chromium Code Reviews| 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 primary_crtc_plane->set_in_use(false); | |
| 351 primary_crtc_plane->set_owning_crtc(0); | |
|
dnicoara
2015/08/19 16:08:46
Do you need these 2 calls? set_in_use() is called
kalyank
2015/08/19 16:15:29
This was to test that the plane was actually added
| |
| 352 EXPECT_TRUE(hdc_controller->SchedulePageFlip( | |
| 353 planes, false, false, | |
| 354 base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, | |
| 355 base::Unretained(this)))); | |
| 356 drm_->RunCallbacks(); | |
| 357 EXPECT_TRUE(primary_crtc_plane->in_use()); | |
| 358 EXPECT_EQ(kPrimaryCrtc, primary_crtc_plane->owning_crtc()); | |
| 280 } | 359 } |
| 281 | 360 |
| 282 TEST_F(HardwareDisplayControllerTest, ModesetWhilePageFlipping) { | 361 TEST_F(HardwareDisplayControllerTest, ModesetWhilePageFlipping) { |
| 283 ui::OverlayPlane plane1(scoped_refptr<ui::ScanoutBuffer>( | 362 ui::OverlayPlane plane1(scoped_refptr<ui::ScanoutBuffer>( |
| 284 new MockScanoutBuffer(kDefaultModeSize))); | 363 new MockScanoutBuffer(kDefaultModeSize))); |
| 285 EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode)); | 364 EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode)); |
| 286 std::vector<ui::OverlayPlane> planes = | 365 std::vector<ui::OverlayPlane> planes = |
| 287 std::vector<ui::OverlayPlane>(1, plane1); | 366 std::vector<ui::OverlayPlane>(1, plane1); |
| 288 EXPECT_TRUE(controller_->SchedulePageFlip( | 367 EXPECT_TRUE(controller_->SchedulePageFlip( |
| 289 planes, false, false, | 368 planes, false, false, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 323 planes, false, false, | 402 planes, false, false, |
| 324 base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, | 403 base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, |
| 325 base::Unretained(this)))); | 404 base::Unretained(this)))); |
| 326 | 405 |
| 327 controller_->RemoveCrtc(drm_, kPrimaryCrtc); | 406 controller_->RemoveCrtc(drm_, kPrimaryCrtc); |
| 328 | 407 |
| 329 EXPECT_EQ(1, page_flips_); | 408 EXPECT_EQ(1, page_flips_); |
| 330 drm_->RunCallbacks(); | 409 drm_->RunCallbacks(); |
| 331 EXPECT_EQ(1, page_flips_); | 410 EXPECT_EQ(1, page_flips_); |
| 332 } | 411 } |
| OLD | NEW |