Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: ui/ozone/platform/drm/gpu/hardware_display_plane_manager_unittest.cc

Issue 1423793003: Optimize plane usage when primary is obscured by Overlay (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Check that primary and Overlay formats are same Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <drm_fourcc.h> 5 #include <drm_fourcc.h>
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 13 matching lines...) Expand all
24 uint32_t allowed_crtc_mask; 24 uint32_t allowed_crtc_mask;
25 }; 25 };
26 26
27 const FakePlaneInfo kOnePlanePerCrtc[] = {{10, 1}, {20, 2}}; 27 const FakePlaneInfo kOnePlanePerCrtc[] = {{10, 1}, {20, 2}};
28 const FakePlaneInfo kTwoPlanesPerCrtc[] = {{10, 1}, {11, 1}, {20, 2}, {21, 2}}; 28 const FakePlaneInfo kTwoPlanesPerCrtc[] = {{10, 1}, {11, 1}, {20, 2}, {21, 2}};
29 const FakePlaneInfo kOnePlanePerCrtcWithShared[] = {{10, 1}, {20, 2}, {50, 3}}; 29 const FakePlaneInfo kOnePlanePerCrtcWithShared[] = {{10, 1}, {20, 2}, {50, 3}};
30 const uint32_t kDummyFormat = 0; 30 const uint32_t kDummyFormat = 0;
31 31
32 class FakeScanoutBuffer : public ui::ScanoutBuffer { 32 class FakeScanoutBuffer : public ui::ScanoutBuffer {
33 public: 33 public:
34 FakeScanoutBuffer(uint32_t format) : format_(format) {} 34 FakeScanoutBuffer(uint32_t format)
35 : format_(format), size_(gfx::Size(2, 2)) {}
35 36
36 // ui::ScanoutBuffer: 37 // ui::ScanoutBuffer:
37 uint32_t GetFramebufferId() const override { return 1; } 38 uint32_t GetFramebufferId() const override { return 1; }
38 uint32_t GetHandle() const override { return 0; } 39 uint32_t GetHandle() const override { return 0; }
39 gfx::Size GetSize() const override { return gfx::Size(1, 1); } 40 void SetSize(const gfx::Size& size) { size_ = size; }
41 gfx::Size GetSize() const override { return size_; }
40 void SetFramebufferPixelFormat(uint32_t format) { format_ = format; } 42 void SetFramebufferPixelFormat(uint32_t format) { format_ = format; }
41 uint32_t GetFramebufferPixelFormat() const override { return format_; } 43 uint32_t GetFramebufferPixelFormat() const override { return format_; }
42 bool RequiresGlFinish() const override { return false; } 44 bool RequiresGlFinish() const override { return false; }
43 45
44 protected: 46 protected:
45 ~FakeScanoutBuffer() override {} 47 ~FakeScanoutBuffer() override {}
46 uint32_t format_; 48 uint32_t format_;
49 gfx::Size size_;
47 }; 50 };
48 51
49 class FakePlaneManager : public ui::HardwareDisplayPlaneManager { 52 class FakePlaneManager : public ui::HardwareDisplayPlaneManager {
50 public: 53 public:
51 FakePlaneManager() : plane_count_(0) {} 54 FakePlaneManager() : plane_count_(0) {}
52 ~FakePlaneManager() override {} 55 ~FakePlaneManager() override {}
53 56
54 // Normally we'd use DRM to figure out the controller configuration. But we 57 // Normally we'd use DRM to figure out the controller configuration. But we
55 // can't use DRM in unit tests, so we just create a fake configuration. 58 // can't use DRM in unit tests, so we just create a fake configuration.
56 void InitForTest(const FakePlaneInfo* planes, 59 void InitForTest(const FakePlaneInfo* planes,
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 EXPECT_EQ(1, plane_manager_->plane_count()); 223 EXPECT_EQ(1, plane_manager_->plane_count());
221 // The other plane should be used. 224 // The other plane should be used.
222 EXPECT_TRUE(plane_manager_->AssignOverlayPlanes(&state_, assigns, 225 EXPECT_TRUE(plane_manager_->AssignOverlayPlanes(&state_, assigns,
223 default_crtcs_[0], nullptr)); 226 default_crtcs_[0], nullptr));
224 EXPECT_EQ(2, plane_manager_->plane_count()); 227 EXPECT_EQ(2, plane_manager_->plane_count());
225 EXPECT_NE(state_.plane_list[0], state_.plane_list[1]); 228 EXPECT_NE(state_.plane_list[0], state_.plane_list[1]);
226 } 229 }
227 230
228 TEST_F(HardwareDisplayPlaneManagerTest, SharedPlanes) { 231 TEST_F(HardwareDisplayPlaneManagerTest, SharedPlanes) {
229 ui::OverlayPlaneList assigns; 232 ui::OverlayPlaneList assigns;
233 scoped_refptr<FakeScanoutBuffer> buffer =
234 new FakeScanoutBuffer(DRM_FORMAT_XRGB8888);
235 buffer->SetSize(gfx::Size(1, 1));
236
230 assigns.push_back(ui::OverlayPlane(fake_buffer_)); 237 assigns.push_back(ui::OverlayPlane(fake_buffer_));
231 assigns.push_back(ui::OverlayPlane(fake_buffer_)); 238 assigns.push_back(ui::OverlayPlane(buffer));
232 plane_manager_->InitForTest(kOnePlanePerCrtcWithShared, 239 plane_manager_->InitForTest(kOnePlanePerCrtcWithShared,
233 arraysize(kOnePlanePerCrtcWithShared), 240 arraysize(kOnePlanePerCrtcWithShared),
234 default_crtcs_); 241 default_crtcs_);
235 242
236 EXPECT_TRUE(plane_manager_->AssignOverlayPlanes(&state_, assigns, 243 EXPECT_TRUE(plane_manager_->AssignOverlayPlanes(&state_, assigns,
237 default_crtcs_[1], nullptr)); 244 default_crtcs_[1], nullptr));
238 EXPECT_EQ(2, plane_manager_->plane_count()); 245 EXPECT_EQ(2, plane_manager_->plane_count());
239 // The shared plane is now unavailable for use by the other CRTC. 246 // The shared plane is now unavailable for use by the other CRTC.
240 EXPECT_FALSE(plane_manager_->AssignOverlayPlanes(&state_, assigns, 247 EXPECT_FALSE(plane_manager_->AssignOverlayPlanes(&state_, assigns,
241 default_crtcs_[0], nullptr)); 248 default_crtcs_[0], nullptr));
(...skipping 18 matching lines...) Expand all
260 plane_manager_->BeginFrame(&state_); 267 plane_manager_->BeginFrame(&state_);
261 EXPECT_FALSE(plane_manager_->AssignOverlayPlanes(&state_, assigns, 268 EXPECT_FALSE(plane_manager_->AssignOverlayPlanes(&state_, assigns,
262 default_crtcs_[0], nullptr)); 269 default_crtcs_[0], nullptr));
263 } 270 }
264 271
265 TEST(HardwareDisplayPlaneManagerLegacyTest, UnusedPlanesAreReleased) { 272 TEST(HardwareDisplayPlaneManagerLegacyTest, UnusedPlanesAreReleased) {
266 std::vector<uint32_t> crtcs; 273 std::vector<uint32_t> crtcs;
267 crtcs.push_back(100); 274 crtcs.push_back(100);
268 scoped_refptr<ui::MockDrmDevice> drm = new ui::MockDrmDevice(false, crtcs, 2); 275 scoped_refptr<ui::MockDrmDevice> drm = new ui::MockDrmDevice(false, crtcs, 2);
269 ui::OverlayPlaneList assigns; 276 ui::OverlayPlaneList assigns;
270 scoped_refptr<FakeScanoutBuffer> fake_buffer = 277 scoped_refptr<FakeScanoutBuffer> primary_buffer =
271 new FakeScanoutBuffer(DRM_FORMAT_XRGB8888); 278 new FakeScanoutBuffer(DRM_FORMAT_XRGB8888);
272 assigns.push_back(ui::OverlayPlane(fake_buffer)); 279 scoped_refptr<FakeScanoutBuffer> overlay_buffer =
273 assigns.push_back(ui::OverlayPlane(fake_buffer)); 280 new FakeScanoutBuffer(DRM_FORMAT_XRGB8888);
281 overlay_buffer->SetSize(gfx::Size(1, 1));
282 assigns.push_back(ui::OverlayPlane(primary_buffer));
283 assigns.push_back(ui::OverlayPlane(overlay_buffer));
274 ui::HardwareDisplayPlaneList hdpl; 284 ui::HardwareDisplayPlaneList hdpl;
275 ui::CrtcController crtc(drm, crtcs[0], 0); 285 ui::CrtcController crtc(drm, crtcs[0], 0);
276 drm->plane_manager()->BeginFrame(&hdpl); 286 drm->plane_manager()->BeginFrame(&hdpl);
277 EXPECT_TRUE(drm->plane_manager()->AssignOverlayPlanes(&hdpl, assigns, 287 EXPECT_TRUE(drm->plane_manager()->AssignOverlayPlanes(&hdpl, assigns,
278 crtcs[0], &crtc)); 288 crtcs[0], &crtc));
279 EXPECT_TRUE(drm->plane_manager()->Commit(&hdpl, false)); 289 EXPECT_TRUE(drm->plane_manager()->Commit(&hdpl, false));
280 assigns.clear(); 290 assigns.clear();
281 assigns.push_back(ui::OverlayPlane(fake_buffer)); 291 assigns.push_back(ui::OverlayPlane(primary_buffer));
282 drm->plane_manager()->BeginFrame(&hdpl); 292 drm->plane_manager()->BeginFrame(&hdpl);
283 EXPECT_TRUE(drm->plane_manager()->AssignOverlayPlanes(&hdpl, assigns, 293 EXPECT_TRUE(drm->plane_manager()->AssignOverlayPlanes(&hdpl, assigns,
284 crtcs[0], &crtc)); 294 crtcs[0], &crtc));
285 EXPECT_EQ(0, drm->get_overlay_clear_call_count()); 295 EXPECT_EQ(0, drm->get_overlay_clear_call_count());
286 EXPECT_TRUE(drm->plane_manager()->Commit(&hdpl, false)); 296 EXPECT_TRUE(drm->plane_manager()->Commit(&hdpl, false));
287 EXPECT_EQ(1, drm->get_overlay_clear_call_count()); 297 EXPECT_EQ(1, drm->get_overlay_clear_call_count());
288 } 298 }
289 299
290 } // namespace 300 } // namespace
OLDNEW
« no previous file with comments | « ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698