Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: content/browser/renderer_host/compositor_impl_android.cc

Issue 2299183002: Revert of content: Fix Context creation logic in ContextProviderFactoryImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 ->AllocateSurfaceClientId())), 387 ->AllocateSurfaceClientId())),
388 resource_manager_(root_window), 388 resource_manager_(root_window),
389 has_transparent_background_(false), 389 has_transparent_background_(false),
390 device_scale_factor_(1), 390 device_scale_factor_(1),
391 window_(NULL), 391 window_(NULL),
392 surface_handle_(gpu::kNullSurfaceHandle), 392 surface_handle_(gpu::kNullSurfaceHandle),
393 client_(client), 393 client_(client),
394 root_window_(root_window), 394 root_window_(root_window),
395 needs_animate_(false), 395 needs_animate_(false),
396 pending_swapbuffers_(0U), 396 pending_swapbuffers_(0U),
397 num_successive_gpu_process_initialization_failures_(0),
398 num_successive_context_creation_failures_(0), 397 num_successive_context_creation_failures_(0),
399 output_surface_request_pending_(false), 398 output_surface_request_pending_(false),
400 needs_begin_frames_(false), 399 needs_begin_frames_(false),
401 weak_factory_(this) { 400 weak_factory_(this) {
402 ui::ContextProviderFactory::GetInstance() 401 ui::ContextProviderFactory::GetInstance()
403 ->GetSurfaceManager() 402 ->GetSurfaceManager()
404 ->RegisterSurfaceClientId(surface_id_allocator_->client_id()); 403 ->RegisterSurfaceClientId(surface_id_allocator_->client_id());
405 DCHECK(client); 404 DCHECK(client);
406 DCHECK(root_window); 405 DCHECK(root_window);
407 DCHECK(root_window->GetLayer() == nullptr); 406 DCHECK(root_window->GetLayer() == nullptr);
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 642
644 if (!display_output_surface) 643 if (!display_output_surface)
645 return; 644 return;
646 645
647 InitializeDisplay(std::move(display_output_surface), 646 InitializeDisplay(std::move(display_output_surface),
648 std::move(vulkan_context_provider), nullptr); 647 std::move(vulkan_context_provider), nullptr);
649 } 648 }
650 #endif 649 #endif
651 650
652 void CompositorImpl::CreateCompositorOutputSurface( 651 void CompositorImpl::CreateCompositorOutputSurface(
653 const scoped_refptr<cc::ContextProvider>& context_provider, 652 const scoped_refptr<cc::ContextProvider>& context_provider) {
654 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.
655 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);
656 662
657 switch (result) { 663 scoped_refptr<ContextProviderCommandBuffer> context_provider_command_buffer =
658 // Don't retry if we are shutting down or if the Gpu Surface handle was 664 static_cast<ContextProviderCommandBuffer*>(context_provider.get());
659 // lost. The Gpu Surface handle loss should happen only if we are invisible 665 std::unique_ptr<cc::OutputSurface> display_output_surface(
660 // or this was from a previous request and the current surface has changed, 666 new OutputSurfaceWithoutParent(
661 // in which case we would have made another request with the factory. 667 context_provider_command_buffer,
662 case ui::ContextProviderFactory::ContextCreationResult:: 668 base::Bind(&CompositorImpl::PopulateGpuCapabilities,
663 FAILURE_FACTORY_SHUTDOWN: 669 base::Unretained(this))));
664 case ui::ContextProviderFactory::ContextCreationResult:: 670 InitializeDisplay(std::move(display_output_surface), nullptr,
665 FAILURE_GPU_SURFACE_HANDLE_LOST: 671 std::move(context_provider));
666 break;
667 case ui::ContextProviderFactory::ContextCreationResult::
668 FAILURE_GPU_PROCESS_INITIALIZATION_FAILED:
669 // Retry only if we are visible.
670 if (host_->visible()) {
671 LOG_IF(FATAL,
672 ++num_successive_gpu_process_initialization_failures_ >= 2)
673 << "Too many GPU Process initialization failures. Giving up... ";
674 HandlePendingOutputSurfaceRequest();
675 }
676 break;
677 case ui::ContextProviderFactory::ContextCreationResult::SUCCESS:
678 DCHECK(host_->visible());
679 DCHECK(window_);
680 DCHECK_NE(surface_handle_, gpu::kNullSurfaceHandle);
681 DCHECK(context_provider);
682
683 num_successive_gpu_process_initialization_failures_ = 0;
684 scoped_refptr<ContextProviderCommandBuffer>
685 context_provider_command_buffer =
686 static_cast<ContextProviderCommandBuffer*>(
687 context_provider.get());
688 std::unique_ptr<cc::OutputSurface> display_output_surface(
689 new OutputSurfaceWithoutParent(
690 context_provider_command_buffer,
691 base::Bind(&CompositorImpl::PopulateGpuCapabilities,
692 base::Unretained(this))));
693 InitializeDisplay(std::move(display_output_surface), nullptr,
694 std::move(context_provider));
695 break;
696 }
697 } 672 }
698 673
699 void CompositorImpl::InitializeDisplay( 674 void CompositorImpl::InitializeDisplay(
700 std::unique_ptr<cc::OutputSurface> display_output_surface, 675 std::unique_ptr<cc::OutputSurface> display_output_surface,
701 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider, 676 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider,
702 scoped_refptr<cc::ContextProvider> context_provider) { 677 scoped_refptr<cc::ContextProvider> context_provider) {
703 DCHECK(output_surface_request_pending_); 678 DCHECK(output_surface_request_pending_);
704 679
705 pending_swapbuffers_ = 0; 680 pending_swapbuffers_ = 0;
706 681
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 795
821 TRACE_EVENT0("compositor", "Compositor::SetNeedsAnimate"); 796 TRACE_EVENT0("compositor", "Compositor::SetNeedsAnimate");
822 host_->SetNeedsAnimate(); 797 host_->SetNeedsAnimate();
823 } 798 }
824 799
825 bool CompositorImpl::HavePendingReadbacks() { 800 bool CompositorImpl::HavePendingReadbacks() {
826 return !readback_layer_tree_->children().empty(); 801 return !readback_layer_tree_->children().empty();
827 } 802 }
828 803
829 } // namespace content 804 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698