Chromium Code Reviews| 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 #include <drm_mode.h> | |
| 8 | 9 |
| 9 #include "base/logging.h" | 10 #include "base/logging.h" |
| 10 #include "ui/ozone/platform/drm/gpu/drm_device.h" | 11 #include "ui/ozone/platform/drm/gpu/drm_device.h" |
| 11 | 12 |
| 12 #ifndef DRM_PLANE_TYPE_OVERLAY | 13 #ifndef DRM_PLANE_TYPE_OVERLAY |
| 13 #define DRM_PLANE_TYPE_OVERLAY 0 | 14 #define DRM_PLANE_TYPE_OVERLAY 0 |
| 14 #endif | 15 #endif |
| 15 | 16 |
| 16 #ifndef DRM_PLANE_TYPE_PRIMARY | 17 #ifndef DRM_PLANE_TYPE_PRIMARY |
| 17 #define DRM_PLANE_TYPE_PRIMARY 1 | 18 #define DRM_PLANE_TYPE_PRIMARY 1 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 49 | 50 |
| 50 HardwareDisplayPlane::~HardwareDisplayPlane() { | 51 HardwareDisplayPlane::~HardwareDisplayPlane() { |
| 51 } | 52 } |
| 52 | 53 |
| 53 bool HardwareDisplayPlane::CanUseForCrtc(uint32_t crtc_index) { | 54 bool HardwareDisplayPlane::CanUseForCrtc(uint32_t crtc_index) { |
| 54 return possible_crtcs_ & (1 << crtc_index); | 55 return possible_crtcs_ & (1 << crtc_index); |
| 55 } | 56 } |
| 56 | 57 |
| 57 bool HardwareDisplayPlane::Initialize(DrmDevice* drm, | 58 bool HardwareDisplayPlane::Initialize(DrmDevice* drm, |
| 58 const std::vector<uint32_t>& formats, | 59 const std::vector<uint32_t>& formats, |
| 60 const std::vector<struct drm_format_info>& format_info, | |
| 59 bool is_dummy, | 61 bool is_dummy, |
| 60 bool test_only) { | 62 bool test_only) { |
| 61 supported_formats_ = formats; | 63 supported_formats_ = formats; |
| 64 supported_format_info_ = format_info; | |
| 65 | |
| 66 for (auto& element : supported_format_info_) { | |
|
Daniele Castagna
2016/12/16 00:27:41
Was this for debugging?
hoegsberg1
2016/12/17 01:10:49
Yeah, removed it.
| |
| 67 LOG(ERROR) << " format info: modifier=" << element.modifier << ", form ats=" << element.formats; | |
| 68 } | |
| 69 | |
| 62 | 70 |
| 63 if (test_only) | 71 if (test_only) |
| 64 return true; | 72 return true; |
| 65 | 73 |
| 66 if (is_dummy) { | 74 if (is_dummy) { |
| 67 type_ = kDummy; | 75 type_ = kDummy; |
| 68 supported_formats_.push_back(DRM_FORMAT_XRGB8888); | 76 supported_formats_.push_back(DRM_FORMAT_XRGB8888); |
| 69 supported_formats_.push_back(DRM_FORMAT_XBGR8888); | 77 supported_formats_.push_back(DRM_FORMAT_XBGR8888); |
| 70 return true; | 78 return true; |
| 71 } | 79 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 } | 113 } |
| 106 | 114 |
| 107 last_used_format_ = 0; | 115 last_used_format_ = 0; |
| 108 return false; | 116 return false; |
| 109 } | 117 } |
| 110 | 118 |
| 111 const std::vector<uint32_t>& HardwareDisplayPlane::supported_formats() const { | 119 const std::vector<uint32_t>& HardwareDisplayPlane::supported_formats() const { |
| 112 return supported_formats_; | 120 return supported_formats_; |
| 113 } | 121 } |
| 114 | 122 |
| 123 uint32_t HardwareDisplayPlane::ModifiersForFormat(uint32_t format, uint64_t *mod ifiers, uint32_t count) { | |
| 124 uint32_t format_index = 0; | |
| 125 for (const auto& f : supported_formats_) { | |
| 126 if (f == format) | |
| 127 break; | |
| 128 format_index++; | |
| 129 } | |
| 130 DCHECK(format_index < supported_formats_.size()); | |
|
Daniele Castagna
2016/12/16 00:27:41
nit: DCHECK_LT
hoegsberg1
2016/12/17 01:10:49
Done - what's better about DCHECK_LT though?
| |
| 131 | |
| 132 uint32_t i = 0; | |
| 133 for (const auto& info : supported_format_info_) { | |
| 134 if (info.formats & (1 << format_index) && i < count) | |
| 135 modifiers[i++] = info.modifier; | |
| 136 } | |
| 137 | |
| 138 return i; | |
| 139 } | |
| 140 | |
| 115 bool HardwareDisplayPlane::InitializeProperties( | 141 bool HardwareDisplayPlane::InitializeProperties( |
| 116 DrmDevice* drm, | 142 DrmDevice* drm, |
| 117 const ScopedDrmObjectPropertyPtr& plane_props) { | 143 const ScopedDrmObjectPropertyPtr& plane_props) { |
| 118 return true; | 144 return true; |
| 119 } | 145 } |
| 120 | 146 |
| 121 } // namespace ui | 147 } // namespace ui |
| OLD | NEW |