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

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

Issue 1936503003: Collapse the initialize methods in WebGraphicsContext3DCommandBufferImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@attributes
Patch Set: collapse: rebase 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
« no previous file with comments | « no previous file | content/common/gpu/client/context_provider_command_buffer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/profiler/scoped_tracker.h"
14 #include "base/single_thread_task_runner.h" 15 #include "base/single_thread_task_runner.h"
15 #include "base/thread_task_runner_handle.h" 16 #include "base/thread_task_runner_handle.h"
16 #include "base/threading/simple_thread.h" 17 #include "base/threading/simple_thread.h"
17 #include "base/threading/thread.h" 18 #include "base/threading/thread.h"
18 #include "build/build_config.h" 19 #include "build/build_config.h"
19 #include "cc/base/histograms.h" 20 #include "cc/base/histograms.h"
20 #include "cc/output/compositor_frame.h" 21 #include "cc/output/compositor_frame.h"
21 #include "cc/output/output_surface.h" 22 #include "cc/output/output_surface.h"
22 #include "cc/output/vulkan_in_process_context_provider.h" 23 #include "cc/output/vulkan_in_process_context_provider.h"
23 #include "cc/raster/single_thread_task_graph_runner.h" 24 #include "cc/raster/single_thread_task_graph_runner.h"
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 BrowserGpuChannelHostFactory::instance()->GetGpuChannel(); 359 BrowserGpuChannelHostFactory::instance()->GetGpuChannel();
359 } 360 }
360 361
361 if (!gpu_channel_host) { 362 if (!gpu_channel_host) {
362 shared_worker_context_provider_ = nullptr; 363 shared_worker_context_provider_ = nullptr;
363 } else { 364 } else {
364 if (!shared_worker_context_provider_) { 365 if (!shared_worker_context_provider_) {
365 shared_worker_context_provider_ = CreateContextCommon( 366 shared_worker_context_provider_ = CreateContextCommon(
366 gpu_channel_host, gpu::kNullSurfaceHandle, nullptr, 367 gpu_channel_host, gpu::kNullSurfaceHandle, nullptr,
367 command_buffer_metrics::BROWSER_WORKER_CONTEXT); 368 command_buffer_metrics::BROWSER_WORKER_CONTEXT);
369 // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is
370 // fixed. Tracking time in BindToCurrentThread.
371 tracked_objects::ScopedTracker tracking_profile(
372 FROM_HERE_WITH_EXPLICIT_FUNCTION(
373 "125248"
374 " GpuProcessTransportFactory::EstablishedGpuChannel"
375 "::Worker"));
368 if (shared_worker_context_provider_->BindToCurrentThread()) 376 if (shared_worker_context_provider_->BindToCurrentThread())
369 shared_worker_context_provider_->SetupLock(); 377 shared_worker_context_provider_->SetupLock();
370 else 378 else
371 shared_worker_context_provider_ = nullptr; 379 shared_worker_context_provider_ = nullptr;
372 } 380 }
373 381
374 // The |context_provider| is used for both the browser compositor and the 382 // The |context_provider| is used for both the browser compositor and the
375 // display compositor. It shares resources with the worker context, so if 383 // display compositor. It shares resources with the worker context, so if
376 // we failed to make a worker context, just start over and try again. 384 // we failed to make a worker context, just start over and try again.
377 if (shared_worker_context_provider_) { 385 if (shared_worker_context_provider_) {
378 context_provider = CreateContextCommon( 386 context_provider = CreateContextCommon(
379 std::move(gpu_channel_host), data->surface_handle, 387 std::move(gpu_channel_host), data->surface_handle,
380 shared_worker_context_provider_.get(), 388 shared_worker_context_provider_.get(),
381 command_buffer_metrics::DISPLAY_COMPOSITOR_ONSCREEN_CONTEXT); 389 command_buffer_metrics::DISPLAY_COMPOSITOR_ONSCREEN_CONTEXT);
390 // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is
391 // fixed. Tracking time in BindToCurrentThread.
392 tracked_objects::ScopedTracker tracking_profile(
393 FROM_HERE_WITH_EXPLICIT_FUNCTION(
394 "125248"
395 " GpuProcessTransportFactory::EstablishedGpuChannel"
396 "::Compositor"));
382 if (!context_provider->BindToCurrentThread()) 397 if (!context_provider->BindToCurrentThread())
383 context_provider = nullptr; 398 context_provider = nullptr;
384 } 399 }
385 } 400 }
386 401
387 bool created_gpu_browser_compositor = 402 bool created_gpu_browser_compositor =
388 !!context_provider && !!shared_worker_context_provider_; 403 !!context_provider && !!shared_worker_context_provider_;
389 404
390 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor", 405 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor",
391 created_gpu_browser_compositor); 406 created_gpu_browser_compositor);
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 return nullptr; 700 return nullptr;
686 701
687 // We need a separate context from the compositor's so that skia and gl_helper 702 // We need a separate context from the compositor's so that skia and gl_helper
688 // don't step on each other. 703 // don't step on each other.
689 shared_main_thread_contexts_ = CreateContextCommon( 704 shared_main_thread_contexts_ = CreateContextCommon(
690 std::move(gpu_channel_host), gpu::kNullSurfaceHandle, nullptr, 705 std::move(gpu_channel_host), gpu::kNullSurfaceHandle, nullptr,
691 command_buffer_metrics::BROWSER_OFFSCREEN_MAINTHREAD_CONTEXT); 706 command_buffer_metrics::BROWSER_OFFSCREEN_MAINTHREAD_CONTEXT);
692 shared_main_thread_contexts_->SetLostContextCallback(base::Bind( 707 shared_main_thread_contexts_->SetLostContextCallback(base::Bind(
693 &GpuProcessTransportFactory::OnLostMainThreadSharedContextInsideCallback, 708 &GpuProcessTransportFactory::OnLostMainThreadSharedContextInsideCallback,
694 callback_factory_.GetWeakPtr())); 709 callback_factory_.GetWeakPtr()));
710 // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is
711 // fixed. Tracking time in BindToCurrentThread.
712 tracked_objects::ScopedTracker tracking_profile(
713 FROM_HERE_WITH_EXPLICIT_FUNCTION(
714 "125248"
715 " GpuProcessTransportFactory::SharedMainThreadContextProvider"));
695 if (!shared_main_thread_contexts_->BindToCurrentThread()) 716 if (!shared_main_thread_contexts_->BindToCurrentThread())
696 shared_main_thread_contexts_ = nullptr; 717 shared_main_thread_contexts_ = nullptr;
697 return shared_main_thread_contexts_; 718 return shared_main_thread_contexts_;
698 } 719 }
699 720
700 GpuProcessTransportFactory::PerCompositorData* 721 GpuProcessTransportFactory::PerCompositorData*
701 GpuProcessTransportFactory::CreatePerCompositorData( 722 GpuProcessTransportFactory::CreatePerCompositorData(
702 ui::Compositor* compositor) { 723 ui::Compositor* compositor) {
703 DCHECK(!per_compositor_data_[compositor]); 724 DCHECK(!per_compositor_data_[compositor]);
704 725
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 shared_vulkan_context_provider_ = 780 shared_vulkan_context_provider_ =
760 cc::VulkanInProcessContextProvider::Create(); 781 cc::VulkanInProcessContextProvider::Create();
761 } 782 }
762 783
763 shared_vulkan_context_provider_initialized_ = true; 784 shared_vulkan_context_provider_initialized_ = true;
764 } 785 }
765 return shared_vulkan_context_provider_; 786 return shared_vulkan_context_provider_;
766 } 787 }
767 788
768 } // namespace content 789 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/common/gpu/client/context_provider_command_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698