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

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

Issue 6793054: Moved code that runs in both the browser and GPU process from content/gpu to content/common/gpu. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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_command_buffer_stub.h ('k') | content/common/gpu/gpu_config.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/common/child_thread.h"
10 #include "content/common/gpu_messages.h" 11 #include "content/common/gpu_messages.h"
11 #include "content/common/child_thread.h" 12 #include "content/common/gpu/gpu_channel.h"
12 #include "content/gpu/gpu_channel.h" 13 #include "content/common/gpu/gpu_channel_manager.h"
13 #include "content/gpu/gpu_command_buffer_stub.h" 14 #include "content/common/gpu/gpu_command_buffer_stub.h"
14 #include "content/gpu/gpu_render_thread.h"
15 #include "content/gpu/gpu_watchdog_thread.h" 15 #include "content/gpu/gpu_watchdog_thread.h"
16 #include "gpu/common/gpu_trace_event.h" 16 #include "gpu/common/gpu_trace_event.h"
17 17
18 #if defined(OS_WIN) 18 #if defined(OS_WIN)
19 #include "base/win/wrapped_window_proc.h" 19 #include "base/win/wrapped_window_proc.h"
20 #endif 20 #endif
21 21
22 using gpu::Buffer; 22 using gpu::Buffer;
23 23
24 #if defined(OS_WIN) 24 #if defined(OS_WIN)
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 NULL, 140 NULL,
141 0, 0, 141 0, 0,
142 parent_rect.right - parent_rect.left, 142 parent_rect.right - parent_rect.left,
143 parent_rect.bottom - parent_rect.top, 143 parent_rect.bottom - parent_rect.top,
144 flags); 144 flags);
145 compositor_window_ = static_cast<gfx::PluginWindowHandle>(compositor_window); 145 compositor_window_ = static_cast<gfx::PluginWindowHandle>(compositor_window);
146 return true; 146 return true;
147 } 147 }
148 148
149 void GpuCommandBufferStub::OnCompositorWindowPainted() { 149 void GpuCommandBufferStub::OnCompositorWindowPainted() {
150 GpuRenderThread* render_thread = channel_->gpu_render_thread(); 150 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager();
151 render_thread->Send(new GpuHostMsg_ScheduleComposite( 151 gpu_channel_manager->Send(new GpuHostMsg_ScheduleComposite(
152 renderer_id_, render_view_id_)); 152 renderer_id_, render_view_id_));
153 } 153 }
154 #endif // defined(OS_WIN) 154 #endif // defined(OS_WIN)
155 155
156 156
157 GpuCommandBufferStub::~GpuCommandBufferStub() { 157 GpuCommandBufferStub::~GpuCommandBufferStub() {
158 if (processor_.get()) { 158 if (processor_.get()) {
159 processor_->Destroy(); 159 processor_->Destroy();
160 } 160 }
161 #if defined(OS_WIN) 161 #if defined(OS_WIN)
162 if (compositor_window_) { 162 if (compositor_window_) {
163 DestroyWindow(static_cast<HWND>(compositor_window_)); 163 DestroyWindow(static_cast<HWND>(compositor_window_));
164 compositor_window_ = NULL; 164 compositor_window_ = NULL;
165 } 165 }
166 #endif // defined(OS_WIN) 166 #endif // defined(OS_WIN)
167 167
168 GpuRenderThread* render_thread = channel_->gpu_render_thread(); 168 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager();
169 render_thread->Send(new GpuHostMsg_DestroyCommandBuffer( 169 gpu_channel_manager->Send(new GpuHostMsg_DestroyCommandBuffer(
170 handle_, renderer_id_, render_view_id_)); 170 handle_, renderer_id_, render_view_id_));
171 } 171 }
172 172
173 bool GpuCommandBufferStub::OnMessageReceived(const IPC::Message& message) { 173 bool GpuCommandBufferStub::OnMessageReceived(const IPC::Message& message) {
174 bool handled = true; 174 bool handled = true;
175 IPC_BEGIN_MESSAGE_MAP(GpuCommandBufferStub, message) 175 IPC_BEGIN_MESSAGE_MAP(GpuCommandBufferStub, message)
176 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Initialize, OnInitialize); 176 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Initialize, OnInitialize);
177 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_GetState, OnGetState); 177 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_GetState, OnGetState);
178 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_AsyncGetState, OnAsyncGetState); 178 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_AsyncGetState, OnAsyncGetState);
179 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Flush, OnFlush); 179 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Flush, OnFlush);
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 processor_->ResizeOffscreenFrameBuffer(size); 361 processor_->ResizeOffscreenFrameBuffer(size);
362 } 362 }
363 363
364 void GpuCommandBufferStub::OnSwapBuffers() { 364 void GpuCommandBufferStub::OnSwapBuffers() {
365 GPU_TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnSwapBuffers"); 365 GPU_TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnSwapBuffers");
366 Send(new GpuCommandBufferMsg_SwapBuffers(route_id_)); 366 Send(new GpuCommandBufferMsg_SwapBuffers(route_id_));
367 } 367 }
368 368
369 #if defined(OS_MACOSX) 369 #if defined(OS_MACOSX)
370 void GpuCommandBufferStub::OnSetWindowSize(const gfx::Size& size) { 370 void GpuCommandBufferStub::OnSetWindowSize(const gfx::Size& size) {
371 GpuRenderThread* gpu_render_thread = channel_->gpu_render_thread(); 371 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager();
372 // Try using the IOSurface version first. 372 // Try using the IOSurface version first.
373 uint64 new_backing_store = processor_->SetWindowSizeForIOSurface(size); 373 uint64 new_backing_store = processor_->SetWindowSizeForIOSurface(size);
374 if (new_backing_store) { 374 if (new_backing_store) {
375 GpuHostMsg_AcceleratedSurfaceSetIOSurface_Params params; 375 GpuHostMsg_AcceleratedSurfaceSetIOSurface_Params params;
376 params.renderer_id = renderer_id_; 376 params.renderer_id = renderer_id_;
377 params.render_view_id = render_view_id_; 377 params.render_view_id = render_view_id_;
378 params.window = handle_; 378 params.window = handle_;
379 params.width = size.width(); 379 params.width = size.width();
380 params.height = size.height(); 380 params.height = size.height();
381 params.identifier = new_backing_store; 381 params.identifier = new_backing_store;
382 gpu_render_thread->Send( 382 gpu_channel_manager->Send(
383 new GpuHostMsg_AcceleratedSurfaceSetIOSurface(params)); 383 new GpuHostMsg_AcceleratedSurfaceSetIOSurface(params));
384 } else { 384 } else {
385 // TODO(kbr): figure out what to do here. It wouldn't be difficult 385 // TODO(kbr): figure out what to do here. It wouldn't be difficult
386 // to support the compositor on 10.5, but the performance would be 386 // to support the compositor on 10.5, but the performance would be
387 // questionable. 387 // questionable.
388 NOTREACHED(); 388 NOTREACHED();
389 } 389 }
390 } 390 }
391 391
392 void GpuCommandBufferStub::SwapBuffersCallback() { 392 void GpuCommandBufferStub::SwapBuffersCallback() {
393 OnSwapBuffers(); 393 OnSwapBuffers();
394 GpuRenderThread* gpu_render_thread = channel_->gpu_render_thread(); 394 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager();
395 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; 395 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params;
396 params.renderer_id = renderer_id_; 396 params.renderer_id = renderer_id_;
397 params.render_view_id = render_view_id_; 397 params.render_view_id = render_view_id_;
398 params.window = handle_; 398 params.window = handle_;
399 params.surface_id = processor_->GetSurfaceId(); 399 params.surface_id = processor_->GetSurfaceId();
400 params.route_id = route_id(); 400 params.route_id = route_id();
401 params.swap_buffers_count = processor_->swap_buffers_count(); 401 params.swap_buffers_count = processor_->swap_buffers_count();
402 gpu_render_thread->Send( 402 gpu_channel_manager->Send(
403 new GpuHostMsg_AcceleratedSurfaceBuffersSwapped(params)); 403 new GpuHostMsg_AcceleratedSurfaceBuffersSwapped(params));
404 } 404 }
405 405
406 void GpuCommandBufferStub::AcceleratedSurfaceBuffersSwapped( 406 void GpuCommandBufferStub::AcceleratedSurfaceBuffersSwapped(
407 uint64 swap_buffers_count) { 407 uint64 swap_buffers_count) {
408 processor_->set_acknowledged_swap_buffers_count(swap_buffers_count); 408 processor_->set_acknowledged_swap_buffers_count(swap_buffers_count);
409 // Wake up the GpuProcessor to start doing work again. 409 // Wake up the GpuProcessor to start doing work again.
410 processor_->ScheduleProcessCommands(); 410 processor_->ScheduleProcessCommands();
411 } 411 }
412 #endif // defined(OS_MACOSX) 412 #endif // defined(OS_MACOSX)
413 413
414 void GpuCommandBufferStub::ResizeCallback(gfx::Size size) { 414 void GpuCommandBufferStub::ResizeCallback(gfx::Size size) {
415 if (handle_ == gfx::kNullPluginWindow) { 415 if (handle_ == gfx::kNullPluginWindow) {
416 processor_->decoder()->ResizeOffscreenFrameBuffer(size); 416 processor_->decoder()->ResizeOffscreenFrameBuffer(size);
417 processor_->decoder()->UpdateOffscreenFrameBufferSize(); 417 processor_->decoder()->UpdateOffscreenFrameBufferSize();
418 } else { 418 } else {
419 #if defined(OS_LINUX) && !defined(TOUCH_UI) 419 #if defined(OS_LINUX) && !defined(TOUCH_UI)
420 GpuRenderThread* gpu_render_thread = channel_->gpu_render_thread(); 420 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager();
421 bool result = false; 421 bool result = false;
422 gpu_render_thread->Send( 422 gpu_channel_manager->Send(
423 new GpuHostMsg_ResizeXID(handle_, size, &result)); 423 new GpuHostMsg_ResizeXID(handle_, size, &result));
424 #elif defined(OS_WIN) 424 #elif defined(OS_WIN)
425 HWND hwnd = static_cast<HWND>(compositor_window_); 425 HWND hwnd = static_cast<HWND>(compositor_window_);
426 UINT swp_flags = SWP_NOSENDCHANGING | SWP_NOOWNERZORDER | SWP_NOCOPYBITS | 426 UINT swp_flags = SWP_NOSENDCHANGING | SWP_NOOWNERZORDER | SWP_NOCOPYBITS |
427 SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_DEFERERASE; 427 SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_DEFERERASE;
428 SetWindowPos(hwnd, NULL, 0, 0, size.width(), size.height(), swp_flags); 428 SetWindowPos(hwnd, NULL, 0, 0, size.width(), size.height(), swp_flags);
429 #endif // defined(OS_LINUX) 429 #endif // defined(OS_LINUX)
430 } 430 }
431 } 431 }
432 432
433 #endif // defined(ENABLE_GPU) 433 #endif // defined(ENABLE_GPU)
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_command_buffer_stub.h ('k') | content/common/gpu/gpu_config.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698