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

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

Issue 540443002: Enable sync allocation of GpuMemoryBuffers from the browser process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
index fe2681bf051df7b4e5efe3aef6b7db461204fe2e..399e6c2c9157b5a1ac86851a1313722add54d30c 100644
--- 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
@@ -14,6 +14,15 @@ namespace {
base::StaticAtomicSequenceNumber g_next_buffer_id;
+void AllocatedOzoneNativeBuffer(
+ const gfx::Size& size,
+ unsigned internalformat,
+ const GpuMemoryBufferImpl::CreationCallback& callback,
+ const gfx::GpuMemoryBufferHandle& handle) {
+ callback.Run(
+ GpuMemoryBufferImpl::CreateFromHandle(handle, size, internalformat));
+}
+
} // namespace
GpuMemoryBufferImplOzoneNativeBuffer::GpuMemoryBufferImplOzoneNativeBuffer(
@@ -26,6 +35,26 @@ GpuMemoryBufferImplOzoneNativeBuffer::~GpuMemoryBufferImplOzoneNativeBuffer() {
}
// static
+void GpuMemoryBufferImplOzoneNativeBuffer::Create(
+ const gfx::Size& size,
+ unsigned internalformat,
+ unsigned usage,
+ const CreationCallback& callback) {
+ gfx::GpuMemoryBufferHandle handle;
+ handle.global_id.primary_id = g_next_buffer_id.GetNext();
+ // This code makes an assumption that client_id for GPU channel using this
+ // buffer is zero.
+ handle.global_id.secondary_id = 0;
+ handle.type = gfx::OZONE_NATIVE_BUFFER;
+ GpuMemoryBufferFactoryHost::GetInstance()->CreateGpuMemoryBuffer(
+ handle,
+ size,
+ internalformat,
+ usage,
+ base::Bind(&AllocatedOzoneNativeBuffer, size, internalformat, callback));
+}
+
+// static
void GpuMemoryBufferImplOzoneNativeBuffer::AllocateOzoneNativeBufferForChildId(
const gfx::Size& size,
unsigned internalformat,
@@ -33,8 +62,7 @@ void GpuMemoryBufferImplOzoneNativeBuffer::AllocateOzoneNativeBufferForChildId(
int child_id,
const AllocationCallback& callback) {
gfx::GpuMemoryBufferHandle handle;
- // +1 ensures we always get non-zero IDs.
- handle.global_id.primary_id = g_next_buffer_id.GetNext() + 1;
+ handle.global_id.primary_id = g_next_buffer_id.GetNext();
handle.global_id.secondary_id = child_id;
handle.type = gfx::OZONE_NATIVE_BUFFER;
GpuMemoryBufferFactoryHost::GetInstance()->CreateGpuMemoryBuffer(

Powered by Google App Engine
This is Rietveld 408576698