| 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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 ->AllocateSurfaceClientId())), | 386 ->AllocateSurfaceClientId())), |
| 387 resource_manager_(root_window), | 387 resource_manager_(root_window), |
| 388 has_transparent_background_(false), | 388 has_transparent_background_(false), |
| 389 device_scale_factor_(1), | 389 device_scale_factor_(1), |
| 390 window_(NULL), | 390 window_(NULL), |
| 391 surface_handle_(gpu::kNullSurfaceHandle), | 391 surface_handle_(gpu::kNullSurfaceHandle), |
| 392 client_(client), | 392 client_(client), |
| 393 root_window_(root_window), | 393 root_window_(root_window), |
| 394 needs_animate_(false), | 394 needs_animate_(false), |
| 395 pending_swapbuffers_(0U), | 395 pending_swapbuffers_(0U), |
| 396 num_successive_gpu_process_initialization_failures_(0), |
| 396 num_successive_context_creation_failures_(0), | 397 num_successive_context_creation_failures_(0), |
| 397 output_surface_request_pending_(false), | 398 output_surface_request_pending_(false), |
| 398 needs_begin_frames_(false), | 399 needs_begin_frames_(false), |
| 399 weak_factory_(this) { | 400 weak_factory_(this) { |
| 400 ui::ContextProviderFactory::GetInstance() | 401 ui::ContextProviderFactory::GetInstance() |
| 401 ->GetSurfaceManager() | 402 ->GetSurfaceManager() |
| 402 ->RegisterSurfaceClientId(surface_id_allocator_->client_id()); | 403 ->RegisterSurfaceClientId(surface_id_allocator_->client_id()); |
| 403 DCHECK(client); | 404 DCHECK(client); |
| 404 DCHECK(root_window); | 405 DCHECK(root_window); |
| 405 DCHECK(root_window->GetLayer() == nullptr); | 406 DCHECK(root_window->GetLayer() == nullptr); |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 | 642 |
| 642 if (!display_output_surface) | 643 if (!display_output_surface) |
| 643 return; | 644 return; |
| 644 | 645 |
| 645 InitializeDisplay(std::move(display_output_surface), | 646 InitializeDisplay(std::move(display_output_surface), |
| 646 std::move(vulkan_context_provider), nullptr); | 647 std::move(vulkan_context_provider), nullptr); |
| 647 } | 648 } |
| 648 #endif | 649 #endif |
| 649 | 650 |
| 650 void CompositorImpl::CreateCompositorOutputSurface( | 651 void CompositorImpl::CreateCompositorOutputSurface( |
| 651 const scoped_refptr<cc::ContextProvider>& context_provider) { | 652 const scoped_refptr<cc::ContextProvider>& context_provider, |
| 652 // This callback should run only if we have a pending output surface request, | 653 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_); | 654 DCHECK(output_surface_request_pending_); |
| 657 DCHECK(host_->visible()); | |
| 658 DCHECK(window_); | |
| 659 DCHECK_NE(surface_handle_, gpu::kNullSurfaceHandle); | |
| 660 DCHECK(context_provider); | |
| 661 | 655 |
| 662 scoped_refptr<ContextProviderCommandBuffer> context_provider_command_buffer = | 656 switch (result) { |
| 663 static_cast<ContextProviderCommandBuffer*>(context_provider.get()); | 657 // Don't retry if we are shutting down or if the Gpu Surface handle was |
| 664 std::unique_ptr<cc::OutputSurface> display_output_surface( | 658 // lost. The Gpu Surface handle loss should happen only if we are invisible |
| 665 new OutputSurfaceWithoutParent( | 659 // or this was from a previous request and the current surface has changed, |
| 666 context_provider_command_buffer, | 660 // in which case we would have made another request with the factory. |
| 667 base::Bind(&CompositorImpl::PopulateGpuCapabilities, | 661 case ui::ContextProviderFactory::ContextCreationResult:: |
| 668 base::Unretained(this)))); | 662 FAILURE_BROWSER_SHUTDOWN: |
| 669 InitializeDisplay(std::move(display_output_surface), nullptr, | 663 case ui::ContextProviderFactory::ContextCreationResult:: |
| 670 std::move(context_provider)); | 664 FAILURE_GPU_SURFACE_HANDLE_LOST: |
| 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 LOG_IF(FATAL, |
| 671 ++num_successive_gpu_process_initialization_failures_ >= 2) |
| 672 << "Too many GPU Process initialization failures. Giving up... "; |
| 673 HandlePendingOutputSurfaceRequest(); |
| 674 } |
| 675 break; |
| 676 case ui::ContextProviderFactory::ContextCreationResult::SUCCESS: |
| 677 DCHECK(host_->visible()); |
| 678 DCHECK(window_); |
| 679 DCHECK_NE(surface_handle_, gpu::kNullSurfaceHandle); |
| 680 DCHECK(context_provider); |
| 681 |
| 682 num_successive_gpu_process_initialization_failures_ = 0; |
| 683 scoped_refptr<ContextProviderCommandBuffer> |
| 684 context_provider_command_buffer = |
| 685 static_cast<ContextProviderCommandBuffer*>( |
| 686 context_provider.get()); |
| 687 std::unique_ptr<cc::OutputSurface> display_output_surface( |
| 688 new OutputSurfaceWithoutParent( |
| 689 context_provider_command_buffer, |
| 690 base::Bind(&CompositorImpl::PopulateGpuCapabilities, |
| 691 base::Unretained(this)))); |
| 692 InitializeDisplay(std::move(display_output_surface), nullptr, |
| 693 std::move(context_provider)); |
| 694 break; |
| 695 } |
| 671 } | 696 } |
| 672 | 697 |
| 673 void CompositorImpl::InitializeDisplay( | 698 void CompositorImpl::InitializeDisplay( |
| 674 std::unique_ptr<cc::OutputSurface> display_output_surface, | 699 std::unique_ptr<cc::OutputSurface> display_output_surface, |
| 675 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider, | 700 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider, |
| 676 scoped_refptr<cc::ContextProvider> context_provider) { | 701 scoped_refptr<cc::ContextProvider> context_provider) { |
| 677 DCHECK(output_surface_request_pending_); | 702 DCHECK(output_surface_request_pending_); |
| 678 | 703 |
| 679 pending_swapbuffers_ = 0; | 704 pending_swapbuffers_ = 0; |
| 680 | 705 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 | 818 |
| 794 TRACE_EVENT0("compositor", "Compositor::SetNeedsAnimate"); | 819 TRACE_EVENT0("compositor", "Compositor::SetNeedsAnimate"); |
| 795 host_->SetNeedsAnimate(); | 820 host_->SetNeedsAnimate(); |
| 796 } | 821 } |
| 797 | 822 |
| 798 bool CompositorImpl::HavePendingReadbacks() { | 823 bool CompositorImpl::HavePendingReadbacks() { |
| 799 return !readback_layer_tree_->children().empty(); | 824 return !readback_layer_tree_->children().empty(); |
| 800 } | 825 } |
| 801 | 826 |
| 802 } // namespace content | 827 } // namespace content |
| OLD | NEW |