Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(219)

Unified Diff: content/common/gpu/client/gpu_memory_buffer_impl_shm.cc

Issue 77023002: gpu: Add IOSurface backed GpuMemoryBuffer implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix overflow check Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/common/gpu/client/gpu_memory_buffer_impl_shm.cc
diff --git a/content/common/gpu/client/gpu_memory_buffer_impl_shm.cc b/content/common/gpu/client/gpu_memory_buffer_impl_shm.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7af4452be1aafb62965f1b6a04fb98ac6bcc6983
--- /dev/null
+++ b/content/common/gpu/client/gpu_memory_buffer_impl_shm.cc
@@ -0,0 +1,56 @@
+// 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.
+
+#include "content/common/gpu/client/gpu_memory_buffer_impl_shm.h"
+
+#include "base/logging.h"
+
+namespace content {
+
+GpuMemoryBufferImplShm::GpuMemoryBufferImplShm(
+ gfx::Size size, unsigned internalformat)
+ : GpuMemoryBufferImpl(size, internalformat) {
+}
+
+GpuMemoryBufferImplShm::~GpuMemoryBufferImplShm() {
+}
+
+bool GpuMemoryBufferImplShm::Initialize(gfx::GpuMemoryBufferHandle handle) {
+ if (!base::SharedMemory::IsHandleValid(handle.handle))
+ return false;
+ shared_memory_.reset(new base::SharedMemory(handle.handle, false));
+ DCHECK(!shared_memory_->memory());
+ return true;
+}
+
+bool GpuMemoryBufferImplShm::InitializeFromSharedMemory(
+ scoped_ptr<base::SharedMemory> shared_memory) {
+ shared_memory_ = shared_memory.Pass();
+ DCHECK(!shared_memory_->memory());
+ return true;
+}
+
+void GpuMemoryBufferImplShm::Map(AccessMode mode, void** vaddr) {
+ DCHECK(!mapped_);
+ *vaddr = NULL;
+ if (!shared_memory_->Map(size_.GetArea() * BytesPerPixel(internalformat_)))
+ return;
+ *vaddr = shared_memory_->memory();
+ mapped_ = true;
+}
+
+void GpuMemoryBufferImplShm::Unmap() {
+ DCHECK(mapped_);
+ shared_memory_->Unmap();
+ mapped_ = false;
+}
+
+gfx::GpuMemoryBufferHandle GpuMemoryBufferImplShm::GetHandle() const {
+ gfx::GpuMemoryBufferHandle handle;
+ handle.type = gfx::SHARED_MEMORY_BUFFER;
+ handle.handle = shared_memory_->handle();
+ return handle;
+}
+
+} // namespace content
« no previous file with comments | « content/common/gpu/client/gpu_memory_buffer_impl_shm.h ('k') | content/common/gpu/client/gpu_memory_buffer_impl_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698