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

Side by Side Diff: content/browser/gpu/browser_gpu_channel_host_factory.h

Issue 1656433002: Sample code: IPC Transport object for GPU Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: GpuMemoryBufferService + Transport object. TODO: Eliminate ChildThreadImpl dependency Created 4 years, 10 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 CONTENT_BROWSER_GPU_BROWSER_GPU_CHANNEL_HOST_FACTORY_H_ 5 #ifndef CONTENT_BROWSER_GPU_BROWSER_GPU_CHANNEL_HOST_FACTORY_H_
6 #define CONTENT_BROWSER_GPU_BROWSER_GPU_CHANNEL_HOST_FACTORY_H_ 6 #define CONTENT_BROWSER_GPU_BROWSER_GPU_CHANNEL_HOST_FACTORY_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <map> 11 #include <map>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "build/build_config.h" 17 #include "build/build_config.h"
18 #include "content/common/gpu/client/gpu_channel_host.h" 18 #include "content/common/gpu/client/gpu_channel_host.h"
19 #include "content/common/gpu/client/gpu_channel_host_factory.h"
20 #include "content/common/gpu/client/ipc/gpu_host_ipc_transport_factory_impl.h"
19 #include "ipc/message_filter.h" 21 #include "ipc/message_filter.h"
20 22
21 namespace content { 23 namespace content {
24
22 class BrowserGpuMemoryBufferManager; 25 class BrowserGpuMemoryBufferManager;
26 struct GpuCreateCommandBufferConfig;
23 27
24 class CONTENT_EXPORT BrowserGpuChannelHostFactory 28 class CONTENT_EXPORT BrowserGpuChannelHostFactory
25 : public GpuChannelHostFactory { 29 : public GpuChannelHostFactory {
26 public: 30 public:
27 static void Initialize(bool establish_gpu_channel); 31 static void Initialize(bool establish_gpu_channel);
28 static void Terminate(); 32 static void Terminate();
29 static BrowserGpuChannelHostFactory* instance() { return instance_; } 33 static BrowserGpuChannelHostFactory* instance() { return instance_; }
30 34
31 // Overridden from GpuChannelHostFactory: 35 // Overridden from GpuChannelHostFactory:
32 bool IsMainThread() override; 36 bool IsMainThread() override;
33 scoped_refptr<base::SingleThreadTaskRunner> GetIOThreadTaskRunner() override; 37 scoped_refptr<base::SingleThreadTaskRunner> GetIOThreadTaskRunner() override;
34 scoped_ptr<base::SharedMemory> AllocateSharedMemory(size_t size) override; 38 scoped_ptr<base::SharedMemory> AllocateSharedMemory(size_t size) override;
35 CreateCommandBufferResult CreateViewCommandBuffer( 39 CreateCommandBufferResult CreateViewCommandBuffer(
36 int32_t surface_id, 40 int32_t surface_id,
37 const GPUCreateCommandBufferConfig& init_params, 41 const GpuCreateCommandBufferConfig& init_params,
38 int32_t route_id) override; 42 int32_t route_id) override;
39 43
40 int GpuProcessHostId() { return gpu_host_id_; } 44 int GpuProcessHostId() { return gpu_host_id_; }
41 #if !defined(OS_ANDROID) 45 #if !defined(OS_ANDROID)
42 GpuChannelHost* EstablishGpuChannelSync( 46 GpuChannelHost* EstablishGpuChannelSync(
43 CauseForGpuLaunch cause_for_gpu_launch); 47 CauseForGpuLaunch cause_for_gpu_launch);
44 #endif 48 #endif
45 void EstablishGpuChannel(CauseForGpuLaunch cause_for_gpu_launch, 49 void EstablishGpuChannel(CauseForGpuLaunch cause_for_gpu_launch,
46 const base::Closure& callback); 50 const base::Closure& callback);
47 GpuChannelHost* GetGpuChannel(); 51 GpuChannelHost* GetGpuChannel();
48 int GetGpuChannelId() { return gpu_client_id_; } 52 int GetGpuChannelId() { return gpu_client_id_; }
49 53
50 // Used to skip GpuChannelHost tests when there can be no GPU process. 54 // Used to skip GpuChannelHost tests when there can be no GPU process.
51 static bool CanUseForTesting(); 55 static bool CanUseForTesting();
52 56
53 private: 57 private:
54 struct CreateRequest; 58 struct CreateRequest;
55 class EstablishRequest; 59 class EstablishRequest;
56 60
57 BrowserGpuChannelHostFactory(); 61 BrowserGpuChannelHostFactory();
58 ~BrowserGpuChannelHostFactory() override; 62 ~BrowserGpuChannelHostFactory() override;
59 63
60 void GpuChannelEstablished(); 64 void GpuChannelEstablished();
61 void CreateViewCommandBufferOnIO( 65 void CreateViewCommandBufferOnIO(
62 CreateRequest* request, 66 CreateRequest* request,
63 int32_t surface_id, 67 int32_t surface_id,
64 const GPUCreateCommandBufferConfig& init_params); 68 const GpuCreateCommandBufferConfig& init_params);
65 static void CommandBufferCreatedOnIO(CreateRequest* request, 69 static void CommandBufferCreatedOnIO(CreateRequest* request,
66 CreateCommandBufferResult result); 70 CreateCommandBufferResult result);
67 static void AddFilterOnIO(int gpu_host_id, 71 static void AddFilterOnIO(int gpu_host_id,
68 scoped_refptr<IPC::MessageFilter> filter); 72 scoped_refptr<IPC::MessageFilter> filter);
69 static void InitializeShaderDiskCacheOnIO(int gpu_client_id, 73 static void InitializeShaderDiskCacheOnIO(int gpu_client_id,
70 const base::FilePath& cache_dir); 74 const base::FilePath& cache_dir);
71 75
72 const int gpu_client_id_; 76 const int gpu_client_id_;
73 const uint64_t gpu_client_tracing_id_; 77 const uint64_t gpu_client_tracing_id_;
74 scoped_ptr<base::WaitableEvent> shutdown_event_; 78 scoped_ptr<base::WaitableEvent> shutdown_event_;
75 scoped_refptr<GpuChannelHost> gpu_channel_; 79 scoped_refptr<GpuChannelHost> gpu_channel_;
76 scoped_ptr<BrowserGpuMemoryBufferManager> gpu_memory_buffer_manager_; 80 scoped_ptr<BrowserGpuMemoryBufferManager> gpu_memory_buffer_manager_;
77 int gpu_host_id_; 81 int gpu_host_id_;
78 scoped_refptr<EstablishRequest> pending_request_; 82 scoped_refptr<EstablishRequest> pending_request_;
79 std::vector<base::Closure> established_callbacks_; 83 std::vector<base::Closure> established_callbacks_;
80 84
85 GpuHostIPCTransportFactoryImpl transport_factory_;
86
81 static BrowserGpuChannelHostFactory* instance_; 87 static BrowserGpuChannelHostFactory* instance_;
82 88
83 DISALLOW_COPY_AND_ASSIGN(BrowserGpuChannelHostFactory); 89 DISALLOW_COPY_AND_ASSIGN(BrowserGpuChannelHostFactory);
84 }; 90 };
85 91
86 } // namespace content 92 } // namespace content
87 93
88 #endif // CONTENT_BROWSER_GPU_BROWSER_GPU_CHANNEL_HOST_FACTORY_H_ 94 #endif // CONTENT_BROWSER_GPU_BROWSER_GPU_CHANNEL_HOST_FACTORY_H_
OLDNEW
« no previous file with comments | « base/threading/thread_restrictions.h ('k') | content/browser/gpu/browser_gpu_channel_host_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698