Chromium Code Reviews| Index: ui/ozone/platform/drm/gpu/hardware_display_plane_manager_unittest.cc |
| diff --git a/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_unittest.cc b/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_unittest.cc |
| index 79d3a415d11e5a92b1b685ef7940866dfcb0a7ad..910137a131716fca46843cae7c57b86086209f17 100644 |
| --- a/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_unittest.cc |
| +++ b/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_unittest.cc |
| @@ -2,6 +2,7 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +#include <drm_fourcc.h> |
|
dnicoara
2015/08/27 13:21:56
empty line between C and C++ includes
kalyank
2015/08/27 16:07:10
Done.
|
| #include <vector> |
| #include "base/memory/scoped_ptr.h" |
| @@ -25,19 +26,22 @@ struct FakePlaneInfo { |
| const FakePlaneInfo kOnePlanePerCrtc[] = {{10, 1}, {20, 2}}; |
| const FakePlaneInfo kTwoPlanesPerCrtc[] = {{10, 1}, {11, 1}, {20, 2}, {21, 2}}; |
| const FakePlaneInfo kOnePlanePerCrtcWithShared[] = {{10, 1}, {20, 2}, {50, 3}}; |
| +const uint32_t kDummyFormat = 0; |
| class FakeScanoutBuffer : public ui::ScanoutBuffer { |
| public: |
| - FakeScanoutBuffer() {} |
| + FakeScanoutBuffer(uint32_t format) : format_(format) {} |
| // ui::ScanoutBuffer: |
| uint32_t GetFramebufferId() const override { return 1; } |
| uint32_t GetHandle() const override { return 0; } |
| gfx::Size GetSize() const override { return gfx::Size(1, 1); } |
| - uint32_t GetFormat() const override { return 0; } |
| + void SetFramebufferPixelFormat(uint32_t format) { format_ = format; } |
| + uint32_t GetFramebufferPixelFormat() const override { return format_; } |
| protected: |
| ~FakeScanoutBuffer() override {} |
| + uint32_t format_; |
| }; |
| class FakePlaneManager : public ui::HardwareDisplayPlaneManager { |
| @@ -52,8 +56,12 @@ class FakePlaneManager : public ui::HardwareDisplayPlaneManager { |
| const std::vector<uint32_t>& crtcs) { |
| crtcs_ = crtcs; |
| for (size_t i = 0; i < count; i++) { |
| - planes_.push_back(new ui::HardwareDisplayPlane( |
| + scoped_ptr<ui::HardwareDisplayPlane> plane(new ui::HardwareDisplayPlane( |
| planes[i].id, planes[i].allowed_crtc_mask)); |
| + // Add support to test more formats. |
| + plane->Initialize(drm_, std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888), |
| + false, true); |
| + planes_.push_back(plane.Pass()); |
| } |
| // The real HDPM uses sorted planes, so sort them for consistency. |
| std::sort(planes_.begin(), planes_.end(), |
| @@ -107,7 +115,7 @@ class HardwareDisplayPlaneManagerTest : public testing::Test { |
| }; |
| void HardwareDisplayPlaneManagerTest::SetUp() { |
| - fake_buffer_ = new FakeScanoutBuffer(); |
| + fake_buffer_ = new FakeScanoutBuffer(DRM_FORMAT_XRGB8888); |
| plane_manager_.reset(new FakePlaneManager()); |
| default_crtcs_.push_back(100); |
| default_crtcs_.push_back(200); |
| @@ -232,12 +240,34 @@ TEST_F(HardwareDisplayPlaneManagerTest, SharedPlanes) { |
| default_crtcs_[0], nullptr)); |
| } |
| +TEST_F(HardwareDisplayPlaneManagerTest, CheckFramebufferFormatMatch) { |
| + ui::OverlayPlaneList assigns; |
| + scoped_refptr<FakeScanoutBuffer> buffer = new FakeScanoutBuffer(kDummyFormat); |
| + assigns.push_back(ui::OverlayPlane(buffer)); |
| + plane_manager_->InitForTest(kOnePlanePerCrtc, arraysize(kOnePlanePerCrtc), |
| + default_crtcs_); |
| + plane_manager_->BeginFrame(&state_); |
| + // This should return false as plane manager creates planes which support |
| + // DRM_FORMAT_XRGB8888 while buffer returns kDummyFormat as its pixelFormat. |
| + EXPECT_FALSE(plane_manager_->AssignOverlayPlanes(&state_, assigns, |
| + default_crtcs_[0], nullptr)); |
| + buffer->SetFramebufferPixelFormat(DRM_FORMAT_XRGB8888); |
| + plane_manager_->BeginFrame(&state_); |
| + EXPECT_TRUE(plane_manager_->AssignOverlayPlanes(&state_, assigns, |
| + default_crtcs_[0], nullptr)); |
| + buffer->SetFramebufferPixelFormat(DRM_FORMAT_ARGB8888); |
| + plane_manager_->BeginFrame(&state_); |
| + EXPECT_FALSE(plane_manager_->AssignOverlayPlanes(&state_, assigns, |
| + default_crtcs_[0], nullptr)); |
| +} |
| + |
| TEST(HardwareDisplayPlaneManagerLegacyTest, UnusedPlanesAreReleased) { |
| std::vector<uint32_t> crtcs; |
| crtcs.push_back(100); |
| scoped_refptr<ui::MockDrmDevice> drm = new ui::MockDrmDevice(false, crtcs, 2); |
| ui::OverlayPlaneList assigns; |
| - scoped_refptr<FakeScanoutBuffer> fake_buffer = new FakeScanoutBuffer(); |
| + scoped_refptr<FakeScanoutBuffer> fake_buffer = |
| + new FakeScanoutBuffer(DRM_FORMAT_XRGB8888); |
| assigns.push_back(ui::OverlayPlane(fake_buffer)); |
| assigns.push_back(ui::OverlayPlane(fake_buffer)); |
| ui::HardwareDisplayPlaneList hdpl; |