| 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 GPU_COMMAND_BUFFER_SERVICE_IMAGE_FACTORY_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_IMAGE_FACTORY_H_ |
| 6 #define GPU_COMMAND_BUFFER_SERVICE_IMAGE_FACTORY_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_IMAGE_FACTORY_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "gpu/gpu_export.h" | 9 #include "gpu/gpu_export.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 gl { | 13 namespace gl { |
| 14 class GLImage; | 14 class GLImage; |
| 15 } | 15 } |
| 16 | 16 |
| 17 namespace gpu { | 17 namespace gpu { |
| 18 struct Capabilities; | |
| 19 | 18 |
| 20 class GPU_EXPORT ImageFactory { | 19 class GPU_EXPORT ImageFactory { |
| 21 public: | 20 public: |
| 22 ImageFactory(); | 21 ImageFactory(); |
| 23 | 22 |
| 24 // Returns a valid GpuMemoryBuffer format given a valid internalformat as | |
| 25 // defined by CHROMIUM_gpu_memory_buffer_image. | |
| 26 static gfx::BufferFormat DefaultBufferFormatForImageFormat( | |
| 27 unsigned internalformat); | |
| 28 | |
| 29 // Returns true if |internalformat| is compatible with |format|. | |
| 30 static bool IsImageFormatCompatibleWithGpuMemoryBufferFormat( | |
| 31 unsigned internalformat, | |
| 32 gfx::BufferFormat format); | |
| 33 | |
| 34 // Returns true if |format| is supported by |capabilities|. | |
| 35 static bool IsGpuMemoryBufferFormatSupported( | |
| 36 gfx::BufferFormat format, | |
| 37 const Capabilities& capabilities); | |
| 38 | |
| 39 // Returns true if |size| is valid for |format|. | |
| 40 static bool IsImageSizeValidForGpuMemoryBufferFormat( | |
| 41 const gfx::Size& size, | |
| 42 gfx::BufferFormat format); | |
| 43 | |
| 44 // Creates a GLImage instance for GPU memory buffer identified by |handle|. | 23 // Creates a GLImage instance for GPU memory buffer identified by |handle|. |
| 45 // |client_id| should be set to the client requesting the creation of instance | 24 // |client_id| should be set to the client requesting the creation of instance |
| 46 // and can be used by factory implementation to verify access rights. | 25 // and can be used by factory implementation to verify access rights. |
| 47 virtual scoped_refptr<gl::GLImage> CreateImageForGpuMemoryBuffer( | 26 virtual scoped_refptr<gl::GLImage> CreateImageForGpuMemoryBuffer( |
| 48 const gfx::GpuMemoryBufferHandle& handle, | 27 const gfx::GpuMemoryBufferHandle& handle, |
| 49 const gfx::Size& size, | 28 const gfx::Size& size, |
| 50 gfx::BufferFormat format, | 29 gfx::BufferFormat format, |
| 51 unsigned internalformat, | 30 unsigned internalformat, |
| 52 int client_id) = 0; | 31 int client_id) = 0; |
| 53 | 32 |
| 54 protected: | 33 protected: |
| 55 virtual ~ImageFactory(); | 34 virtual ~ImageFactory(); |
| 56 }; | 35 }; |
| 57 | 36 |
| 58 } // namespace gpu | 37 } // namespace gpu |
| 59 | 38 |
| 60 #endif // GPU_COMMAND_BUFFER_SERVICE_IMAGE_FACTORY_H_ | 39 #endif // GPU_COMMAND_BUFFER_SERVICE_IMAGE_FACTORY_H_ |
| OLD | NEW |