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

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..5460b9d83bfd5b9c82fb10425d4be2b3476f62c9
--- /dev/null
+++ b/content/common/gpu/client/gpu_memory_buffer_impl_ozone_native_buffer.cc
@@ -0,0 +1,109 @@
+// 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 "content/common/gpu/client/gpu_memory_buffer_factory_host.h"
+#include "ui/gl/gl_bindings.h"
+
+namespace content {
+namespace {
+const int kBrowserId = 1;
+uint32_t g_next_buffer_id = 1;
+uint32_t GetNextBufferId() {
reveman 2014/08/12 20:19:11 is this function worth having?
+ return g_next_buffer_id++;
+}
+} // 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,
+ int child_id,
+ GpuMemoryBufferFactoryHost* factory_host,
+ const AllocationCallback& callback) {
+ gfx::GpuMemoryBufferHandle handle;
+ handle.global_id.primary_id = GetNextBufferId();
+ handle.global_id.secondary_id = child_id;
+ handle.type = gfx::OZONE_NATIVE_BUFFER;
+ factory_host->CreateGpuMemoryBuffer(
+ handle, size, internalformat, usage, callback);
reveman 2014/08/12 20:19:11 Hm, it's a bit nasty to use a GpuMemoryBufferImpl:
achaulk 2014/08/12 21:38:02 Done.
+}
+
+// static
+bool GpuMemoryBufferImplOzoneNativeBuffer::IsFormatSupported(
+ unsigned internalformat) {
+ switch (internalformat) {
+ case GL_RGBA8_OES:
+ case GL_RGB8_OES:
reveman 2014/08/12 20:19:11 GL_RGB8_OES is not supported by the GpuMemoryBuffe
achaulk 2014/08/12 21:38:02 Okay, this is only used by the surfaceless code an
+ 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(
+ const gfx::Size& size,
reveman 2014/08/12 20:19:11 please remove |size| parameter if unused.
achaulk 2014/08/12 21:38:02 Done.
+ unsigned internalformat,
+ unsigned usage) {
+ return IsFormatSupported(internalformat) && IsUsageSupported(usage);
+}
+
+bool GpuMemoryBufferImplOzoneNativeBuffer::Initialize() {
+ id_.primary_id = GetNextBufferId();
+ id_.secondary_id = kBrowserId;
+ return true;
+}
+
+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