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

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

Issue 458313002: Browser side OZONE_NATIVE_BUFFER allocation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months 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_ozone_native_buffer.cc
diff --git a/content/common/gpu/client/gpu_memory_buffer_impl_ozone_native_buffer.cc b/content/common/gpu/client/gpu_memory_buffer_impl_ozone_native_buffer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..570f9362aa69c8e6bc27e8f7ede1b5c1cf9c96b7
--- /dev/null
+++ b/content/common/gpu/client/gpu_memory_buffer_impl_ozone_native_buffer.cc
@@ -0,0 +1,115 @@
+// Copyright 2014 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_ozone_native_buffer.h"
+
+#include "base/bind.h"
+#include "content/common/gpu/client/gpu_memory_buffer_factory_host.h"
+#include "ui/gl/gl_bindings.h"
+
+namespace content {
+namespace {
reveman 2014/08/13 08:03:11 nit: blank line between "namespace {" and first va
+const int kBrowserId = 1;
reveman 2014/08/13 08:03:11 I don't think this should be part of this patch.
achaulk 2014/08/13 15:53:19 Done.
+uint32_t g_next_buffer_id = 1;
+
+void GpuAllocationCallback(
reveman 2014/08/13 08:03:11 I'd make this a private member of GpuMemoryBufferI
achaulk 2014/08/13 15:53:20 Done.
+ const GpuMemoryBufferImpl::AllocationCallback& callback,
+ const gfx::GpuMemoryBufferHandle& handle) {
+ callback.Run(handle);
+}
reveman 2014/08/13 08:03:11 nit: blank line between function and "} // namesp
+} // namespace
+
+GpuMemoryBufferImplOzoneNativeBuffer::GpuMemoryBufferImplOzoneNativeBuffer(
+ const gfx::Size& size,
+ unsigned internalformat)
+ : GpuMemoryBufferImpl(size, internalformat) {
+}
+
+GpuMemoryBufferImplOzoneNativeBuffer::~GpuMemoryBufferImplOzoneNativeBuffer() {
+}
+
+// static
+void GpuMemoryBufferImplOzoneNativeBuffer::AllocateSharedMemoryForChildProcess(
+ const gfx::Size& size,
+ unsigned internalformat,
+ unsigned usage,
+ base::ProcessHandle child_process,
reveman 2014/08/13 08:03:11 remove this parameter if unused.
achaulk 2014/08/13 15:53:19 Done.
+ int child_id,
+ GpuMemoryBufferFactoryHost* factory_host,
+ const AllocationCallback& callback) {
+ gfx::GpuMemoryBufferHandle handle;
+ handle.global_id.primary_id = g_next_buffer_id++;
+ handle.global_id.secondary_id = child_id;
+ handle.type = gfx::OZONE_NATIVE_BUFFER;
+ factory_host->CreateGpuMemoryBuffer(
+ handle,
+ size,
+ internalformat,
+ usage,
+ base::Bind(&GpuAllocationCallback, callback));
+}
+
+// static
+bool GpuMemoryBufferImplOzoneNativeBuffer::IsFormatSupported(
+ unsigned internalformat) {
+ switch (internalformat) {
+ case GL_RGBA8_OES:
+ return true;
+ default:
+ return false;
+ }
+}
+
+// static
+bool GpuMemoryBufferImplOzoneNativeBuffer::IsUsageSupported(unsigned usage) {
+ switch (usage) {
+ case GL_IMAGE_SCANOUT_CHROMIUM:
+ return true;
+ default:
+ return false;
+ }
+}
+
+// static
+bool GpuMemoryBufferImplOzoneNativeBuffer::IsConfigurationSupported(
+ unsigned internalformat,
+ unsigned usage) {
+ return IsFormatSupported(internalformat) && IsUsageSupported(usage);
+}
+
+bool GpuMemoryBufferImplOzoneNativeBuffer::Initialize() {
+ id_.primary_id = g_next_buffer_id++;
+ id_.secondary_id = kBrowserId;
+ return true;
+}
reveman 2014/08/13 08:03:11 remove this function completely as it doesn't work
achaulk 2014/08/13 15:53:19 Done.
+
+bool GpuMemoryBufferImplOzoneNativeBuffer::InitializeFromHandle(
+ const gfx::GpuMemoryBufferHandle& handle) {
+ id_ = handle.global_id;
+ return true;
+}
+
+void* GpuMemoryBufferImplOzoneNativeBuffer::Map() {
+ NOTREACHED();
+ return NULL;
+}
+
+void GpuMemoryBufferImplOzoneNativeBuffer::Unmap() {
+ NOTREACHED();
+}
+
+uint32 GpuMemoryBufferImplOzoneNativeBuffer::GetStride() const {
+ NOTREACHED();
+ return 0;
+}
+
+gfx::GpuMemoryBufferHandle GpuMemoryBufferImplOzoneNativeBuffer::GetHandle()
+ const {
+ gfx::GpuMemoryBufferHandle handle;
+ handle.type = gfx::OZONE_NATIVE_BUFFER;
+ handle.global_id = id_;
+ return handle;
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698