| 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/hardware_display_plane_atomic.h" | 5 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_atomic.h" |
| 6 | 6 |
| 7 #include <drm/drm_fourcc.h> | 7 #include <drm/drm_fourcc.h> |
| 8 #include <gbm.h> | 8 #include <gbm.h> |
| 9 | 9 |
| 10 #include "ui/ozone/platform/drm/gpu/drm_device.h" | 10 #include "ui/ozone/platform/drm/gpu/drm_device.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 src_rect.width()) || | 79 src_rect.width()) || |
| 80 drmModePropertySetAdd(property_set, plane_id_, src_h_prop_.id, | 80 drmModePropertySetAdd(property_set, plane_id_, src_h_prop_.id, |
| 81 src_rect.height()); | 81 src_rect.height()); |
| 82 if (plane_set_error) { | 82 if (plane_set_error) { |
| 83 PLOG(ERROR) << "Failed to set plane data"; | 83 PLOG(ERROR) << "Failed to set plane data"; |
| 84 return false; | 84 return false; |
| 85 } | 85 } |
| 86 return true; | 86 return true; |
| 87 } | 87 } |
| 88 | 88 |
| 89 bool HardwareDisplayPlaneAtomic::Initialize( | 89 bool HardwareDisplayPlaneAtomic::InitializeProperties( |
| 90 DrmDevice* drm, | 90 DrmDevice* drm, |
| 91 const std::vector<uint32_t>& formats) { | 91 const ScopedDrmObjectPropertyPtr& plane_props) { |
| 92 ScopedDrmObjectPropertyPtr plane_props(drmModeObjectGetProperties( | |
| 93 drm->get_fd(), plane_id_, DRM_MODE_OBJECT_PLANE)); | |
| 94 | |
| 95 if (!plane_props) { | |
| 96 PLOG(ERROR) << "Unable to get plane properties."; | |
| 97 return false; | |
| 98 } | |
| 99 | |
| 100 bool props_init = crtc_prop_.Initialize(drm, kCrtcPropName, plane_props) && | 92 bool props_init = crtc_prop_.Initialize(drm, kCrtcPropName, plane_props) && |
| 101 fb_prop_.Initialize(drm, kFbPropName, plane_props) && | 93 fb_prop_.Initialize(drm, kFbPropName, plane_props) && |
| 102 crtc_x_prop_.Initialize(drm, kCrtcXPropName, plane_props) && | 94 crtc_x_prop_.Initialize(drm, kCrtcXPropName, plane_props) && |
| 103 crtc_y_prop_.Initialize(drm, kCrtcYPropName, plane_props) && | 95 crtc_y_prop_.Initialize(drm, kCrtcYPropName, plane_props) && |
| 104 crtc_w_prop_.Initialize(drm, kCrtcWPropName, plane_props) && | 96 crtc_w_prop_.Initialize(drm, kCrtcWPropName, plane_props) && |
| 105 crtc_h_prop_.Initialize(drm, kCrtcHPropName, plane_props) && | 97 crtc_h_prop_.Initialize(drm, kCrtcHPropName, plane_props) && |
| 106 src_x_prop_.Initialize(drm, kSrcXPropName, plane_props) && | 98 src_x_prop_.Initialize(drm, kSrcXPropName, plane_props) && |
| 107 src_y_prop_.Initialize(drm, kSrcYPropName, plane_props) && | 99 src_y_prop_.Initialize(drm, kSrcYPropName, plane_props) && |
| 108 src_w_prop_.Initialize(drm, kSrcWPropName, plane_props) && | 100 src_w_prop_.Initialize(drm, kSrcWPropName, plane_props) && |
| 109 src_h_prop_.Initialize(drm, kSrcHPropName, plane_props); | 101 src_h_prop_.Initialize(drm, kSrcHPropName, plane_props); |
| 110 | 102 |
| 111 if (!props_init) { | 103 if (!props_init) { |
| 112 LOG(ERROR) << "Unable to get plane properties."; | 104 LOG(ERROR) << "Unable to get plane properties."; |
| 113 return false; | 105 return false; |
| 114 } | 106 } |
| 115 | 107 |
| 116 supported_formats_ = formats; | |
| 117 if (is_dummy()) | |
| 118 supported_formats_.push_back(DRM_FORMAT_XRGB8888); | |
| 119 | |
| 120 return true; | 108 return true; |
| 121 } | 109 } |
| 122 | 110 |
| 123 bool HardwareDisplayPlaneAtomic::IsSupportedFormat(uint32_t format) const { | 111 bool HardwareDisplayPlaneAtomic::IsSupportedFormat(uint32_t format) const { |
| 124 uint32_t format_type = 0; | 112 uint32_t format_type = 0; |
| 125 switch (format) { | 113 switch (format) { |
| 126 case GBM_BO_FORMAT_ARGB8888: { | 114 case GBM_BO_FORMAT_ARGB8888: { |
| 127 // We create a FB of 24 bit color depth. | 115 // We create a FB of 24 bit color depth. |
| 128 format_type = DRM_FORMAT_XRGB8888; | 116 format_type = DRM_FORMAT_XRGB8888; |
| 129 break; | 117 break; |
| 130 } | 118 } |
| 131 case GBM_BO_FORMAT_XRGB8888: { | 119 case GBM_BO_FORMAT_XRGB8888: { |
| 132 format_type = DRM_FORMAT_XRGB8888; | 120 format_type = DRM_FORMAT_XRGB8888; |
| 133 break; | 121 break; |
| 134 } | 122 } |
| 135 default: | 123 default: |
| 136 NOTREACHED(); | 124 NOTREACHED(); |
| 137 return false; | 125 return false; |
| 138 } | 126 } |
| 139 | 127 |
| 140 for (auto& element : supported_formats_) { | 128 for (auto& element : supported_formats_) { |
| 141 if (element == format_type) | 129 if (element == format_type) |
| 142 return true; | 130 return true; |
| 143 } | 131 } |
| 144 | 132 |
| 145 return false; | 133 return false; |
| 146 } | 134 } |
| 147 | 135 |
| 148 } // namespace ui | 136 } // namespace ui |
| OLD | NEW |