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

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: 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 unified diff | Download patch
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(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 scoped_ptr<GpuMemoryBufferImpl> buffer(GpuMemoryBufferImpl::CreateFromHandle(
1300 handle, gfx::Size(width, height), internalformat) 1309 handle,
1301 .PassAs<gfx::GpuMemoryBuffer>(); 1310 gfx::Size(width, height),
1302 } 1311 internalformat,
1312 base::Bind(&DeletedGpuMemoryBuffer,
1313 make_scoped_refptr(thread_safe_sender()),
1314 handle.type,
1315 handle.global_id)));
1316 if (!buffer) {
1317 thread_safe_sender()->Send(new ChildProcessHostMsg_DeletedGpuMemoryBuffer(
1318 handle.type, handle.global_id));
1319 return scoped_ptr<gfx::GpuMemoryBuffer>();
1320 }
1303 1321
1304 void RenderThreadImpl::DeleteGpuMemoryBuffer( 1322 return buffer.PassAs<gfx::GpuMemoryBuffer>();
1305 scoped_ptr<gfx::GpuMemoryBuffer> buffer) {
1306 gfx::GpuMemoryBufferHandle handle(buffer->GetHandle());
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 } 1323 }
1314 1324
1315 void RenderThreadImpl::DoNotSuspendWebKitSharedTimer() { 1325 void RenderThreadImpl::DoNotSuspendWebKitSharedTimer() {
1316 suspend_webkit_shared_timer_ = false; 1326 suspend_webkit_shared_timer_ = false;
1317 } 1327 }
1318 1328
1319 void RenderThreadImpl::DoNotNotifyWebKitOfModalLoop() { 1329 void RenderThreadImpl::DoNotNotifyWebKitOfModalLoop() {
1320 notify_webkit_of_modal_loop_ = false; 1330 notify_webkit_of_modal_loop_ = false;
1321 } 1331 }
1322 1332
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 hidden_widget_count_--; 1662 hidden_widget_count_--;
1653 1663
1654 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { 1664 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) {
1655 return; 1665 return;
1656 } 1666 }
1657 1667
1658 ScheduleIdleHandler(kLongIdleHandlerDelayMs); 1668 ScheduleIdleHandler(kLongIdleHandlerDelayMs);
1659 } 1669 }
1660 1670
1661 } // namespace content 1671 } // namespace content
OLDNEW
« 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