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