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

Side by Side Diff: content/common/gpu/gpu_channel_manager.cc

Issue 10534173: GPU Program Caching (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: memory limit + lru Created 8 years, 6 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/common/gpu/gpu_channel_manager.h" 5 #include "content/common/gpu/gpu_channel_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "content/common/child_thread.h" 8 #include "content/common/child_thread.h"
9 #include "content/common/gpu/gpu_channel.h" 9 #include "content/common/gpu/gpu_channel.h"
10 #include "content/common/gpu/gpu_memory_manager.h" 10 #include "content/common/gpu/gpu_memory_manager.h"
11 #include "content/common/gpu/gpu_messages.h" 11 #include "content/common/gpu/gpu_messages.h"
12 #include "content/common/gpu/sync_point_manager.h" 12 #include "content/common/gpu/sync_point_manager.h"
13 #include "gpu/command_buffer/service/mailbox_manager.h" 13 #include "gpu/command_buffer/service/mailbox_manager.h"
14 #include "gpu/command_buffer/service/memory_program_cache.h"
15 #include "ui/gl/gl_bindings.h"
14 #include "ui/gl/gl_share_group.h" 16 #include "ui/gl/gl_share_group.h"
15 17
16 GpuChannelManager::GpuChannelManager(ChildThread* gpu_child_thread, 18 GpuChannelManager::GpuChannelManager(ChildThread* gpu_child_thread,
17 GpuWatchdog* watchdog, 19 GpuWatchdog* watchdog,
18 base::MessageLoopProxy* io_message_loop, 20 base::MessageLoopProxy* io_message_loop,
19 base::WaitableEvent* shutdown_event) 21 base::WaitableEvent* shutdown_event)
20 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), 22 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
21 io_message_loop_(io_message_loop), 23 io_message_loop_(io_message_loop),
22 shutdown_event_(shutdown_event), 24 shutdown_event_(shutdown_event),
23 gpu_child_thread_(gpu_child_thread), 25 gpu_child_thread_(gpu_child_thread),
24 ALLOW_THIS_IN_INITIALIZER_LIST(gpu_memory_manager_(this, 26 ALLOW_THIS_IN_INITIALIZER_LIST(gpu_memory_manager_(this,
25 GpuMemoryManager::kDefaultMaxSurfacesWithFrontbufferSoftLimit)), 27 GpuMemoryManager::kDefaultMaxSurfacesWithFrontbufferSoftLimit)),
26 watchdog_(watchdog), 28 watchdog_(watchdog),
27 sync_point_manager_(new SyncPointManager) { 29 sync_point_manager_(new SyncPointManager),
30 program_cache_(gfx::g_glProgramBinary && gfx::g_glGetProgramBinary ?
31 new gpu::gles2::MemoryProgramCache() :
32 NULL){
28 DCHECK(gpu_child_thread); 33 DCHECK(gpu_child_thread);
29 DCHECK(io_message_loop); 34 DCHECK(io_message_loop);
30 DCHECK(shutdown_event); 35 DCHECK(shutdown_event);
31 } 36 }
32 37
33 GpuChannelManager::~GpuChannelManager() { 38 GpuChannelManager::~GpuChannelManager() {
34 gpu_channels_.clear(); 39 gpu_channels_.clear();
35 } 40 }
36 41
37 void GpuChannelManager::RemoveChannel(int client_id) { 42 void GpuChannelManager::RemoveChannel(int client_id) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 } 104 }
100 share_group = share_group_; 105 share_group = share_group_;
101 mailbox_manager = mailbox_manager_; 106 mailbox_manager = mailbox_manager_;
102 } 107 }
103 108
104 scoped_refptr<GpuChannel> channel = new GpuChannel(this, 109 scoped_refptr<GpuChannel> channel = new GpuChannel(this,
105 watchdog_, 110 watchdog_,
106 share_group, 111 share_group,
107 mailbox_manager, 112 mailbox_manager,
108 client_id, 113 client_id,
109 false); 114 false,
115 program_cache_.get());
110 if (channel->Init(io_message_loop_, shutdown_event_)) { 116 if (channel->Init(io_message_loop_, shutdown_event_)) {
111 gpu_channels_[client_id] = channel; 117 gpu_channels_[client_id] = channel;
112 channel_handle.name = channel->GetChannelName(); 118 channel_handle.name = channel->GetChannelName();
113 119
114 #if defined(OS_POSIX) 120 #if defined(OS_POSIX)
115 // On POSIX, pass the renderer-side FD. Also mark it as auto-close so 121 // On POSIX, pass the renderer-side FD. Also mark it as auto-close so
116 // that it gets closed after it has been sent. 122 // that it gets closed after it has been sent.
117 int renderer_fd = channel->TakeRendererFileDescriptor(); 123 int renderer_fd = channel->TakeRendererFileDescriptor();
118 DCHECK_NE(-1, renderer_fd); 124 DCHECK_NE(-1, renderer_fd);
119 channel_handle.socket = base::FileDescriptor(renderer_fd, true); 125 channel_handle.socket = base::FileDescriptor(renderer_fd, true);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 void GpuChannelManager::LoseAllContexts() { 160 void GpuChannelManager::LoseAllContexts() {
155 MessageLoop::current()->PostTask( 161 MessageLoop::current()->PostTask(
156 FROM_HERE, 162 FROM_HERE,
157 base::Bind(&GpuChannelManager::OnLoseAllContexts, 163 base::Bind(&GpuChannelManager::OnLoseAllContexts,
158 weak_factory_.GetWeakPtr())); 164 weak_factory_.GetWeakPtr()));
159 } 165 }
160 166
161 void GpuChannelManager::OnLoseAllContexts() { 167 void GpuChannelManager::OnLoseAllContexts() {
162 gpu_channels_.clear(); 168 gpu_channels_.clear();
163 } 169 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698