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

Side by Side Diff: components/mus/gles2/gpu_state.cc

Issue 2119963002: Move mus to //services/ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 5 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 | « components/mus/gles2/gpu_state.h ('k') | components/mus/gles2/ozone_gpu_memory_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
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "components/mus/gles2/gpu_state.h"
6
7 #include "base/bind.h"
8 #include "base/command_line.h"
9 #include "base/synchronization/waitable_event.h"
10 #include "base/threading/thread_restrictions.h"
11 #include "gpu/config/gpu_info_collector.h"
12 #include "ui/gl/gl_implementation.h"
13 #include "ui/gl/init/gl_factory.h"
14
15 #if defined(USE_OZONE)
16 #include "ui/ozone/public/ozone_platform.h"
17 #endif
18
19 namespace mus {
20
21 GpuState::GpuState()
22 : gpu_thread_("gpu_thread"),
23 control_thread_("gpu_command_buffer_control"),
24 gpu_driver_bug_workarounds_(base::CommandLine::ForCurrentProcess()),
25 hardware_rendering_available_(false) {
26 base::ThreadRestrictions::ScopedAllowWait allow_wait;
27 gpu_thread_.Start();
28 control_thread_.Start();
29 control_thread_task_runner_ = control_thread_.task_runner();
30 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::MANUAL,
31 base::WaitableEvent::InitialState::NOT_SIGNALED);
32 gpu_thread_.task_runner()->PostTask(
33 FROM_HERE, base::Bind(&GpuState::InitializeOnGpuThread,
34 base::Unretained(this), &event));
35 event.Wait();
36 }
37
38 GpuState::~GpuState() {}
39
40 void GpuState::StopThreads() {
41 control_thread_.Stop();
42 gpu_thread_.task_runner()->PostTask(
43 FROM_HERE,
44 base::Bind(&GpuState::DestroyGpuSpecificStateOnGpuThread, this));
45 gpu_thread_.Stop();
46 }
47
48 void GpuState::InitializeOnGpuThread(base::WaitableEvent* event) {
49 #if defined(USE_OZONE)
50 ui::OzonePlatform::InitializeForGPU();
51 #endif
52 hardware_rendering_available_ = gl::init::InitializeGLOneOff();
53 command_buffer_task_runner_ = new CommandBufferTaskRunner;
54 driver_manager_.reset(new CommandBufferDriverManager);
55 sync_point_manager_.reset(new gpu::SyncPointManager(true));
56 share_group_ = new gl::GLShareGroup;
57 mailbox_manager_ = new gpu::gles2::MailboxManagerImpl;
58
59 // TODO(penghuang): investigate why gpu::CollectBasicGraphicsInfo() failed on
60 // windows remote desktop.
61 const gl::GLImplementation impl = gl::GetGLImplementation();
62 if (impl != gl::kGLImplementationNone &&
63 impl != gl::kGLImplementationOSMesaGL &&
64 impl != gl::kGLImplementationMockGL) {
65 gpu::CollectInfoResult result = gpu::CollectBasicGraphicsInfo(&gpu_info_);
66 LOG_IF(ERROR, result != gpu::kCollectInfoSuccess)
67 << "Collect basic graphics info failed!";
68 }
69 if (impl != gl::kGLImplementationNone) {
70 gpu::CollectInfoResult result = gpu::CollectContextGraphicsInfo(&gpu_info_);
71 LOG_IF(ERROR, result != gpu::kCollectInfoSuccess)
72 << "Collect context graphics info failed!";
73 }
74 event->Signal();
75
76 }
77
78 void GpuState::DestroyGpuSpecificStateOnGpuThread() {
79 driver_manager_.reset();
80 }
81
82 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/gles2/gpu_state.h ('k') | components/mus/gles2/ozone_gpu_memory_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698