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

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

Issue 1963263002: Fix Mac resize, delete more Mac code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporate review feedback Created 4 years, 7 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"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 #include "ui/ozone/public/overlay_candidates_ozone.h" 68 #include "ui/ozone/public/overlay_candidates_ozone.h"
69 #include "ui/ozone/public/overlay_manager_ozone.h" 69 #include "ui/ozone/public/overlay_manager_ozone.h"
70 #include "ui/ozone/public/ozone_platform.h" 70 #include "ui/ozone/public/ozone_platform.h"
71 #include "ui/ozone/public/ozone_switches.h" 71 #include "ui/ozone/public/ozone_switches.h"
72 #elif defined(USE_X11) 72 #elif defined(USE_X11)
73 #include "content/browser/compositor/software_output_device_x11.h" 73 #include "content/browser/compositor/software_output_device_x11.h"
74 #elif defined(OS_MACOSX) 74 #elif defined(OS_MACOSX)
75 #include "components/display_compositor/compositor_overlay_candidate_validator_m ac.h" 75 #include "components/display_compositor/compositor_overlay_candidate_validator_m ac.h"
76 #include "content/browser/compositor/software_output_device_mac.h" 76 #include "content/browser/compositor/software_output_device_mac.h"
77 #include "gpu/config/gpu_driver_bug_workaround_type.h" 77 #include "gpu/config/gpu_driver_bug_workaround_type.h"
78 #include "ui/accelerated_widget_mac/window_resize_helper_mac.h"
78 #include "ui/base/cocoa/remote_layer_api.h" 79 #include "ui/base/cocoa/remote_layer_api.h"
79 #include "ui/base/ui_base_switches.h" 80 #include "ui/base/ui_base_switches.h"
80 #elif defined(OS_ANDROID) 81 #elif defined(OS_ANDROID)
81 #include "components/display_compositor/compositor_overlay_candidate_validator_a ndroid.h" 82 #include "components/display_compositor/compositor_overlay_candidate_validator_a ndroid.h"
82 #endif 83 #endif
83 #if !defined(GPU_SURFACE_HANDLE_IS_ACCELERATED_WINDOW) 84 #if !defined(GPU_SURFACE_HANDLE_IS_ACCELERATED_WINDOW)
84 #include "content/browser/gpu/gpu_surface_tracker.h" 85 #include "content/browser/gpu/gpu_surface_tracker.h"
85 #endif 86 #endif
86 87
87 #if defined(ENABLE_VULKAN) 88 #if defined(ENABLE_VULKAN)
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 return GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor(); 270 return GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor();
270 } 271 }
271 272
272 void GpuProcessTransportFactory::CreateOutputSurface( 273 void GpuProcessTransportFactory::CreateOutputSurface(
273 base::WeakPtr<ui::Compositor> compositor) { 274 base::WeakPtr<ui::Compositor> compositor) {
274 DCHECK(!!compositor); 275 DCHECK(!!compositor);
275 PerCompositorData* data = per_compositor_data_[compositor.get()]; 276 PerCompositorData* data = per_compositor_data_[compositor.get()];
276 if (!data) { 277 if (!data) {
277 data = CreatePerCompositorData(compositor.get()); 278 data = CreatePerCompositorData(compositor.get());
278 } else { 279 } else {
279 #if defined(OS_MACOSX)
280 // TODO(piman): Use GpuSurfaceTracker to map ids to surfaces instead of an
281 // output_surface_map_ here.
282 output_surface_map_.Remove(data->surface_handle);
283 #endif
284 data->surface = nullptr; 280 data->surface = nullptr;
285 } 281 }
286 282
287 #if defined(OS_WIN) 283 #if defined(OS_WIN)
288 gfx::RenderingWindowManager::GetInstance()->UnregisterParent( 284 gfx::RenderingWindowManager::GetInstance()->UnregisterParent(
289 compositor->widget()); 285 compositor->widget());
290 #endif 286 #endif
291 287
292 const bool use_vulkan = SharedVulkanContextProvider(); 288 const bool use_vulkan = SharedVulkanContextProvider();
293 289
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 std::move(gpu_channel_host), data->surface_handle, 384 std::move(gpu_channel_host), data->surface_handle,
389 shared_worker_context_provider_.get(), 385 shared_worker_context_provider_.get(),
390 command_buffer_metrics::DISPLAY_COMPOSITOR_ONSCREEN_CONTEXT); 386 command_buffer_metrics::DISPLAY_COMPOSITOR_ONSCREEN_CONTEXT);
391 // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is 387 // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is
392 // fixed. Tracking time in BindToCurrentThread. 388 // fixed. Tracking time in BindToCurrentThread.
393 tracked_objects::ScopedTracker tracking_profile( 389 tracked_objects::ScopedTracker tracking_profile(
394 FROM_HERE_WITH_EXPLICIT_FUNCTION( 390 FROM_HERE_WITH_EXPLICIT_FUNCTION(
395 "125248" 391 "125248"
396 " GpuProcessTransportFactory::EstablishedGpuChannel" 392 " GpuProcessTransportFactory::EstablishedGpuChannel"
397 "::Compositor")); 393 "::Compositor"));
394 #if defined(OS_MACOSX)
395 // On Mac, GpuCommandBufferMsg_SwapBuffersCompleted must be handled in
396 // a nested message loop during resize.
397 context_provider->SetDefaultTaskRunner(
398 ui::WindowResizeHelperMac::Get()->task_runner());
399 #endif
398 if (!context_provider->BindToCurrentThread()) 400 if (!context_provider->BindToCurrentThread())
399 context_provider = nullptr; 401 context_provider = nullptr;
400 } 402 }
401 } 403 }
402 404
403 bool created_gpu_browser_compositor = 405 bool created_gpu_browser_compositor =
404 !!context_provider && !!shared_worker_context_provider_; 406 !!context_provider && !!shared_worker_context_provider_;
405 407
406 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor", 408 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor",
407 created_gpu_browser_compositor); 409 created_gpu_browser_compositor);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 validator = CreateOverlayCandidateValidator(compositor->widget()); 471 validator = CreateOverlayCandidateValidator(compositor->widget());
470 #endif 472 #endif
471 surface = base::WrapUnique(new GpuBrowserCompositorOutputSurface( 473 surface = base::WrapUnique(new GpuBrowserCompositorOutputSurface(
472 context_provider, shared_worker_context_provider_, 474 context_provider, shared_worker_context_provider_,
473 compositor->vsync_manager(), compositor->task_runner().get(), 475 compositor->vsync_manager(), compositor->task_runner().get(),
474 std::move(validator))); 476 std::move(validator)));
475 } 477 }
476 } 478 }
477 } 479 }
478 480
479 #if defined(OS_MACOSX)
480 // TODO(piman): Use GpuSurfaceTracker to map ids to surfaces instead of an
481 // output_surface_map_ here.
482 output_surface_map_.AddWithID(surface.get(), data->surface_handle);
483 #endif
484 data->surface = surface.get(); 481 data->surface = surface.get();
485 if (data->reflector) 482 if (data->reflector)
486 data->reflector->OnSourceSurfaceReady(data->surface); 483 data->reflector->OnSourceSurfaceReady(data->surface);
487 484
488 #if defined(OS_WIN) 485 #if defined(OS_WIN)
489 gfx::RenderingWindowManager::GetInstance()->DoSetParentOnChild( 486 gfx::RenderingWindowManager::GetInstance()->DoSetParentOnChild(
490 compositor->widget()); 487 compositor->widget());
491 #endif 488 #endif
492 489
493 // This gets a bit confusing. Here we have a ContextProvider in the |surface| 490 // This gets a bit confusing. Here we have a ContextProvider in the |surface|
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 data->reflector->Shutdown(); 537 data->reflector->Shutdown();
541 data->reflector = nullptr; 538 data->reflector = nullptr;
542 } 539 }
543 540
544 void GpuProcessTransportFactory::RemoveCompositor(ui::Compositor* compositor) { 541 void GpuProcessTransportFactory::RemoveCompositor(ui::Compositor* compositor) {
545 PerCompositorDataMap::iterator it = per_compositor_data_.find(compositor); 542 PerCompositorDataMap::iterator it = per_compositor_data_.find(compositor);
546 if (it == per_compositor_data_.end()) 543 if (it == per_compositor_data_.end())
547 return; 544 return;
548 PerCompositorData* data = it->second; 545 PerCompositorData* data = it->second;
549 DCHECK(data); 546 DCHECK(data);
550 #if defined(OS_MACOSX)
551 // TODO(piman): Use GpuSurfaceTracker to map ids to surfaces instead of an
552 // output_surface_map_ here.
553 if (data->surface)
554 output_surface_map_.Remove(data->surface_handle);
555 #endif
556 #if !defined(GPU_SURFACE_HANDLE_IS_ACCELERATED_WINDOW) 547 #if !defined(GPU_SURFACE_HANDLE_IS_ACCELERATED_WINDOW)
557 if (data->surface_handle) 548 if (data->surface_handle)
558 GpuSurfaceTracker::Get()->RemoveSurface(data->surface_handle); 549 GpuSurfaceTracker::Get()->RemoveSurface(data->surface_handle);
559 #endif 550 #endif
560 delete data; 551 delete data;
561 per_compositor_data_.erase(it); 552 per_compositor_data_.erase(it);
562 if (per_compositor_data_.empty()) { 553 if (per_compositor_data_.empty()) {
563 // Destroying the GLHelper may cause some async actions to be cancelled, 554 // Destroying the GLHelper may cause some async actions to be cancelled,
564 // causing things to request a new GLHelper. Due to crbug.com/176091 the 555 // causing things to request a new GLHelper. Due to crbug.com/176091 the
565 // GLHelper created in this case would be lost/leaked if we just reset() 556 // GLHelper created in this case would be lost/leaked if we just reset()
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 ui::Compositor* compositor, 663 ui::Compositor* compositor,
673 bool suspended) { 664 bool suspended) {
674 PerCompositorDataMap::iterator it = per_compositor_data_.find(compositor); 665 PerCompositorDataMap::iterator it = per_compositor_data_.find(compositor);
675 if (it == per_compositor_data_.end()) 666 if (it == per_compositor_data_.end())
676 return; 667 return;
677 PerCompositorData* data = it->second; 668 PerCompositorData* data = it->second;
678 DCHECK(data); 669 DCHECK(data);
679 if (data->surface) 670 if (data->surface)
680 data->surface->SetSurfaceSuspendedForRecycle(suspended); 671 data->surface->SetSurfaceSuspendedForRecycle(suspended);
681 } 672 }
682
683 bool GpuProcessTransportFactory::
684 SurfaceShouldNotShowFramesAfterSuspendForRecycle(
685 gpu::SurfaceHandle surface_handle) const {
686 BrowserCompositorOutputSurface* surface =
687 output_surface_map_.Lookup(surface_handle);
688 if (surface)
689 return surface->SurfaceShouldNotShowFramesAfterSuspendForRecycle();
690 return false;
691 }
692 #endif 673 #endif
693 674
694 scoped_refptr<cc::ContextProvider> 675 scoped_refptr<cc::ContextProvider>
695 GpuProcessTransportFactory::SharedMainThreadContextProvider() { 676 GpuProcessTransportFactory::SharedMainThreadContextProvider() {
696 if (shared_main_thread_contexts_) 677 if (shared_main_thread_contexts_)
697 return shared_main_thread_contexts_; 678 return shared_main_thread_contexts_;
698 679
699 if (!GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) 680 if (!GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor())
700 return nullptr; 681 return nullptr;
701 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host( 682 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 shared_vulkan_context_provider_ = 766 shared_vulkan_context_provider_ =
786 cc::VulkanInProcessContextProvider::Create(); 767 cc::VulkanInProcessContextProvider::Create();
787 } 768 }
788 769
789 shared_vulkan_context_provider_initialized_ = true; 770 shared_vulkan_context_provider_initialized_ = true;
790 } 771 }
791 return shared_vulkan_context_provider_; 772 return shared_vulkan_context_provider_;
792 } 773 }
793 774
794 } // namespace content 775 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698