Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / gpu / command_buffer / service / image_factory.h
blobc805db08fe8fe091c40469d8edbd3c2452bb4f18
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.
5 #ifndef GPU_COMMAND_BUFFER_SERVICE_IMAGE_FACTORY_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_IMAGE_FACTORY_H_
8 #include "base/memory/ref_counted.h"
9 #include "gpu/gpu_export.h"
10 #include "ui/gfx/geometry/size.h"
11 #include "ui/gfx/gpu_memory_buffer.h"
13 namespace gfx {
14 class GLImage;
17 namespace gpu {
18 struct Capabilities;
20 class GPU_EXPORT ImageFactory {
21 public:
22 ImageFactory();
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);
29 // Returns a valid GpuMemoryBuffer usage given a valid usage as defined by
30 // CHROMIUM_gpu_memory_buffer_image.
31 static gfx::BufferUsage ImageUsageToGpuMemoryBufferUsage(unsigned usage);
33 // Returns true if |internalformat| is compatible with |format|.
34 static bool IsImageFormatCompatibleWithGpuMemoryBufferFormat(
35 unsigned internalformat,
36 gfx::BufferFormat format);
38 // Returns true if |format| is supported by |capabilities|.
39 static bool IsGpuMemoryBufferFormatSupported(
40 gfx::BufferFormat format,
41 const Capabilities& capabilities);
43 // Returns true if |size| is valid for |format|.
44 static bool IsImageSizeValidForGpuMemoryBufferFormat(
45 const gfx::Size& size,
46 gfx::BufferFormat format);
48 // Creates a GLImage instance for GPU memory buffer identified by |handle|.
49 // |client_id| should be set to the client requesting the creation of instance
50 // and can be used by factory implementation to verify access rights.
51 virtual scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer(
52 const gfx::GpuMemoryBufferHandle& handle,
53 const gfx::Size& size,
54 gfx::BufferFormat format,
55 unsigned internalformat,
56 int client_id) = 0;
58 protected:
59 virtual ~ImageFactory();
62 } // namespace gpu
64 #endif // GPU_COMMAND_BUFFER_SERVICE_IMAGE_FACTORY_H_