| 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 "content/common/gpu/gpu_memory_buffer_factory_x11_pixmap.h" | 8 #include "content/common/gpu/gpu_memory_buffer_factory_x11_pixmap.h" |
| 9 #include "ui/gl/gl_image.h" | 9 #include "ui/gl/gl_image.h" |
| 10 #include "ui/gl/gl_image_shared_memory.h" | 10 #include "ui/gl/gl_image_shared_memory.h" |
| 11 | 11 |
| 12 namespace content { | 12 namespace content { |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 class GpuMemoryBufferFactoryImpl : public GpuMemoryBufferFactory { | 15 class GpuMemoryBufferFactoryImpl : public GpuMemoryBufferFactory { |
| 16 public: | 16 public: |
| 17 // Overridden from GpuMemoryBufferFactory: | 17 // Overridden from GpuMemoryBufferFactory: |
| 18 virtual gfx::GpuMemoryBufferHandle CreateGpuMemoryBuffer( | 18 virtual gfx::GpuMemoryBufferHandle CreateGpuMemoryBuffer( |
| 19 const gfx::GpuMemoryBufferHandle& handle, | 19 const gfx::GpuMemoryBufferHandle& handle, |
| 20 const gfx::Size& size, | 20 const gfx::Size& size, |
| 21 unsigned internalformat, | 21 unsigned internalformat, |
| 22 unsigned usage) OVERRIDE { | 22 unsigned usage) override { |
| 23 switch (handle.type) { | 23 switch (handle.type) { |
| 24 case gfx::X11_PIXMAP_BUFFER: | 24 case gfx::X11_PIXMAP_BUFFER: |
| 25 x11_pixmap_factory_.CreateGpuMemoryBuffer(handle.global_id, | 25 x11_pixmap_factory_.CreateGpuMemoryBuffer(handle.global_id, |
| 26 handle.pixmap); | 26 handle.pixmap); |
| 27 return handle; | 27 return handle; |
| 28 default: | 28 default: |
| 29 NOTREACHED(); | 29 NOTREACHED(); |
| 30 return gfx::GpuMemoryBufferHandle(); | 30 return gfx::GpuMemoryBufferHandle(); |
| 31 } | 31 } |
| 32 } | 32 } |
| 33 virtual void DestroyGpuMemoryBuffer( | 33 virtual void DestroyGpuMemoryBuffer( |
| 34 const gfx::GpuMemoryBufferHandle& handle) OVERRIDE { | 34 const gfx::GpuMemoryBufferHandle& handle) override { |
| 35 switch (handle.type) { | 35 switch (handle.type) { |
| 36 case gfx::X11_PIXMAP_BUFFER: | 36 case gfx::X11_PIXMAP_BUFFER: |
| 37 x11_pixmap_factory_.DestroyGpuMemoryBuffer(handle.global_id); | 37 x11_pixmap_factory_.DestroyGpuMemoryBuffer(handle.global_id); |
| 38 break; | 38 break; |
| 39 default: | 39 default: |
| 40 NOTREACHED(); | 40 NOTREACHED(); |
| 41 break; | 41 break; |
| 42 } | 42 } |
| 43 } | 43 } |
| 44 virtual scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer( | 44 virtual scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer( |
| 45 const gfx::GpuMemoryBufferHandle& handle, | 45 const gfx::GpuMemoryBufferHandle& handle, |
| 46 const gfx::Size& size, | 46 const gfx::Size& size, |
| 47 unsigned internalformat, | 47 unsigned internalformat, |
| 48 int client_id) OVERRIDE { | 48 int client_id) override { |
| 49 switch (handle.type) { | 49 switch (handle.type) { |
| 50 case gfx::SHARED_MEMORY_BUFFER: { | 50 case gfx::SHARED_MEMORY_BUFFER: { |
| 51 scoped_refptr<gfx::GLImageSharedMemory> image( | 51 scoped_refptr<gfx::GLImageSharedMemory> image( |
| 52 new gfx::GLImageSharedMemory(size, internalformat)); | 52 new gfx::GLImageSharedMemory(size, internalformat)); |
| 53 if (!image->Initialize(handle)) | 53 if (!image->Initialize(handle)) |
| 54 return NULL; | 54 return NULL; |
| 55 | 55 |
| 56 return image; | 56 return image; |
| 57 } | 57 } |
| 58 case gfx::X11_PIXMAP_BUFFER: | 58 case gfx::X11_PIXMAP_BUFFER: |
| (...skipping 15 matching lines...) Expand all Loading... |
| 74 | 74 |
| 75 } // namespace | 75 } // namespace |
| 76 | 76 |
| 77 // static | 77 // static |
| 78 scoped_ptr<GpuMemoryBufferFactory> GpuMemoryBufferFactory::Create() { | 78 scoped_ptr<GpuMemoryBufferFactory> GpuMemoryBufferFactory::Create() { |
| 79 return make_scoped_ptr<GpuMemoryBufferFactory>( | 79 return make_scoped_ptr<GpuMemoryBufferFactory>( |
| 80 new GpuMemoryBufferFactoryImpl); | 80 new GpuMemoryBufferFactoryImpl); |
| 81 } | 81 } |
| 82 | 82 |
| 83 } // namespace content | 83 } // namespace content |
| OLD | NEW |