| 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 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 GURL RenderWidget::GetURLForGraphicsContext3D() { | 565 GURL RenderWidget::GetURLForGraphicsContext3D() { |
| 566 return GURL(); | 566 return GURL(); |
| 567 } | 567 } |
| 568 | 568 |
| 569 bool RenderWidget::ForceCompositingModeEnabled() { | 569 bool RenderWidget::ForceCompositingModeEnabled() { |
| 570 return false; | 570 return false; |
| 571 } | 571 } |
| 572 | 572 |
| 573 scoped_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface() { | 573 scoped_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface() { |
| 574 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 574 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 575 |
| 576 #if defined(OS_ANDROID) |
| 577 if (command_line.HasSwitch(switches::kEnableSynchronousRendererCompositor)) { |
| 578 return scoped_ptr<cc::OutputSurface>( |
| 579 new SynchronousCompositorOutputSurface(routing_id())); |
| 580 } |
| 581 #endif |
| 582 |
| 575 if (command_line.HasSwitch(switches::kEnableSoftwareCompositingGLAdapter)) { | 583 if (command_line.HasSwitch(switches::kEnableSoftwareCompositingGLAdapter)) { |
| 576 return scoped_ptr<cc::OutputSurface>( | 584 return scoped_ptr<cc::OutputSurface>( |
| 577 new CompositorOutputSurface(routing_id(), NULL, | 585 new CompositorOutputSurface(routing_id(), NULL, |
| 578 new CompositorSoftwareOutputDevice())); | 586 new CompositorSoftwareOutputDevice())); |
| 579 } | 587 } |
| 580 | 588 |
| 581 // Explicitly disable antialiasing for the compositor. As of the time of | 589 // Explicitly disable antialiasing for the compositor. As of the time of |
| 582 // this writing, the only platform that supported antialiasing for the | 590 // this writing, the only platform that supported antialiasing for the |
| 583 // compositor was Mac OS X, because the on-screen OpenGL context creation | 591 // compositor was Mac OS X, because the on-screen OpenGL context creation |
| 584 // code paths on Windows and Linux didn't yet have multisampling support. | 592 // code paths on Windows and Linux didn't yet have multisampling support. |
| 585 // Mac OS X essentially always behaves as though it's rendering offscreen. | 593 // Mac OS X essentially always behaves as though it's rendering offscreen. |
| 586 // Multisampling has a heavy cost especially on devices with relatively low | 594 // Multisampling has a heavy cost especially on devices with relatively low |
| 587 // fill rate like most notebooks, and the Mac implementation would need to | 595 // fill rate like most notebooks, and the Mac implementation would need to |
| 588 // be optimized to resolve directly into the IOSurface shared between the | 596 // be optimized to resolve directly into the IOSurface shared between the |
| 589 // GPU and browser processes. For these reasons and to avoid platform | 597 // GPU and browser processes. For these reasons and to avoid platform |
| 590 // disparities we explicitly disable antialiasing. | 598 // disparities we explicitly disable antialiasing. |
| 591 WebKit::WebGraphicsContext3D::Attributes attributes; | 599 WebKit::WebGraphicsContext3D::Attributes attributes; |
| 592 attributes.antialias = false; | 600 attributes.antialias = false; |
| 593 attributes.shareResources = true; | 601 attributes.shareResources = true; |
| 594 attributes.noAutomaticFlushes = true; | 602 attributes.noAutomaticFlushes = true; |
| 595 WebGraphicsContext3DCommandBufferImpl* context = | 603 WebGraphicsContext3DCommandBufferImpl* context = |
| 596 CreateGraphicsContext3D(attributes); | 604 CreateGraphicsContext3D(attributes); |
| 597 if (!context) | 605 if (!context) |
| 598 return scoped_ptr<cc::OutputSurface>(); | 606 return scoped_ptr<cc::OutputSurface>(); |
| 599 | 607 |
| 600 #if defined(OS_ANDROID) | |
| 601 if (command_line.HasSwitch(switches::kEnableSynchronousRendererCompositor)) { | |
| 602 // TODO(joth): Move above the |context| creation step above when the | |
| 603 // SynchronousCompositor no longer depends on externally created context. | |
| 604 return scoped_ptr<cc::OutputSurface>( | |
| 605 new SynchronousCompositorOutputSurface(routing_id(), | |
| 606 context)); | |
| 607 } | |
| 608 #endif | |
| 609 | |
| 610 bool composite_to_mailbox = | 608 bool composite_to_mailbox = |
| 611 command_line.HasSwitch(cc::switches::kCompositeToMailbox) && | 609 command_line.HasSwitch(cc::switches::kCompositeToMailbox) && |
| 612 !command_line.HasSwitch(switches::kEnableDelegatedRenderer); | 610 !command_line.HasSwitch(switches::kEnableDelegatedRenderer); |
| 613 DCHECK(!composite_to_mailbox || command_line.HasSwitch( | 611 DCHECK(!composite_to_mailbox || command_line.HasSwitch( |
| 614 cc::switches::kEnableCompositorFrameMessage)); | 612 cc::switches::kEnableCompositorFrameMessage)); |
| 615 // No swap throttling yet when compositing on the main thread. | 613 // No swap throttling yet when compositing on the main thread. |
| 616 DCHECK(!composite_to_mailbox || is_threaded_compositing_enabled_); | 614 DCHECK(!composite_to_mailbox || is_threaded_compositing_enabled_); |
| 617 return scoped_ptr<cc::OutputSurface>(composite_to_mailbox ? | 615 return scoped_ptr<cc::OutputSurface>(composite_to_mailbox ? |
| 618 new MailboxOutputSurface(routing_id(), context, NULL) : | 616 new MailboxOutputSurface(routing_id(), context, NULL) : |
| 619 new CompositorOutputSurface(routing_id(), context, NULL)); | 617 new CompositorOutputSurface(routing_id(), context, NULL)); |
| (...skipping 1723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2343 | 2341 |
| 2344 if (!context->Initialize( | 2342 if (!context->Initialize( |
| 2345 attributes, | 2343 attributes, |
| 2346 false /* bind generates resources */, | 2344 false /* bind generates resources */, |
| 2347 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)
) | 2345 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)
) |
| 2348 return NULL; | 2346 return NULL; |
| 2349 return context.release(); | 2347 return context.release(); |
| 2350 } | 2348 } |
| 2351 | 2349 |
| 2352 } // namespace content | 2350 } // namespace content |
| OLD | NEW |