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/utf_string_conversions.h" | 15 #include "base/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/swapped_out_messages.h" | 23 #include "content/common/swapped_out_messages.h" |
24 #include "content/common/view_messages.h" | 24 #include "content/common/view_messages.h" |
25 #include "content/public/common/content_switches.h" | 25 #include "content/public/common/content_switches.h" |
26 #include "content/renderer/gpu/compositor_output_surface.h" | 26 #include "content/renderer/gpu/compositor_output_surface.h" |
27 #include "content/renderer/gpu/compositor_software_output_device_gl_adapter.h" | |
28 #include "content/renderer/gpu/input_handler_manager.h" | 27 #include "content/renderer/gpu/input_handler_manager.h" |
29 #include "content/renderer/gpu/mailbox_output_surface.h" | 28 #include "content/renderer/gpu/mailbox_output_surface.h" |
30 #include "content/renderer/gpu/render_widget_compositor.h" | 29 #include "content/renderer/gpu/render_widget_compositor.h" |
31 #include "content/renderer/render_process.h" | 30 #include "content/renderer/render_process.h" |
32 #include "content/renderer/render_thread_impl.h" | 31 #include "content/renderer/render_thread_impl.h" |
33 #include "content/renderer/renderer_webkitplatformsupport_impl.h" | 32 #include "content/renderer/renderer_webkitplatformsupport_impl.h" |
34 #include "ipc/ipc_sync_message.h" | 33 #include "ipc/ipc_sync_message.h" |
35 #include "skia/ext/platform_canvas.h" | 34 #include "skia/ext/platform_canvas.h" |
36 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h" | 35 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h" |
37 #include "third_party/WebKit/Source/Platform/chromium/public/WebPoint.h" | 36 #include "third_party/WebKit/Source/Platform/chromium/public/WebPoint.h" |
(...skipping 12 matching lines...) Expand all Loading... | |
50 #include "ui/gfx/rect_conversions.h" | 49 #include "ui/gfx/rect_conversions.h" |
51 #include "ui/gfx/size_conversions.h" | 50 #include "ui/gfx/size_conversions.h" |
52 #include "ui/gfx/skia_util.h" | 51 #include "ui/gfx/skia_util.h" |
53 #include "ui/gl/gl_switches.h" | 52 #include "ui/gl/gl_switches.h" |
54 #include "ui/surface/transport_dib.h" | 53 #include "ui/surface/transport_dib.h" |
55 #include "webkit/compositor_bindings/web_rendering_stats_impl.h" | 54 #include "webkit/compositor_bindings/web_rendering_stats_impl.h" |
56 #include "webkit/glue/webkit_glue.h" | 55 #include "webkit/glue/webkit_glue.h" |
57 #include "webkit/plugins/npapi/webplugin.h" | 56 #include "webkit/plugins/npapi/webplugin.h" |
58 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 57 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
59 | 58 |
59 #if defined(USE_AURA) | |
60 #include "content/renderer/gpu/compositor_software_output_device.h" | |
61 #else | |
62 #include "content/renderer/gpu/compositor_software_output_device_gl_adapter.h" | |
63 #endif // defined(USE_AURA) | |
64 | |
60 #if defined(OS_POSIX) | 65 #if defined(OS_POSIX) |
61 #include "ipc/ipc_channel_posix.h" | 66 #include "ipc/ipc_channel_posix.h" |
62 #include "third_party/skia/include/core/SkMallocPixelRef.h" | 67 #include "third_party/skia/include/core/SkMallocPixelRef.h" |
63 #include "third_party/skia/include/core/SkPixelRef.h" | 68 #include "third_party/skia/include/core/SkPixelRef.h" |
64 #endif // defined(OS_POSIX) | 69 #endif // defined(OS_POSIX) |
65 | 70 |
66 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWidget.h" | 71 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWidget.h" |
67 | 72 |
68 using WebKit::WebCompositionUnderline; | 73 using WebKit::WebCompositionUnderline; |
69 using WebKit::WebCursorInfo; | 74 using WebKit::WebCursorInfo; |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
548 | 553 |
549 GURL RenderWidget::GetURLForGraphicsContext3D() { | 554 GURL RenderWidget::GetURLForGraphicsContext3D() { |
550 return GURL(); | 555 return GURL(); |
551 } | 556 } |
552 | 557 |
553 bool RenderWidget::ForceCompositingModeEnabled() { | 558 bool RenderWidget::ForceCompositingModeEnabled() { |
554 return false; | 559 return false; |
555 } | 560 } |
556 | 561 |
557 scoped_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface() { | 562 scoped_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface() { |
563 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
564 | |
565 #if defined(USE_AURA) | |
piman
2013/04/03 18:31:26
AURA is really a UI concept, which shouldn't have
slavi
2013/04/03 21:38:22
Done.
I'll rename the flag in a separate CL that
| |
566 if (command_line.HasSwitch(switches::kEnableSoftwareCompositingGLAdapter)) { | |
567 return scoped_ptr<cc::OutputSurface>( | |
568 new CompositorOutputSurface(routing_id(), NULL, | |
569 new CompositorSoftwareOutputDevice())); | |
570 } | |
571 #endif // defined(USE_AURA) | |
572 | |
558 // Explicitly disable antialiasing for the compositor. As of the time of | 573 // Explicitly disable antialiasing for the compositor. As of the time of |
559 // this writing, the only platform that supported antialiasing for the | 574 // this writing, the only platform that supported antialiasing for the |
560 // compositor was Mac OS X, because the on-screen OpenGL context creation | 575 // compositor was Mac OS X, because the on-screen OpenGL context creation |
561 // code paths on Windows and Linux didn't yet have multisampling support. | 576 // code paths on Windows and Linux didn't yet have multisampling support. |
562 // Mac OS X essentially always behaves as though it's rendering offscreen. | 577 // Mac OS X essentially always behaves as though it's rendering offscreen. |
563 // Multisampling has a heavy cost especially on devices with relatively low | 578 // Multisampling has a heavy cost especially on devices with relatively low |
564 // fill rate like most notebooks, and the Mac implementation would need to | 579 // fill rate like most notebooks, and the Mac implementation would need to |
565 // be optimized to resolve directly into the IOSurface shared between the | 580 // be optimized to resolve directly into the IOSurface shared between the |
566 // GPU and browser processes. For these reasons and to avoid platform | 581 // GPU and browser processes. For these reasons and to avoid platform |
567 // disparities we explicitly disable antialiasing. | 582 // disparities we explicitly disable antialiasing. |
568 WebKit::WebGraphicsContext3D::Attributes attributes; | 583 WebKit::WebGraphicsContext3D::Attributes attributes; |
569 attributes.antialias = false; | 584 attributes.antialias = false; |
570 attributes.shareResources = true; | 585 attributes.shareResources = true; |
571 attributes.noAutomaticFlushes = true; | 586 attributes.noAutomaticFlushes = true; |
572 WebKit::WebGraphicsContext3D* context = CreateGraphicsContext3D(attributes); | 587 WebKit::WebGraphicsContext3D* context = CreateGraphicsContext3D(attributes); |
573 if (!context) | 588 if (!context) |
574 return scoped_ptr<cc::OutputSurface>(); | 589 return scoped_ptr<cc::OutputSurface>(); |
575 | 590 |
576 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 591 #if !defined(USE_AURA) |
577 if (command_line.HasSwitch(switches::kEnableSoftwareCompositingGLAdapter)) { | 592 if (command_line.HasSwitch(switches::kEnableSoftwareCompositingGLAdapter)) { |
578 // In the absence of a software-based delegating renderer, use this | |
579 // stopgap adapter class to present the software renderer output using a | |
580 // 3d context. | |
581 return scoped_ptr<cc::OutputSurface>( | 593 return scoped_ptr<cc::OutputSurface>( |
582 new CompositorOutputSurface(routing_id(), NULL, | 594 new CompositorOutputSurface(routing_id(), NULL, |
583 new CompositorSoftwareOutputDeviceGLAdapter(context))); | 595 new CompositorSoftwareOutputDeviceGLAdapter(context))); |
584 } else { | |
585 bool composite_to_mailbox = | |
586 command_line.HasSwitch(cc::switches::kCompositeToMailbox); | |
587 DCHECK(!composite_to_mailbox || command_line.HasSwitch( | |
588 cc::switches::kEnableCompositorFrameMessage)); | |
589 // No swap throttling yet when compositing on the main thread. | |
590 DCHECK(!composite_to_mailbox || is_threaded_compositing_enabled_); | |
591 return scoped_ptr<cc::OutputSurface>(composite_to_mailbox ? | |
592 new MailboxOutputSurface(routing_id(), context, NULL) : | |
593 new CompositorOutputSurface(routing_id(), context, NULL)); | |
594 } | 596 } |
597 #endif // !defined(USE_AURA) | |
598 | |
599 bool composite_to_mailbox = | |
600 command_line.HasSwitch(cc::switches::kCompositeToMailbox); | |
601 DCHECK(!composite_to_mailbox || command_line.HasSwitch( | |
602 cc::switches::kEnableCompositorFrameMessage)); | |
603 // No swap throttling yet when compositing on the main thread. | |
604 DCHECK(!composite_to_mailbox || is_threaded_compositing_enabled_); | |
605 return scoped_ptr<cc::OutputSurface>(composite_to_mailbox ? | |
606 new MailboxOutputSurface(routing_id(), context, NULL) : | |
607 new CompositorOutputSurface(routing_id(), context, NULL)); | |
595 } | 608 } |
596 | 609 |
597 void RenderWidget::OnViewContextSwapBuffersAborted() { | 610 void RenderWidget::OnViewContextSwapBuffersAborted() { |
598 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersAborted"); | 611 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersAborted"); |
599 while (!updates_pending_swap_.empty()) { | 612 while (!updates_pending_swap_.empty()) { |
600 ViewHostMsg_UpdateRect* msg = updates_pending_swap_.front(); | 613 ViewHostMsg_UpdateRect* msg = updates_pending_swap_.front(); |
601 updates_pending_swap_.pop_front(); | 614 updates_pending_swap_.pop_front(); |
602 // msg can be NULL if the swap doesn't correspond to an DoDeferredUpdate | 615 // msg can be NULL if the swap doesn't correspond to an DoDeferredUpdate |
603 // compositing pass, hence doesn't require an UpdateRect message. | 616 // compositing pass, hence doesn't require an UpdateRect message. |
604 if (msg) | 617 if (msg) |
(...skipping 1708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2313 | 2326 |
2314 if (!context->Initialize( | 2327 if (!context->Initialize( |
2315 attributes, | 2328 attributes, |
2316 false /* bind generates resources */, | 2329 false /* bind generates resources */, |
2317 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE) ) | 2330 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE) ) |
2318 return NULL; | 2331 return NULL; |
2319 return context.release(); | 2332 return context.release(); |
2320 } | 2333 } |
2321 | 2334 |
2322 } // namespace content | 2335 } // namespace content |
OLD | NEW |