OLD | NEW |
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 "ui/ozone/platform/drm/gpu/hardware_display_plane.h" | 5 #include "ui/ozone/platform/drm/gpu/hardware_display_plane.h" |
6 | 6 |
7 #include <drm_fourcc.h> | 7 #include <drm_fourcc.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "ui/ozone/platform/drm/gpu/drm_device.h" | 10 #include "ui/ozone/platform/drm/gpu/drm_device.h" |
(...skipping 38 matching lines...) Loading... |
49 | 49 |
50 HardwareDisplayPlane::~HardwareDisplayPlane() { | 50 HardwareDisplayPlane::~HardwareDisplayPlane() { |
51 } | 51 } |
52 | 52 |
53 bool HardwareDisplayPlane::CanUseForCrtc(uint32_t crtc_index) { | 53 bool HardwareDisplayPlane::CanUseForCrtc(uint32_t crtc_index) { |
54 return possible_crtcs_ & (1 << crtc_index); | 54 return possible_crtcs_ & (1 << crtc_index); |
55 } | 55 } |
56 | 56 |
57 bool HardwareDisplayPlane::Initialize(DrmDevice* drm, | 57 bool HardwareDisplayPlane::Initialize(DrmDevice* drm, |
58 const std::vector<uint32_t>& formats, | 58 const std::vector<uint32_t>& formats, |
59 bool is_dummy) { | 59 bool is_dummy, |
| 60 bool test_only) { |
| 61 supported_formats_ = formats; |
| 62 |
| 63 if (test_only) |
| 64 return true; |
| 65 |
60 if (is_dummy) { | 66 if (is_dummy) { |
61 type_ = kDummy; | 67 type_ = kDummy; |
62 supported_formats_.push_back(DRM_FORMAT_XRGB8888); | 68 supported_formats_.push_back(DRM_FORMAT_XRGB8888); |
63 return true; | 69 return true; |
64 } | 70 } |
65 | 71 |
66 supported_formats_ = formats; | |
67 | |
68 ScopedDrmObjectPropertyPtr plane_props(drmModeObjectGetProperties( | 72 ScopedDrmObjectPropertyPtr plane_props(drmModeObjectGetProperties( |
69 drm->get_fd(), plane_id_, DRM_MODE_OBJECT_PLANE)); | 73 drm->get_fd(), plane_id_, DRM_MODE_OBJECT_PLANE)); |
70 if (!plane_props) { | 74 if (!plane_props) { |
71 PLOG(ERROR) << "Unable to get plane properties."; | 75 PLOG(ERROR) << "Unable to get plane properties."; |
72 return false; | 76 return false; |
73 } | 77 } |
74 | 78 |
75 uint32_t count_props = plane_props->count_props; | 79 uint32_t count_props = plane_props->count_props; |
76 for (uint32_t i = 0; i < count_props; i++) { | 80 for (uint32_t i = 0; i < count_props; i++) { |
77 ScopedDrmPropertyPtr property( | 81 ScopedDrmPropertyPtr property( |
78 drmModeGetProperty(drm->get_fd(), plane_props->props[i])); | 82 drmModeGetProperty(drm->get_fd(), plane_props->props[i])); |
79 if (property && !strcmp(property->name, kTypePropName)) { | 83 if (property && !strcmp(property->name, kTypePropName)) { |
80 type_ = GetPlaneType(plane_props->prop_values[i]); | 84 type_ = GetPlaneType(plane_props->prop_values[i]); |
81 } | 85 } |
82 } | 86 } |
83 | 87 |
84 return InitializeProperties(drm, plane_props); | 88 return InitializeProperties(drm, plane_props); |
85 } | 89 } |
86 | 90 |
87 bool HardwareDisplayPlane::IsSupportedFormat(uint32_t format) const { | 91 bool HardwareDisplayPlane::IsSupportedFormat(uint32_t format) { |
88 return true; | 92 if (!format) |
| 93 return false; |
| 94 |
| 95 if (last_used_format_ == format) |
| 96 return true; |
| 97 |
| 98 for (auto& element : supported_formats_) { |
| 99 if (element == format) { |
| 100 last_used_format_ = format; |
| 101 return true; |
| 102 } |
| 103 } |
| 104 |
| 105 last_used_format_ = 0; |
| 106 return false; |
89 } | 107 } |
90 | 108 |
91 bool HardwareDisplayPlane::InitializeProperties( | 109 bool HardwareDisplayPlane::InitializeProperties( |
92 DrmDevice* drm, | 110 DrmDevice* drm, |
93 const ScopedDrmObjectPropertyPtr& plane_props) { | 111 const ScopedDrmObjectPropertyPtr& plane_props) { |
94 return true; | 112 return true; |
95 } | 113 } |
96 | 114 |
97 } // namespace ui | 115 } // namespace ui |
OLD | NEW |