| 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 #ifndef CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_H_ | 5 #ifndef CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_H_ |
| 6 #define CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_H_ | 6 #define CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "ui/gfx/geometry/size.h" | 10 #include "ui/gfx/geometry/size.h" |
| 11 #include "ui/gfx/gpu_memory_buffer.h" | 11 #include "ui/gfx/gpu_memory_buffer.h" |
| 12 | 12 |
| 13 namespace gfx { | 13 namespace gfx { |
| 14 class GLImage; | 14 class GLImage; |
| 15 } | 15 } |
| 16 | 16 |
| 17 namespace gpu { |
| 18 class ImageFactory; |
| 19 } |
| 20 |
| 17 namespace content { | 21 namespace content { |
| 18 | 22 |
| 19 class GpuMemoryBufferFactory { | 23 class GpuMemoryBufferFactory { |
| 20 public: | 24 public: |
| 21 GpuMemoryBufferFactory() {} | 25 GpuMemoryBufferFactory() {} |
| 22 virtual ~GpuMemoryBufferFactory() {} | 26 virtual ~GpuMemoryBufferFactory() {} |
| 23 | 27 |
| 24 // Creates a new platform specific factory instance. | 28 // Creates a new platform specific factory instance. |
| 25 static scoped_ptr<GpuMemoryBufferFactory> Create(); | 29 static scoped_ptr<GpuMemoryBufferFactory> Create(); |
| 26 | 30 |
| 27 // Creates a GPU memory buffer instance from |handle|. Whether the storage for | 31 // Creates a GPU memory buffer instance from |handle|. Whether the storage for |
| 28 // the buffer is passed with the handle or allocated as part of buffer | 32 // the buffer is passed with the handle or allocated as part of buffer |
| 29 // creation depends on the type. A valid handle is returned on success. | 33 // creation depends on the type. A valid handle is returned on success. |
| 30 virtual gfx::GpuMemoryBufferHandle CreateGpuMemoryBuffer( | 34 virtual gfx::GpuMemoryBufferHandle CreateGpuMemoryBuffer( |
| 31 const gfx::GpuMemoryBufferHandle& handle, | 35 const gfx::GpuMemoryBufferHandle& handle, |
| 32 const gfx::Size& size, | 36 const gfx::Size& size, |
| 33 gfx::GpuMemoryBuffer::Format format, | 37 gfx::GpuMemoryBuffer::Format format, |
| 34 gfx::GpuMemoryBuffer::Usage usage) = 0; | 38 gfx::GpuMemoryBuffer::Usage usage) = 0; |
| 35 | 39 |
| 36 // Destroys GPU memory buffer identified by |handle|. | 40 // Destroys GPU memory buffer identified by |handle|. |
| 37 virtual void DestroyGpuMemoryBuffer( | 41 virtual void DestroyGpuMemoryBuffer( |
| 38 const gfx::GpuMemoryBufferHandle& handle) = 0; | 42 const gfx::GpuMemoryBufferHandle& handle) = 0; |
| 39 | 43 |
| 40 // Creates a GLImage instance for GPU memory buffer identified by |handle|. | 44 // Type-checking downcast routine. |
| 41 // |client_id| should be set to the client requesting the creation of instance | 45 virtual gpu::ImageFactory* AsImageFactory() = 0; |
| 42 // and can be used by factory implementation to verify access rights. | |
| 43 virtual scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer( | |
| 44 const gfx::GpuMemoryBufferHandle& handle, | |
| 45 const gfx::Size& size, | |
| 46 gfx::GpuMemoryBuffer::Format format, | |
| 47 unsigned internalformat, | |
| 48 int client_id) = 0; | |
| 49 | 46 |
| 50 private: | 47 private: |
| 51 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferFactory); | 48 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferFactory); |
| 52 }; | 49 }; |
| 53 | 50 |
| 54 } // namespace content | 51 } // namespace content |
| 55 | 52 |
| 56 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_H_ | 53 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_H_ |
| OLD | NEW |