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.h" | 5 #include "content/common/gpu/gpu_memory_buffer_factory.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "gpu/command_buffer/service/image_factory.h" |
8 #include "ui/gl/gl_image.h" | 9 #include "ui/gl/gl_image.h" |
9 #include "ui/gl/gl_image_shared_memory.h" | 10 #include "ui/gl/gl_image_shared_memory.h" |
10 #include "ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.h" | 11 #include "ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.h" |
11 | 12 |
12 namespace content { | 13 namespace content { |
13 namespace { | 14 namespace { |
14 | 15 |
15 class GpuMemoryBufferFactoryImpl : public GpuMemoryBufferFactory { | 16 class GpuMemoryBufferFactoryImpl : public GpuMemoryBufferFactory, |
| 17 public gpu::ImageFactory { |
16 public: | 18 public: |
17 // Overridden from GpuMemoryBufferFactory: | 19 // Overridden from GpuMemoryBufferFactory: |
18 virtual gfx::GpuMemoryBufferHandle CreateGpuMemoryBuffer( | 20 virtual gfx::GpuMemoryBufferHandle CreateGpuMemoryBuffer( |
19 const gfx::GpuMemoryBufferHandle& handle, | 21 const gfx::GpuMemoryBufferHandle& handle, |
20 const gfx::Size& size, | 22 const gfx::Size& size, |
21 gfx::GpuMemoryBuffer::Format format, | 23 gfx::GpuMemoryBuffer::Format format, |
22 gfx::GpuMemoryBuffer::Usage usage) override { | 24 gfx::GpuMemoryBuffer::Usage usage) override { |
23 switch (handle.type) { | 25 switch (handle.type) { |
24 case gfx::OZONE_NATIVE_BUFFER: | 26 case gfx::OZONE_NATIVE_BUFFER: |
25 return ozone_buffer_factory_.CreateGpuMemoryBuffer( | 27 return ozone_buffer_factory_.CreateGpuMemoryBuffer( |
26 handle.global_id, size, format, usage) | 28 handle.global_id, size, format, usage) |
27 ? handle | 29 ? handle |
28 : gfx::GpuMemoryBufferHandle(); | 30 : gfx::GpuMemoryBufferHandle(); |
29 default: | 31 default: |
30 NOTREACHED(); | 32 NOTREACHED(); |
31 return gfx::GpuMemoryBufferHandle(); | 33 return gfx::GpuMemoryBufferHandle(); |
32 } | 34 } |
33 } | 35 } |
34 virtual void DestroyGpuMemoryBuffer( | 36 virtual void DestroyGpuMemoryBuffer( |
35 const gfx::GpuMemoryBufferHandle& handle) override { | 37 const gfx::GpuMemoryBufferHandle& handle) override { |
36 switch (handle.type) { | 38 switch (handle.type) { |
37 case gfx::OZONE_NATIVE_BUFFER: | 39 case gfx::OZONE_NATIVE_BUFFER: |
38 ozone_buffer_factory_.DestroyGpuMemoryBuffer(handle.global_id); | 40 ozone_buffer_factory_.DestroyGpuMemoryBuffer(handle.global_id); |
39 break; | 41 break; |
40 default: | 42 default: |
41 NOTREACHED(); | 43 NOTREACHED(); |
42 break; | 44 break; |
43 } | 45 } |
44 } | 46 } |
| 47 virtual gpu::ImageFactory* AsImageFactory() override { return this; } |
| 48 |
| 49 // Overridden from gpu::ImageFactory: |
45 virtual scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer( | 50 virtual scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer( |
46 const gfx::GpuMemoryBufferHandle& handle, | 51 const gfx::GpuMemoryBufferHandle& handle, |
47 const gfx::Size& size, | 52 const gfx::Size& size, |
48 gfx::GpuMemoryBuffer::Format format, | 53 gfx::GpuMemoryBuffer::Format format, |
49 unsigned internalformat, | 54 unsigned internalformat, |
50 int client_id) override { | 55 int client_id) override { |
51 switch (handle.type) { | 56 switch (handle.type) { |
52 case gfx::SHARED_MEMORY_BUFFER: { | 57 case gfx::SHARED_MEMORY_BUFFER: { |
53 scoped_refptr<gfx::GLImageSharedMemory> image( | 58 scoped_refptr<gfx::GLImageSharedMemory> image( |
54 new gfx::GLImageSharedMemory(size, internalformat)); | 59 new gfx::GLImageSharedMemory(size, internalformat)); |
(...skipping 21 matching lines...) Expand all Loading... |
76 | 81 |
77 } // namespace | 82 } // namespace |
78 | 83 |
79 // static | 84 // static |
80 scoped_ptr<GpuMemoryBufferFactory> GpuMemoryBufferFactory::Create() { | 85 scoped_ptr<GpuMemoryBufferFactory> GpuMemoryBufferFactory::Create() { |
81 return make_scoped_ptr<GpuMemoryBufferFactory>( | 86 return make_scoped_ptr<GpuMemoryBufferFactory>( |
82 new GpuMemoryBufferFactoryImpl); | 87 new GpuMemoryBufferFactoryImpl); |
83 } | 88 } |
84 | 89 |
85 } // namespace content | 90 } // namespace content |
OLD | NEW |