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 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 } | 633 } |
634 | 634 |
635 GURL RenderWidget::GetURLForGraphicsContext3D() { | 635 GURL RenderWidget::GetURLForGraphicsContext3D() { |
636 return GURL(); | 636 return GURL(); |
637 } | 637 } |
638 | 638 |
639 bool RenderWidget::ForceCompositingModeEnabled() { | 639 bool RenderWidget::ForceCompositingModeEnabled() { |
640 return false; | 640 return false; |
641 } | 641 } |
642 | 642 |
643 scoped_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface(bool fallback) { | 643 scoped_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface( |
| 644 bool fallback, size_t max_bytes_pending_upload) { |
644 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 645 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
645 | 646 |
646 #if defined(OS_ANDROID) | 647 #if defined(OS_ANDROID) |
647 if (SynchronousCompositorFactory* factory = | 648 if (SynchronousCompositorFactory* factory = |
648 SynchronousCompositorFactory::GetInstance()) { | 649 SynchronousCompositorFactory::GetInstance()) { |
649 return factory->CreateOutputSurface(routing_id()); | 650 return factory->CreateOutputSurface(routing_id()); |
650 } | 651 } |
651 #endif | 652 #endif |
652 | 653 |
653 uint32 output_surface_id = next_output_surface_id_++; | 654 uint32 output_surface_id = next_output_surface_id_++; |
(...skipping 12 matching lines...) Expand all Loading... |
666 attributes.antialias = false; | 667 attributes.antialias = false; |
667 attributes.shareResources = true; | 668 attributes.shareResources = true; |
668 attributes.noAutomaticFlushes = true; | 669 attributes.noAutomaticFlushes = true; |
669 attributes.depth = false; | 670 attributes.depth = false; |
670 attributes.stencil = false; | 671 attributes.stencil = false; |
671 if (command_line.HasSwitch(cc::switches::kForceDirectLayerDrawing)) | 672 if (command_line.HasSwitch(cc::switches::kForceDirectLayerDrawing)) |
672 attributes.stencil = true; | 673 attributes.stencil = true; |
673 scoped_refptr<ContextProviderCommandBuffer> context_provider; | 674 scoped_refptr<ContextProviderCommandBuffer> context_provider; |
674 if (!fallback) { | 675 if (!fallback) { |
675 context_provider = ContextProviderCommandBuffer::Create( | 676 context_provider = ContextProviderCommandBuffer::Create( |
676 CreateGraphicsContext3D(attributes)); | 677 CreateGraphicsContext3D(attributes, max_bytes_pending_upload)); |
677 } | 678 } |
678 | 679 |
679 if (!context_provider.get()) { | 680 if (!context_provider.get()) { |
680 if (!command_line.HasSwitch(switches::kEnableSoftwareCompositing)) | 681 if (!command_line.HasSwitch(switches::kEnableSoftwareCompositing)) |
681 return scoped_ptr<cc::OutputSurface>(); | 682 return scoped_ptr<cc::OutputSurface>(); |
682 | 683 |
683 scoped_ptr<cc::SoftwareOutputDevice> software_device( | 684 scoped_ptr<cc::SoftwareOutputDevice> software_device( |
684 new CompositorSoftwareOutputDevice()); | 685 new CompositorSoftwareOutputDevice()); |
685 | 686 |
686 return scoped_ptr<cc::OutputSurface>(new CompositorOutputSurface( | 687 return scoped_ptr<cc::OutputSurface>(new CompositorOutputSurface( |
(...skipping 1832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2519 void RenderWidget::hasTouchEventHandlers(bool has_handlers) { | 2520 void RenderWidget::hasTouchEventHandlers(bool has_handlers) { |
2520 Send(new ViewHostMsg_HasTouchEventHandlers(routing_id_, has_handlers)); | 2521 Send(new ViewHostMsg_HasTouchEventHandlers(routing_id_, has_handlers)); |
2521 } | 2522 } |
2522 | 2523 |
2523 bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const { | 2524 bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const { |
2524 return true; | 2525 return true; |
2525 } | 2526 } |
2526 | 2527 |
2527 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> | 2528 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> |
2528 RenderWidget::CreateGraphicsContext3D( | 2529 RenderWidget::CreateGraphicsContext3D( |
2529 const WebKit::WebGraphicsContext3D::Attributes& attributes) { | 2530 const WebKit::WebGraphicsContext3D::Attributes& attributes, |
| 2531 size_t max_bytes_pending_upload) { |
2530 if (!webwidget_) | 2532 if (!webwidget_) |
2531 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); | 2533 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); |
2532 if (CommandLine::ForCurrentProcess()->HasSwitch( | 2534 if (CommandLine::ForCurrentProcess()->HasSwitch( |
2533 switches::kDisableGpuCompositing)) | 2535 switches::kDisableGpuCompositing)) |
2534 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); | 2536 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); |
2535 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( | 2537 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( |
2536 new WebGraphicsContext3DCommandBufferImpl( | 2538 new WebGraphicsContext3DCommandBufferImpl( |
2537 surface_id(), | 2539 surface_id(), |
2538 GetURLForGraphicsContext3D(), | 2540 GetURLForGraphicsContext3D(), |
2539 RenderThreadImpl::current(), | 2541 RenderThreadImpl::current(), |
2540 weak_ptr_factory_.GetWeakPtr())); | 2542 weak_ptr_factory_.GetWeakPtr())); |
2541 | 2543 |
2542 if (!context->InitializeWithDefaultBufferSizes( | 2544 // We keep the MappedMemoryReclaimLimit the same as the upload limit |
| 2545 // to avoid unnecessarily stalling the compositor thread. |
| 2546 const size_t kMappedMemoryReclaimLimit = max_bytes_pending_upload; |
| 2547 |
| 2548 if (!context->Initialize( |
2543 attributes, | 2549 attributes, |
2544 false /* bind generates resources */, | 2550 false /* bind generates resources */, |
2545 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)
) | 2551 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE, |
| 2552 kDefaultCommandBufferSize, |
| 2553 kDefaultStartTransferBufferSize, |
| 2554 kDefaultMinTransferBufferSize, |
| 2555 kDefaultMaxTransferBufferSize, |
| 2556 kMappedMemoryReclaimLimit)) |
2546 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); | 2557 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); |
2547 return context.Pass(); | 2558 return context.Pass(); |
2548 } | 2559 } |
2549 | 2560 |
2550 } // namespace content | 2561 } // namespace content |
OLD | NEW |