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

Side by Side Diff: ui/ozone/platform/drm/gpu/hardware_display_controller_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 | « no previous file | ui/ozone/platform/drm/gpu/hardware_display_plane_manager.h » ('j') | 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 "base/bind.h" 7 #include "base/bind.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "third_party/skia/include/core/SkCanvas.h" 9 #include "third_party/skia/include/core/SkCanvas.h"
10 #include "ui/ozone/platform/drm/gpu/crtc_controller.h" 10 #include "ui/ozone/platform/drm/gpu/crtc_controller.h"
11 #include "ui/ozone/platform/drm/gpu/drm_buffer.h" 11 #include "ui/ozone/platform/drm/gpu/drm_buffer.h"
12 #include "ui/ozone/platform/drm/gpu/drm_device.h" 12 #include "ui/ozone/platform/drm/gpu/drm_device.h"
13 #include "ui/ozone/platform/drm/gpu/hardware_display_controller.h" 13 #include "ui/ozone/platform/drm/gpu/hardware_display_controller.h"
14 #include "ui/ozone/platform/drm/gpu/mock_drm_device.h" 14 #include "ui/ozone/platform/drm/gpu/mock_drm_device.h"
15 #include "ui/ozone/public/native_pixmap.h" 15 #include "ui/ozone/public/native_pixmap.h"
16 16
17 namespace { 17 namespace {
18 18
19 // Create a basic mode for a 6x4 screen. 19 // Create a basic mode for a 6x4 screen.
20 const drmModeModeInfo kDefaultMode = 20 const drmModeModeInfo kDefaultMode =
21 {0, 6, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, {'\0'}}; 21 {0, 6, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, {'\0'}};
22 22
23 const uint32_t kPrimaryCrtc = 1; 23 const uint32_t kPrimaryCrtc = 1;
24 const uint32_t kPrimaryConnector = 2; 24 const uint32_t kPrimaryConnector = 2;
25 const uint32_t kSecondaryCrtc = 3; 25 const uint32_t kSecondaryCrtc = 3;
26 const uint32_t kSecondaryConnector = 4; 26 const uint32_t kSecondaryConnector = 4;
27 const size_t kPlanesPerCrtc = 2; 27 const size_t kPlanesPerCrtc = 2;
28 28
29 const gfx::Size kDefaultModeSize(kDefaultMode.hdisplay, kDefaultMode.vdisplay); 29 const gfx::Size kDefaultModeSize(kDefaultMode.hdisplay, kDefaultMode.vdisplay);
30 const gfx::Size kOverlaySize(kDefaultMode.hdisplay / 2,
31 kDefaultMode.vdisplay / 2);
30 const gfx::SizeF kDefaultModeSizeF(1.0, 1.0); 32 const gfx::SizeF kDefaultModeSizeF(1.0, 1.0);
31 33
32 class MockScanoutBuffer : public ui::ScanoutBuffer { 34 class MockScanoutBuffer : public ui::ScanoutBuffer {
33 public: 35 public:
34 MockScanoutBuffer(const gfx::Size& size) : size_(size) {} 36 MockScanoutBuffer(const gfx::Size& size) : size_(size) {}
35 37
36 // ScanoutBuffer: 38 // ScanoutBuffer:
37 uint32_t GetFramebufferId() const override { return 0; } 39 uint32_t GetFramebufferId() const override { return 0; }
38 uint32_t GetHandle() const override { return 0; } 40 uint32_t GetHandle() const override { return 0; }
39 gfx::Size GetSize() const override { return size_; } 41 gfx::Size GetSize() const override { return size_; }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 planes.clear(); 153 planes.clear();
152 154
153 EXPECT_FALSE(plane1.buffer->HasOneRef()); 155 EXPECT_FALSE(plane1.buffer->HasOneRef());
154 EXPECT_TRUE(plane2.buffer->HasOneRef()); 156 EXPECT_TRUE(plane2.buffer->HasOneRef());
155 } 157 }
156 158
157 TEST_F(HardwareDisplayControllerTest, CheckOverlayPresent) { 159 TEST_F(HardwareDisplayControllerTest, CheckOverlayPresent) {
158 ui::OverlayPlane plane1(scoped_refptr<ui::ScanoutBuffer>( 160 ui::OverlayPlane plane1(scoped_refptr<ui::ScanoutBuffer>(
159 new MockScanoutBuffer(kDefaultModeSize))); 161 new MockScanoutBuffer(kDefaultModeSize)));
160 ui::OverlayPlane plane2( 162 ui::OverlayPlane plane2(
161 scoped_refptr<ui::ScanoutBuffer>(new MockScanoutBuffer(kDefaultModeSize)), 163 scoped_refptr<ui::ScanoutBuffer>(new MockScanoutBuffer(kOverlaySize)), 1,
162 1, gfx::OVERLAY_TRANSFORM_NONE, gfx::Rect(kDefaultModeSize), 164 gfx::OVERLAY_TRANSFORM_NONE, gfx::Rect(kOverlaySize),
163 gfx::RectF(kDefaultModeSizeF)); 165 gfx::RectF(kDefaultModeSizeF));
164 166
165 EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode)); 167 EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode));
166 168
167 std::vector<ui::OverlayPlane> planes; 169 std::vector<ui::OverlayPlane> planes;
168 planes.push_back(plane1); 170 planes.push_back(plane1);
169 planes.push_back(plane2); 171 planes.push_back(plane2);
170 172
171 EXPECT_TRUE(controller_->SchedulePageFlip( 173 EXPECT_TRUE(controller_->SchedulePageFlip(
172 planes, false /* test_only */, 174 planes, false /* test_only */,
173 base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, 175 base::Bind(&HardwareDisplayControllerTest::PageFlipCallback,
174 base::Unretained(this)))); 176 base::Unretained(this))));
175 drm_->RunCallbacks(); 177 drm_->RunCallbacks();
176 EXPECT_EQ(1, drm_->get_page_flip_call_count()); 178 EXPECT_EQ(1, drm_->get_page_flip_call_count());
177 EXPECT_EQ(1, drm_->get_overlay_flip_call_count()); 179 EXPECT_EQ(1, drm_->get_overlay_flip_call_count());
178 } 180 }
179 181
180 TEST_F(HardwareDisplayControllerTest, CheckOverlayTestMode) { 182 TEST_F(HardwareDisplayControllerTest, CheckOverlayTestMode) {
181 ui::OverlayPlane plane1(scoped_refptr<ui::ScanoutBuffer>( 183 ui::OverlayPlane plane1(scoped_refptr<ui::ScanoutBuffer>(
182 new MockScanoutBuffer(kDefaultModeSize))); 184 new MockScanoutBuffer(kDefaultModeSize)));
183 ui::OverlayPlane plane2( 185 ui::OverlayPlane plane2(
184 scoped_refptr<ui::ScanoutBuffer>(new MockScanoutBuffer(kDefaultModeSize)), 186 scoped_refptr<ui::ScanoutBuffer>(new MockScanoutBuffer(kOverlaySize)), 1,
185 1, gfx::OVERLAY_TRANSFORM_NONE, gfx::Rect(kDefaultModeSize), 187 gfx::OVERLAY_TRANSFORM_NONE, gfx::Rect(kOverlaySize),
186 gfx::RectF(kDefaultModeSizeF)); 188 gfx::RectF(kDefaultModeSizeF));
187 189
188 EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode)); 190 EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode));
189 191
190 std::vector<ui::OverlayPlane> planes; 192 std::vector<ui::OverlayPlane> planes;
191 planes.push_back(plane1); 193 planes.push_back(plane1);
192 planes.push_back(plane2); 194 planes.push_back(plane2);
193 195
194 EXPECT_TRUE(controller_->SchedulePageFlip( 196 EXPECT_TRUE(controller_->SchedulePageFlip(
195 planes, false /* test_only */, 197 planes, false /* test_only */,
(...skipping 14 matching lines...) Expand all
210 // Regular flips should continue on normally. 212 // Regular flips should continue on normally.
211 EXPECT_TRUE(controller_->SchedulePageFlip( 213 EXPECT_TRUE(controller_->SchedulePageFlip(
212 planes, false /* test_only */, 214 planes, false /* test_only */,
213 base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, 215 base::Bind(&HardwareDisplayControllerTest::PageFlipCallback,
214 base::Unretained(this)))); 216 base::Unretained(this))));
215 drm_->RunCallbacks(); 217 drm_->RunCallbacks();
216 EXPECT_EQ(2, drm_->get_page_flip_call_count()); 218 EXPECT_EQ(2, drm_->get_page_flip_call_count());
217 EXPECT_EQ(2, drm_->get_overlay_flip_call_count()); 219 EXPECT_EQ(2, drm_->get_overlay_flip_call_count());
218 } 220 }
219 221
222 TEST_F(HardwareDisplayControllerTest, CheckOverlayFullScreenMode) {
223 ui::OverlayPlane plane1(scoped_refptr<ui::ScanoutBuffer>(
224 new MockScanoutBuffer(kDefaultModeSize)));
225 ui::OverlayPlane plane2(
226 scoped_refptr<ui::ScanoutBuffer>(new MockScanoutBuffer(kDefaultModeSize)),
227 1, gfx::OVERLAY_TRANSFORM_NONE, gfx::Rect(kDefaultModeSize),
228 gfx::RectF(kDefaultModeSizeF));
229
230 EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode));
231
232 std::vector<ui::OverlayPlane> planes;
233 planes.push_back(plane1);
234 planes.push_back(plane2);
235
236 EXPECT_TRUE(controller_->SchedulePageFlip(
237 planes, false /* test_only */,
238 base::Bind(&HardwareDisplayControllerTest::PageFlipCallback,
239 base::Unretained(this))));
240 drm_->RunCallbacks();
241 EXPECT_EQ(1, drm_->get_page_flip_call_count());
242 EXPECT_EQ(0, drm_->get_overlay_flip_call_count());
243 }
244
220 TEST_F(HardwareDisplayControllerTest, RejectUnderlays) { 245 TEST_F(HardwareDisplayControllerTest, RejectUnderlays) {
221 ui::OverlayPlane plane1(scoped_refptr<ui::ScanoutBuffer>( 246 ui::OverlayPlane plane1(scoped_refptr<ui::ScanoutBuffer>(
222 new MockScanoutBuffer(kDefaultModeSize))); 247 new MockScanoutBuffer(kDefaultModeSize)));
223 ui::OverlayPlane plane2( 248 ui::OverlayPlane plane2(
224 scoped_refptr<ui::ScanoutBuffer>(new MockScanoutBuffer(kDefaultModeSize)), 249 scoped_refptr<ui::ScanoutBuffer>(new MockScanoutBuffer(kDefaultModeSize)),
225 -1, gfx::OVERLAY_TRANSFORM_NONE, gfx::Rect(kDefaultModeSize), 250 -1, gfx::OVERLAY_TRANSFORM_NONE, gfx::Rect(kDefaultModeSize),
226 gfx::RectF(kDefaultModeSizeF)); 251 gfx::RectF(kDefaultModeSizeF));
227 252
228 EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode)); 253 EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode));
229 254
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 planes, false /* test_only */, 468 planes, false /* test_only */,
444 base::Bind(&HardwareDisplayControllerTest::PageFlipCallback, 469 base::Bind(&HardwareDisplayControllerTest::PageFlipCallback,
445 base::Unretained(this)))); 470 base::Unretained(this))));
446 471
447 controller_->RemoveCrtc(drm_, kPrimaryCrtc); 472 controller_->RemoveCrtc(drm_, kPrimaryCrtc);
448 473
449 EXPECT_EQ(1, page_flips_); 474 EXPECT_EQ(1, page_flips_);
450 drm_->RunCallbacks(); 475 drm_->RunCallbacks();
451 EXPECT_EQ(1, page_flips_); 476 EXPECT_EQ(1, page_flips_);
452 } 477 }
OLDNEW
« no previous file with comments | « no previous file | ui/ozone/platform/drm/gpu/hardware_display_plane_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698