OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ui/ozone/platform/drm/gpu/mock_hardware_display_plane_manager.h" | 5 #include "ui/ozone/platform/drm/gpu/mock_hardware_display_plane_manager.h" |
6 | 6 |
7 #include <drm_fourcc.h> | 7 #include <drm_fourcc.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "ui/ozone/platform/drm/gpu/fake_plane_info.h" | 11 #include "ui/ozone/platform/drm/gpu/fake_plane_info.h" |
12 #include "ui/ozone/platform/drm/gpu/mock_scanout_buffer.h" | 12 #include "ui/ozone/platform/drm/gpu/mock_scanout_buffer.h" |
13 | 13 |
14 namespace ui { | 14 namespace ui { |
15 | 15 |
16 MockHardwareDisplayPlaneManager::MockHardwareDisplayPlaneManager( | 16 MockHardwareDisplayPlaneManager::MockHardwareDisplayPlaneManager( |
17 DrmDevice* drm, | 17 DrmDevice* drm, |
18 const std::vector<uint32_t>& crtcs, | 18 const std::vector<uint32_t>& crtcs, |
19 uint32_t planes_per_crtc) { | 19 uint32_t planes_per_crtc) { |
20 const int kPlaneBaseId = 50; | 20 const int kPlaneBaseId = 50; |
21 drm_ = drm; | 21 drm_ = drm; |
22 crtcs_ = crtcs; | 22 crtcs_ = crtcs; |
23 for (size_t crtc_idx = 0; crtc_idx < crtcs_.size(); crtc_idx++) { | 23 for (size_t crtc_idx = 0; crtc_idx < crtcs_.size(); crtc_idx++) { |
24 for (size_t i = 0; i < planes_per_crtc; i++) { | 24 for (size_t i = 0; i < planes_per_crtc; i++) { |
25 scoped_ptr<HardwareDisplayPlane> plane( | 25 std::unique_ptr<HardwareDisplayPlane> plane( |
26 new HardwareDisplayPlane(kPlaneBaseId + i, 1 << crtc_idx)); | 26 new HardwareDisplayPlane(kPlaneBaseId + i, 1 << crtc_idx)); |
27 plane->Initialize(drm, std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888), | 27 plane->Initialize(drm, std::vector<uint32_t>(1, DRM_FORMAT_XRGB8888), |
28 false, true); | 28 false, true); |
29 planes_.push_back(std::move(plane)); | 29 planes_.push_back(std::move(plane)); |
30 } | 30 } |
31 } | 31 } |
32 | 32 |
33 // The real HDPM uses sorted planes, so sort them for consistency. | 33 // The real HDPM uses sorted planes, so sort them for consistency. |
34 std::sort(planes_.begin(), planes_.end(), | 34 std::sort(planes_.begin(), planes_.end(), |
35 [](const scoped_ptr<HardwareDisplayPlane>& l, | 35 [](const std::unique_ptr<HardwareDisplayPlane>& l, |
36 const scoped_ptr<HardwareDisplayPlane>& r) { | 36 const std::unique_ptr<HardwareDisplayPlane>& r) { |
37 return l->plane_id() < r->plane_id(); | 37 return l->plane_id() < r->plane_id(); |
38 }); | 38 }); |
39 } | 39 } |
40 | 40 |
41 MockHardwareDisplayPlaneManager::MockHardwareDisplayPlaneManager( | 41 MockHardwareDisplayPlaneManager::MockHardwareDisplayPlaneManager( |
42 DrmDevice* drm) { | 42 DrmDevice* drm) { |
43 drm_ = drm; | 43 drm_ = drm; |
44 } | 44 } |
45 | 45 |
46 MockHardwareDisplayPlaneManager::~MockHardwareDisplayPlaneManager() {} | 46 MockHardwareDisplayPlaneManager::~MockHardwareDisplayPlaneManager() {} |
47 | 47 |
48 void MockHardwareDisplayPlaneManager::InitForTest( | 48 void MockHardwareDisplayPlaneManager::InitForTest( |
49 const FakePlaneInfo* planes, | 49 const FakePlaneInfo* planes, |
50 size_t count, | 50 size_t count, |
51 const std::vector<uint32_t>& crtcs) { | 51 const std::vector<uint32_t>& crtcs) { |
52 crtcs_ = crtcs; | 52 crtcs_ = crtcs; |
53 planes_.clear(); | 53 planes_.clear(); |
54 for (size_t i = 0; i < count; i++) { | 54 for (size_t i = 0; i < count; i++) { |
55 scoped_ptr<HardwareDisplayPlane> plane( | 55 std::unique_ptr<HardwareDisplayPlane> plane( |
56 new HardwareDisplayPlane(planes[i].id, planes[i].allowed_crtc_mask)); | 56 new HardwareDisplayPlane(planes[i].id, planes[i].allowed_crtc_mask)); |
57 plane->Initialize(drm_, planes[i].allowed_formats, false, true); | 57 plane->Initialize(drm_, planes[i].allowed_formats, false, true); |
58 planes_.push_back(std::move(plane)); | 58 planes_.push_back(std::move(plane)); |
59 } | 59 } |
60 // The real HDPM uses sorted planes, so sort them for consistency. | 60 // The real HDPM uses sorted planes, so sort them for consistency. |
61 std::sort(planes_.begin(), planes_.end(), | 61 std::sort(planes_.begin(), planes_.end(), |
62 [](const scoped_ptr<HardwareDisplayPlane>& l, | 62 [](const std::unique_ptr<HardwareDisplayPlane>& l, |
63 const scoped_ptr<HardwareDisplayPlane>& r) { | 63 const std::unique_ptr<HardwareDisplayPlane>& r) { |
64 return l->plane_id() < r->plane_id(); | 64 return l->plane_id() < r->plane_id(); |
65 }); | 65 }); |
66 } | 66 } |
67 | 67 |
68 void MockHardwareDisplayPlaneManager::SetPlaneProperties( | 68 void MockHardwareDisplayPlaneManager::SetPlaneProperties( |
69 const std::vector<FakePlaneInfo>& planes) { | 69 const std::vector<FakePlaneInfo>& planes) { |
70 planes_.clear(); | 70 planes_.clear(); |
71 uint32_t count = planes.size(); | 71 uint32_t count = planes.size(); |
72 for (size_t i = 0; i < count; i++) { | 72 for (size_t i = 0; i < count; i++) { |
73 scoped_ptr<HardwareDisplayPlane> plane( | 73 std::unique_ptr<HardwareDisplayPlane> plane( |
74 new HardwareDisplayPlane(planes[i].id, planes[i].allowed_crtc_mask)); | 74 new HardwareDisplayPlane(planes[i].id, planes[i].allowed_crtc_mask)); |
75 plane->Initialize(drm_, planes[i].allowed_formats, false, true); | 75 plane->Initialize(drm_, planes[i].allowed_formats, false, true); |
76 planes_.push_back(std::move(plane)); | 76 planes_.push_back(std::move(plane)); |
77 } | 77 } |
78 | 78 |
79 // The real HDPM uses sorted planes, so sort them for consistency. | 79 // The real HDPM uses sorted planes, so sort them for consistency. |
80 std::sort(planes_.begin(), planes_.end(), | 80 std::sort(planes_.begin(), planes_.end(), |
81 [](const scoped_ptr<HardwareDisplayPlane>& l, | 81 [](const std::unique_ptr<HardwareDisplayPlane>& l, |
82 const scoped_ptr<HardwareDisplayPlane>& r) { | 82 const std::unique_ptr<HardwareDisplayPlane>& r) { |
83 return l->plane_id() < r->plane_id(); | 83 return l->plane_id() < r->plane_id(); |
84 }); | 84 }); |
85 | 85 |
86 ResetPlaneCount(); | 86 ResetPlaneCount(); |
87 } | 87 } |
88 | 88 |
89 void MockHardwareDisplayPlaneManager::SetCrtcInfo( | 89 void MockHardwareDisplayPlaneManager::SetCrtcInfo( |
90 const std::vector<uint32_t>& crtcs) { | 90 const std::vector<uint32_t>& crtcs) { |
91 crtcs_ = crtcs; | 91 crtcs_ = crtcs; |
92 planes_.clear(); | 92 planes_.clear(); |
(...skipping 18 matching lines...) Expand all Loading... |
111 | 111 |
112 int MockHardwareDisplayPlaneManager::plane_count() const { | 112 int MockHardwareDisplayPlaneManager::plane_count() const { |
113 return plane_count_; | 113 return plane_count_; |
114 } | 114 } |
115 | 115 |
116 void MockHardwareDisplayPlaneManager::ResetPlaneCount() { | 116 void MockHardwareDisplayPlaneManager::ResetPlaneCount() { |
117 plane_count_ = 0; | 117 plane_count_ = 0; |
118 } | 118 } |
119 | 119 |
120 } // namespace ui | 120 } // namespace ui |
OLD | NEW |