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

Unified Diff: content/renderer/render_thread_impl.cc

Issue 600693002: content: Cleanup GpuMemoryBufferImpl destruction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove scoped_refptr<> from sender param of DeletedGpuMemoryBuffer 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
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_thread_impl.cc
diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc
index 3842bca15684605283d42e4376996aeb1eb0c7fa..ade02fb0747d11cefeceb0bd2e4d440b2a0392b6 100644
--- a/content/renderer/render_thread_impl.cc
+++ b/content/renderer/render_thread_impl.cc
@@ -318,6 +318,13 @@ blink::WebGraphicsContext3D::Attributes GetOffscreenAttribs() {
return attributes;
}
+void DeletedGpuMemoryBuffer(ThreadSafeSender* sender,
+ gfx::GpuMemoryBufferType type,
+ const gfx::GpuMemoryBufferId& id) {
+ TRACE_EVENT0("renderer", "RenderThreadImpl::DeletedGpuMemoryBuffer");
+ sender->Send(new ChildProcessHostMsg_DeletedGpuMemoryBuffer(type, id));
+}
+
} // namespace
// For measuring memory usage after each task. Behind a command line flag.
@@ -1277,6 +1284,8 @@ scoped_ptr<gfx::GpuMemoryBuffer> RenderThreadImpl::AllocateGpuMemoryBuffer(
size_t height,
unsigned internalformat,
unsigned usage) {
+ TRACE_EVENT0("renderer", "RenderThreadImpl::AllocateGpuMemoryBuffer");
+
DCHECK(allocate_gpu_memory_buffer_thread_checker_.CalledOnValidThread());
if (!GpuMemoryBufferImpl::IsFormatValid(internalformat))
@@ -1296,20 +1305,21 @@ scoped_ptr<gfx::GpuMemoryBuffer> RenderThreadImpl::AllocateGpuMemoryBuffer(
if (!success)
return scoped_ptr<gfx::GpuMemoryBuffer>();
- return GpuMemoryBufferImpl::CreateFromHandle(
- handle, gfx::Size(width, height), internalformat)
- .PassAs<gfx::GpuMemoryBuffer>();
-}
-
-void RenderThreadImpl::DeleteGpuMemoryBuffer(
- scoped_ptr<gfx::GpuMemoryBuffer> buffer) {
- gfx::GpuMemoryBufferHandle handle(buffer->GetHandle());
-
- IPC::Message* message = new ChildProcessHostMsg_DeletedGpuMemoryBuffer(
- handle.type, handle.global_id);
+ scoped_ptr<GpuMemoryBufferImpl> buffer(GpuMemoryBufferImpl::CreateFromHandle(
+ handle,
+ gfx::Size(width, height),
+ internalformat,
+ base::Bind(&DeletedGpuMemoryBuffer,
+ make_scoped_refptr(thread_safe_sender()),
+ handle.type,
+ handle.global_id)));
+ if (!buffer) {
+ thread_safe_sender()->Send(new ChildProcessHostMsg_DeletedGpuMemoryBuffer(
+ handle.type, handle.global_id));
+ return scoped_ptr<gfx::GpuMemoryBuffer>();
+ }
- // Allow calling this from the compositor thread.
- thread_safe_sender()->Send(message);
+ return buffer.PassAs<gfx::GpuMemoryBuffer>();
}
void RenderThreadImpl::DoNotSuspendWebKitSharedTimer() {
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698