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 } | |
| 282 | |
| 283 TEST_F(HardwareDisplayControllerTest, PlaneStateAfterDestroyingCrtc) { | |
| 284 ui::OverlayPlane plane1(scoped_refptr<ui::ScanoutBuffer>( | |
| 285 new MockScanoutBuffer(kDefaultModeSize))); | |
| 286 EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode)); | |
| 287 std::vector<ui::OverlayPlane> planes = | |
| 288 std::vector<ui::OverlayPlane>(1, plane1); | |
| 289 EXPECT_TRUE(controller_->SchedulePageFlip( | |
| 290 planes, false, false, | |
| 291 base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, | |
| 292 base::Unretained(this)))); | |
| 293 drm_->RunCallbacks(); | |
| 294 | |
| 295 const ui::HardwareDisplayPlane* owned_plane = nullptr; | |
| 296 for (const auto& plane : drm_->plane_manager()->planes()) | |
| 297 if (plane->in_use()) | |
| 298 owned_plane = plane; | |
| 299 ASSERT_TRUE(owned_plane != nullptr); | |
| 300 EXPECT_EQ(kPrimaryCrtc, owned_plane->owning_crtc()); | |
| 301 scoped_ptr<ui::CrtcController> crtc = | |
| 302 controller_->RemoveCrtc(drm_, kPrimaryCrtc); | |
| 303 // Destroying crtc should free the plane. | |
| 304 crtc.reset(); | |
| 305 uint32_t crtc_nullid = 0; | |
| 279 EXPECT_FALSE(owned_plane->in_use()); | 306 EXPECT_FALSE(owned_plane->in_use()); |
| 307 EXPECT_EQ(crtc_nullid, owned_plane->owning_crtc()); | |
| 308 } | |
| 309 | |
| 310 TEST_F(HardwareDisplayControllerTest, OwnedPlanesAfterRemoveCrtc) { | |
| 311 ui::OverlayPlane plane1(scoped_refptr<ui::ScanoutBuffer>( | |
| 312 new MockScanoutBuffer(kDefaultModeSize))); | |
| 313 EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode)); | |
| 314 std::vector<ui::OverlayPlane> planes = | |
| 315 std::vector<ui::OverlayPlane>(1, plane1); | |
| 316 EXPECT_TRUE(controller_->SchedulePageFlip( | |
| 317 planes, false, false, | |
| 318 base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, | |
| 319 base::Unretained(this)))); | |
| 320 drm_->RunCallbacks(); | |
| 321 | |
| 322 const ui::HardwareDisplayPlane* primary_crtc_plane = nullptr; | |
| 323 for (const auto& plane : drm_->plane_manager()->planes()) { | |
| 324 if (plane->in_use() && kPrimaryCrtc == plane->owning_crtc()) | |
| 325 primary_crtc_plane = plane; | |
| 326 } | |
| 327 | |
| 328 ASSERT_TRUE(primary_crtc_plane != nullptr); | |
| 329 scoped_ptr<ui::CrtcController> crtc = | |
| 330 controller_->RemoveCrtc(drm_, kPrimaryCrtc); | |
| 331 EXPECT_FALSE(controller_->HasPlane(drm_.get(), primary_crtc_plane->plane_id(), | |
|
dnicoara
2015/08/19 14:09:44
I'm not a fan of test only functions in non-test o
kalyank
2015/08/19 15:38:55
Done.
| |
| 332 kPrimaryCrtc)); | |
| 333 } | |
| 334 | |
| 335 TEST_F(HardwareDisplayControllerTest, OwnedPlanesAfterAddCrtc) { | |
| 336 ui::OverlayPlane plane1(scoped_refptr<ui::ScanoutBuffer>( | |
| 337 new MockScanoutBuffer(kDefaultModeSize))); | |
| 338 EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode)); | |
| 339 std::vector<ui::OverlayPlane> planes = | |
| 340 std::vector<ui::OverlayPlane>(1, plane1); | |
| 341 EXPECT_TRUE(controller_->SchedulePageFlip( | |
| 342 planes, false, false, | |
| 343 base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, | |
| 344 base::Unretained(this)))); | |
| 345 drm_->RunCallbacks(); | |
| 346 | |
| 347 const ui::HardwareDisplayPlane* primary_crtc_plane = nullptr; | |
| 348 for (const auto& plane : drm_->plane_manager()->planes()) { | |
| 349 if (plane->in_use() && kPrimaryCrtc == plane->owning_crtc()) | |
| 350 primary_crtc_plane = plane; | |
| 351 } | |
| 352 | |
| 353 ASSERT_TRUE(primary_crtc_plane != nullptr); | |
| 354 | |
| 355 scoped_ptr<ui::HardwareDisplayController> hdc_controller; | |
| 356 hdc_controller.reset(new ui::HardwareDisplayController( | |
| 357 controller_->RemoveCrtc(drm_, kPrimaryCrtc), controller_->origin())); | |
| 358 EXPECT_FALSE(controller_->HasPlane(drm_.get(), primary_crtc_plane->plane_id(), | |
| 359 kPrimaryCrtc)); | |
| 360 EXPECT_TRUE(hdc_controller->HasPlane( | |
| 361 drm_.get(), primary_crtc_plane->plane_id(), kPrimaryCrtc)); | |
| 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 |