| 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 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 } | 628 } |
| 629 | 629 |
| 630 GURL RenderWidget::GetURLForGraphicsContext3D() { | 630 GURL RenderWidget::GetURLForGraphicsContext3D() { |
| 631 return GURL(); | 631 return GURL(); |
| 632 } | 632 } |
| 633 | 633 |
| 634 bool RenderWidget::ForceCompositingModeEnabled() { | 634 bool RenderWidget::ForceCompositingModeEnabled() { |
| 635 return false; | 635 return false; |
| 636 } | 636 } |
| 637 | 637 |
| 638 scoped_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface() { | 638 scoped_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface(bool fallback) { |
| 639 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 639 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 640 | 640 |
| 641 #if defined(OS_ANDROID) | 641 #if defined(OS_ANDROID) |
| 642 if (SynchronousCompositorFactory* factory = | 642 if (SynchronousCompositorFactory* factory = |
| 643 SynchronousCompositorFactory::GetInstance()) { | 643 SynchronousCompositorFactory::GetInstance()) { |
| 644 return factory->CreateOutputSurface(routing_id()); | 644 return factory->CreateOutputSurface(routing_id()); |
| 645 } | 645 } |
| 646 #endif | 646 #endif |
| 647 | 647 |
| 648 uint32 output_surface_id = next_output_surface_id_++; | 648 uint32 output_surface_id = next_output_surface_id_++; |
| 649 | 649 |
| 650 if (command_line.HasSwitch(switches::kEnableSoftwareCompositingGLAdapter)) { | |
| 651 return scoped_ptr<cc::OutputSurface>( | |
| 652 new CompositorOutputSurface(routing_id(), output_surface_id, NULL, | |
| 653 new CompositorSoftwareOutputDevice(), true)); | |
| 654 } | |
| 655 | |
| 656 // Explicitly disable antialiasing for the compositor. As of the time of | 650 // Explicitly disable antialiasing for the compositor. As of the time of |
| 657 // this writing, the only platform that supported antialiasing for the | 651 // this writing, the only platform that supported antialiasing for the |
| 658 // compositor was Mac OS X, because the on-screen OpenGL context creation | 652 // compositor was Mac OS X, because the on-screen OpenGL context creation |
| 659 // code paths on Windows and Linux didn't yet have multisampling support. | 653 // code paths on Windows and Linux didn't yet have multisampling support. |
| 660 // Mac OS X essentially always behaves as though it's rendering offscreen. | 654 // Mac OS X essentially always behaves as though it's rendering offscreen. |
| 661 // Multisampling has a heavy cost especially on devices with relatively low | 655 // Multisampling has a heavy cost especially on devices with relatively low |
| 662 // fill rate like most notebooks, and the Mac implementation would need to | 656 // fill rate like most notebooks, and the Mac implementation would need to |
| 663 // be optimized to resolve directly into the IOSurface shared between the | 657 // be optimized to resolve directly into the IOSurface shared between the |
| 664 // GPU and browser processes. For these reasons and to avoid platform | 658 // GPU and browser processes. For these reasons and to avoid platform |
| 665 // disparities we explicitly disable antialiasing. | 659 // disparities we explicitly disable antialiasing. |
| 666 WebKit::WebGraphicsContext3D::Attributes attributes; | 660 WebKit::WebGraphicsContext3D::Attributes attributes; |
| 667 attributes.antialias = false; | 661 attributes.antialias = false; |
| 668 attributes.shareResources = true; | 662 attributes.shareResources = true; |
| 669 attributes.noAutomaticFlushes = true; | 663 attributes.noAutomaticFlushes = true; |
| 670 attributes.depth = false; | 664 attributes.depth = false; |
| 671 attributes.stencil = false; | 665 attributes.stencil = false; |
| 672 if (command_line.HasSwitch(cc::switches::kForceDirectLayerDrawing)) | 666 if (command_line.HasSwitch(cc::switches::kForceDirectLayerDrawing)) |
| 673 attributes.stencil = true; | 667 attributes.stencil = true; |
| 674 WebGraphicsContext3DCommandBufferImpl* context = | 668 WebGraphicsContext3DCommandBufferImpl* context = NULL; |
| 675 CreateGraphicsContext3D(attributes); | 669 if (!fallback) |
| 676 if (!context) | 670 context = CreateGraphicsContext3D(attributes); |
| 677 return scoped_ptr<cc::OutputSurface>(); | 671 |
| 672 if (!context) { |
| 673 if (!command_line.HasSwitch(switches::kEnableSoftwareCompositing)) |
| 674 return scoped_ptr<cc::OutputSurface>(); |
| 675 return scoped_ptr<cc::OutputSurface>( |
| 676 new CompositorOutputSurface(routing_id(), |
| 677 output_surface_id, |
| 678 NULL, |
| 679 new CompositorSoftwareOutputDevice(), |
| 680 true)); |
| 681 } |
| 678 | 682 |
| 679 if (command_line.HasSwitch(switches::kEnableDelegatedRenderer) && | 683 if (command_line.HasSwitch(switches::kEnableDelegatedRenderer) && |
| 680 !command_line.HasSwitch(switches::kDisableDelegatedRenderer)) { | 684 !command_line.HasSwitch(switches::kDisableDelegatedRenderer)) { |
| 681 DCHECK(is_threaded_compositing_enabled_); | 685 DCHECK(is_threaded_compositing_enabled_); |
| 682 return scoped_ptr<cc::OutputSurface>( | 686 return scoped_ptr<cc::OutputSurface>( |
| 683 new DelegatedCompositorOutputSurface(routing_id(), output_surface_id, | 687 new DelegatedCompositorOutputSurface(routing_id(), output_surface_id, |
| 684 context, NULL)); | 688 context, NULL)); |
| 685 } | 689 } |
| 686 if (command_line.HasSwitch(cc::switches::kCompositeToMailbox)) { | 690 if (command_line.HasSwitch(cc::switches::kCompositeToMailbox)) { |
| 687 DCHECK(is_threaded_compositing_enabled_); | 691 DCHECK(is_threaded_compositing_enabled_); |
| (...skipping 1785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2473 } | 2477 } |
| 2474 | 2478 |
| 2475 bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const { | 2479 bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const { |
| 2476 return true; | 2480 return true; |
| 2477 } | 2481 } |
| 2478 | 2482 |
| 2479 WebGraphicsContext3DCommandBufferImpl* RenderWidget::CreateGraphicsContext3D( | 2483 WebGraphicsContext3DCommandBufferImpl* RenderWidget::CreateGraphicsContext3D( |
| 2480 const WebKit::WebGraphicsContext3D::Attributes& attributes) { | 2484 const WebKit::WebGraphicsContext3D::Attributes& attributes) { |
| 2481 if (!webwidget_) | 2485 if (!webwidget_) |
| 2482 return NULL; | 2486 return NULL; |
| 2487 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 2488 switches::kDisableGpuCompositing)) |
| 2489 return NULL; |
| 2483 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( | 2490 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( |
| 2484 new WebGraphicsContext3DCommandBufferImpl( | 2491 new WebGraphicsContext3DCommandBufferImpl( |
| 2485 surface_id(), | 2492 surface_id(), |
| 2486 GetURLForGraphicsContext3D(), | 2493 GetURLForGraphicsContext3D(), |
| 2487 RenderThreadImpl::current(), | 2494 RenderThreadImpl::current(), |
| 2488 weak_ptr_factory_.GetWeakPtr())); | 2495 weak_ptr_factory_.GetWeakPtr())); |
| 2489 | 2496 |
| 2490 if (!context->InitializeWithDefaultBufferSizes( | 2497 if (!context->InitializeWithDefaultBufferSizes( |
| 2491 attributes, | 2498 attributes, |
| 2492 false /* bind generates resources */, | 2499 false /* bind generates resources */, |
| 2493 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)
) | 2500 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)
) |
| 2494 return NULL; | 2501 return NULL; |
| 2495 return context.release(); | 2502 return context.release(); |
| 2496 } | 2503 } |
| 2497 | 2504 |
| 2498 } // namespace content | 2505 } // namespace content |
| OLD | NEW |