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

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

Issue 16294003: Update content/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 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 | Annotate | Revision Log
« no previous file with comments | « content/common/gpu/gpu_channel_manager.h ('k') | content/common/gpu/gpu_command_buffer_stub.h » ('j') | 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/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 "base/command_line.h" 8 #include "base/command_line.h"
9 #include "content/common/child_thread.h" 9 #include "content/common/child_thread.h"
10 #include "content/common/gpu/gpu_channel.h" 10 #include "content/common/gpu/gpu_channel.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 watchdog_(watchdog), 42 watchdog_(watchdog),
43 sync_point_manager_(new SyncPointManager), 43 sync_point_manager_(new SyncPointManager),
44 program_cache_(NULL) { 44 program_cache_(NULL) {
45 DCHECK(gpu_child_thread); 45 DCHECK(gpu_child_thread);
46 DCHECK(io_message_loop); 46 DCHECK(io_message_loop);
47 DCHECK(shutdown_event); 47 DCHECK(shutdown_event);
48 } 48 }
49 49
50 GpuChannelManager::~GpuChannelManager() { 50 GpuChannelManager::~GpuChannelManager() {
51 gpu_channels_.clear(); 51 gpu_channels_.clear();
52 if (default_offscreen_surface_) { 52 if (default_offscreen_surface_.get()) {
53 default_offscreen_surface_->Destroy(); 53 default_offscreen_surface_->Destroy();
54 default_offscreen_surface_ = NULL; 54 default_offscreen_surface_ = NULL;
55 } 55 }
56 DCHECK(image_operations_.empty()); 56 DCHECK(image_operations_.empty());
57 } 57 }
58 58
59 gpu::gles2::ProgramCache* GpuChannelManager::program_cache() { 59 gpu::gles2::ProgramCache* GpuChannelManager::program_cache() {
60 if (!program_cache_.get() && 60 if (!program_cache_.get() &&
61 (gfx::g_driver_gl.ext.b_ARB_get_program_binary || 61 (gfx::g_driver_gl.ext.b_ARB_get_program_binary ||
62 gfx::g_driver_gl.ext.b_OES_get_program_binary) && 62 gfx::g_driver_gl.ext.b_OES_get_program_binary) &&
(...skipping 20 matching lines...) Expand all
83 83
84 void GpuChannelManager::RemoveRoute(int32 routing_id) { 84 void GpuChannelManager::RemoveRoute(int32 routing_id) {
85 gpu_child_thread_->RemoveRoute(routing_id); 85 gpu_child_thread_->RemoveRoute(routing_id);
86 } 86 }
87 87
88 GpuChannel* GpuChannelManager::LookupChannel(int32 client_id) { 88 GpuChannel* GpuChannelManager::LookupChannel(int32 client_id) {
89 GpuChannelMap::const_iterator iter = gpu_channels_.find(client_id); 89 GpuChannelMap::const_iterator iter = gpu_channels_.find(client_id);
90 if (iter == gpu_channels_.end()) 90 if (iter == gpu_channels_.end())
91 return NULL; 91 return NULL;
92 else 92 else
93 return iter->second; 93 return iter->second.get();
94 } 94 }
95 95
96 bool GpuChannelManager::OnMessageReceived(const IPC::Message& msg) { 96 bool GpuChannelManager::OnMessageReceived(const IPC::Message& msg) {
97 bool msg_is_ok = true; 97 bool msg_is_ok = true;
98 bool handled = true; 98 bool handled = true;
99 IPC_BEGIN_MESSAGE_MAP_EX(GpuChannelManager, msg, msg_is_ok) 99 IPC_BEGIN_MESSAGE_MAP_EX(GpuChannelManager, msg, msg_is_ok)
100 IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel) 100 IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel)
101 IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel) 101 IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel)
102 IPC_MESSAGE_HANDLER(GpuMsg_CreateViewCommandBuffer, 102 IPC_MESSAGE_HANDLER(GpuMsg_CreateViewCommandBuffer,
103 OnCreateViewCommandBuffer) 103 OnCreateViewCommandBuffer)
104 IPC_MESSAGE_HANDLER(GpuMsg_CreateImage, OnCreateImage) 104 IPC_MESSAGE_HANDLER(GpuMsg_CreateImage, OnCreateImage)
105 IPC_MESSAGE_HANDLER(GpuMsg_DeleteImage, OnDeleteImage) 105 IPC_MESSAGE_HANDLER(GpuMsg_DeleteImage, OnDeleteImage)
106 IPC_MESSAGE_HANDLER(GpuMsg_LoadedShader, OnLoadedShader) 106 IPC_MESSAGE_HANDLER(GpuMsg_LoadedShader, OnLoadedShader)
107 IPC_MESSAGE_UNHANDLED(handled = false) 107 IPC_MESSAGE_UNHANDLED(handled = false)
108 IPC_END_MESSAGE_MAP_EX() 108 IPC_END_MESSAGE_MAP_EX()
109 return handled; 109 return handled;
110 } 110 }
111 111
112 bool GpuChannelManager::Send(IPC::Message* msg) { 112 bool GpuChannelManager::Send(IPC::Message* msg) {
113 return gpu_child_thread_->Send(msg); 113 return gpu_child_thread_->Send(msg);
114 } 114 }
115 115
116 void GpuChannelManager::OnEstablishChannel(int client_id, bool share_context) { 116 void GpuChannelManager::OnEstablishChannel(int client_id, bool share_context) {
117 IPC::ChannelHandle channel_handle; 117 IPC::ChannelHandle channel_handle;
118 118
119 gfx::GLShareGroup* share_group = NULL; 119 gfx::GLShareGroup* share_group = NULL;
120 gpu::gles2::MailboxManager* mailbox_manager = NULL; 120 gpu::gles2::MailboxManager* mailbox_manager = NULL;
121 if (share_context) { 121 if (share_context) {
122 if (!share_group_) { 122 if (!share_group_.get()) {
123 share_group_ = new gfx::GLShareGroup; 123 share_group_ = new gfx::GLShareGroup;
124 DCHECK(!mailbox_manager_); 124 DCHECK(!mailbox_manager_.get());
125 mailbox_manager_ = new gpu::gles2::MailboxManager; 125 mailbox_manager_ = new gpu::gles2::MailboxManager;
126 } 126 }
127 share_group = share_group_; 127 share_group = share_group_.get();
128 mailbox_manager = mailbox_manager_; 128 mailbox_manager = mailbox_manager_.get();
129 } 129 }
130 130
131 scoped_refptr<GpuChannel> channel = new GpuChannel(this, 131 scoped_refptr<GpuChannel> channel = new GpuChannel(this,
132 watchdog_, 132 watchdog_,
133 share_group, 133 share_group,
134 mailbox_manager, 134 mailbox_manager,
135 client_id, 135 client_id,
136 false); 136 false);
137 if (channel->Init(io_message_loop_, shutdown_event_)) { 137 if (channel->Init(io_message_loop_.get(), shutdown_event_)) {
138 gpu_channels_[client_id] = channel; 138 gpu_channels_[client_id] = channel;
139 channel_handle.name = channel->GetChannelName(); 139 channel_handle.name = channel->GetChannelName();
140 140
141 #if defined(OS_POSIX) 141 #if defined(OS_POSIX)
142 // On POSIX, pass the renderer-side FD. Also mark it as auto-close so 142 // On POSIX, pass the renderer-side FD. Also mark it as auto-close so
143 // that it gets closed after it has been sent. 143 // that it gets closed after it has been sent.
144 int renderer_fd = channel->TakeRendererFileDescriptor(); 144 int renderer_fd = channel->TakeRendererFileDescriptor();
145 DCHECK_NE(-1, renderer_fd); 145 DCHECK_NE(-1, renderer_fd);
146 channel_handle.socket = base::FileDescriptor(renderer_fd, true); 146 channel_handle.socket = base::FileDescriptor(renderer_fd, true);
147 #endif 147 #endif
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 FROM_HERE, 282 FROM_HERE,
283 base::Bind(&GpuChannelManager::OnLoseAllContexts, 283 base::Bind(&GpuChannelManager::OnLoseAllContexts,
284 weak_factory_.GetWeakPtr())); 284 weak_factory_.GetWeakPtr()));
285 } 285 }
286 286
287 void GpuChannelManager::OnLoseAllContexts() { 287 void GpuChannelManager::OnLoseAllContexts() {
288 gpu_channels_.clear(); 288 gpu_channels_.clear();
289 } 289 }
290 290
291 gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() { 291 gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() {
292 if (!default_offscreen_surface_) { 292 if (!default_offscreen_surface_.get()) {
293 default_offscreen_surface_ = gfx::GLSurface::CreateOffscreenGLSurface( 293 default_offscreen_surface_ =
294 false, gfx::Size(1, 1)); 294 gfx::GLSurface::CreateOffscreenGLSurface(false, gfx::Size(1, 1));
295 } 295 }
296 return default_offscreen_surface_.get(); 296 return default_offscreen_surface_.get();
297 } 297 }
298 298
299 } // namespace content 299 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_channel_manager.h ('k') | content/common/gpu/gpu_command_buffer_stub.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698