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

Side by Side 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, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/render_thread_impl.h" 5 #include "content/renderer/render_thread_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <map> 9 #include <map>
10 #include <vector> 10 #include <vector>
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 blink::WebGraphicsContext3D::Attributes GetOffscreenAttribs() { 311 blink::WebGraphicsContext3D::Attributes GetOffscreenAttribs() {
312 blink::WebGraphicsContext3D::Attributes attributes; 312 blink::WebGraphicsContext3D::Attributes attributes;
313 attributes.shareResources = true; 313 attributes.shareResources = true;
314 attributes.depth = false; 314 attributes.depth = false;
315 attributes.stencil = false; 315 attributes.stencil = false;
316 attributes.antialias = false; 316 attributes.antialias = false;
317 attributes.noAutomaticFlushes = true; 317 attributes.noAutomaticFlushes = true;
318 return attributes; 318 return attributes;
319 } 319 }
320 320
321 void DeletedGpuMemoryBuffer(scoped_refptr<ThreadSafeSender> sender,
322 gfx::GpuMemoryBufferType type,
323 const gfx::GpuMemoryBufferId& id) {
324 TRACE_EVENT0("renderer", "RenderThreadImpl::DeletedGpuMemoryBuffer");
325 sender->Send(new ChildProcessHostMsg_DeletedGpuMemoryBuffer(type, id));
326 }
327
321 } // namespace 328 } // namespace
322 329
323 // For measuring memory usage after each task. Behind a command line flag. 330 // For measuring memory usage after each task. Behind a command line flag.
324 class MemoryObserver : public base::MessageLoop::TaskObserver { 331 class MemoryObserver : public base::MessageLoop::TaskObserver {
325 public: 332 public:
326 MemoryObserver() {} 333 MemoryObserver() {}
327 virtual ~MemoryObserver() {} 334 virtual ~MemoryObserver() {}
328 335
329 virtual void WillProcessTask(const base::PendingTask& pending_task) OVERRIDE { 336 virtual void WillProcessTask(const base::PendingTask& pending_task) OVERRIDE {
330 } 337 }
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 thread_safe_sender()->Send(message); 1277 thread_safe_sender()->Send(message);
1271 1278
1272 return result; 1279 return result;
1273 } 1280 }
1274 1281
1275 scoped_ptr<gfx::GpuMemoryBuffer> RenderThreadImpl::AllocateGpuMemoryBuffer( 1282 scoped_ptr<gfx::GpuMemoryBuffer> RenderThreadImpl::AllocateGpuMemoryBuffer(
1276 size_t width, 1283 size_t width,
1277 size_t height, 1284 size_t height,
1278 unsigned internalformat, 1285 unsigned internalformat,
1279 unsigned usage) { 1286 unsigned usage) {
1287 TRACE_EVENT0("renderer", "RenderThreadImpl::AllocateGpuMemoryBuffer");
1288
1280 DCHECK(allocate_gpu_memory_buffer_thread_checker_.CalledOnValidThread()); 1289 DCHECK(allocate_gpu_memory_buffer_thread_checker_.CalledOnValidThread());
1281 1290
1282 if (!GpuMemoryBufferImpl::IsFormatValid(internalformat)) 1291 if (!GpuMemoryBufferImpl::IsFormatValid(internalformat))
1283 return scoped_ptr<gfx::GpuMemoryBuffer>(); 1292 return scoped_ptr<gfx::GpuMemoryBuffer>();
1284 1293
1285 gfx::GpuMemoryBufferHandle handle; 1294 gfx::GpuMemoryBufferHandle handle;
1286 bool success; 1295 bool success;
1287 IPC::Message* message = new ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer( 1296 IPC::Message* message = new ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer(
1288 width, height, internalformat, usage, &handle); 1297 width, height, internalformat, usage, &handle);
1289 1298
1290 // Allow calling this from the compositor thread. 1299 // Allow calling this from the compositor thread.
1291 if (base::MessageLoop::current() == message_loop()) 1300 if (base::MessageLoop::current() == message_loop())
1292 success = ChildThread::Send(message); 1301 success = ChildThread::Send(message);
1293 else 1302 else
1294 success = sync_message_filter()->Send(message); 1303 success = sync_message_filter()->Send(message);
1295 1304
1296 if (!success) 1305 if (!success)
1297 return scoped_ptr<gfx::GpuMemoryBuffer>(); 1306 return scoped_ptr<gfx::GpuMemoryBuffer>();
1298 1307
1299 return GpuMemoryBufferImpl::CreateFromHandle( 1308 return GpuMemoryBufferImpl::CreateFromHandle(
1300 handle, gfx::Size(width, height), internalformat) 1309 handle,
1301 .PassAs<gfx::GpuMemoryBuffer>(); 1310 gfx::Size(width, height),
1302 } 1311 internalformat,
1303 1312 base::Bind(&DeletedGpuMemoryBuffer,
1304 void RenderThreadImpl::DeleteGpuMemoryBuffer( 1313 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
1305 scoped_ptr<gfx::GpuMemoryBuffer> buffer) { 1314 handle.type,
1306 gfx::GpuMemoryBufferHandle handle(buffer->GetHandle()); 1315 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.
1307
1308 IPC::Message* message = new ChildProcessHostMsg_DeletedGpuMemoryBuffer(
1309 handle.type, handle.global_id);
1310
1311 // Allow calling this from the compositor thread.
1312 thread_safe_sender()->Send(message);
1313 } 1316 }
1314 1317
1315 void RenderThreadImpl::DoNotSuspendWebKitSharedTimer() { 1318 void RenderThreadImpl::DoNotSuspendWebKitSharedTimer() {
1316 suspend_webkit_shared_timer_ = false; 1319 suspend_webkit_shared_timer_ = false;
1317 } 1320 }
1318 1321
1319 void RenderThreadImpl::DoNotNotifyWebKitOfModalLoop() { 1322 void RenderThreadImpl::DoNotNotifyWebKitOfModalLoop() {
1320 notify_webkit_of_modal_loop_ = false; 1323 notify_webkit_of_modal_loop_ = false;
1321 } 1324 }
1322 1325
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 hidden_widget_count_--; 1655 hidden_widget_count_--;
1653 1656
1654 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { 1657 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) {
1655 return; 1658 return;
1656 } 1659 }
1657 1660
1658 ScheduleIdleHandler(kLongIdleHandlerDelayMs); 1661 ScheduleIdleHandler(kLongIdleHandlerDelayMs);
1659 } 1662 }
1660 1663
1661 } // namespace content 1664 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698