summaryrefslogtreecommitdiffstats
path: root/chromium/content/common/gpu/client/gpu_memory_buffer_impl.h
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/content/common/gpu/client/gpu_memory_buffer_impl.h')
-rw-r--r--chromium/content/common/gpu/client/gpu_memory_buffer_impl.h41
1 files changed, 34 insertions, 7 deletions
diff --git a/chromium/content/common/gpu/client/gpu_memory_buffer_impl.h b/chromium/content/common/gpu/client/gpu_memory_buffer_impl.h
index ee85f0f7b57..95bddccff2e 100644
--- a/chromium/content/common/gpu/client/gpu_memory_buffer_impl.h
+++ b/chromium/content/common/gpu/client/gpu_memory_buffer_impl.h
@@ -5,6 +5,7 @@
#ifndef CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_H_
#define CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_H_
+#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
#include "ui/gfx/gpu_memory_buffer.h"
#include "ui/gfx/size.h"
@@ -14,25 +15,51 @@ namespace content {
// Provides common implementation of a GPU memory buffer.
class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer {
public:
- static scoped_ptr<GpuMemoryBufferImpl> Create(
- gfx::GpuMemoryBufferHandle handle,
- gfx::Size size,
- unsigned internalformat);
+ typedef base::Callback<void(const gfx::GpuMemoryBufferHandle& handle)>
+ AllocationCallback;
virtual ~GpuMemoryBufferImpl();
+ // Creates a GPU memory buffer instance with |size| and |internalformat| for
+ // |usage|.
+ static scoped_ptr<GpuMemoryBufferImpl> Create(const gfx::Size& size,
+ unsigned internalformat,
+ unsigned usage);
+
+ // Allocates a GPU memory buffer with |size| and |internalformat| for |usage|
+ // by |child_process|. The |handle| returned can be used by the
+ // |child_process| to create an instance of this class.
+ static void AllocateForChildProcess(const gfx::Size& size,
+ unsigned internalformat,
+ unsigned usage,
+ base::ProcessHandle child_process,
+ const AllocationCallback& callback);
+
+ // Creates an instance from the given |handle|. |size| and |internalformat|
+ // should match what was used to allocate the |handle|.
+ static scoped_ptr<GpuMemoryBufferImpl> CreateFromHandle(
+ gfx::GpuMemoryBufferHandle handle,
+ const gfx::Size& size,
+ unsigned internalformat);
+
+ // Returns true if |internalformat| is a format recognized by this base class.
static bool IsFormatValid(unsigned internalformat);
+
+ // Returns true if |usage| is recognized by this base class.
+ static bool IsUsageValid(unsigned usage);
+
+ // Returns the number of bytes per pixel that must be used by an
+ // implementation when using |internalformat|.
static size_t BytesPerPixel(unsigned internalformat);
// Overridden from gfx::GpuMemoryBuffer:
virtual bool IsMapped() const OVERRIDE;
- virtual uint32 GetStride() const OVERRIDE;
protected:
- GpuMemoryBufferImpl(gfx::Size size, unsigned internalformat);
+ GpuMemoryBufferImpl(const gfx::Size& size, unsigned internalformat);
const gfx::Size size_;
- unsigned internalformat_;
+ const unsigned internalformat_;
bool mapped_;
DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferImpl);