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

Side by Side Diff: content/browser/compositor/gpu_process_transport_factory.cc

Issue 1902463002: Introduce components/display_compositor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove bot changes. Will do in a separate CL Created 4 years, 8 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/compositor/gpu_process_transport_factory.h" 5 #include "content/browser/compositor/gpu_process_transport_factory.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
15 #include "base/thread_task_runner_handle.h" 15 #include "base/thread_task_runner_handle.h"
16 #include "base/threading/simple_thread.h" 16 #include "base/threading/simple_thread.h"
17 #include "base/threading/thread.h" 17 #include "base/threading/thread.h"
18 #include "build/build_config.h" 18 #include "build/build_config.h"
19 #include "cc/base/histograms.h" 19 #include "cc/base/histograms.h"
20 #include "cc/output/compositor_frame.h" 20 #include "cc/output/compositor_frame.h"
21 #include "cc/output/output_surface.h" 21 #include "cc/output/output_surface.h"
22 #include "cc/output/vulkan_in_process_context_provider.h" 22 #include "cc/output/vulkan_in_process_context_provider.h"
23 #include "cc/raster/single_thread_task_graph_runner.h" 23 #include "cc/raster/single_thread_task_graph_runner.h"
24 #include "cc/raster/task_graph_runner.h" 24 #include "cc/raster/task_graph_runner.h"
25 #include "cc/surfaces/onscreen_display_client.h" 25 #include "cc/surfaces/onscreen_display_client.h"
26 #include "cc/surfaces/surface_display_output_surface.h" 26 #include "cc/surfaces/surface_display_output_surface.h"
27 #include "cc/surfaces/surface_manager.h" 27 #include "cc/surfaces/surface_manager.h"
28 #include "components/display_compositor/gl_helper.h"
28 #include "content/browser/compositor/browser_compositor_output_surface.h" 29 #include "content/browser/compositor/browser_compositor_output_surface.h"
29 #include "content/browser/compositor/browser_compositor_overlay_candidate_valida tor.h" 30 #include "content/browser/compositor/browser_compositor_overlay_candidate_valida tor.h"
30 #include "content/browser/compositor/gl_helper.h"
31 #include "content/browser/compositor/gpu_browser_compositor_output_surface.h" 31 #include "content/browser/compositor/gpu_browser_compositor_output_surface.h"
32 #include "content/browser/compositor/gpu_surfaceless_browser_compositor_output_s urface.h" 32 #include "content/browser/compositor/gpu_surfaceless_browser_compositor_output_s urface.h"
33 #include "content/browser/compositor/offscreen_browser_compositor_output_surface .h" 33 #include "content/browser/compositor/offscreen_browser_compositor_output_surface .h"
34 #include "content/browser/compositor/reflector_impl.h" 34 #include "content/browser/compositor/reflector_impl.h"
35 #include "content/browser/compositor/software_browser_compositor_output_surface. h" 35 #include "content/browser/compositor/software_browser_compositor_output_surface. h"
36 #include "content/browser/compositor/software_output_device_mus.h" 36 #include "content/browser/compositor/software_output_device_mus.h"
37 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" 37 #include "content/browser/gpu/browser_gpu_channel_host_factory.h"
38 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" 38 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h"
39 #include "content/browser/gpu/gpu_data_manager_impl.h" 39 #include "content/browser/gpu/gpu_data_manager_impl.h"
40 #include "content/browser/gpu/gpu_surface_tracker.h" 40 #include "content/browser/gpu/gpu_surface_tracker.h"
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 if (data->surface_id) 514 if (data->surface_id)
515 GpuSurfaceTracker::Get()->RemoveSurface(data->surface_id); 515 GpuSurfaceTracker::Get()->RemoveSurface(data->surface_id);
516 delete data; 516 delete data;
517 per_compositor_data_.erase(it); 517 per_compositor_data_.erase(it);
518 if (per_compositor_data_.empty()) { 518 if (per_compositor_data_.empty()) {
519 // Destroying the GLHelper may cause some async actions to be cancelled, 519 // Destroying the GLHelper may cause some async actions to be cancelled,
520 // causing things to request a new GLHelper. Due to crbug.com/176091 the 520 // causing things to request a new GLHelper. Due to crbug.com/176091 the
521 // GLHelper created in this case would be lost/leaked if we just reset() 521 // GLHelper created in this case would be lost/leaked if we just reset()
522 // on the |gl_helper_| variable directly. So instead we call reset() on a 522 // on the |gl_helper_| variable directly. So instead we call reset() on a
523 // local std::unique_ptr. 523 // local std::unique_ptr.
524 std::unique_ptr<GLHelper> helper = std::move(gl_helper_); 524 std::unique_ptr<display_compositor::GLHelper> helper =
525 std::move(gl_helper_);
525 526
526 // If there are any observer left at this point, make sure they clean up 527 // If there are any observer left at this point, make sure they clean up
527 // before we destroy the GLHelper. 528 // before we destroy the GLHelper.
528 FOR_EACH_OBSERVER( 529 FOR_EACH_OBSERVER(
529 ImageTransportFactoryObserver, observer_list_, OnLostResources()); 530 ImageTransportFactoryObserver, observer_list_, OnLostResources());
530 531
531 helper.reset(); 532 helper.reset();
532 DCHECK(!gl_helper_) << "Destroying the GLHelper should not cause a new " 533 DCHECK(!gl_helper_) << "Destroying the GLHelper should not cause a new "
533 "GLHelper to be created."; 534 "GLHelper to be created.";
534 } 535 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 PerCompositorData* data = it->second; 581 PerCompositorData* data = it->second;
581 DCHECK(data); 582 DCHECK(data);
582 if (data->display_client) 583 if (data->display_client)
583 data->display_client->display()->Resize(size); 584 data->display_client->display()->Resize(size);
584 } 585 }
585 586
586 cc::SurfaceManager* GpuProcessTransportFactory::GetSurfaceManager() { 587 cc::SurfaceManager* GpuProcessTransportFactory::GetSurfaceManager() {
587 return surface_manager_.get(); 588 return surface_manager_.get();
588 } 589 }
589 590
590 GLHelper* GpuProcessTransportFactory::GetGLHelper() { 591 display_compositor::GLHelper* GpuProcessTransportFactory::GetGLHelper() {
591 if (!gl_helper_ && !per_compositor_data_.empty()) { 592 if (!gl_helper_ && !per_compositor_data_.empty()) {
592 scoped_refptr<cc::ContextProvider> provider = 593 scoped_refptr<cc::ContextProvider> provider =
593 SharedMainThreadContextProvider(); 594 SharedMainThreadContextProvider();
594 if (provider.get()) 595 if (provider.get())
595 gl_helper_.reset(new GLHelper(provider->ContextGL(), 596 gl_helper_.reset(new display_compositor::GLHelper(
596 provider->ContextSupport())); 597 provider->ContextGL(), provider->ContextSupport()));
597 } 598 }
598 return gl_helper_.get(); 599 return gl_helper_.get();
599 } 600 }
600 601
601 void GpuProcessTransportFactory::AddObserver( 602 void GpuProcessTransportFactory::AddObserver(
602 ImageTransportFactoryObserver* observer) { 603 ImageTransportFactoryObserver* observer) {
603 observer_list_.AddObserver(observer); 604 observer_list_.AddObserver(observer);
604 } 605 }
605 606
606 void GpuProcessTransportFactory::RemoveObserver( 607 void GpuProcessTransportFactory::RemoveObserver(
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 LOG(ERROR) << "Lost UI shared context."; 704 LOG(ERROR) << "Lost UI shared context.";
704 705
705 // Keep old resources around while we call the observers, but ensure that 706 // Keep old resources around while we call the observers, but ensure that
706 // new resources are created if needed. 707 // new resources are created if needed.
707 // Kill shared contexts for both threads in tandem so they are always in 708 // Kill shared contexts for both threads in tandem so they are always in
708 // the same share group. 709 // the same share group.
709 scoped_refptr<cc::ContextProvider> lost_shared_main_thread_contexts = 710 scoped_refptr<cc::ContextProvider> lost_shared_main_thread_contexts =
710 shared_main_thread_contexts_; 711 shared_main_thread_contexts_;
711 shared_main_thread_contexts_ = NULL; 712 shared_main_thread_contexts_ = NULL;
712 713
713 std::unique_ptr<GLHelper> lost_gl_helper = std::move(gl_helper_); 714 std::unique_ptr<display_compositor::GLHelper> lost_gl_helper =
715 std::move(gl_helper_);
714 716
715 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, 717 FOR_EACH_OBSERVER(ImageTransportFactoryObserver,
716 observer_list_, 718 observer_list_,
717 OnLostResources()); 719 OnLostResources());
718 720
719 // Kill things that use the shared context before killing the shared context. 721 // Kill things that use the shared context before killing the shared context.
720 lost_gl_helper.reset(); 722 lost_gl_helper.reset();
721 lost_shared_main_thread_contexts = NULL; 723 lost_shared_main_thread_contexts = NULL;
722 } 724 }
723 725
724 scoped_refptr<cc::VulkanInProcessContextProvider> 726 scoped_refptr<cc::VulkanInProcessContextProvider>
725 GpuProcessTransportFactory::SharedVulkanContextProvider() { 727 GpuProcessTransportFactory::SharedVulkanContextProvider() {
726 if (!shared_vulkan_context_provider_initialized_) { 728 if (!shared_vulkan_context_provider_initialized_) {
727 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 729 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
728 switches::kEnableVulkan)) { 730 switches::kEnableVulkan)) {
729 shared_vulkan_context_provider_ = 731 shared_vulkan_context_provider_ =
730 cc::VulkanInProcessContextProvider::Create(); 732 cc::VulkanInProcessContextProvider::Create();
731 } 733 }
732 734
733 shared_vulkan_context_provider_initialized_ = true; 735 shared_vulkan_context_provider_initialized_ = true;
734 } 736 }
735 return shared_vulkan_context_provider_; 737 return shared_vulkan_context_provider_;
736 } 738 }
737 739
738 } // namespace content 740 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698