Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(273)

Side by Side Diff: ui/ozone/platform/drm/gpu/hardware_display_plane.cc

Issue 2576263002: ozone: Allocate scanout buffer according to KMS modifiers (Closed)
Patch Set: ozone: Allocate scanout buffer according to KMS modifiers Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 29 matching lines...) Expand all
47 : plane_id_(plane_id), possible_crtcs_(possible_crtcs) { 48 : plane_id_(plane_id), possible_crtcs_(possible_crtcs) {
48 } 49 }
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(
58 const std::vector<uint32_t>& formats, 59 DrmDevice* drm,
59 bool is_dummy, 60 const std::vector<uint32_t>& formats,
60 bool test_only) { 61 const std::vector<struct drm_format_modifier>& format_modifiers,
62 bool is_dummy,
63 bool test_only) {
61 supported_formats_ = formats; 64 supported_formats_ = formats;
65 supported_format_modifiers_ = format_modifiers;
62 66
63 if (test_only) 67 if (test_only)
64 return true; 68 return true;
65 69
66 if (is_dummy) { 70 if (is_dummy) {
67 type_ = kDummy; 71 type_ = kDummy;
68 supported_formats_.push_back(DRM_FORMAT_XRGB8888); 72 supported_formats_.push_back(DRM_FORMAT_XRGB8888);
69 supported_formats_.push_back(DRM_FORMAT_XBGR8888); 73 supported_formats_.push_back(DRM_FORMAT_XBGR8888);
70 return true; 74 return true;
71 } 75 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 } 109 }
106 110
107 last_used_format_ = 0; 111 last_used_format_ = 0;
108 return false; 112 return false;
109 } 113 }
110 114
111 const std::vector<uint32_t>& HardwareDisplayPlane::supported_formats() const { 115 const std::vector<uint32_t>& HardwareDisplayPlane::supported_formats() const {
112 return supported_formats_; 116 return supported_formats_;
113 } 117 }
114 118
119 std::vector<uint64_t> HardwareDisplayPlane::ModifiersForFormat(
120 uint32_t format) {
121 uint32_t format_index = 0;
122 std::vector<uint64_t> modifiers;
123
124 for (const auto& f : supported_formats_) {
Daniele Castagna 2016/12/20 18:03:28 This is a vector of ints. In general, it doesn't m
hoegsberg1 2016/12/22 23:05:21 Sure. I guess that's idiomatic, but it's a lot har
125 if (f == format)
126 break;
127 format_index++;
128 }
129 DCHECK_LT(format_index, supported_formats_.size());
130
131 for (const auto& modifier : supported_format_modifiers_) {
Daniele Castagna 2016/12/20 18:03:28 No need to use a ref for built in types.
hoegsberg1 2016/12/22 23:05:21 We're iterating through std:vector<struct drm_form
132 if (modifier.formats & (1 << format_index))
133 modifiers.push_back(modifier.modifier);
134 }
135
136 return modifiers;
137 }
138
115 bool HardwareDisplayPlane::InitializeProperties( 139 bool HardwareDisplayPlane::InitializeProperties(
116 DrmDevice* drm, 140 DrmDevice* drm,
117 const ScopedDrmObjectPropertyPtr& plane_props) { 141 const ScopedDrmObjectPropertyPtr& plane_props) {
118 return true; 142 return true;
119 } 143 }
120 144
121 } // namespace ui 145 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698