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

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

Issue 2297933002: blimp: Set up the CompositorDependencies for blimp in Chrome. (Closed)
Patch Set: Addressed comments. 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 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 if (!host_->visible()) 603 if (!host_->visible())
604 return; 604 return;
605 605
606 #if defined(ENABLE_VULKAN) 606 #if defined(ENABLE_VULKAN)
607 CreateVulkanOutputSurface() 607 CreateVulkanOutputSurface()
608 if (display_) 608 if (display_)
609 return; 609 return;
610 #endif 610 #endif
611 611
612 DCHECK(surface_handle_ != gpu::kNullSurfaceHandle); 612 DCHECK(surface_handle_ != gpu::kNullSurfaceHandle);
613 613 ContextProviderFactoryImpl::GetInstance()->RequestGpuChannelHost(base::Bind(
614 ContextProviderFactoryImpl::GetInstance()->CreateDisplayContextProvider( 614 &CompositorImpl::OnGpuChannelEstablished, weak_factory_.GetWeakPtr()));
615 surface_handle_, GetCompositorContextSharedMemoryLimits(),
616 GetCompositorContextAttributes(has_transparent_background_),
617 false /*support_locking*/, false /*automatic_flushes*/,
618 base::Bind(&CompositorImpl::CreateCompositorOutputSurface,
619 weak_factory_.GetWeakPtr()));
620 } 615 }
621 616
622 #if defined(ENABLE_VULKAN) 617 #if defined(ENABLE_VULKAN)
623 void CompositorImpl::CreateVulkanOutputSurface() { 618 void CompositorImpl::CreateVulkanOutputSurface() {
624 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 619 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
625 switches::kEnableVulkan)) 620 switches::kEnableVulkan))
626 return; 621 return;
627 622
628 std::unique_ptr<cc::OutputSurface> display_output_surface; 623 std::unique_ptr<cc::OutputSurface> display_output_surface;
629 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider = 624 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider =
(...skipping 11 matching lines...) Expand all
641 } 636 }
642 637
643 if (!display_output_surface) 638 if (!display_output_surface)
644 return; 639 return;
645 640
646 InitializeDisplay(std::move(display_output_surface), 641 InitializeDisplay(std::move(display_output_surface),
647 std::move(vulkan_context_provider), nullptr); 642 std::move(vulkan_context_provider), nullptr);
648 } 643 }
649 #endif 644 #endif
650 645
651 void CompositorImpl::CreateCompositorOutputSurface( 646 void CompositorImpl::OnGpuChannelEstablished(
652 const scoped_refptr<cc::ContextProvider>& context_provider, 647 const scoped_refptr<gpu::GpuChannelHost>& gpu_channel_host,
danakj 2016/09/02 00:35:29 This should be by value too.
Khushal 2016/09/02 16:26:47 Done.
653 ui::ContextProviderFactory::ContextCreationResult result) { 648 ui::ContextProviderFactory::GpuChannelHostResult result) {
654 DCHECK(output_surface_request_pending_); 649 DCHECK(output_surface_request_pending_);
655 650
656 switch (result) { 651 switch (result) {
657 // Don't retry if we are shutting down or if the Gpu Surface handle was 652 // Don't retry if we are shutting down.
658 // lost. The Gpu Surface handle loss should happen only if we are invisible 653 case ui::ContextProviderFactory::GpuChannelHostResult::
659 // or this was from a previous request and the current surface has changed,
660 // in which case we would have made another request with the factory.
661 case ui::ContextProviderFactory::ContextCreationResult::
662 FAILURE_FACTORY_SHUTDOWN: 654 FAILURE_FACTORY_SHUTDOWN:
663 case ui::ContextProviderFactory::ContextCreationResult::
664 FAILURE_GPU_SURFACE_HANDLE_LOST:
665 break; 655 break;
666 case ui::ContextProviderFactory::ContextCreationResult:: 656 case ui::ContextProviderFactory::GpuChannelHostResult::
667 FAILURE_GPU_PROCESS_INITIALIZATION_FAILED: 657 FAILURE_GPU_PROCESS_INITIALIZATION_FAILED:
668 // Retry only if we are visible. 658 HandlePendingOutputSurfaceRequest();
669 if (host_->visible()) {
670 HandlePendingOutputSurfaceRequest();
671 }
672 break; 659 break;
673 case ui::ContextProviderFactory::ContextCreationResult::SUCCESS: 660 case ui::ContextProviderFactory::GpuChannelHostResult::SUCCESS:
674 DCHECK(host_->visible()); 661 // We don't need the context anymore if we are invisible.
662 if (!host_->visible())
663 return;
664
675 DCHECK(window_); 665 DCHECK(window_);
676 DCHECK_NE(surface_handle_, gpu::kNullSurfaceHandle); 666 DCHECK_NE(surface_handle_, gpu::kNullSurfaceHandle);
677 DCHECK(context_provider); 667 scoped_refptr<cc::ContextProvider> context_provider =
668 ContextProviderFactoryImpl::GetInstance()
669 ->CreateDisplayContextProvider(
670 surface_handle_, GetCompositorContextSharedMemoryLimits(),
671 GetCompositorContextAttributes(has_transparent_background_),
672 false /*support_locking*/, false /*automatic_flushes*/,
673 gpu_channel_host);
danakj 2016/09/02 00:35:29 And std::move() here
Khushal 2016/09/02 16:26:47 Done.
678 674
679 scoped_refptr<ContextProviderCommandBuffer> 675 scoped_refptr<ContextProviderCommandBuffer>
680 context_provider_command_buffer = 676 context_provider_command_buffer =
681 static_cast<ContextProviderCommandBuffer*>( 677 static_cast<ContextProviderCommandBuffer*>(
682 context_provider.get()); 678 context_provider.get());
683 std::unique_ptr<cc::OutputSurface> display_output_surface( 679 std::unique_ptr<cc::OutputSurface> display_output_surface(
684 new OutputSurfaceWithoutParent( 680 new OutputSurfaceWithoutParent(
685 context_provider_command_buffer, 681 context_provider_command_buffer,
686 base::Bind(&CompositorImpl::PopulateGpuCapabilities, 682 base::Bind(&CompositorImpl::PopulateGpuCapabilities,
687 base::Unretained(this)))); 683 base::Unretained(this))));
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 811
816 TRACE_EVENT0("compositor", "Compositor::SetNeedsAnimate"); 812 TRACE_EVENT0("compositor", "Compositor::SetNeedsAnimate");
817 host_->SetNeedsAnimate(); 813 host_->SetNeedsAnimate();
818 } 814 }
819 815
820 bool CompositorImpl::HavePendingReadbacks() { 816 bool CompositorImpl::HavePendingReadbacks() {
821 return !readback_layer_tree_->children().empty(); 817 return !readback_layer_tree_->children().empty();
822 } 818 }
823 819
824 } // namespace content 820 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698