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 "gpu/ipc/service/gpu_memory_buffer_factory_native_pixmap.h" | 5 #include "gpu/ipc/service/gpu_memory_buffer_factory_native_pixmap.h" |
| 6 | 6 |
| 7 #include "ui/gfx/client_native_pixmap.h" | 7 #include "ui/gfx/client_native_pixmap.h" |
| 8 #include "ui/gfx/native_pixmap.h" | 8 #include "ui/gfx/native_pixmap.h" |
| 9 #include "ui/gl/gl_image_native_pixmap.h" | 9 #include "ui/gl/gl_image_native_pixmap.h" |
| 10 | 10 |
| 11 #if defined(USE_OZONE) | 11 #if defined(USE_OZONE) |
| 12 #include "ui/ozone/public/ozone_platform.h" | 12 #include "ui/ozone/public/ozone_platform.h" |
| 13 #include "ui/ozone/public/surface_factory_ozone.h" | 13 #include "ui/ozone/public/surface_factory_ozone.h" |
| 14 #elif defined(OS_LINUX) | |
| 15 #include "ui/gfx/linux/native_pixmap_dmabuf_stub.h" | |
| 14 #endif | 16 #endif |
| 15 | 17 |
| 16 namespace gpu { | 18 namespace gpu { |
| 17 | 19 |
| 18 GpuMemoryBufferFactoryNativePixmap::GpuMemoryBufferFactoryNativePixmap() {} | 20 GpuMemoryBufferFactoryNativePixmap::GpuMemoryBufferFactoryNativePixmap() {} |
| 19 | 21 |
| 20 GpuMemoryBufferFactoryNativePixmap::~GpuMemoryBufferFactoryNativePixmap() {} | 22 GpuMemoryBufferFactoryNativePixmap::~GpuMemoryBufferFactoryNativePixmap() {} |
| 21 | 23 |
| 22 gfx::GpuMemoryBufferHandle | 24 gfx::GpuMemoryBufferHandle |
| 23 GpuMemoryBufferFactoryNativePixmap::CreateGpuMemoryBuffer( | 25 GpuMemoryBufferFactoryNativePixmap::CreateGpuMemoryBuffer( |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 } | 96 } |
| 95 | 97 |
| 96 // Create new pixmap from handle if one doesn't already exist. | 98 // Create new pixmap from handle if one doesn't already exist. |
| 97 if (!pixmap) { | 99 if (!pixmap) { |
| 98 #if defined(USE_OZONE) | 100 #if defined(USE_OZONE) |
| 99 pixmap = ui::OzonePlatform::GetInstance() | 101 pixmap = ui::OzonePlatform::GetInstance() |
| 100 ->GetSurfaceFactoryOzone() | 102 ->GetSurfaceFactoryOzone() |
| 101 ->CreateNativePixmapFromHandle(surface_handle, size, format, | 103 ->CreateNativePixmapFromHandle(surface_handle, size, format, |
| 102 handle.native_pixmap_handle); | 104 handle.native_pixmap_handle); |
| 103 #else | 105 #else |
| 104 // TODO(j.isorce): implement this to enable glCreateImageCHROMIUM on Linux. | 106 pixmap = new ui::NativePixmapDmaBufStub(size, format, |
|
reveman
2017/04/12 18:21:36
should we be using make_scoped_refptr here to make
Julien Isorce
2017/04/13 12:46:02
Sure, I will do it.
| |
| 105 NOTIMPLEMENTED(); | 107 handle.native_pixmap_handle); |
| 106 #endif | 108 #endif |
| 107 if (!pixmap.get()) { | 109 if (!pixmap.get()) { |
| 108 DLOG(ERROR) << "Failed to create pixmap from handle"; | 110 DLOG(ERROR) << "Failed to create pixmap from handle"; |
| 109 return nullptr; | 111 return nullptr; |
| 110 } | 112 } |
| 111 } else { | 113 } else { |
| 112 for (const auto& fd : handle.native_pixmap_handle.fds) { | 114 for (const auto& fd : handle.native_pixmap_handle.fds) { |
| 113 // Close the fd by wrapping it in a ScopedFD and letting it fall | 115 // Close the fd by wrapping it in a ScopedFD and letting it fall |
| 114 // out of scope. | 116 // out of scope. |
| 115 base::ScopedFD scoped_fd(fd.fd); | 117 base::ScopedFD scoped_fd(fd.fd); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 153 return nullptr; | 155 return nullptr; |
| 154 } | 156 } |
| 155 return image; | 157 return image; |
| 156 } | 158 } |
| 157 | 159 |
| 158 unsigned GpuMemoryBufferFactoryNativePixmap::RequiredTextureType() { | 160 unsigned GpuMemoryBufferFactoryNativePixmap::RequiredTextureType() { |
| 159 return GL_TEXTURE_EXTERNAL_OES; | 161 return GL_TEXTURE_EXTERNAL_OES; |
| 160 } | 162 } |
| 161 | 163 |
| 162 } // namespace gpu | 164 } // namespace gpu |
| OLD | NEW |