OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/common/gpu/gpu_memory_buffer_factory.h" |
| 6 |
| 7 #include "ui/gl/gl_image.h" |
| 8 #include "ui/gl/gl_image_shared_memory.h" |
| 9 |
| 10 namespace content { |
| 11 namespace { |
| 12 |
| 13 class GpuMemoryBufferFactoryImpl : public GpuMemoryBufferFactory { |
| 14 public: |
| 15 // Overridden from GpuMemoryBufferFactory: |
| 16 virtual gfx::GpuMemoryBufferHandle CreateGpuMemoryBuffer( |
| 17 const gfx::GpuMemoryBufferHandle& handle, |
| 18 const gfx::Size& size, |
| 19 unsigned internalformat, |
| 20 unsigned usage) OVERRIDE { |
| 21 NOTREACHED(); |
| 22 return gfx::GpuMemoryBufferHandle(); |
| 23 } |
| 24 virtual void DestroyGpuMemoryBuffer( |
| 25 const gfx::GpuMemoryBufferHandle& handle) OVERRIDE { |
| 26 NOTREACHED(); |
| 27 } |
| 28 virtual scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer( |
| 29 const gfx::GpuMemoryBufferHandle& handle, |
| 30 const gfx::Size& size, |
| 31 unsigned internalformat, |
| 32 int client_id) OVERRIDE { |
| 33 switch (handle.type) { |
| 34 case gfx::SHARED_MEMORY_BUFFER: { |
| 35 scoped_refptr<gfx::GLImageSharedMemory> image( |
| 36 new gfx::GLImageSharedMemory(size, internalformat)); |
| 37 if (!image->Initialize(handle)) |
| 38 return NULL; |
| 39 |
| 40 return image; |
| 41 } |
| 42 default: |
| 43 NOTREACHED(); |
| 44 return scoped_refptr<gfx::GLImage>(); |
| 45 } |
| 46 } |
| 47 }; |
| 48 |
| 49 } // namespace |
| 50 |
| 51 // static |
| 52 scoped_ptr<GpuMemoryBufferFactory> GpuMemoryBufferFactory::Create() { |
| 53 return make_scoped_ptr<GpuMemoryBufferFactory>( |
| 54 new GpuMemoryBufferFactoryImpl); |
| 55 } |
| 56 |
| 57 } // namespace content |
OLD | NEW |