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 std::unique_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 std::vector<drm_format_modifier>(), // modifiers |
28 false, true); | 29 false, true); |
29 planes_.push_back(std::move(plane)); | 30 planes_.push_back(std::move(plane)); |
30 } | 31 } |
31 } | 32 } |
32 | 33 |
33 // The real HDPM uses sorted planes, so sort them for consistency. | 34 // The real HDPM uses sorted planes, so sort them for consistency. |
34 std::sort(planes_.begin(), planes_.end(), | 35 std::sort(planes_.begin(), planes_.end(), |
35 [](const std::unique_ptr<HardwareDisplayPlane>& l, | 36 [](const std::unique_ptr<HardwareDisplayPlane>& l, |
36 const std::unique_ptr<HardwareDisplayPlane>& r) { | 37 const std::unique_ptr<HardwareDisplayPlane>& r) { |
37 return l->plane_id() < r->plane_id(); | 38 return l->plane_id() < r->plane_id(); |
38 }); | 39 }); |
39 } | 40 } |
40 | 41 |
41 MockHardwareDisplayPlaneManager::MockHardwareDisplayPlaneManager( | 42 MockHardwareDisplayPlaneManager::MockHardwareDisplayPlaneManager( |
42 DrmDevice* drm) { | 43 DrmDevice* drm) { |
43 drm_ = drm; | 44 drm_ = drm; |
44 } | 45 } |
45 | 46 |
46 MockHardwareDisplayPlaneManager::~MockHardwareDisplayPlaneManager() {} | 47 MockHardwareDisplayPlaneManager::~MockHardwareDisplayPlaneManager() {} |
47 | 48 |
48 void MockHardwareDisplayPlaneManager::InitForTest( | 49 void MockHardwareDisplayPlaneManager::InitForTest( |
49 const FakePlaneInfo* planes, | 50 const FakePlaneInfo* planes, |
50 size_t count, | 51 size_t count, |
51 const std::vector<uint32_t>& crtcs) { | 52 const std::vector<uint32_t>& crtcs) { |
52 crtcs_ = crtcs; | 53 crtcs_ = crtcs; |
53 planes_.clear(); | 54 planes_.clear(); |
54 for (size_t i = 0; i < count; i++) { | 55 for (size_t i = 0; i < count; i++) { |
55 std::unique_ptr<HardwareDisplayPlane> plane( | 56 std::unique_ptr<HardwareDisplayPlane> plane( |
56 new HardwareDisplayPlane(planes[i].id, planes[i].allowed_crtc_mask)); | 57 new HardwareDisplayPlane(planes[i].id, planes[i].allowed_crtc_mask)); |
57 plane->Initialize(drm_, planes[i].allowed_formats, false, true); | 58 plane->Initialize(drm_, planes[i].allowed_formats, |
| 59 std::vector<drm_format_modifier>(), // modifiers |
| 60 false, true); |
58 planes_.push_back(std::move(plane)); | 61 planes_.push_back(std::move(plane)); |
59 } | 62 } |
60 // The real HDPM uses sorted planes, so sort them for consistency. | 63 // The real HDPM uses sorted planes, so sort them for consistency. |
61 std::sort(planes_.begin(), planes_.end(), | 64 std::sort(planes_.begin(), planes_.end(), |
62 [](const std::unique_ptr<HardwareDisplayPlane>& l, | 65 [](const std::unique_ptr<HardwareDisplayPlane>& l, |
63 const std::unique_ptr<HardwareDisplayPlane>& r) { | 66 const std::unique_ptr<HardwareDisplayPlane>& r) { |
64 return l->plane_id() < r->plane_id(); | 67 return l->plane_id() < r->plane_id(); |
65 }); | 68 }); |
66 } | 69 } |
67 | 70 |
68 void MockHardwareDisplayPlaneManager::SetPlaneProperties( | 71 void MockHardwareDisplayPlaneManager::SetPlaneProperties( |
69 const std::vector<FakePlaneInfo>& planes) { | 72 const std::vector<FakePlaneInfo>& planes) { |
70 planes_.clear(); | 73 planes_.clear(); |
71 uint32_t count = planes.size(); | 74 uint32_t count = planes.size(); |
72 for (size_t i = 0; i < count; i++) { | 75 for (size_t i = 0; i < count; i++) { |
73 std::unique_ptr<HardwareDisplayPlane> plane( | 76 std::unique_ptr<HardwareDisplayPlane> plane( |
74 new HardwareDisplayPlane(planes[i].id, planes[i].allowed_crtc_mask)); | 77 new HardwareDisplayPlane(planes[i].id, planes[i].allowed_crtc_mask)); |
75 plane->Initialize(drm_, planes[i].allowed_formats, false, true); | 78 plane->Initialize(drm_, planes[i].allowed_formats, |
| 79 std::vector<drm_format_modifier>(), // modifiers |
| 80 false, true); |
76 planes_.push_back(std::move(plane)); | 81 planes_.push_back(std::move(plane)); |
77 } | 82 } |
78 | 83 |
79 // The real HDPM uses sorted planes, so sort them for consistency. | 84 // The real HDPM uses sorted planes, so sort them for consistency. |
80 std::sort(planes_.begin(), planes_.end(), | 85 std::sort(planes_.begin(), planes_.end(), |
81 [](const std::unique_ptr<HardwareDisplayPlane>& l, | 86 [](const std::unique_ptr<HardwareDisplayPlane>& l, |
82 const std::unique_ptr<HardwareDisplayPlane>& r) { | 87 const std::unique_ptr<HardwareDisplayPlane>& r) { |
83 return l->plane_id() < r->plane_id(); | 88 return l->plane_id() < r->plane_id(); |
84 }); | 89 }); |
85 | 90 |
(...skipping 25 matching lines...) Expand all Loading... |
111 | 116 |
112 int MockHardwareDisplayPlaneManager::plane_count() const { | 117 int MockHardwareDisplayPlaneManager::plane_count() const { |
113 return plane_count_; | 118 return plane_count_; |
114 } | 119 } |
115 | 120 |
116 void MockHardwareDisplayPlaneManager::ResetPlaneCount() { | 121 void MockHardwareDisplayPlaneManager::ResetPlaneCount() { |
117 plane_count_ = 0; | 122 plane_count_ = 0; |
118 } | 123 } |
119 | 124 |
120 } // namespace ui | 125 } // namespace ui |
OLD | NEW |