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