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_command_buffer_stub.cc

Issue 8241012: Enable accelerated WebKit compositor for Aura. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address reviewer comments. Created 9 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 | Annotate | Revision Log
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/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/shared_memory.h" 10 #include "base/shared_memory.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "content/common/gpu/gpu_channel.h" 12 #include "content/common/gpu/gpu_channel.h"
13 #include "content/common/gpu/gpu_channel_manager.h" 13 #include "content/common/gpu/gpu_channel_manager.h"
14 #include "content/common/gpu/gpu_command_buffer_stub.h" 14 #include "content/common/gpu/gpu_command_buffer_stub.h"
15 #include "content/common/gpu/gpu_messages.h" 15 #include "content/common/gpu/gpu_messages.h"
16 #include "content/common/gpu/gpu_watchdog.h" 16 #include "content/common/gpu/gpu_watchdog.h"
17 #include "gpu/command_buffer/common/constants.h" 17 #include "gpu/command_buffer/common/constants.h"
18 #include "ui/gfx/gl/gl_switches.h" 18 #include "ui/gfx/gl/gl_switches.h"
19 19
20 #if defined(OS_MACOSX) || defined(TOUCH_UI) 20 #if defined(OS_MACOSX) || defined(UI_COMPOSITOR_IMAGE_TRANSPORT)
21 #include "content/common/gpu/image_transport_surface.h" 21 #include "content/common/gpu/image_transport_surface.h"
22 #endif 22 #endif
23 23
24 GpuCommandBufferStub::GpuCommandBufferStub( 24 GpuCommandBufferStub::GpuCommandBufferStub(
25 GpuChannel* channel, 25 GpuChannel* channel,
26 GpuCommandBufferStub* share_group, 26 GpuCommandBufferStub* share_group,
27 gfx::PluginWindowHandle handle, 27 gfx::PluginWindowHandle handle,
28 const gfx::Size& size, 28 const gfx::Size& size,
29 const gpu::gles2::DisallowedFeatures& disallowed_features, 29 const gpu::gles2::DisallowedFeatures& disallowed_features,
30 const std::string& allowed_extensions, 30 const std::string& allowed_extensions,
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 170
171 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group_.get())); 171 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group_.get()));
172 172
173 scheduler_.reset(new gpu::GpuScheduler(command_buffer_.get(), 173 scheduler_.reset(new gpu::GpuScheduler(command_buffer_.get(),
174 decoder_.get(), 174 decoder_.get(),
175 NULL)); 175 NULL));
176 176
177 decoder_->set_engine(scheduler_.get()); 177 decoder_->set_engine(scheduler_.get());
178 178
179 if (handle_) { 179 if (handle_) {
180 #if defined(TOUCH_UI) || defined(OS_MACOSX) 180 #if defined(OS_MACOSX) || defined(UI_COMPOSITOR_IMAGE_TRANSPORT)
181 if (software_) { 181 if (software_) {
182 OnInitializeFailed(reply_message); 182 OnInitializeFailed(reply_message);
183 return; 183 return;
184 } 184 }
185 185
186 surface_ = ImageTransportSurface::CreateSurface( 186 surface_ = ImageTransportSurface::CreateSurface(
187 channel_->gpu_channel_manager(), 187 channel_->gpu_channel_manager(),
188 render_view_id_, 188 render_view_id_,
189 renderer_id_, 189 renderer_id_,
190 route_id_, 190 route_id_,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 NewCallback(scheduler_.get(), 234 NewCallback(scheduler_.get(),
235 &gpu::GpuScheduler::PutChanged)); 235 &gpu::GpuScheduler::PutChanged));
236 command_buffer_->SetParseErrorCallback( 236 command_buffer_->SetParseErrorCallback(
237 NewCallback(this, &GpuCommandBufferStub::OnParseError)); 237 NewCallback(this, &GpuCommandBufferStub::OnParseError));
238 scheduler_->SetScheduledCallback( 238 scheduler_->SetScheduledCallback(
239 NewCallback(channel_, &GpuChannel::OnScheduled)); 239 NewCallback(channel_, &GpuChannel::OnScheduled));
240 240
241 // On platforms that use an ImageTransportSurface, the surface 241 // On platforms that use an ImageTransportSurface, the surface
242 // handles co-ordinating the resize with the browser process. The 242 // handles co-ordinating the resize with the browser process. The
243 // surface sets it's own resize callback, so we shouldn't do it here. 243 // surface sets it's own resize callback, so we shouldn't do it here.
244 #if !defined(TOUCH_UI) && !defined(OS_MACOSX) 244 #if !defined(OS_MACOSX) && !defined(UI_COMPOSITOR_IMAGE_TRANSPORT)
245 if (handle_ != gfx::kNullPluginWindow) { 245 if (handle_ != gfx::kNullPluginWindow) {
246 decoder_->SetResizeCallback( 246 decoder_->SetResizeCallback(
247 NewCallback(this, &GpuCommandBufferStub::OnResize)); 247 NewCallback(this, &GpuCommandBufferStub::OnResize));
248 } 248 }
249 #endif 249 #endif
250 250
251 if (watchdog_) { 251 if (watchdog_) {
252 scheduler_->SetCommandProcessedCallback( 252 scheduler_->SetCommandProcessedCallback(
253 NewCallback(this, &GpuCommandBufferStub::OnCommandProcessed)); 253 NewCallback(this, &GpuCommandBufferStub::OnCommandProcessed));
254 } 254 }
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 411
412 void GpuCommandBufferStub::OnCommandProcessed() { 412 void GpuCommandBufferStub::OnCommandProcessed() {
413 if (watchdog_) 413 if (watchdog_)
414 watchdog_->CheckArmed(); 414 watchdog_->CheckArmed();
415 } 415 }
416 416
417 void GpuCommandBufferStub::OnResize(gfx::Size size) { 417 void GpuCommandBufferStub::OnResize(gfx::Size size) {
418 if (handle_ == gfx::kNullPluginWindow) 418 if (handle_ == gfx::kNullPluginWindow)
419 return; 419 return;
420 420
421 #if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI) || defined(OS_WIN) 421 #if defined(TOOLKIT_USES_GTK) && !defined(UI_COMPOSITOR_IMAGE_TRANSPORT) || \
422 defined(OS_WIN)
422 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); 423 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager();
423 424
424 // On Windows, Linux, we need to coordinate resizing of onscreen 425 // On Windows, Linux, we need to coordinate resizing of onscreen
425 // contexts with the resizing of the actual OS-level window. We do this by 426 // contexts with the resizing of the actual OS-level window. We do this by
426 // sending a resize message to the browser process and descheduling the 427 // sending a resize message to the browser process and descheduling the
427 // context until the ViewResized message comes back in reply. 428 // context until the ViewResized message comes back in reply.
428 // Send the resize message if needed 429 // Send the resize message if needed
429 gpu_channel_manager->Send( 430 gpu_channel_manager->Send(
430 new GpuHostMsg_ResizeView(renderer_id_, 431 new GpuHostMsg_ResizeView(renderer_id_,
431 render_view_id_, 432 render_view_id_,
432 route_id_, 433 route_id_,
433 size)); 434 size));
434 435
435 scheduler_->SetScheduled(false); 436 scheduler_->SetScheduled(false);
436 #endif // defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI) || defined(OS_WIN) 437 #endif
437 } 438 }
438 439
439 void GpuCommandBufferStub::ViewResized() { 440 void GpuCommandBufferStub::ViewResized() {
440 #if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI) || defined(OS_WIN) 441 #if defined(TOOLKIT_USES_GTK) && !defined(UI_COMPOSITOR_IMAGE_TRANSPORT) || \
442 defined(OS_WIN)
441 DCHECK(handle_ != gfx::kNullPluginWindow); 443 DCHECK(handle_ != gfx::kNullPluginWindow);
442 scheduler_->SetScheduled(true); 444 scheduler_->SetScheduled(true);
443 #endif 445 #endif
444 446
445 #if defined(OS_WIN) 447 #if defined(OS_WIN)
446 // Recreate the view surface to match the window size. Swap chains do not 448 // Recreate the view surface to match the window size. Swap chains do not
447 // automatically resize with window size with D3D. 449 // automatically resize with window size with D3D.
448 context_->ReleaseCurrent(surface_.get()); 450 context_->ReleaseCurrent(surface_.get());
449 if (surface_.get()) { 451 if (surface_.get()) {
450 surface_->Destroy(); 452 surface_->Destroy();
451 surface_->Initialize(); 453 surface_->Initialize();
452 SetSwapInterval(); 454 SetSwapInterval();
453 } 455 }
454 #endif 456 #endif
455 } 457 }
456 458
457 void GpuCommandBufferStub::ReportState() { 459 void GpuCommandBufferStub::ReportState() {
458 gpu::CommandBuffer::State state = command_buffer_->GetState(); 460 gpu::CommandBuffer::State state = command_buffer_->GetState();
459 if (state.error == gpu::error::kLostContext && 461 if (state.error == gpu::error::kLostContext &&
460 gfx::GLContext::LosesAllContextsOnContextLost()) { 462 gfx::GLContext::LosesAllContextsOnContextLost()) {
461 channel_->LoseAllContexts(); 463 channel_->LoseAllContexts();
462 } else { 464 } else {
463 IPC::Message* msg = new GpuCommandBufferMsg_UpdateState(route_id_, state); 465 IPC::Message* msg = new GpuCommandBufferMsg_UpdateState(route_id_, state);
464 msg->set_unblock(true); 466 msg->set_unblock(true);
465 Send(msg); 467 Send(msg);
466 } 468 }
467 } 469 }
468 470
469 void GpuCommandBufferStub::SetSwapInterval() { 471 void GpuCommandBufferStub::SetSwapInterval() {
470 #if !defined(OS_MACOSX) && !defined(TOUCH_UI) 472 #if !defined(OS_MACOSX) && !defined(UI_COMPOSITOR_IMAGE_TRANSPORT)
471 // Set up swap interval for onscreen contexts. 473 // Set up swap interval for onscreen contexts.
472 if (!surface_->IsOffscreen()) { 474 if (!surface_->IsOffscreen()) {
473 decoder_->MakeCurrent(); 475 decoder_->MakeCurrent();
474 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableGpuVsync)) 476 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableGpuVsync))
475 context_->SetSwapInterval(0); 477 context_->SetSwapInterval(0);
476 else 478 else
477 context_->SetSwapInterval(1); 479 context_->SetSwapInterval(1);
478 } 480 }
479 #endif 481 #endif
480 } 482 }
(...skipping 10 matching lines...) Expand all
491 channel_->AddRoute(decoder_route_id, decoder); 493 channel_->AddRoute(decoder_route_id, decoder);
492 decoder->Initialize(profile, reply_message); 494 decoder->Initialize(profile, reply_message);
493 } 495 }
494 496
495 void GpuCommandBufferStub::OnDestroyVideoDecoder(int decoder_route_id) { 497 void GpuCommandBufferStub::OnDestroyVideoDecoder(int decoder_route_id) {
496 channel_->RemoveRoute(decoder_route_id); 498 channel_->RemoveRoute(decoder_route_id);
497 video_decoders_.Remove(decoder_route_id); 499 video_decoders_.Remove(decoder_route_id);
498 } 500 }
499 501
500 #endif // defined(ENABLE_GPU) 502 #endif // defined(ENABLE_GPU)
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view.h ('k') | content/common/gpu/gpu_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698