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

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

Issue 649533003: C++11 declares a type safe null pointer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed Presubmit errors 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
« no previous file with comments | « content/common/gpu/gpu_channel.cc ('k') | content/common/gpu/gpu_command_buffer_stub.cc » ('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/gpu/gpu_channel.h" 9 #include "content/common/gpu/gpu_channel.h"
10 #include "content/common/gpu/gpu_memory_buffer_factory.h" 10 #include "content/common/gpu/gpu_memory_buffer_factory.h"
(...skipping 11 matching lines...) Expand all
22 #include "ui/gl/gl_share_group.h" 22 #include "ui/gl/gl_share_group.h"
23 23
24 namespace content { 24 namespace content {
25 25
26 namespace { 26 namespace {
27 27
28 class GpuChannelManagerMessageFilter : public IPC::MessageFilter { 28 class GpuChannelManagerMessageFilter : public IPC::MessageFilter {
29 public: 29 public:
30 GpuChannelManagerMessageFilter( 30 GpuChannelManagerMessageFilter(
31 GpuMemoryBufferFactory* gpu_memory_buffer_factory) 31 GpuMemoryBufferFactory* gpu_memory_buffer_factory)
32 : sender_(NULL), gpu_memory_buffer_factory_(gpu_memory_buffer_factory) {} 32 : sender_(nullptr),
33 gpu_memory_buffer_factory_(gpu_memory_buffer_factory) {}
33 34
34 virtual void OnFilterAdded(IPC::Sender* sender) override { 35 virtual void OnFilterAdded(IPC::Sender* sender) override {
35 DCHECK(!sender_); 36 DCHECK(!sender_);
36 sender_ = sender; 37 sender_ = sender;
37 } 38 }
38 39
39 virtual void OnFilterRemoved() override { 40 virtual void OnFilterRemoved() override {
40 DCHECK(sender_); 41 DCHECK(sender_);
41 sender_ = NULL; 42 sender_ = nullptr;
42 } 43 }
43 44
44 virtual bool OnMessageReceived(const IPC::Message& message) override { 45 virtual bool OnMessageReceived(const IPC::Message& message) override {
45 DCHECK(sender_); 46 DCHECK(sender_);
46 bool handled = true; 47 bool handled = true;
47 IPC_BEGIN_MESSAGE_MAP(GpuChannelManagerMessageFilter, message) 48 IPC_BEGIN_MESSAGE_MAP(GpuChannelManagerMessageFilter, message)
48 IPC_MESSAGE_HANDLER(GpuMsg_CreateGpuMemoryBuffer, OnCreateGpuMemoryBuffer) 49 IPC_MESSAGE_HANDLER(GpuMsg_CreateGpuMemoryBuffer, OnCreateGpuMemoryBuffer)
49 IPC_MESSAGE_UNHANDLED(handled = false) 50 IPC_MESSAGE_UNHANDLED(handled = false)
50 IPC_END_MESSAGE_MAP() 51 IPC_END_MESSAGE_MAP()
51 return handled; 52 return handled;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 DCHECK(router_); 97 DCHECK(router_);
97 DCHECK(io_message_loop); 98 DCHECK(io_message_loop);
98 DCHECK(shutdown_event); 99 DCHECK(shutdown_event);
99 channel_->AddFilter(filter_.get()); 100 channel_->AddFilter(filter_.get());
100 } 101 }
101 102
102 GpuChannelManager::~GpuChannelManager() { 103 GpuChannelManager::~GpuChannelManager() {
103 gpu_channels_.clear(); 104 gpu_channels_.clear();
104 if (default_offscreen_surface_.get()) { 105 if (default_offscreen_surface_.get()) {
105 default_offscreen_surface_->Destroy(); 106 default_offscreen_surface_->Destroy();
106 default_offscreen_surface_ = NULL; 107 default_offscreen_surface_ = nullptr;
107 } 108 }
108 } 109 }
109 110
110 gpu::gles2::ProgramCache* GpuChannelManager::program_cache() { 111 gpu::gles2::ProgramCache* GpuChannelManager::program_cache() {
111 if (!program_cache_.get() && 112 if (!program_cache_.get() &&
112 (gfx::g_driver_gl.ext.b_GL_ARB_get_program_binary || 113 (gfx::g_driver_gl.ext.b_GL_ARB_get_program_binary ||
113 gfx::g_driver_gl.ext.b_GL_OES_get_program_binary) && 114 gfx::g_driver_gl.ext.b_GL_OES_get_program_binary) &&
114 !CommandLine::ForCurrentProcess()->HasSwitch( 115 !CommandLine::ForCurrentProcess()->HasSwitch(
115 switches::kDisableGpuProgramCache)) { 116 switches::kDisableGpuProgramCache)) {
116 program_cache_.reset(new gpu::gles2::MemoryProgramCache()); 117 program_cache_.reset(new gpu::gles2::MemoryProgramCache());
(...skipping 22 matching lines...) Expand all
139 router_->AddRoute(routing_id, listener); 140 router_->AddRoute(routing_id, listener);
140 } 141 }
141 142
142 void GpuChannelManager::RemoveRoute(int32 routing_id) { 143 void GpuChannelManager::RemoveRoute(int32 routing_id) {
143 router_->RemoveRoute(routing_id); 144 router_->RemoveRoute(routing_id);
144 } 145 }
145 146
146 GpuChannel* GpuChannelManager::LookupChannel(int32 client_id) { 147 GpuChannel* GpuChannelManager::LookupChannel(int32 client_id) {
147 GpuChannelMap::const_iterator iter = gpu_channels_.find(client_id); 148 GpuChannelMap::const_iterator iter = gpu_channels_.find(client_id);
148 if (iter == gpu_channels_.end()) 149 if (iter == gpu_channels_.end())
149 return NULL; 150 return nullptr;
150 else 151 else
151 return iter->second; 152 return iter->second;
152 } 153 }
153 154
154 bool GpuChannelManager::OnMessageReceived(const IPC::Message& msg) { 155 bool GpuChannelManager::OnMessageReceived(const IPC::Message& msg) {
155 bool handled = true; 156 bool handled = true;
156 IPC_BEGIN_MESSAGE_MAP(GpuChannelManager, msg) 157 IPC_BEGIN_MESSAGE_MAP(GpuChannelManager, msg)
157 IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel) 158 IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel)
158 IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel) 159 IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel)
159 IPC_MESSAGE_HANDLER(GpuMsg_CreateViewCommandBuffer, 160 IPC_MESSAGE_HANDLER(GpuMsg_CreateViewCommandBuffer,
160 OnCreateViewCommandBuffer) 161 OnCreateViewCommandBuffer)
161 IPC_MESSAGE_HANDLER(GpuMsg_DestroyGpuMemoryBuffer, OnDestroyGpuMemoryBuffer) 162 IPC_MESSAGE_HANDLER(GpuMsg_DestroyGpuMemoryBuffer, OnDestroyGpuMemoryBuffer)
162 IPC_MESSAGE_HANDLER(GpuMsg_LoadedShader, OnLoadedShader) 163 IPC_MESSAGE_HANDLER(GpuMsg_LoadedShader, OnLoadedShader)
163 IPC_MESSAGE_UNHANDLED(handled = false) 164 IPC_MESSAGE_UNHANDLED(handled = false)
164 IPC_END_MESSAGE_MAP() 165 IPC_END_MESSAGE_MAP()
165 return handled; 166 return handled;
166 } 167 }
167 168
168 bool GpuChannelManager::Send(IPC::Message* msg) { return router_->Send(msg); } 169 bool GpuChannelManager::Send(IPC::Message* msg) { return router_->Send(msg); }
169 170
170 void GpuChannelManager::OnEstablishChannel(int client_id, 171 void GpuChannelManager::OnEstablishChannel(int client_id,
171 bool share_context, 172 bool share_context,
172 bool allow_future_sync_points) { 173 bool allow_future_sync_points) {
173 IPC::ChannelHandle channel_handle; 174 IPC::ChannelHandle channel_handle;
174 175
175 gfx::GLShareGroup* share_group = NULL; 176 gfx::GLShareGroup* share_group = nullptr;
176 gpu::gles2::MailboxManager* mailbox_manager = NULL; 177 gpu::gles2::MailboxManager* mailbox_manager = nullptr;
177 if (share_context) { 178 if (share_context) {
178 if (!share_group_.get()) { 179 if (!share_group_.get()) {
179 share_group_ = new gfx::GLShareGroup; 180 share_group_ = new gfx::GLShareGroup;
180 DCHECK(!mailbox_manager_.get()); 181 DCHECK(!mailbox_manager_.get());
181 mailbox_manager_ = new gpu::gles2::MailboxManager; 182 mailbox_manager_ = new gpu::gles2::MailboxManager;
182 } 183 }
183 share_group = share_group_.get(); 184 share_group = share_group_.get();
184 mailbox_manager = mailbox_manager_.get(); 185 mailbox_manager = mailbox_manager_.get();
185 } 186 }
186 187
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 305
305 gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() { 306 gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() {
306 if (!default_offscreen_surface_.get()) { 307 if (!default_offscreen_surface_.get()) {
307 default_offscreen_surface_ = 308 default_offscreen_surface_ =
308 gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size()); 309 gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size());
309 } 310 }
310 return default_offscreen_surface_.get(); 311 return default_offscreen_surface_.get();
311 } 312 }
312 313
313 } // namespace content 314 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_channel.cc ('k') | content/common/gpu/gpu_command_buffer_stub.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698