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/browser/renderer_host/compositor_impl_android.h" | 5 #include "content/browser/renderer_host/compositor_impl_android.h" |
6 | 6 |
7 #include <android/bitmap.h> | 7 #include <android/bitmap.h> |
8 #include <android/native_window_jni.h> | 8 #include <android/native_window_jni.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <unordered_set> | 10 #include <unordered_set> |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
641 | 641 |
642 if (!display_output_surface) | 642 if (!display_output_surface) |
643 return; | 643 return; |
644 | 644 |
645 InitializeDisplay(std::move(display_output_surface), | 645 InitializeDisplay(std::move(display_output_surface), |
646 std::move(vulkan_context_provider), nullptr); | 646 std::move(vulkan_context_provider), nullptr); |
647 } | 647 } |
648 #endif | 648 #endif |
649 | 649 |
650 void CompositorImpl::CreateCompositorOutputSurface( | 650 void CompositorImpl::CreateCompositorOutputSurface( |
651 const scoped_refptr<cc::ContextProvider>& context_provider) { | 651 const scoped_refptr<cc::ContextProvider>& context_provider, |
652 // This callback should run only if we have a pending output surface request, | 652 ui::ContextProviderFactory::ContextCreationResult result) { |
653 // since that is when we should have queued a context request. | |
654 // In case the surface was invalidated after the context request was queued, | |
655 // the request should have been dropped by the ContextProviderFactory. | |
656 DCHECK(output_surface_request_pending_); | 653 DCHECK(output_surface_request_pending_); |
657 DCHECK(host_->visible()); | |
658 DCHECK(window_); | |
659 DCHECK_NE(surface_handle_, gpu::kNullSurfaceHandle); | |
660 DCHECK(context_provider); | |
661 | 654 |
662 scoped_refptr<ContextProviderCommandBuffer> context_provider_command_buffer = | 655 switch (result) { |
663 static_cast<ContextProviderCommandBuffer*>(context_provider.get()); | 656 // Don't retry if we are shutting down or if the Gpu Surface handle was |
664 std::unique_ptr<cc::OutputSurface> display_output_surface( | 657 // lost. The Gpu Surface handle loss should happen only if we are invisible |
665 new OutputSurfaceWithoutParent( | 658 // or this was from a previous request and the current surface has changed, |
666 context_provider_command_buffer, | 659 // in which case we would have made another request with the factory. |
667 base::Bind(&CompositorImpl::PopulateGpuCapabilities, | 660 case ui::ContextProviderFactory::ContextCreationResult:: |
668 base::Unretained(this)))); | 661 FAILURE_BROWSER_SHUTDOWN: |
669 InitializeDisplay(std::move(display_output_surface), nullptr, | 662 case ui::ContextProviderFactory::ContextCreationResult:: |
670 std::move(context_provider)); | 663 FAILURE_GPU_SURFACE_HANDLE_LOST: |
664 break; | |
665 case ui::ContextProviderFactory::ContextCreationResult:: | |
666 FAILURE_GPU_PROCESS_INITIALIZATION_FAILED: | |
667 // Retry only if we are visible. | |
Khushal
2016/08/17 21:24:56
Should there be a check for consecutive failures?
no sievers
2016/08/17 21:34:39
Yes, I think a LOG(FATAL) here would be good if th
Khushal
2016/08/17 21:55:54
Done.
| |
668 if (host_->visible()) | |
669 HandlePendingOutputSurfaceRequest(); | |
670 break; | |
671 case ui::ContextProviderFactory::ContextCreationResult::SUCCESS: | |
672 DCHECK(host_->visible()); | |
673 DCHECK(window_); | |
674 DCHECK_NE(surface_handle_, gpu::kNullSurfaceHandle); | |
675 DCHECK(context_provider); | |
676 scoped_refptr<ContextProviderCommandBuffer> | |
677 context_provider_command_buffer = | |
678 static_cast<ContextProviderCommandBuffer*>( | |
679 context_provider.get()); | |
680 std::unique_ptr<cc::OutputSurface> display_output_surface( | |
681 new OutputSurfaceWithoutParent( | |
682 context_provider_command_buffer, | |
683 base::Bind(&CompositorImpl::PopulateGpuCapabilities, | |
684 base::Unretained(this)))); | |
685 InitializeDisplay(std::move(display_output_surface), nullptr, | |
686 std::move(context_provider)); | |
687 break; | |
688 } | |
671 } | 689 } |
672 | 690 |
673 void CompositorImpl::InitializeDisplay( | 691 void CompositorImpl::InitializeDisplay( |
674 std::unique_ptr<cc::OutputSurface> display_output_surface, | 692 std::unique_ptr<cc::OutputSurface> display_output_surface, |
675 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider, | 693 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider, |
676 scoped_refptr<cc::ContextProvider> context_provider) { | 694 scoped_refptr<cc::ContextProvider> context_provider) { |
677 DCHECK(output_surface_request_pending_); | 695 DCHECK(output_surface_request_pending_); |
678 | 696 |
679 pending_swapbuffers_ = 0; | 697 pending_swapbuffers_ = 0; |
680 | 698 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
793 | 811 |
794 TRACE_EVENT0("compositor", "Compositor::SetNeedsAnimate"); | 812 TRACE_EVENT0("compositor", "Compositor::SetNeedsAnimate"); |
795 host_->SetNeedsAnimate(); | 813 host_->SetNeedsAnimate(); |
796 } | 814 } |
797 | 815 |
798 bool CompositorImpl::HavePendingReadbacks() { | 816 bool CompositorImpl::HavePendingReadbacks() { |
799 return !readback_layer_tree_->children().empty(); | 817 return !readback_layer_tree_->children().empty(); |
800 } | 818 } |
801 | 819 |
802 } // namespace content | 820 } // namespace content |
OLD | NEW |