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"
19 class GPU_EXPORT ImageFactory
{
23 // Returns a valid GpuMemoryBuffer format given a valid internalformat as
24 // defined by CHROMIUM_gpu_memory_buffer_image.
25 static gfx::GpuMemoryBuffer::Format
ImageFormatToGpuMemoryBufferFormat(
26 unsigned internalformat
);
28 // Returns a valid GpuMemoryBuffer usage given a valid usage as defined by
29 // CHROMIUM_gpu_memory_buffer_image.
30 static gfx::GpuMemoryBuffer::Usage
ImageUsageToGpuMemoryBufferUsage(
33 // Returns true if |internalformat| is compatible with |format|.
34 static bool IsImageFormatCompatibleWithGpuMemoryBufferFormat(
35 unsigned internalformat
,
36 gfx::GpuMemoryBuffer::Format format
);
38 // Creates a GLImage instance for GPU memory buffer identified by |handle|.
39 // |client_id| should be set to the client requesting the creation of instance
40 // and can be used by factory implementation to verify access rights.
41 virtual scoped_refptr
<gfx::GLImage
> CreateImageForGpuMemoryBuffer(
42 const gfx::GpuMemoryBufferHandle
& handle
,
43 const gfx::Size
& size
,
44 gfx::GpuMemoryBuffer::Format format
,
45 unsigned internalformat
,
49 virtual ~ImageFactory();
54 #endif // GPU_COMMAND_BUFFER_SERVICE_IMAGE_FACTORY_H_