summaryrefslogtreecommitdiffstats
path: root/content/common/gpu/client/gpu_memory_buffer_impl.h
diff options
context:
space:
mode:
authorreveman@chromium.org <reveman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-22 23:13:09 +0000
committerreveman@chromium.org <reveman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-22 23:13:09 +0000
commitbc10f46abc6b4d6338fd1819b0360bc9115846f2 (patch)
tree34595adeaffa513af37b0caa4e9afd05cfcf65d0 /content/common/gpu/client/gpu_memory_buffer_impl.h
parent9f67dd0edac097ff862e9f92e988da2f5cb19348 (diff)
downloadchromium_src-bc10f46abc6b4d6338fd1819b0360bc9115846f2.zip
chromium_src-bc10f46abc6b4d6338fd1819b0360bc9115846f2.tar.gz
chromium_src-bc10f46abc6b4d6338fd1819b0360bc9115846f2.tar.bz2
Add multi-process GpuMemoryBuffer framework.
This adds a multi-process framework for reading/writing directly to memory that the 3D graphics hardware can use for rendering without any costly copying having to be done on the GPU process side. A GpuMemoryBuffer is a type of shared memory that can be accessed by the GPU. The high level procedure required to allocate this type of memory is almost exactly the same as that for standard shared memory. Only the browser process can allocated the memory and it needs to be shared and registered with the GPU process before it can be used. This also adds a GpuMemoryBuffer type that is backed by standard shared memory for testing purposes. TEST=gpu_unittests --gtest_filter=MockGpuMemoryBufferTest.Lifecycle BUG=261649 Review URL: https://codereview.chromium.org/19762004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@230248 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/common/gpu/client/gpu_memory_buffer_impl.h')
-rw-r--r--content/common/gpu/client/gpu_memory_buffer_impl.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/content/common/gpu/client/gpu_memory_buffer_impl.h b/content/common/gpu/client/gpu_memory_buffer_impl.h
new file mode 100644
index 0000000..3858c3f
--- /dev/null
+++ b/content/common/gpu/client/gpu_memory_buffer_impl.h
@@ -0,0 +1,45 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_H_
+#define CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "ui/gfx/gpu_memory_buffer.h"
+#include "ui/gfx/size.h"
+
+namespace content {
+
+// Provides common implementation of a GPU memory buffer based
+// on a shared memory handle.
+class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer {
+ public:
+ GpuMemoryBufferImpl(scoped_ptr<base::SharedMemory> shared_memory,
+ size_t width,
+ size_t height,
+ unsigned internalformat);
+ virtual ~GpuMemoryBufferImpl();
+
+ // Overridden from gfx::GpuMemoryBuffer:
+ virtual void Map(AccessMode mode, void** vaddr) OVERRIDE;
+ virtual void Unmap() OVERRIDE;
+ virtual bool IsMapped() const OVERRIDE;
+ virtual uint32 GetStride() const OVERRIDE;
+ virtual gfx::GpuMemoryBufferHandle GetHandle() const OVERRIDE;
+
+ static bool IsFormatValid(unsigned internalformat);
+ static size_t BytesPerPixel(unsigned internalformat);
+
+ private:
+ scoped_ptr<base::SharedMemory> shared_memory_;
+ const gfx::Size size_;
+ unsigned internalformat_;
+ bool mapped_;
+
+ DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferImpl);
+};
+
+} // namespace content
+
+#endif // CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_H_