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

Side by Side Diff: services/ui/common/gpu_service.h

Issue 2184943002: services/ui: Move some files into the client lib. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@chrome-gpu-in-mus-windows
Patch Set: . Created 4 years, 4 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 | « services/ui/common/gpu_memory_buffer_impl.cc ('k') | services/ui/common/gpu_service.cc » ('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 2016 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 #ifndef SERVICES_UI_COMMON_GPU_SERVICE_H_
6 #define SERVICES_UI_COMMON_GPU_SERVICE_H_
7
8 #include <stdint.h>
9 #include <vector>
10
11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/single_thread_task_runner.h"
14 #include "base/synchronization/lock.h"
15 #include "base/synchronization/waitable_event.h"
16 #include "base/threading/thread.h"
17 #include "gpu/ipc/client/gpu_channel_host.h"
18 #include "services/ui/common/mojo_gpu_memory_buffer_manager.h"
19 #include "services/ui/common/mus_common_export.h"
20 #include "services/ui/public/interfaces/gpu_service.mojom.h"
21
22 namespace shell {
23 class Connector;
24 }
25
26 namespace ui {
27
28 class MUS_COMMON_EXPORT GpuService : public gpu::GpuChannelHostFactory,
29 public gpu::GpuChannelEstablishFactory {
30 public:
31 ~GpuService() override;
32
33 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager() const {
34 return gpu_memory_buffer_manager_.get();
35 }
36
37 // The GpuService has to be initialized in the main thread before establishing
38 // the gpu channel.
39 static std::unique_ptr<GpuService> Initialize(shell::Connector* connector);
40
41 // gpu::GpuChannelEstablishFactory:
42 void EstablishGpuChannel(
43 const gpu::GpuChannelEstablishedCallback& callback) override;
44 scoped_refptr<gpu::GpuChannelHost> EstablishGpuChannelSync() override;
45
46 private:
47 friend struct base::DefaultSingletonTraits<GpuService>;
48
49 explicit GpuService(shell::Connector* connector);
50
51 scoped_refptr<gpu::GpuChannelHost> GetGpuChannelLocked();
52 void EstablishGpuChannelOnMainThread();
53 void EstablishGpuChannelOnMainThreadSyncLocked();
54 void EstablishGpuChannelOnMainThreadDone(
55 bool locked,
56 int client_id,
57 mojom::ChannelHandlePtr channel_handle,
58 mojom::GpuInfoPtr gpu_info);
59
60 // gpu::GpuChannelHostFactory overrides:
61 bool IsMainThread() override;
62 scoped_refptr<base::SingleThreadTaskRunner> GetIOThreadTaskRunner() override;
63 std::unique_ptr<base::SharedMemory> AllocateSharedMemory(
64 size_t size) override;
65
66 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
67 shell::Connector* connector_;
68 base::WaitableEvent shutdown_event_;
69 base::Thread io_thread_;
70 std::unique_ptr<MojoGpuMemoryBufferManager> gpu_memory_buffer_manager_;
71
72 // Lock for |gpu_channel_|, |establish_callbacks_| & |is_establishing_|.
73 base::Lock lock_;
74 bool is_establishing_;
75 ui::mojom::GpuServicePtr gpu_service_;
76 scoped_refptr<gpu::GpuChannelHost> gpu_channel_;
77 std::vector<gpu::GpuChannelEstablishedCallback> establish_callbacks_;
78 base::ConditionVariable establishing_condition_;
79
80 DISALLOW_COPY_AND_ASSIGN(GpuService);
81 };
82
83 } // namespace ui
84
85 #endif // COMPONENTS_MUS_PUBLIC_CPP_LIB_GPU_SERVICE_CONNECTION_H_
OLDNEW
« no previous file with comments | « services/ui/common/gpu_memory_buffer_impl.cc ('k') | services/ui/common/gpu_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698