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

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: 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/renderer/render_thread_impl.cc
diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc
index 3842bca15684605283d42e4376996aeb1eb0c7fa..3effe911c5a87416446522ddbfb99c05f7824cc4 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(scoped_refptr<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))
@@ -1297,19 +1306,13 @@ scoped_ptr<gfx::GpuMemoryBuffer> RenderThreadImpl::AllocateGpuMemoryBuffer(
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);
-
- // Allow calling this from the compositor thread.
- thread_safe_sender()->Send(message);
+ handle,
+ gfx::Size(width, height),
+ internalformat,
+ base::Bind(&DeletedGpuMemoryBuffer,
+ make_scoped_refptr(thread_safe_sender()),
piman 2014/09/24 03:19:10 nit: you don't need make_scoped_refptr, Bind figur
reveman 2014/09/24 06:03:38 hm, I think we do, unless I'm doing something comp
piman 2014/09/24 06:40:28 Ah, sorry you're right. What I said is only true f
reveman 2014/09/24 07:10:54 Are you saying I could safely use base::Unretained
+ handle.type,
+ handle.global_id)).PassAs<gfx::GpuMemoryBuffer>();
piman 2014/09/24 03:19:10 Should DeletedGpuMemoryBuffer be called if CreateF
reveman 2014/09/24 06:03:38 Good catch. Done.
}
void RenderThreadImpl::DoNotSuspendWebKitSharedTimer() {

Powered by Google App Engine
This is Rietveld 408576698