| 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 "ui/gl/gl_image.h" | 8 #include "ui/gl/gl_image.h" |
| 9 #include "ui/gl/gl_image_shared_memory.h" | 9 #include "ui/gl/gl_image_shared_memory.h" |
| 10 #include "ui/gl/gl_image_surface_texture.h" | 10 #include "ui/gl/gl_image_surface_texture.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 NOTREACHED(); | 23 NOTREACHED(); |
| 24 return gfx::GpuMemoryBufferHandle(); | 24 return gfx::GpuMemoryBufferHandle(); |
| 25 } | 25 } |
| 26 virtual void DestroyGpuMemoryBuffer( | 26 virtual void DestroyGpuMemoryBuffer( |
| 27 const gfx::GpuMemoryBufferHandle& handle) OVERRIDE { | 27 const gfx::GpuMemoryBufferHandle& handle) override { |
| 28 NOTREACHED(); | 28 NOTREACHED(); |
| 29 } | 29 } |
| 30 virtual scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer( | 30 virtual scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer( |
| 31 const gfx::GpuMemoryBufferHandle& handle, | 31 const gfx::GpuMemoryBufferHandle& handle, |
| 32 const gfx::Size& size, | 32 const gfx::Size& size, |
| 33 unsigned internalformat, | 33 unsigned internalformat, |
| 34 int client_id) OVERRIDE { | 34 int client_id) override { |
| 35 switch (handle.type) { | 35 switch (handle.type) { |
| 36 case gfx::SHARED_MEMORY_BUFFER: { | 36 case gfx::SHARED_MEMORY_BUFFER: { |
| 37 scoped_refptr<gfx::GLImageSharedMemory> image( | 37 scoped_refptr<gfx::GLImageSharedMemory> image( |
| 38 new gfx::GLImageSharedMemory(size, internalformat)); | 38 new gfx::GLImageSharedMemory(size, internalformat)); |
| 39 if (!image->Initialize(handle)) | 39 if (!image->Initialize(handle)) |
| 40 return NULL; | 40 return NULL; |
| 41 | 41 |
| 42 return image; | 42 return image; |
| 43 } | 43 } |
| 44 case gfx::SURFACE_TEXTURE_BUFFER: { | 44 case gfx::SURFACE_TEXTURE_BUFFER: { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 58 | 58 |
| 59 } // namespace | 59 } // namespace |
| 60 | 60 |
| 61 // static | 61 // static |
| 62 scoped_ptr<GpuMemoryBufferFactory> GpuMemoryBufferFactory::Create() { | 62 scoped_ptr<GpuMemoryBufferFactory> GpuMemoryBufferFactory::Create() { |
| 63 return make_scoped_ptr<GpuMemoryBufferFactory>( | 63 return make_scoped_ptr<GpuMemoryBufferFactory>( |
| 64 new GpuMemoryBufferFactoryImpl); | 64 new GpuMemoryBufferFactoryImpl); |
| 65 } | 65 } |
| 66 | 66 |
| 67 } // namespace content | 67 } // namespace content |
| OLD | NEW |