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 "content/common/gpu/gpu_memory_buffer_factory_ozone_native_buffer.h" | 5 #include "content/common/gpu/gpu_memory_buffer_factory_ozone_native_buffer.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ui/gl/gl_image.h" | 8 #include "ui/gl/gl_image.h" |
9 #include "ui/ozone/public/surface_factory_ozone.h" | 9 #include "ui/ozone/public/surface_factory_ozone.h" |
10 | 10 |
11 namespace content { | 11 namespace content { |
12 namespace { | 12 namespace { |
13 | 13 |
14 const GpuMemoryBufferFactory::Configuration kSupportedConfigurations[] = { | 14 const GpuMemoryBufferFactory::Configuration kSupportedConfigurations[] = { |
15 { gfx::GpuMemoryBuffer::RGBA_8888, gfx::GpuMemoryBuffer::SCANOUT }, | 15 {gfx::GpuMemoryBuffer::RGBA_8888, gfx::GpuMemoryBuffer::SCANOUT}, |
16 { gfx::GpuMemoryBuffer::RGBX_8888, gfx::GpuMemoryBuffer::SCANOUT } | 16 {gfx::GpuMemoryBuffer::RGBX_8888, gfx::GpuMemoryBuffer::SCANOUT}, |
17 #if defined(USE_OZONE_GBM) | |
reveman
2015/05/11 16:40:56
There shouldn't be a USE_OZONE_GBM ifdef here. I t
dshwang
2015/05/14 12:25:46
Done.
| |
18 {gfx::GpuMemoryBuffer::BGRA_8888, gfx::GpuMemoryBuffer::MAP} | |
19 #endif | |
17 }; | 20 }; |
18 | 21 |
19 } // namespace | 22 } // namespace |
20 | 23 |
21 GpuMemoryBufferFactoryOzoneNativeBuffer:: | 24 GpuMemoryBufferFactoryOzoneNativeBuffer:: |
22 GpuMemoryBufferFactoryOzoneNativeBuffer() { | 25 GpuMemoryBufferFactoryOzoneNativeBuffer() { |
23 } | 26 } |
24 | 27 |
25 GpuMemoryBufferFactoryOzoneNativeBuffer:: | 28 GpuMemoryBufferFactoryOzoneNativeBuffer:: |
26 ~GpuMemoryBufferFactoryOzoneNativeBuffer() { | 29 ~GpuMemoryBufferFactoryOzoneNativeBuffer() { |
(...skipping 24 matching lines...) Expand all Loading... | |
51 } | 54 } |
52 | 55 |
53 gfx::GpuMemoryBufferHandle | 56 gfx::GpuMemoryBufferHandle |
54 GpuMemoryBufferFactoryOzoneNativeBuffer::CreateGpuMemoryBuffer( | 57 GpuMemoryBufferFactoryOzoneNativeBuffer::CreateGpuMemoryBuffer( |
55 gfx::GpuMemoryBufferId id, | 58 gfx::GpuMemoryBufferId id, |
56 const gfx::Size& size, | 59 const gfx::Size& size, |
57 gfx::GpuMemoryBuffer::Format format, | 60 gfx::GpuMemoryBuffer::Format format, |
58 gfx::GpuMemoryBuffer::Usage usage, | 61 gfx::GpuMemoryBuffer::Usage usage, |
59 int client_id, | 62 int client_id, |
60 gfx::PluginWindowHandle surface_handle) { | 63 gfx::PluginWindowHandle surface_handle) { |
61 if (!ozone_native_buffer_factory_.CreateGpuMemoryBuffer( | |
62 id, size, format, usage, client_id, surface_handle)) { | |
63 return gfx::GpuMemoryBufferHandle(); | |
64 } | |
65 gfx::GpuMemoryBufferHandle handle; | 64 gfx::GpuMemoryBufferHandle handle; |
66 handle.type = gfx::OZONE_NATIVE_BUFFER; | 65 handle.type = gfx::OZONE_NATIVE_BUFFER; |
67 handle.id = id; | 66 handle.id = id; |
67 if (!ozone_native_buffer_factory_.CreateGpuMemoryBuffer( | |
68 id, size, format, usage, client_id, surface_handle, &handle)) { | |
69 return gfx::GpuMemoryBufferHandle(); | |
70 } | |
68 return handle; | 71 return handle; |
69 } | 72 } |
70 | 73 |
71 void GpuMemoryBufferFactoryOzoneNativeBuffer::DestroyGpuMemoryBuffer( | 74 void GpuMemoryBufferFactoryOzoneNativeBuffer::DestroyGpuMemoryBuffer( |
72 gfx::GpuMemoryBufferId id, | 75 gfx::GpuMemoryBufferId id, |
73 int client_id) { | 76 int client_id) { |
74 ozone_native_buffer_factory_.DestroyGpuMemoryBuffer(id, client_id); | 77 ozone_native_buffer_factory_.DestroyGpuMemoryBuffer(id, client_id); |
75 } | 78 } |
76 | 79 |
77 gpu::ImageFactory* GpuMemoryBufferFactoryOzoneNativeBuffer::AsImageFactory() { | 80 gpu::ImageFactory* GpuMemoryBufferFactoryOzoneNativeBuffer::AsImageFactory() { |
78 return this; | 81 return this; |
79 } | 82 } |
80 | 83 |
81 scoped_refptr<gfx::GLImage> | 84 scoped_refptr<gfx::GLImage> |
82 GpuMemoryBufferFactoryOzoneNativeBuffer::CreateImageForGpuMemoryBuffer( | 85 GpuMemoryBufferFactoryOzoneNativeBuffer::CreateImageForGpuMemoryBuffer( |
83 const gfx::GpuMemoryBufferHandle& handle, | 86 const gfx::GpuMemoryBufferHandle& handle, |
84 const gfx::Size& size, | 87 const gfx::Size& size, |
85 gfx::GpuMemoryBuffer::Format format, | 88 gfx::GpuMemoryBuffer::Format format, |
86 unsigned internalformat, | 89 unsigned internalformat, |
87 int client_id) { | 90 int client_id) { |
88 DCHECK_EQ(handle.type, gfx::OZONE_NATIVE_BUFFER); | 91 DCHECK_EQ(handle.type, gfx::OZONE_NATIVE_BUFFER); |
89 return ozone_native_buffer_factory_.CreateImageForGpuMemoryBuffer( | 92 return ozone_native_buffer_factory_.CreateImageForGpuMemoryBuffer( |
90 handle.id, size, format, internalformat, client_id); | 93 handle.id, size, format, internalformat, client_id); |
91 } | 94 } |
92 | 95 |
93 } // namespace content | 96 } // namespace content |
OLD | NEW |