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" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
17 #include "cc/base/switches.h" | 17 #include "cc/base/switches.h" |
18 #include "cc/base/thread.h" | 18 #include "cc/base/thread.h" |
19 #include "cc/base/thread_impl.h" | 19 #include "cc/base/thread_impl.h" |
20 #include "cc/output/output_surface.h" | 20 #include "cc/output/output_surface.h" |
21 #include "cc/trees/layer_tree_host.h" | 21 #include "cc/trees/layer_tree_host.h" |
22 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 22 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
23 #include "content/common/input_messages.h" | 23 #include "content/common/input_messages.h" |
24 #include "content/common/swapped_out_messages.h" | 24 #include "content/common/swapped_out_messages.h" |
25 #include "content/common/view_messages.h" | 25 #include "content/common/view_messages.h" |
26 #include "content/public/common/content_switches.h" | 26 #include "content/public/common/content_switches.h" |
27 #include "content/renderer/gpu/compositor_output_surface.h" | 27 #include "content/renderer/gpu/compositor_output_surface.h" |
28 #include "content/renderer/gpu/compositor_software_output_device.h" | 28 #include "content/renderer/gpu/compositor_software_output_device.h" |
| 29 #include "content/renderer/gpu/delegated_compositor_output_surface.h" |
29 #include "content/renderer/gpu/input_handler_manager.h" | 30 #include "content/renderer/gpu/input_handler_manager.h" |
30 #include "content/renderer/gpu/mailbox_output_surface.h" | 31 #include "content/renderer/gpu/mailbox_output_surface.h" |
31 #include "content/renderer/gpu/render_widget_compositor.h" | 32 #include "content/renderer/gpu/render_widget_compositor.h" |
32 #include "content/renderer/ime_event_guard.h" | 33 #include "content/renderer/ime_event_guard.h" |
33 #include "content/renderer/render_process.h" | 34 #include "content/renderer/render_process.h" |
34 #include "content/renderer/render_thread_impl.h" | 35 #include "content/renderer/render_thread_impl.h" |
35 #include "content/renderer/renderer_webkitplatformsupport_impl.h" | 36 #include "content/renderer/renderer_webkitplatformsupport_impl.h" |
36 #include "ipc/ipc_sync_message.h" | 37 #include "ipc/ipc_sync_message.h" |
37 #include "skia/ext/platform_canvas.h" | 38 #include "skia/ext/platform_canvas.h" |
38 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | 39 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" |
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 #if defined(OS_ANDROID) | 594 #if defined(OS_ANDROID) |
594 if (SynchronousCompositorFactory* factory = | 595 if (SynchronousCompositorFactory* factory = |
595 SynchronousCompositorFactory::GetInstance()) { | 596 SynchronousCompositorFactory::GetInstance()) { |
596 return factory->CreateOutputSurface(routing_id()); | 597 return factory->CreateOutputSurface(routing_id()); |
597 } | 598 } |
598 #endif | 599 #endif |
599 | 600 |
600 if (command_line.HasSwitch(switches::kEnableSoftwareCompositingGLAdapter)) { | 601 if (command_line.HasSwitch(switches::kEnableSoftwareCompositingGLAdapter)) { |
601 return scoped_ptr<cc::OutputSurface>( | 602 return scoped_ptr<cc::OutputSurface>( |
602 new CompositorOutputSurface(routing_id(), NULL, | 603 new CompositorOutputSurface(routing_id(), NULL, |
603 new CompositorSoftwareOutputDevice())); | 604 new CompositorSoftwareOutputDevice(), true)); |
604 } | 605 } |
605 | 606 |
606 // Explicitly disable antialiasing for the compositor. As of the time of | 607 // Explicitly disable antialiasing for the compositor. As of the time of |
607 // this writing, the only platform that supported antialiasing for the | 608 // this writing, the only platform that supported antialiasing for the |
608 // compositor was Mac OS X, because the on-screen OpenGL context creation | 609 // compositor was Mac OS X, because the on-screen OpenGL context creation |
609 // code paths on Windows and Linux didn't yet have multisampling support. | 610 // code paths on Windows and Linux didn't yet have multisampling support. |
610 // Mac OS X essentially always behaves as though it's rendering offscreen. | 611 // Mac OS X essentially always behaves as though it's rendering offscreen. |
611 // Multisampling has a heavy cost especially on devices with relatively low | 612 // Multisampling has a heavy cost especially on devices with relatively low |
612 // fill rate like most notebooks, and the Mac implementation would need to | 613 // fill rate like most notebooks, and the Mac implementation would need to |
613 // be optimized to resolve directly into the IOSurface shared between the | 614 // be optimized to resolve directly into the IOSurface shared between the |
614 // GPU and browser processes. For these reasons and to avoid platform | 615 // GPU and browser processes. For these reasons and to avoid platform |
615 // disparities we explicitly disable antialiasing. | 616 // disparities we explicitly disable antialiasing. |
616 WebKit::WebGraphicsContext3D::Attributes attributes; | 617 WebKit::WebGraphicsContext3D::Attributes attributes; |
617 attributes.antialias = false; | 618 attributes.antialias = false; |
618 attributes.shareResources = true; | 619 attributes.shareResources = true; |
619 attributes.noAutomaticFlushes = true; | 620 attributes.noAutomaticFlushes = true; |
620 attributes.depth = false; | 621 attributes.depth = false; |
621 attributes.stencil = false; | 622 attributes.stencil = false; |
622 if (command_line.HasSwitch(cc::switches::kForceDirectLayerDrawing)) | 623 if (command_line.HasSwitch(cc::switches::kForceDirectLayerDrawing)) |
623 attributes.stencil = true; | 624 attributes.stencil = true; |
624 WebGraphicsContext3DCommandBufferImpl* context = | 625 WebGraphicsContext3DCommandBufferImpl* context = |
625 CreateGraphicsContext3D(attributes); | 626 CreateGraphicsContext3D(attributes); |
626 if (!context) | 627 if (!context) |
627 return scoped_ptr<cc::OutputSurface>(); | 628 return scoped_ptr<cc::OutputSurface>(); |
628 | 629 |
629 bool composite_to_mailbox = | 630 if (command_line.HasSwitch(switches::kEnableDelegatedRenderer)) { |
630 command_line.HasSwitch(cc::switches::kCompositeToMailbox) && | 631 DCHECK(is_threaded_compositing_enabled_); |
631 !command_line.HasSwitch(switches::kEnableDelegatedRenderer); | 632 return scoped_ptr<cc::OutputSurface>( |
632 // No swap throttling yet when compositing on the main thread. | 633 new DelegatedCompositorOutputSurface(routing_id(), context, NULL)); |
633 DCHECK(!composite_to_mailbox || is_threaded_compositing_enabled_); | 634 } |
634 return scoped_ptr<cc::OutputSurface>(composite_to_mailbox ? | 635 if (command_line.HasSwitch(cc::switches::kCompositeToMailbox)) { |
635 new MailboxOutputSurface(routing_id(), context, NULL) : | 636 DCHECK(is_threaded_compositing_enabled_); |
636 new CompositorOutputSurface(routing_id(), context, NULL)); | 637 return scoped_ptr<cc::OutputSurface>( |
| 638 new MailboxOutputSurface(routing_id(), context, NULL)); |
| 639 } |
| 640 return scoped_ptr<cc::OutputSurface>( |
| 641 new CompositorOutputSurface(routing_id(), context, NULL, false)); |
637 } | 642 } |
638 | 643 |
639 void RenderWidget::OnViewContextSwapBuffersAborted() { | 644 void RenderWidget::OnViewContextSwapBuffersAborted() { |
640 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersAborted"); | 645 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersAborted"); |
641 while (!updates_pending_swap_.empty()) { | 646 while (!updates_pending_swap_.empty()) { |
642 ViewHostMsg_UpdateRect* msg = updates_pending_swap_.front(); | 647 ViewHostMsg_UpdateRect* msg = updates_pending_swap_.front(); |
643 updates_pending_swap_.pop_front(); | 648 updates_pending_swap_.pop_front(); |
644 // msg can be NULL if the swap doesn't correspond to an DoDeferredUpdate | 649 // msg can be NULL if the swap doesn't correspond to an DoDeferredUpdate |
645 // compositing pass, hence doesn't require an UpdateRect message. | 650 // compositing pass, hence doesn't require an UpdateRect message. |
646 if (msg) | 651 if (msg) |
(...skipping 1758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2405 | 2410 |
2406 if (!context->InitializeWithDefaultBufferSizes( | 2411 if (!context->InitializeWithDefaultBufferSizes( |
2407 attributes, | 2412 attributes, |
2408 false /* bind generates resources */, | 2413 false /* bind generates resources */, |
2409 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)
) | 2414 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)
) |
2410 return NULL; | 2415 return NULL; |
2411 return context.release(); | 2416 return context.release(); |
2412 } | 2417 } |
2413 | 2418 |
2414 } // namespace content | 2419 } // namespace content |
OLD | NEW |