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

Side by Side Diff: components/mus/common/gpu_service.h

Issue 2087333002: mus::GpuService: Support establish GpuChannel asynchronously. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update Created 4 years, 6 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 2016 The Chromium Authors. All rights reserved. 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 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 #ifndef COMPONENTS_MUS_COMMON_GPU_SERVICE_H_ 5 #ifndef COMPONENTS_MUS_COMMON_GPU_SERVICE_H_
6 #define COMPONENTS_MUS_COMMON_GPU_SERVICE_H_ 6 #define COMPONENTS_MUS_COMMON_GPU_SERVICE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/synchronization/lock.h" 12 #include "base/synchronization/lock.h"
13 #include "base/synchronization/waitable_event.h" 13 #include "base/synchronization/waitable_event.h"
14 #include "base/threading/thread.h" 14 #include "base/threading/thread.h"
15 #include "components/mus/common/mojo_gpu_memory_buffer_manager.h"
15 #include "components/mus/common/mus_common_export.h" 16 #include "components/mus/common/mus_common_export.h"
17 #include "components/mus/public/interfaces/gpu_service.mojom.h"
16 #include "gpu/ipc/client/gpu_channel_host.h" 18 #include "gpu/ipc/client/gpu_channel_host.h"
17 19
18 namespace shell { 20 namespace shell {
19 class Connector; 21 class Connector;
20 } 22 }
21 23
22 namespace mus { 24 namespace mus {
23 25
24 class MojoGpuMemoryBufferManager;
25
26 class MUS_COMMON_EXPORT GpuService : public gpu::GpuChannelHostFactory { 26 class MUS_COMMON_EXPORT GpuService : public gpu::GpuChannelHostFactory {
27 public: 27 public:
28 scoped_refptr<gpu::GpuChannelHost> EstablishGpuChannel( 28 void EstablishGpuChannel(const base::Closure& callback);
29 shell::Connector* connector); 29 scoped_refptr<gpu::GpuChannelHost> EstablishGpuChannelSync();
30 scoped_refptr<gpu::GpuChannelHost> GetGpuChannel();
31 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager() const {
32 return gpu_memory_buffer_manager_.get();
33 }
30 34
31 static bool UseChromeGpuCommandBuffer(); 35 static bool UseChromeGpuCommandBuffer();
36
37 // The GpuService has to be initialized in the main thread before establishing
38 // the gpu channel.
39 static void Initialize(shell::Connector* connector);
32 static GpuService* GetInstance(); 40 static GpuService* GetInstance();
33 41
34 private: 42 private:
35 friend struct base::DefaultSingletonTraits<GpuService>; 43 friend struct base::DefaultSingletonTraits<GpuService>;
36 44
37 GpuService(); 45 GpuService();
38 ~GpuService() override; 46 ~GpuService() override;
39 47
48 void Init(shell::Connector* connector);
49
50 scoped_refptr<gpu::GpuChannelHost> GetGpuChannelLocked();
51 void EstablishGpuChannelOnMainThread();
52 void EstablishGpuChannelOnMainThreadDone(
53 bool locked,
54 int client_id,
55 mojom::ChannelHandlePtr channel_handle,
56 mojom::GpuInfoPtr gpu_info);
57
40 // gpu::GpuChannelHostFactory overrides: 58 // gpu::GpuChannelHostFactory overrides:
41 bool IsMainThread() override; 59 bool IsMainThread() override;
42 scoped_refptr<base::SingleThreadTaskRunner> GetIOThreadTaskRunner() override; 60 scoped_refptr<base::SingleThreadTaskRunner> GetIOThreadTaskRunner() override;
43 std::unique_ptr<base::SharedMemory> AllocateSharedMemory( 61 std::unique_ptr<base::SharedMemory> AllocateSharedMemory(
44 size_t size) override; 62 size_t size) override;
45 63
46 base::MessageLoop* main_message_loop_; 64 base::MessageLoop* main_message_loop_;
65 shell::Connector* connector_;
47 base::WaitableEvent shutdown_event_; 66 base::WaitableEvent shutdown_event_;
48 base::Thread io_thread_; 67 base::Thread io_thread_;
49 std::unique_ptr<MojoGpuMemoryBufferManager> gpu_memory_buffer_manager_; 68 std::unique_ptr<MojoGpuMemoryBufferManager> gpu_memory_buffer_manager_;
50 69
51 // Lock for |gpu_channel_|. 70 // Lock for |gpu_channel_|, |establish_callbacks_| & |is_establishing_|.
52 base::Lock lock_; 71 base::Lock lock_;
72 bool is_establishing_;
53 scoped_refptr<gpu::GpuChannelHost> gpu_channel_; 73 scoped_refptr<gpu::GpuChannelHost> gpu_channel_;
74 std::vector<base::Closure> establish_callbacks_;
75 base::ConditionVariable establishing_condition_;
76 base::Closure quite_run_loop_closure_;
piman 2016/06/22 17:58:10 nit: quite->quit
Peng 2016/06/22 19:28:30 Done.
54 77
55 DISALLOW_COPY_AND_ASSIGN(GpuService); 78 DISALLOW_COPY_AND_ASSIGN(GpuService);
56 }; 79 };
57 80
58 } // namespace mus 81 } // namespace mus
59 82
60 #endif // COMPONENTS_MUS_PUBLIC_CPP_LIB_GPU_SERVICE_CONNECTION_H_ 83 #endif // COMPONENTS_MUS_PUBLIC_CPP_LIB_GPU_SERVICE_CONNECTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698