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

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

Issue 2471413006: Disable multi-planar import for now (Closed)
Patch Set: Make sure to import only one plane Created 4 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/gbm_buffer.h" 5 #include "ui/ozone/platform/drm/gpu/gbm_buffer.h"
6 6
7 #include <drm.h> 7 #include <drm.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <gbm.h> 9 #include <gbm.h>
10 #include <xf86drm.h> 10 #include <xf86drm.h>
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 std::vector<base::ScopedFD>&& fds, 159 std::vector<base::ScopedFD>&& fds,
160 const std::vector<gfx::NativePixmapPlane>& planes) { 160 const std::vector<gfx::NativePixmapPlane>& planes) {
161 TRACE_EVENT2("drm", "GbmBuffer::CreateBufferFromFD", "device", 161 TRACE_EVENT2("drm", "GbmBuffer::CreateBufferFromFD", "device",
162 gbm->device_path().value(), "size", size.ToString()); 162 gbm->device_path().value(), "size", size.ToString());
163 DCHECK_LE(fds.size(), planes.size()); 163 DCHECK_LE(fds.size(), planes.size());
164 DCHECK_EQ(planes[0].offset, 0); 164 DCHECK_EQ(planes[0].offset, 0);
165 165
166 uint32_t fourcc_format = GetFourCCFormatFromBufferFormat(format); 166 uint32_t fourcc_format = GetFourCCFormatFromBufferFormat(format);
167 167
168 // Use scanout if supported. 168 // Use scanout if supported.
169 bool use_scanout = gbm_device_is_format_supported( 169 bool use_scanout = gbm_device_is_format_supported(
Daniele Castagna 2016/11/05 00:21:33 I was thinking of something like bool use_scanout
170 gbm->device(), fourcc_format, GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING); 170 gbm->device(), fourcc_format, GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
171 171
172 gbm_bo* bo = nullptr; 172 gbm_bo* bo = nullptr;
173 if (use_scanout) { 173 if (use_scanout && planes.size() == 1) {
174 struct gbm_import_fd_planar_data fd_data {}; 174 struct gbm_import_fd_data fd_data;
175 for (size_t i = 0; i < fds.size(); ++i) 175 fd_data.fd = fds[0].get();
176 fd_data.fds[i] = fds[i].get();
177
178 fd_data.width = size.width(); 176 fd_data.width = size.width();
179 fd_data.height = size.height(); 177 fd_data.height = size.height();
178 fd_data.stride = planes[0].stride;
180 fd_data.format = fourcc_format; 179 fd_data.format = fourcc_format;
181 180
182 for (size_t i = 0; i < planes.size(); ++i) { 181 // The fd passed to gbm_bo_import is not ref-counted and need to be
183 fd_data.strides[i] = planes[i].stride;
184 fd_data.offsets[i] = planes[i].offset;
185 fd_data.format_modifiers[i] = planes[i].modifier;
186 }
187
188 // The fds passed to gbm_bo_import are not ref-counted and need to be
189 // kept open for the lifetime of the buffer. 182 // kept open for the lifetime of the buffer.
190 bo = gbm_bo_import(gbm->device(), GBM_BO_IMPORT_FD_PLANAR, &fd_data, 183 bo = gbm_bo_import(gbm->device(), GBM_BO_IMPORT_FD, &fd_data,
191 GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING); 184 GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
192 if (!bo) { 185 if (!bo) {
193 LOG(ERROR) << "nullptr returned from gbm_bo_import"; 186 LOG(ERROR) << "nullptr returned from gbm_bo_import";
194 return nullptr; 187 return nullptr;
195 } 188 }
196 } 189 }
197 190
198 scoped_refptr<GbmBuffer> buffer(new GbmBuffer( 191 scoped_refptr<GbmBuffer> buffer(new GbmBuffer(
199 gbm, bo, format, 192 gbm, bo, format,
200 use_scanout ? gfx::BufferUsage::SCANOUT : gfx::BufferUsage::GPU_READ, 193 use_scanout ? gfx::BufferUsage::SCANOUT : gfx::BufferUsage::GPU_READ,
201 std::move(fds), size, std::move(planes))); 194 std::move(fds), size, std::move(planes)));
202 // If scanout support for buffer is expected then make sure we managed to 195 // If scanout support for buffer is expected then make sure we managed to
203 // create a framebuffer for it as otherwise using it for scanout will fail. 196 // create a framebuffer for it as otherwise using it for scanout will fail.
204 if (use_scanout && !buffer->GetFramebufferId()) 197 if (use_scanout && !buffer->GetFramebufferId())
Daniele Castagna 2016/11/05 00:18:35 Wouldn't we hit this?
205 return nullptr; 198 return nullptr;
206 199
207 return buffer; 200 return buffer;
208 } 201 }
209 202
210 GbmPixmap::GbmPixmap(GbmSurfaceFactory* surface_manager, 203 GbmPixmap::GbmPixmap(GbmSurfaceFactory* surface_manager,
211 const scoped_refptr<GbmBuffer>& buffer) 204 const scoped_refptr<GbmBuffer>& buffer)
212 : surface_manager_(surface_manager), buffer_(buffer) {} 205 : surface_manager_(surface_manager), buffer_(buffer) {}
213 206
214 void GbmPixmap::SetProcessingCallback( 207 void GbmPixmap::SetProcessingCallback(
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 DCHECK(!processing_callback_.is_null()); 312 DCHECK(!processing_callback_.is_null());
320 if (!processing_callback_.Run(this, processed_pixmap_)) { 313 if (!processing_callback_.Run(this, processed_pixmap_)) {
321 LOG(ERROR) << "Failed processing NativePixmap"; 314 LOG(ERROR) << "Failed processing NativePixmap";
322 return nullptr; 315 return nullptr;
323 } 316 }
324 317
325 return processed_pixmap_->buffer(); 318 return processed_pixmap_->buffer();
326 } 319 }
327 320
328 } // namespace ui 321 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698