| 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 | 10 |
| 11 namespace content { | 11 namespace content { |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 class GpuMemoryBufferFactoryImpl : public GpuMemoryBufferFactory { | 14 class GpuMemoryBufferFactoryImpl : public GpuMemoryBufferFactory { |
| 15 public: | 15 public: |
| 16 // Overridden from GpuMemoryBufferFactory: | 16 // Overridden from GpuMemoryBufferFactory: |
| 17 virtual gfx::GpuMemoryBufferHandle CreateGpuMemoryBuffer( | 17 virtual gfx::GpuMemoryBufferHandle CreateGpuMemoryBuffer( |
| 18 const gfx::GpuMemoryBufferHandle& handle, | 18 const gfx::GpuMemoryBufferHandle& handle, |
| 19 const gfx::Size& size, | 19 const gfx::Size& size, |
| 20 unsigned internalformat, | 20 gfx::GpuMemoryBuffer::Format format, |
| 21 unsigned usage) override { | 21 gfx::GpuMemoryBuffer::Usage usage) override { |
| 22 NOTREACHED(); | 22 NOTREACHED(); |
| 23 return gfx::GpuMemoryBufferHandle(); | 23 return gfx::GpuMemoryBufferHandle(); |
| 24 } | 24 } |
| 25 virtual void DestroyGpuMemoryBuffer( | 25 virtual void DestroyGpuMemoryBuffer( |
| 26 const gfx::GpuMemoryBufferHandle& handle) override { | 26 const gfx::GpuMemoryBufferHandle& handle) override { |
| 27 NOTREACHED(); | 27 NOTREACHED(); |
| 28 } | 28 } |
| 29 virtual scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer( | 29 virtual scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer( |
| 30 const gfx::GpuMemoryBufferHandle& handle, | 30 const gfx::GpuMemoryBufferHandle& handle, |
| 31 const gfx::Size& size, | 31 const gfx::Size& size, |
| 32 gfx::GpuMemoryBuffer::Format format, |
| 32 unsigned internalformat, | 33 unsigned internalformat, |
| 33 int client_id) override { | 34 int client_id) override { |
| 34 switch (handle.type) { | 35 switch (handle.type) { |
| 35 case gfx::SHARED_MEMORY_BUFFER: { | 36 case gfx::SHARED_MEMORY_BUFFER: { |
| 36 scoped_refptr<gfx::GLImageSharedMemory> image( | 37 scoped_refptr<gfx::GLImageSharedMemory> image( |
| 37 new gfx::GLImageSharedMemory(size, internalformat)); | 38 new gfx::GLImageSharedMemory(size, internalformat)); |
| 38 if (!image->Initialize(handle)) | 39 if (!image->Initialize(handle, format)) |
| 39 return NULL; | 40 return NULL; |
| 40 | 41 |
| 41 return image; | 42 return image; |
| 42 } | 43 } |
| 43 default: | 44 default: |
| 44 NOTREACHED(); | 45 NOTREACHED(); |
| 45 return scoped_refptr<gfx::GLImage>(); | 46 return scoped_refptr<gfx::GLImage>(); |
| 46 } | 47 } |
| 47 } | 48 } |
| 48 }; | 49 }; |
| 49 | 50 |
| 50 } // namespace | 51 } // namespace |
| 51 | 52 |
| 52 // static | 53 // static |
| 53 scoped_ptr<GpuMemoryBufferFactory> GpuMemoryBufferFactory::Create() { | 54 scoped_ptr<GpuMemoryBufferFactory> GpuMemoryBufferFactory::Create() { |
| 54 return make_scoped_ptr<GpuMemoryBufferFactory>( | 55 return make_scoped_ptr<GpuMemoryBufferFactory>( |
| 55 new GpuMemoryBufferFactoryImpl); | 56 new GpuMemoryBufferFactoryImpl); |
| 56 } | 57 } |
| 57 | 58 |
| 58 } // namespace content | 59 } // namespace content |
| OLD | NEW |