OLD | NEW |
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/renderer/render_widget.h" | 5 #include "content/renderer/render_widget.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 "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 #include "ui/base/ui_base_switches.h" | 50 #include "ui/base/ui_base_switches.h" |
51 #include "ui/gfx/rect_conversions.h" | 51 #include "ui/gfx/rect_conversions.h" |
52 #include "ui/gfx/size_conversions.h" | 52 #include "ui/gfx/size_conversions.h" |
53 #include "ui/gfx/skia_util.h" | 53 #include "ui/gfx/skia_util.h" |
54 #include "ui/gl/gl_switches.h" | 54 #include "ui/gl/gl_switches.h" |
55 #include "ui/surface/transport_dib.h" | 55 #include "ui/surface/transport_dib.h" |
56 #include "webkit/glue/webkit_glue.h" | 56 #include "webkit/glue/webkit_glue.h" |
57 #include "webkit/plugins/npapi/webplugin.h" | 57 #include "webkit/plugins/npapi/webplugin.h" |
58 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 58 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
59 #include "webkit/renderer/compositor_bindings/web_rendering_stats_impl.h" | 59 #include "webkit/renderer/compositor_bindings/web_rendering_stats_impl.h" |
| 60 #include "webkit/renderer/compositor_bindings/web_to_ccinput_handler_adapter.h" |
60 | 61 |
61 #if defined(OS_ANDROID) | 62 #if defined(OS_ANDROID) |
| 63 #include "content/renderer/android/synchronous_compositor_impl.h" |
62 #include "content/renderer/android/synchronous_compositor_output_surface.h" | 64 #include "content/renderer/android/synchronous_compositor_output_surface.h" |
63 #endif | 65 #endif |
64 | 66 |
65 #if defined(OS_POSIX) | 67 #if defined(OS_POSIX) |
66 #include "ipc/ipc_channel_posix.h" | 68 #include "ipc/ipc_channel_posix.h" |
67 #include "third_party/skia/include/core/SkMallocPixelRef.h" | 69 #include "third_party/skia/include/core/SkMallocPixelRef.h" |
68 #include "third_party/skia/include/core/SkPixelRef.h" | 70 #include "third_party/skia/include/core/SkPixelRef.h" |
69 #endif // defined(OS_POSIX) | 71 #endif // defined(OS_POSIX) |
70 | 72 |
71 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWidget.h" | 73 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWidget.h" |
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 return GURL(); | 577 return GURL(); |
576 } | 578 } |
577 | 579 |
578 bool RenderWidget::ForceCompositingModeEnabled() { | 580 bool RenderWidget::ForceCompositingModeEnabled() { |
579 return false; | 581 return false; |
580 } | 582 } |
581 | 583 |
582 scoped_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface() { | 584 scoped_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface() { |
583 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 585 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
584 | 586 |
585 #if defined(OS_ANDROID) | 587 if (GetSynchronousCompositor()) { |
586 if (command_line.HasSwitch(switches::kEnableSynchronousRendererCompositor)) { | 588 return GetSynchronousCompositor()->CreateOutputSurface(); |
587 return scoped_ptr<cc::OutputSurface>( | |
588 new SynchronousCompositorOutputSurface(routing_id())); | |
589 } | 589 } |
590 #endif | |
591 | 590 |
592 if (command_line.HasSwitch(switches::kEnableSoftwareCompositingGLAdapter)) { | 591 if (command_line.HasSwitch(switches::kEnableSoftwareCompositingGLAdapter)) { |
593 return scoped_ptr<cc::OutputSurface>( | 592 return scoped_ptr<cc::OutputSurface>( |
594 new CompositorOutputSurface(routing_id(), NULL, | 593 new CompositorOutputSurface(routing_id(), NULL, |
595 new CompositorSoftwareOutputDevice())); | 594 new CompositorSoftwareOutputDevice())); |
596 } | 595 } |
597 | 596 |
598 // Explicitly disable antialiasing for the compositor. As of the time of | 597 // Explicitly disable antialiasing for the compositor. As of the time of |
599 // this writing, the only platform that supported antialiasing for the | 598 // this writing, the only platform that supported antialiasing for the |
600 // compositor was Mac OS X, because the on-screen OpenGL context creation | 599 // compositor was Mac OS X, because the on-screen OpenGL context creation |
(...skipping 18 matching lines...) Expand all Loading... |
619 bool composite_to_mailbox = | 618 bool composite_to_mailbox = |
620 command_line.HasSwitch(cc::switches::kCompositeToMailbox) && | 619 command_line.HasSwitch(cc::switches::kCompositeToMailbox) && |
621 !command_line.HasSwitch(switches::kEnableDelegatedRenderer); | 620 !command_line.HasSwitch(switches::kEnableDelegatedRenderer); |
622 // No swap throttling yet when compositing on the main thread. | 621 // No swap throttling yet when compositing on the main thread. |
623 DCHECK(!composite_to_mailbox || is_threaded_compositing_enabled_); | 622 DCHECK(!composite_to_mailbox || is_threaded_compositing_enabled_); |
624 return scoped_ptr<cc::OutputSurface>(composite_to_mailbox ? | 623 return scoped_ptr<cc::OutputSurface>(composite_to_mailbox ? |
625 new MailboxOutputSurface(routing_id(), context, NULL) : | 624 new MailboxOutputSurface(routing_id(), context, NULL) : |
626 new CompositorOutputSurface(routing_id(), context, NULL)); | 625 new CompositorOutputSurface(routing_id(), context, NULL)); |
627 } | 626 } |
628 | 627 |
| 628 SynchronousCompositorImpl* RenderWidget::GetSynchronousCompositor() { |
| 629 #if defined(OS_ANDROID) |
| 630 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 631 if (command_line.HasSwitch(switches::kEnableSynchronousRendererCompositor)) { |
| 632 synchronous_compositor_.reset(new SynchronousCompositorImpl(routing_id())); |
| 633 } |
| 634 return synchronous_compositor_.get(); |
| 635 #else |
| 636 return NULL; |
| 637 #endif |
| 638 } |
| 639 |
629 void RenderWidget::OnViewContextSwapBuffersAborted() { | 640 void RenderWidget::OnViewContextSwapBuffersAborted() { |
630 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersAborted"); | 641 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersAborted"); |
631 while (!updates_pending_swap_.empty()) { | 642 while (!updates_pending_swap_.empty()) { |
632 ViewHostMsg_UpdateRect* msg = updates_pending_swap_.front(); | 643 ViewHostMsg_UpdateRect* msg = updates_pending_swap_.front(); |
633 updates_pending_swap_.pop_front(); | 644 updates_pending_swap_.pop_front(); |
634 // msg can be NULL if the swap doesn't correspond to an DoDeferredUpdate | 645 // msg can be NULL if the swap doesn't correspond to an DoDeferredUpdate |
635 // compositing pass, hence doesn't require an UpdateRect message. | 646 // compositing pass, hence doesn't require an UpdateRect message. |
636 if (msg) | 647 if (msg) |
637 Send(msg); | 648 Send(msg); |
638 } | 649 } |
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1441 // going to switch to accelerated compositing, the GPU process may need | 1452 // going to switch to accelerated compositing, the GPU process may need |
1442 // round-trips to the browser's UI thread before finishing the frame, | 1453 // round-trips to the browser's UI thread before finishing the frame, |
1443 // causing deadlocks if we delay the UpdateRect until we receive the | 1454 // causing deadlocks if we delay the UpdateRect until we receive the |
1444 // OnSwapBuffersComplete. So send a dummy message that will unblock the | 1455 // OnSwapBuffersComplete. So send a dummy message that will unblock the |
1445 // browser's UI thread. This is not necessary on Mac, because SwapBuffers | 1456 // browser's UI thread. This is not necessary on Mac, because SwapBuffers |
1446 // now unblocks GetBackingStore on Mac. | 1457 // now unblocks GetBackingStore on Mac. |
1447 Send(new ViewHostMsg_UpdateIsDelayed(routing_id_)); | 1458 Send(new ViewHostMsg_UpdateIsDelayed(routing_id_)); |
1448 } | 1459 } |
1449 #endif | 1460 #endif |
1450 | 1461 |
| 1462 #if defined(OS_ANDROID) |
| 1463 if (GetSynchronousCompositor()) { |
| 1464 GetSynchronousCompositor()->didCreateInputHandler( |
| 1465 compositor_->GetInputHandler()); |
| 1466 } |
| 1467 #endif |
| 1468 |
1451 is_accelerated_compositing_active_ = true; | 1469 is_accelerated_compositing_active_ = true; |
1452 Send(new ViewHostMsg_DidActivateAcceleratedCompositing( | 1470 Send(new ViewHostMsg_DidActivateAcceleratedCompositing( |
1453 routing_id_, is_accelerated_compositing_active_)); | 1471 routing_id_, is_accelerated_compositing_active_)); |
1454 } | 1472 } |
1455 | 1473 |
1456 void RenderWidget::didDeactivateCompositor() { | 1474 void RenderWidget::didDeactivateCompositor() { |
1457 TRACE_EVENT0("gpu", "RenderWidget::didDeactivateCompositor"); | 1475 TRACE_EVENT0("gpu", "RenderWidget::didDeactivateCompositor"); |
1458 | 1476 |
1459 is_accelerated_compositing_active_ = false; | 1477 is_accelerated_compositing_active_ = false; |
1460 Send(new ViewHostMsg_DidActivateAcceleratedCompositing( | 1478 Send(new ViewHostMsg_DidActivateAcceleratedCompositing( |
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2362 | 2380 |
2363 if (!context->Initialize( | 2381 if (!context->Initialize( |
2364 attributes, | 2382 attributes, |
2365 false /* bind generates resources */, | 2383 false /* bind generates resources */, |
2366 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)
) | 2384 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)
) |
2367 return NULL; | 2385 return NULL; |
2368 return context.release(); | 2386 return context.release(); |
2369 } | 2387 } |
2370 | 2388 |
2371 } // namespace content | 2389 } // namespace content |
OLD | NEW |