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 gfx::NativePixmapDmaBufStub(size, format, |
105 // On going in http://codereview.chromium.org/2705213005, crbug.com/584248. | 107 handle.native_pixmap_handle); |
106 NOTIMPLEMENTED(); | |
107 #endif | 108 #endif |
108 if (!pixmap.get()) { | 109 if (!pixmap.get()) { |
109 DLOG(ERROR) << "Failed to create pixmap from handle"; | 110 DLOG(ERROR) << "Failed to create pixmap from handle"; |
110 return nullptr; | 111 return nullptr; |
111 } | 112 } |
112 } else { | 113 } else { |
113 for (const auto& fd : handle.native_pixmap_handle.fds) { | 114 for (const auto& fd : handle.native_pixmap_handle.fds) { |
114 // 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 |
115 // out of scope. | 116 // out of scope. |
116 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... |
154 return nullptr; | 155 return nullptr; |
155 } | 156 } |
156 return image; | 157 return image; |
157 } | 158 } |
158 | 159 |
159 unsigned GpuMemoryBufferFactoryNativePixmap::RequiredTextureType() { | 160 unsigned GpuMemoryBufferFactoryNativePixmap::RequiredTextureType() { |
160 return GL_TEXTURE_EXTERNAL_OES; | 161 return GL_TEXTURE_EXTERNAL_OES; |
161 } | 162 } |
162 | 163 |
163 } // namespace gpu | 164 } // namespace gpu |
OLD | NEW |