| 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 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 | 642 |
| 643 if (!display_output_surface) | 643 if (!display_output_surface) |
| 644 return; | 644 return; |
| 645 | 645 |
| 646 InitializeDisplay(std::move(display_output_surface), | 646 InitializeDisplay(std::move(display_output_surface), |
| 647 std::move(vulkan_context_provider), nullptr); | 647 std::move(vulkan_context_provider), nullptr); |
| 648 } | 648 } |
| 649 #endif | 649 #endif |
| 650 | 650 |
| 651 void CompositorImpl::CreateCompositorOutputSurface( | 651 void CompositorImpl::CreateCompositorOutputSurface( |
| 652 const scoped_refptr<cc::ContextProvider>& context_provider, | 652 const scoped_refptr<cc::ContextProvider>& context_provider) { |
| 653 ui::ContextProviderFactory::ContextCreationResult result) { | 653 // This callback should run only if we have a pending output surface request, |
| 654 // since that is when we should have queued a context request. |
| 655 // In case the surface was invalidated after the context request was queued, |
| 656 // the request should have been dropped by the ContextProviderFactory. |
| 654 DCHECK(output_surface_request_pending_); | 657 DCHECK(output_surface_request_pending_); |
| 658 DCHECK(host_->visible()); |
| 659 DCHECK(window_); |
| 660 DCHECK_NE(surface_handle_, gpu::kNullSurfaceHandle); |
| 661 DCHECK(context_provider); |
| 655 | 662 |
| 656 switch (result) { | 663 scoped_refptr<ContextProviderCommandBuffer> context_provider_command_buffer = |
| 657 // Don't retry if we are shutting down or if the Gpu Surface handle was | 664 static_cast<ContextProviderCommandBuffer*>(context_provider.get()); |
| 658 // lost. The Gpu Surface handle loss should happen only if we are invisible | 665 std::unique_ptr<cc::OutputSurface> display_output_surface( |
| 659 // or this was from a previous request and the current surface has changed, | 666 new OutputSurfaceWithoutParent( |
| 660 // in which case we would have made another request with the factory. | 667 context_provider_command_buffer, |
| 661 case ui::ContextProviderFactory::ContextCreationResult:: | 668 base::Bind(&CompositorImpl::PopulateGpuCapabilities, |
| 662 FAILURE_FACTORY_SHUTDOWN: | 669 base::Unretained(this)))); |
| 663 case ui::ContextProviderFactory::ContextCreationResult:: | 670 InitializeDisplay(std::move(display_output_surface), nullptr, |
| 664 FAILURE_GPU_SURFACE_HANDLE_LOST: | 671 std::move(context_provider)); |
| 665 break; | |
| 666 case ui::ContextProviderFactory::ContextCreationResult:: | |
| 667 FAILURE_GPU_PROCESS_INITIALIZATION_FAILED: | |
| 668 // Retry only if we are visible. | |
| 669 if (host_->visible()) { | |
| 670 HandlePendingOutputSurfaceRequest(); | |
| 671 } | |
| 672 break; | |
| 673 case ui::ContextProviderFactory::ContextCreationResult::SUCCESS: | |
| 674 DCHECK(host_->visible()); | |
| 675 DCHECK(window_); | |
| 676 DCHECK_NE(surface_handle_, gpu::kNullSurfaceHandle); | |
| 677 DCHECK(context_provider); | |
| 678 | |
| 679 scoped_refptr<ContextProviderCommandBuffer> | |
| 680 context_provider_command_buffer = | |
| 681 static_cast<ContextProviderCommandBuffer*>( | |
| 682 context_provider.get()); | |
| 683 std::unique_ptr<cc::OutputSurface> display_output_surface( | |
| 684 new OutputSurfaceWithoutParent( | |
| 685 context_provider_command_buffer, | |
| 686 base::Bind(&CompositorImpl::PopulateGpuCapabilities, | |
| 687 base::Unretained(this)))); | |
| 688 InitializeDisplay(std::move(display_output_surface), nullptr, | |
| 689 std::move(context_provider)); | |
| 690 break; | |
| 691 } | |
| 692 } | 672 } |
| 693 | 673 |
| 694 void CompositorImpl::InitializeDisplay( | 674 void CompositorImpl::InitializeDisplay( |
| 695 std::unique_ptr<cc::OutputSurface> display_output_surface, | 675 std::unique_ptr<cc::OutputSurface> display_output_surface, |
| 696 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider, | 676 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider, |
| 697 scoped_refptr<cc::ContextProvider> context_provider) { | 677 scoped_refptr<cc::ContextProvider> context_provider) { |
| 698 DCHECK(output_surface_request_pending_); | 678 DCHECK(output_surface_request_pending_); |
| 699 | 679 |
| 700 pending_swapbuffers_ = 0; | 680 pending_swapbuffers_ = 0; |
| 701 | 681 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 | 795 |
| 816 TRACE_EVENT0("compositor", "Compositor::SetNeedsAnimate"); | 796 TRACE_EVENT0("compositor", "Compositor::SetNeedsAnimate"); |
| 817 host_->SetNeedsAnimate(); | 797 host_->SetNeedsAnimate(); |
| 818 } | 798 } |
| 819 | 799 |
| 820 bool CompositorImpl::HavePendingReadbacks() { | 800 bool CompositorImpl::HavePendingReadbacks() { |
| 821 return !readback_layer_tree_->children().empty(); | 801 return !readback_layer_tree_->children().empty(); |
| 822 } | 802 } |
| 823 | 803 |
| 824 } // namespace content | 804 } // namespace content |
| OLD | NEW |