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

Side by Side Diff: ui/ozone/platform/dri/hardware_display_plane_manager_unittest.cc

Issue 812913003: ozone: fix HDPMLegacy - do the PF after overlays, also clear old overlays (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add tests Created 5 years, 11 months 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
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 <vector> 5 #include <vector>
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/ozone/platform/dri/crtc_controller.h"
9 #include "ui/ozone/platform/dri/hardware_display_controller.h" 10 #include "ui/ozone/platform/dri/hardware_display_controller.h"
10 #include "ui/ozone/platform/dri/hardware_display_plane.h" 11 #include "ui/ozone/platform/dri/hardware_display_plane.h"
11 #include "ui/ozone/platform/dri/hardware_display_plane_manager.h" 12 #include "ui/ozone/platform/dri/hardware_display_plane_manager.h"
13 #include "ui/ozone/platform/dri/hardware_display_plane_manager_legacy.h"
12 #include "ui/ozone/platform/dri/overlay_plane.h" 14 #include "ui/ozone/platform/dri/overlay_plane.h"
13 #include "ui/ozone/platform/dri/scanout_buffer.h" 15 #include "ui/ozone/platform/dri/scanout_buffer.h"
16 #include "ui/ozone/platform/dri/test/mock_dri_wrapper.h"
14 17
15 namespace { 18 namespace {
16 19
17 struct FakePlaneInfo { 20 struct FakePlaneInfo {
18 uint32_t id; 21 uint32_t id;
19 uint32_t allowed_crtc_mask; 22 uint32_t allowed_crtc_mask;
20 }; 23 };
21 24
22 const FakePlaneInfo kOnePlanePerCrtc[] = {{10, 1}, {20, 2}}; 25 const FakePlaneInfo kOnePlanePerCrtc[] = {{10, 1}, {20, 2}};
23 const FakePlaneInfo kTwoPlanesPerCrtc[] = {{10, 1}, {11, 1}, {20, 2}, {21, 2}}; 26 const FakePlaneInfo kTwoPlanesPerCrtc[] = {{10, 1}, {11, 1}, {20, 2}, {21, 2}};
24 const FakePlaneInfo kOnePlanePerCrtcWithShared[] = {{10, 1}, {20, 2}, {50, 3}}; 27 const FakePlaneInfo kOnePlanePerCrtcWithShared[] = {{10, 1}, {20, 2}, {50, 3}};
25 28
26 class FakeScanoutBuffer : public ui::ScanoutBuffer { 29 class FakeScanoutBuffer : public ui::ScanoutBuffer {
27 public: 30 public:
28 FakeScanoutBuffer() {} 31 FakeScanoutBuffer() {}
29 32
30 // ui::ScanoutBuffer: 33 // ui::ScanoutBuffer:
31 uint32_t GetFramebufferId() const override { return 0; } 34 uint32_t GetFramebufferId() const override { return 1; }
32 uint32_t GetHandle() const override { return 0; } 35 uint32_t GetHandle() const override { return 0; }
33 gfx::Size GetSize() const override { return gfx::Size(1, 1); } 36 gfx::Size GetSize() const override { return gfx::Size(1, 1); }
34 37
35 protected: 38 protected:
36 ~FakeScanoutBuffer() override {} 39 ~FakeScanoutBuffer() override {}
37 }; 40 };
38 41
39 class FakePlaneManager : public ui::HardwareDisplayPlaneManager { 42 class FakePlaneManager : public ui::HardwareDisplayPlaneManager {
40 public: 43 public:
41 FakePlaneManager() : plane_count_(0) {} 44 FakePlaneManager() : plane_count_(0) {}
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 TEST_F(HardwareDisplayPlaneManagerTest, MultipleFrames) { 180 TEST_F(HardwareDisplayPlaneManagerTest, MultipleFrames) {
178 ui::OverlayPlaneList assigns; 181 ui::OverlayPlaneList assigns;
179 assigns.push_back(ui::OverlayPlane(fake_buffer_)); 182 assigns.push_back(ui::OverlayPlane(fake_buffer_));
180 plane_manager_->InitForTest(kTwoPlanesPerCrtc, arraysize(kTwoPlanesPerCrtc), 183 plane_manager_->InitForTest(kTwoPlanesPerCrtc, arraysize(kTwoPlanesPerCrtc),
181 default_crtcs_); 184 default_crtcs_);
182 185
183 EXPECT_TRUE(plane_manager_->AssignOverlayPlanes(&state_, assigns, 186 EXPECT_TRUE(plane_manager_->AssignOverlayPlanes(&state_, assigns,
184 default_crtcs_[0], nullptr)); 187 default_crtcs_[0], nullptr));
185 EXPECT_EQ(1, plane_manager_->plane_count()); 188 EXPECT_EQ(1, plane_manager_->plane_count());
186 // Pretend we committed the frame. 189 // Pretend we committed the frame.
190 state_.committed = true;
187 state_.plane_list.swap(state_.old_plane_list); 191 state_.plane_list.swap(state_.old_plane_list);
188 ui::HardwareDisplayPlane* old_plane = state_.old_plane_list[0]; 192 ui::HardwareDisplayPlane* old_plane = state_.old_plane_list[0];
189 // The same plane should be used. 193 // The same plane should be used.
190 EXPECT_TRUE(plane_manager_->AssignOverlayPlanes(&state_, assigns, 194 EXPECT_TRUE(plane_manager_->AssignOverlayPlanes(&state_, assigns,
191 default_crtcs_[0], nullptr)); 195 default_crtcs_[0], nullptr));
192 EXPECT_EQ(2, plane_manager_->plane_count()); 196 EXPECT_EQ(2, plane_manager_->plane_count());
193 EXPECT_EQ(state_.plane_list[0], old_plane); 197 EXPECT_EQ(state_.plane_list[0], old_plane);
194 } 198 }
195 199
196 TEST_F(HardwareDisplayPlaneManagerTest, MultipleFramesDifferentPlanes) { 200 TEST_F(HardwareDisplayPlaneManagerTest, MultipleFramesDifferentPlanes) {
(...skipping 21 matching lines...) Expand all
218 default_crtcs_); 222 default_crtcs_);
219 223
220 EXPECT_TRUE(plane_manager_->AssignOverlayPlanes(&state_, assigns, 224 EXPECT_TRUE(plane_manager_->AssignOverlayPlanes(&state_, assigns,
221 default_crtcs_[1], nullptr)); 225 default_crtcs_[1], nullptr));
222 EXPECT_EQ(2, plane_manager_->plane_count()); 226 EXPECT_EQ(2, plane_manager_->plane_count());
223 // The shared plane is now unavailable for use by the other CRTC. 227 // The shared plane is now unavailable for use by the other CRTC.
224 EXPECT_FALSE(plane_manager_->AssignOverlayPlanes(&state_, assigns, 228 EXPECT_FALSE(plane_manager_->AssignOverlayPlanes(&state_, assigns,
225 default_crtcs_[0], nullptr)); 229 default_crtcs_[0], nullptr));
226 } 230 }
227 231
232 TEST(HardwareDisplayPlaneManagerLegacyTest, UnusedPlanesAreReleased) {
233 std::vector<uint32_t> crtcs;
234 crtcs.push_back(100);
235 ui::MockDriWrapper drm(3, false, crtcs, 2);
236 ui::OverlayPlaneList assigns;
237 scoped_refptr<FakeScanoutBuffer> fake_buffer = new FakeScanoutBuffer();
238 assigns.push_back(ui::OverlayPlane(fake_buffer));
239 assigns.push_back(ui::OverlayPlane(fake_buffer));
240 ui::HardwareDisplayPlaneList hdpl;
241 ui::CrtcController crtc(&drm, crtcs[0], 0);
242 EXPECT_TRUE(drm.plane_manager()->AssignOverlayPlanes(&hdpl, assigns, crtcs[0],
243 &crtc));
244 EXPECT_TRUE(drm.plane_manager()->Commit(&hdpl));
245 assigns.clear();
246 assigns.push_back(ui::OverlayPlane(fake_buffer));
247 EXPECT_TRUE(drm.plane_manager()->AssignOverlayPlanes(&hdpl, assigns, crtcs[0],
248 &crtc));
249 EXPECT_EQ(0, drm.get_overlay_clear_call_count());
250 EXPECT_TRUE(drm.plane_manager()->Commit(&hdpl));
251 EXPECT_EQ(1, drm.get_overlay_clear_call_count());
252 }
253
228 } // namespace 254 } // namespace
OLDNEW
« no previous file with comments | « ui/ozone/platform/dri/hardware_display_plane_manager_legacy.cc ('k') | ui/ozone/platform/dri/test/mock_dri_wrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698