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/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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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( |
| 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 use_scanout &= (planes.size() == 1); | |
|
Daniele Castagna
2016/11/05 01:01:38
nit: Why are you using a bitwise operator with a b
gurchetansingh
2016/11/05 01:11:53
fixed
| |
| 173 | |
| 172 gbm_bo* bo = nullptr; | 174 gbm_bo* bo = nullptr; |
| 173 if (use_scanout) { | 175 if (use_scanout) { |
| 174 struct gbm_import_fd_planar_data fd_data {}; | 176 struct gbm_import_fd_data fd_data; |
| 175 for (size_t i = 0; i < fds.size(); ++i) | 177 fd_data.fd = fds[0].get(); |
| 176 fd_data.fds[i] = fds[i].get(); | |
| 177 | |
| 178 fd_data.width = size.width(); | 178 fd_data.width = size.width(); |
| 179 fd_data.height = size.height(); | 179 fd_data.height = size.height(); |
| 180 fd_data.stride = planes[0].stride; | |
| 180 fd_data.format = fourcc_format; | 181 fd_data.format = fourcc_format; |
| 181 | 182 |
| 182 for (size_t i = 0; i < planes.size(); ++i) { | 183 // 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. | 184 // kept open for the lifetime of the buffer. |
| 190 bo = gbm_bo_import(gbm->device(), GBM_BO_IMPORT_FD_PLANAR, &fd_data, | 185 bo = gbm_bo_import(gbm->device(), GBM_BO_IMPORT_FD, &fd_data, |
| 191 GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING); | 186 GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING); |
| 192 if (!bo) { | 187 if (!bo) { |
| 193 LOG(ERROR) << "nullptr returned from gbm_bo_import"; | 188 LOG(ERROR) << "nullptr returned from gbm_bo_import"; |
| 194 return nullptr; | 189 return nullptr; |
| 195 } | 190 } |
| 196 } | 191 } |
| 197 | 192 |
| 198 scoped_refptr<GbmBuffer> buffer(new GbmBuffer( | 193 scoped_refptr<GbmBuffer> buffer(new GbmBuffer( |
| 199 gbm, bo, format, | 194 gbm, bo, format, |
| 200 use_scanout ? gfx::BufferUsage::SCANOUT : gfx::BufferUsage::GPU_READ, | 195 use_scanout ? gfx::BufferUsage::SCANOUT : gfx::BufferUsage::GPU_READ, |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 319 DCHECK(!processing_callback_.is_null()); | 314 DCHECK(!processing_callback_.is_null()); |
| 320 if (!processing_callback_.Run(this, processed_pixmap_)) { | 315 if (!processing_callback_.Run(this, processed_pixmap_)) { |
| 321 LOG(ERROR) << "Failed processing NativePixmap"; | 316 LOG(ERROR) << "Failed processing NativePixmap"; |
| 322 return nullptr; | 317 return nullptr; |
| 323 } | 318 } |
| 324 | 319 |
| 325 return processed_pixmap_->buffer(); | 320 return processed_pixmap_->buffer(); |
| 326 } | 321 } |
| 327 | 322 |
| 328 } // namespace ui | 323 } // namespace ui |
| OLD | NEW |