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

Unified Diff: content/common/gpu/client/gpu_memory_buffer_impl_ozone.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: formatting 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.cc
diff --git a/content/common/gpu/client/gpu_memory_buffer_impl_ozone.cc b/content/common/gpu/client/gpu_memory_buffer_impl_ozone.cc
index 784f75c6c900c124178e4723b99f84733424bea3..91ed84301296efa0f4d5f1bfa232473848aa76ad 100644
--- a/content/common/gpu/client/gpu_memory_buffer_impl_ozone.cc
+++ b/content/common/gpu/client/gpu_memory_buffer_impl_ozone.cc
@@ -4,27 +4,53 @@
#include "content/common/gpu/client/gpu_memory_buffer_impl.h"
+#include "base/bind.h"
#include "content/common/gpu/client/gpu_memory_buffer_impl_ozone_native_buffer.h"
#include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h"
namespace content {
-// static
-scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::Create(
+namespace {
+
+void AllocatedOzoneNativeBuffer(
const gfx::Size& size,
unsigned internalformat,
- unsigned usage) {
+ const GpuMemoryBufferImpl::CreationCallback& callback,
+ const gfx::GpuMemoryBufferHandle& handle) {
+ callback.Run(
+ GpuMemoryBufferImpl::CreateFromHandle(handle, size, internalformat));
+}
reveman 2014/09/09 17:18:26 As mentioned in the other comment. I think this wo
+
+} // namespace
+
+// static
+void GpuMemoryBufferImpl::Create(const gfx::Size& size,
+ unsigned internalformat,
+ unsigned usage,
+ const CreationCallback& callback) {
+ if (GpuMemoryBufferImplOzoneNativeBuffer::IsConfigurationSupported(
+ internalformat, usage)) {
+ GpuMemoryBufferImplOzoneNativeBuffer::AllocateOzoneNativeBufferForChildId(
+ size,
+ internalformat,
+ usage,
+ 0,
+ base::Bind(
+ &AllocatedOzoneNativeBuffer, size, internalformat, callback));
+ return;
+ }
+
if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported(
size, internalformat, usage)) {
scoped_ptr<GpuMemoryBufferImplSharedMemory> buffer(
new GpuMemoryBufferImplSharedMemory(size, internalformat));
- if (!buffer->Initialize())
- return scoped_ptr<GpuMemoryBufferImpl>();
-
- return buffer.PassAs<GpuMemoryBufferImpl>();
+ if (buffer->Initialize()) {
+ callback.Run(buffer.PassAs<GpuMemoryBufferImpl>());
+ return;
+ }
}
- return scoped_ptr<GpuMemoryBufferImpl>();
+ callback.Run(scoped_ptr<GpuMemoryBufferImpl>());
}
// static

Powered by Google App Engine
This is Rietveld 408576698