Chromium Code Reviews| Index: ui/ozone/platform/drm/gpu/gbm_buffer.cc |
| diff --git a/ui/ozone/platform/drm/gpu/gbm_buffer.cc b/ui/ozone/platform/drm/gpu/gbm_buffer.cc |
| index 5d4643411a6e5f0f9de70d737a2c51c0dc209e44..aab2bf06f8bcded81ea9fb909cd297d2b7715978 100644 |
| --- a/ui/ozone/platform/drm/gpu/gbm_buffer.cc |
| +++ b/ui/ozone/platform/drm/gpu/gbm_buffer.cc |
| @@ -184,23 +184,27 @@ scoped_refptr<GbmBuffer> GbmBuffer::CreateBufferFromFds( |
| DCHECK_EQ(planes[0].offset, 0); |
| // Try to use scanout if supported. |
| - bool try_scanout = |
| - gbm_device_is_format_supported( |
| - gbm->device(), format, GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING) && |
| - (planes.size() == 1); |
| + bool try_scanout = gbm_device_is_format_supported( |
| + gbm->device(), format, GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING); |
| gbm_bo* bo = nullptr; |
| if (try_scanout) { |
| - struct gbm_import_fd_data fd_data; |
| - fd_data.fd = fds[0].get(); |
| + struct gbm_import_fd_planar_data fd_data {}; |
|
reveman
2017/03/21 03:36:09
nit: leave uninitialized so asan can detect if gbm
Daniele Castagna
2017/03/21 03:47:09
Done.
|
| fd_data.width = size.width(); |
| fd_data.height = size.height(); |
| - fd_data.stride = planes[0].stride; |
| fd_data.format = format; |
| + DCHECK_LT(planes.size(), 3u); |
| + for (size_t i = 0; i < planes.size(); ++i) { |
| + fd_data.fds[i] = fds[i < fds.size() ? i : 0].get(); |
|
reveman
2017/03/21 03:36:09
what if fds.size() is 2 and planes.size() is 3. do
Daniele Castagna
2017/03/21 03:47:09
This is consistent with what we do for eglCreateIm
|
| + fd_data.strides[i] = planes[i].stride; |
| + fd_data.offsets[i] = planes[i].offset; |
| + fd_data.format_modifiers[i] = planes[i].modifier; |
| + } |
| + |
| // The fd passed to gbm_bo_import is not ref-counted and need to be |
| // kept open for the lifetime of the buffer. |
| - bo = gbm_bo_import(gbm->device(), GBM_BO_IMPORT_FD, &fd_data, |
| + bo = gbm_bo_import(gbm->device(), GBM_BO_IMPORT_FD_PLANAR, &fd_data, |
| GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING); |
| if (!bo) { |
| LOG(ERROR) << "nullptr returned from gbm_bo_import"; |