| Index: ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.cc
|
| diff --git a/ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.cc b/ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.cc
|
| index 8d6d8142f625618a42b86d447ecd843bb6ef4159..0d1ac640e5ccbb165ef882e035d984c352844bf7 100644
|
| --- a/ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.cc
|
| +++ b/ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.cc
|
| @@ -48,12 +48,26 @@ class GLImageOzoneNativePixmapDmaBuf : public gfx::GLImageLinuxDMABuffer {
|
| unsigned internalformat)
|
| : GLImageLinuxDMABuffer(size, internalformat) {}
|
|
|
| - bool Initialize(NativePixmap* pixmap, gfx::GpuMemoryBuffer::Format format) {
|
| - base::FileDescriptor handle(pixmap->GetDmaBufFd(), false);
|
| - if (!GLImageLinuxDMABuffer::Initialize(handle, format,
|
| - pixmap->GetDmaBufPitch()))
|
| + bool Initialize(int num_buffers,
|
| + const std::vector<NativePixmap*>& pixmaps,
|
| + const std::vector<gfx::GpuMemoryBuffer::Format>& formats) {
|
| + if (num_buffers != 1) {
|
| + NOTIMPLEMENTED();
|
| + return scoped_refptr<gfx::GLImage>();
|
| + }
|
| +
|
| + std::vector<base::FileDescriptor> handles;
|
| + handles.reserve(num_buffers);
|
| + std::vector<int> pitches;
|
| + pitches.reserve(num_buffers);
|
| + for (const auto& pixmap : pixmaps) {
|
| + handles.push_back(base::FileDescriptor(pixmap->GetDmaBufFd(), false));
|
| + pitches.push_back(pixmap->GetDmaBufPitch());
|
| + }
|
| + if (!GLImageLinuxDMABuffer::Initialize(num_buffers, handles, formats,
|
| + pitches))
|
| return false;
|
| - pixmap_ = pixmap;
|
| + pixmap_ = pixmaps[0];
|
| return true;
|
| }
|
|
|
| @@ -150,43 +164,54 @@ void GpuMemoryBufferFactoryOzoneNativeBuffer::DestroyGpuMemoryBuffer(
|
| }
|
|
|
| scoped_refptr<gfx::GLImage>
|
| -GpuMemoryBufferFactoryOzoneNativeBuffer::CreateImageForGpuMemoryBuffer(
|
| - gfx::GpuMemoryBufferId id,
|
| +GpuMemoryBufferFactoryOzoneNativeBuffer::CreateImageForGpuMemoryBuffers(
|
| + int num_buffers,
|
| + const std::vector<gfx::GpuMemoryBufferId>& ids,
|
| const gfx::Size& size,
|
| - gfx::GpuMemoryBuffer::Format format,
|
| + const std::vector<gfx::GpuMemoryBuffer::Format>& formats,
|
| unsigned internalformat,
|
| int client_id) {
|
| - NativePixmap* pixmap = nullptr;
|
| - {
|
| + ScopedVector<NativePixmap> pixmaps;
|
| + pixmaps.reserve(num_buffers);
|
| + for (const auto id : ids) {
|
| base::AutoLock lock(native_pixmap_map_lock_);
|
| BufferToPixmapMap::iterator it =
|
| native_pixmap_map_.find(GetIndex(id, client_id));
|
| if (it == native_pixmap_map_.end()) {
|
| return scoped_refptr<gfx::GLImage>();
|
| }
|
| - pixmap = it->second.get();
|
| + pixmaps.push_back(it->second.get());
|
| }
|
| - return CreateImageForPixmap(pixmap, size, format, internalformat);
|
| + return CreateImageForPixmaps(num_buffers, pixmaps.Pass(), size, formats,
|
| + internalformat);
|
| }
|
|
|
| scoped_refptr<gfx::GLImage>
|
| -GpuMemoryBufferFactoryOzoneNativeBuffer::CreateImageForPixmap(
|
| - scoped_refptr<NativePixmap> pixmap,
|
| +GpuMemoryBufferFactoryOzoneNativeBuffer::CreateImageForPixmaps(
|
| + int num_buffers,
|
| + ScopedVector<NativePixmap> pixmaps,
|
| const gfx::Size& size,
|
| - gfx::GpuMemoryBuffer::Format format,
|
| + const std::vector<gfx::GpuMemoryBuffer::Format>& formats,
|
| unsigned internalformat) {
|
| - if (pixmap->GetEGLClientBuffer()) {
|
| + bool are_pixmaps_EGLClientBufs = pixmaps[0]->GetEGLClientBuffer();
|
| + bool are_pixmaps_DmaBufs = pixmaps[0]->GetDmaBufFd();
|
| +
|
| + if (are_pixmaps_EGLClientBufs) {
|
| scoped_refptr<GLImageOzoneNativePixmap> image =
|
| new GLImageOzoneNativePixmap(size);
|
| - if (!image->Initialize(pixmap.get())) {
|
| + if (num_buffers != 1) {
|
| + NOTIMPLEMENTED();
|
| + return image;
|
| + }
|
| + if (!image->Initialize(pixmaps[0])) {
|
| return scoped_refptr<gfx::GLImage>();
|
| }
|
| return image;
|
| }
|
| - if (pixmap->GetDmaBufFd() > 0) {
|
| + if (are_pixmaps_DmaBufs) {
|
| scoped_refptr<GLImageOzoneNativePixmapDmaBuf> image =
|
| new GLImageOzoneNativePixmapDmaBuf(size, internalformat);
|
| - if (!image->Initialize(pixmap.get(), format)) {
|
| + if (!image->Initialize(num_buffers, pixmaps.get(), formats)) {
|
| return scoped_refptr<gfx::GLImage>();
|
| }
|
| return image;
|
|
|