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

Side by Side Diff: chrome/gpu/gpu_command_buffer_stub.cc

Issue 5618002: Coverity: Initialize member variables. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years 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 | « chrome/gpu/gpu_command_buffer_stub.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #if defined(ENABLE_GPU) 5 #if defined(ENABLE_GPU)
6 6
7 #include "base/process_util.h" 7 #include "base/process_util.h"
8 #include "base/shared_memory.h" 8 #include "base/shared_memory.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "chrome/common/child_thread.h" 10 #include "chrome/common/child_thread.h"
11 #include "chrome/common/gpu_messages.h" 11 #include "chrome/common/gpu_messages.h"
12 #include "chrome/gpu/gpu_channel.h" 12 #include "chrome/gpu/gpu_channel.h"
13 #include "chrome/gpu/gpu_command_buffer_stub.h" 13 #include "chrome/gpu/gpu_command_buffer_stub.h"
14 14
15 using gpu::Buffer; 15 using gpu::Buffer;
16 16
17 #if defined(OS_WIN) 17 #if defined(OS_WIN)
18 #define kCompositorWindowOwner L"CompositorWindowOwner" 18 #define kCompositorWindowOwner L"CompositorWindowOwner"
19 #endif 19 #endif // defined(OS_WIN)
20 20
21 GpuCommandBufferStub::GpuCommandBufferStub( 21 GpuCommandBufferStub::GpuCommandBufferStub(
22 GpuChannel* channel, 22 GpuChannel* channel,
23 gfx::PluginWindowHandle handle, 23 gfx::PluginWindowHandle handle,
24 GpuCommandBufferStub* parent, 24 GpuCommandBufferStub* parent,
25 const gfx::Size& size, 25 const gfx::Size& size,
26 const std::string& allowed_extensions, 26 const std::string& allowed_extensions,
27 const std::vector<int32>& attribs, 27 const std::vector<int32>& attribs,
28 uint32 parent_texture_id, 28 uint32 parent_texture_id,
29 int32 route_id, 29 int32 route_id,
30 int32 renderer_id, 30 int32 renderer_id,
31 int32 render_view_id) 31 int32 render_view_id)
32 : channel_(channel), 32 : channel_(channel),
33 handle_(handle), 33 handle_(handle),
34 parent_( 34 parent_(
35 parent ? parent->AsWeakPtr() : base::WeakPtr<GpuCommandBufferStub>()), 35 parent ? parent->AsWeakPtr() : base::WeakPtr<GpuCommandBufferStub>()),
36 initial_size_(size), 36 initial_size_(size),
37 allowed_extensions_(allowed_extensions), 37 allowed_extensions_(allowed_extensions),
38 requested_attribs_(attribs), 38 requested_attribs_(attribs),
39 parent_texture_id_(parent_texture_id), 39 parent_texture_id_(parent_texture_id),
40 route_id_(route_id), 40 route_id_(route_id),
41 #if defined(OS_WIN)
42 compositor_window_(NULL),
43 #endif // defined(OS_WIN)
41 renderer_id_(renderer_id), 44 renderer_id_(renderer_id),
42 render_view_id_(render_view_id) { 45 render_view_id_(render_view_id) {
43 } 46 }
44 47
45 #if defined(OS_WIN) 48 #if defined(OS_WIN)
46 static LRESULT CALLBACK CompositorWindowProc( 49 static LRESULT CALLBACK CompositorWindowProc(
47 HWND hwnd, 50 HWND hwnd,
48 UINT message, 51 UINT message,
49 WPARAM wparam, 52 WPARAM wparam,
50 LPARAM lparam) { 53 LPARAM lparam) {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 } 159 }
157 #if defined(OS_WIN) 160 #if defined(OS_WIN)
158 if (compositor_window_) { 161 if (compositor_window_) {
159 DestroyWindow(static_cast<HWND>(compositor_window_)); 162 DestroyWindow(static_cast<HWND>(compositor_window_));
160 compositor_window_ = NULL; 163 compositor_window_ = NULL;
161 } 164 }
162 #elif defined(OS_LINUX) 165 #elif defined(OS_LINUX)
163 ChildThread* gpu_thread = ChildThread::current(); 166 ChildThread* gpu_thread = ChildThread::current();
164 gpu_thread->Send( 167 gpu_thread->Send(
165 new GpuHostMsg_ReleaseXID(handle_)); 168 new GpuHostMsg_ReleaseXID(handle_));
166 #endif 169 #endif // defined(OS_WIN)
167 } 170 }
168 171
169 void GpuCommandBufferStub::OnMessageReceived(const IPC::Message& message) { 172 void GpuCommandBufferStub::OnMessageReceived(const IPC::Message& message) {
170 IPC_BEGIN_MESSAGE_MAP(GpuCommandBufferStub, message) 173 IPC_BEGIN_MESSAGE_MAP(GpuCommandBufferStub, message)
171 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Initialize, OnInitialize); 174 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Initialize, OnInitialize);
172 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_GetState, OnGetState); 175 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_GetState, OnGetState);
173 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_AsyncGetState, OnAsyncGetState); 176 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_AsyncGetState, OnAsyncGetState);
174 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Flush, OnFlush); 177 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Flush, OnFlush);
175 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_AsyncFlush, OnAsyncFlush); 178 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_AsyncFlush, OnAsyncFlush);
176 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_CreateTransferBuffer, 179 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_CreateTransferBuffer,
177 OnCreateTransferBuffer); 180 OnCreateTransferBuffer);
178 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyTransferBuffer, 181 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_DestroyTransferBuffer,
179 OnDestroyTransferBuffer); 182 OnDestroyTransferBuffer);
180 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_GetTransferBuffer, 183 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_GetTransferBuffer,
181 OnGetTransferBuffer); 184 OnGetTransferBuffer);
182 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_ResizeOffscreenFrameBuffer, 185 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_ResizeOffscreenFrameBuffer,
183 OnResizeOffscreenFrameBuffer); 186 OnResizeOffscreenFrameBuffer);
184 #if defined(OS_MACOSX) 187 #if defined(OS_MACOSX)
185 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SetWindowSize, OnSetWindowSize); 188 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SetWindowSize, OnSetWindowSize);
186 #endif 189 #endif // defined(OS_MACOSX)
187 IPC_MESSAGE_UNHANDLED_ERROR() 190 IPC_MESSAGE_UNHANDLED_ERROR()
188 IPC_END_MESSAGE_MAP() 191 IPC_END_MESSAGE_MAP()
189 } 192 }
190 193
191 bool GpuCommandBufferStub::Send(IPC::Message* message) { 194 bool GpuCommandBufferStub::Send(IPC::Message* message) {
192 return channel_->Send(message); 195 return channel_->Send(message);
193 } 196 }
194 197
195 void GpuCommandBufferStub::OnInitialize( 198 void GpuCommandBufferStub::OnInitialize(
196 int32 size, 199 int32 size,
(...skipping 10 matching lines...) Expand all
207 if (handle_) { 210 if (handle_) {
208 if (!CreateCompositorWindow()) { 211 if (!CreateCompositorWindow()) {
209 return; 212 return;
210 } 213 }
211 output_window_handle = compositor_window_; 214 output_window_handle = compositor_window_;
212 } else { 215 } else {
213 output_window_handle = handle_; 216 output_window_handle = handle_;
214 } 217 }
215 #else 218 #else
216 gfx::PluginWindowHandle output_window_handle = handle_; 219 gfx::PluginWindowHandle output_window_handle = handle_;
217 #endif 220 #endif // defined(OS_WIN)
218 221
219 // Initialize the CommandBufferService and GPUProcessor. 222 // Initialize the CommandBufferService and GPUProcessor.
220 if (command_buffer_->Initialize(size)) { 223 if (command_buffer_->Initialize(size)) {
221 Buffer buffer = command_buffer_->GetRingBuffer(); 224 Buffer buffer = command_buffer_->GetRingBuffer();
222 if (buffer.shared_memory) { 225 if (buffer.shared_memory) {
223 gpu::GPUProcessor* parent_processor = 226 gpu::GPUProcessor* parent_processor =
224 parent_ ? parent_->processor_.get() : NULL; 227 parent_ ? parent_->processor_.get() : NULL;
225 processor_.reset(new gpu::GPUProcessor(command_buffer_.get(), NULL)); 228 processor_.reset(new gpu::GPUProcessor(command_buffer_.get(), NULL));
226 if (processor_->Initialize( 229 if (processor_->Initialize(
227 output_window_handle, 230 output_window_handle,
(...skipping 23 matching lines...) Expand all
251 &GpuCommandBufferStub::SwapBuffersCallback)); 254 &GpuCommandBufferStub::SwapBuffersCallback));
252 } 255 }
253 #elif defined(OS_LINUX) || defined(OS_WIN) 256 #elif defined(OS_LINUX) || defined(OS_WIN)
254 if (handle_) { 257 if (handle_) {
255 // Set up a pathway for resizing the output window at the right time 258 // Set up a pathway for resizing the output window at the right time
256 // relative to other GL commands. 259 // relative to other GL commands.
257 processor_->SetResizeCallback( 260 processor_->SetResizeCallback(
258 NewCallback(this, 261 NewCallback(this,
259 &GpuCommandBufferStub::ResizeCallback)); 262 &GpuCommandBufferStub::ResizeCallback));
260 } 263 }
261 #endif 264 #endif // defined(OS_MACOSX)
262 } else { 265 } else {
263 processor_.reset(); 266 processor_.reset();
264 command_buffer_.reset(); 267 command_buffer_.reset();
265 } 268 }
266 } 269 }
267 } 270 }
268 } 271 }
269 272
270 void GpuCommandBufferStub::OnGetState(gpu::CommandBuffer::State* state) { 273 void GpuCommandBufferStub::OnGetState(gpu::CommandBuffer::State* state) {
271 *state = command_buffer_->GetState(); 274 *state = command_buffer_->GetState();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 OnSwapBuffers(); 348 OnSwapBuffers();
346 ChildThread* gpu_thread = ChildThread::current(); 349 ChildThread* gpu_thread = ChildThread::current();
347 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; 350 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params;
348 params.renderer_id = renderer_id_; 351 params.renderer_id = renderer_id_;
349 params.render_view_id = render_view_id_; 352 params.render_view_id = render_view_id_;
350 params.window = handle_; 353 params.window = handle_;
351 params.surface_id = processor_->GetSurfaceId(); 354 params.surface_id = processor_->GetSurfaceId();
352 params.route_id = route_id(); 355 params.route_id = route_id();
353 #if defined(OS_MACOSX) 356 #if defined(OS_MACOSX)
354 params.swap_buffers_count = processor_->swap_buffers_count(); 357 params.swap_buffers_count = processor_->swap_buffers_count();
355 #endif 358 #endif // defined(OS_MACOSX)
356 gpu_thread->Send(new GpuHostMsg_AcceleratedSurfaceBuffersSwapped(params)); 359 gpu_thread->Send(new GpuHostMsg_AcceleratedSurfaceBuffersSwapped(params));
357 } 360 }
358 361
359 void GpuCommandBufferStub::AcceleratedSurfaceBuffersSwapped( 362 void GpuCommandBufferStub::AcceleratedSurfaceBuffersSwapped(
360 uint64 swap_buffers_count) { 363 uint64 swap_buffers_count) {
361 processor_->set_acknowledged_swap_buffers_count(swap_buffers_count); 364 processor_->set_acknowledged_swap_buffers_count(swap_buffers_count);
362 // Wake up the GpuProcessor to start doing work again. 365 // Wake up the GpuProcessor to start doing work again.
363 processor_->ScheduleProcessCommands(); 366 processor_->ScheduleProcessCommands();
364 } 367 }
365 #endif // defined(OS_MACOSX) 368 #endif // defined(OS_MACOSX)
366 369
367 void GpuCommandBufferStub::ResizeCallback(gfx::Size size) { 370 void GpuCommandBufferStub::ResizeCallback(gfx::Size size) {
368 if (handle_ == gfx::kNullPluginWindow) 371 if (handle_ == gfx::kNullPluginWindow)
369 return; 372 return;
370 373
371 #if defined(OS_LINUX) 374 #if defined(OS_LINUX)
372 ChildThread* gpu_thread = ChildThread::current(); 375 ChildThread* gpu_thread = ChildThread::current();
373 bool result = false; 376 bool result = false;
374 gpu_thread->Send( 377 gpu_thread->Send(
375 new GpuHostMsg_ResizeXID(handle_, size, &result)); 378 new GpuHostMsg_ResizeXID(handle_, size, &result));
376 #elif defined(OS_WIN) 379 #elif defined(OS_WIN)
377 HWND hwnd = static_cast<HWND>(compositor_window_); 380 HWND hwnd = static_cast<HWND>(compositor_window_);
378 UINT swp_flags = SWP_NOSENDCHANGING | SWP_NOOWNERZORDER | SWP_NOCOPYBITS | 381 UINT swp_flags = SWP_NOSENDCHANGING | SWP_NOOWNERZORDER | SWP_NOCOPYBITS |
379 SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_DEFERERASE; 382 SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_DEFERERASE;
380 SetWindowPos(hwnd, NULL, 0, 0, size.width(), size.height(), swp_flags); 383 SetWindowPos(hwnd, NULL, 0, 0, size.width(), size.height(), swp_flags);
381 #endif 384 #endif // defined(OS_LINUX)
382 } 385 }
383 386
384 #endif // ENABLE_GPU 387 #endif // defined(ENABLE_GPU)
OLDNEW
« no previous file with comments | « chrome/gpu/gpu_command_buffer_stub.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698