| OLD | NEW |
| 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> |
| 9 #include <stdint.h> |
| 10 |
| 8 #include <map> | 11 #include <map> |
| 9 #include <vector> | 12 #include <vector> |
| 10 | 13 |
| 14 #include "base/macros.h" |
| 11 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "build/build_config.h" |
| 13 #include "content/common/gpu/client/gpu_channel_host.h" | 18 #include "content/common/gpu/client/gpu_channel_host.h" |
| 14 #include "ipc/message_filter.h" | 19 #include "ipc/message_filter.h" |
| 15 | 20 |
| 16 namespace content { | 21 namespace content { |
| 17 class BrowserGpuMemoryBufferManager; | 22 class BrowserGpuMemoryBufferManager; |
| 18 | 23 |
| 19 class CONTENT_EXPORT BrowserGpuChannelHostFactory | 24 class CONTENT_EXPORT BrowserGpuChannelHostFactory |
| 20 : public GpuChannelHostFactory { | 25 : public GpuChannelHostFactory { |
| 21 public: | 26 public: |
| 22 static void Initialize(bool establish_gpu_channel); | 27 static void Initialize(bool establish_gpu_channel); |
| 23 static void Terminate(); | 28 static void Terminate(); |
| 24 static BrowserGpuChannelHostFactory* instance() { return instance_; } | 29 static BrowserGpuChannelHostFactory* instance() { return instance_; } |
| 25 | 30 |
| 26 // Overridden from GpuChannelHostFactory: | 31 // Overridden from GpuChannelHostFactory: |
| 27 bool IsMainThread() override; | 32 bool IsMainThread() override; |
| 28 scoped_refptr<base::SingleThreadTaskRunner> GetIOThreadTaskRunner() override; | 33 scoped_refptr<base::SingleThreadTaskRunner> GetIOThreadTaskRunner() override; |
| 29 scoped_ptr<base::SharedMemory> AllocateSharedMemory(size_t size) override; | 34 scoped_ptr<base::SharedMemory> AllocateSharedMemory(size_t size) override; |
| 30 CreateCommandBufferResult CreateViewCommandBuffer( | 35 CreateCommandBufferResult CreateViewCommandBuffer( |
| 31 int32 surface_id, | 36 int32_t surface_id, |
| 32 const GPUCreateCommandBufferConfig& init_params, | 37 const GPUCreateCommandBufferConfig& init_params, |
| 33 int32 route_id) override; | 38 int32_t route_id) override; |
| 34 | 39 |
| 35 int GpuProcessHostId() { return gpu_host_id_; } | 40 int GpuProcessHostId() { return gpu_host_id_; } |
| 36 #if !defined(OS_ANDROID) | 41 #if !defined(OS_ANDROID) |
| 37 GpuChannelHost* EstablishGpuChannelSync( | 42 GpuChannelHost* EstablishGpuChannelSync( |
| 38 CauseForGpuLaunch cause_for_gpu_launch); | 43 CauseForGpuLaunch cause_for_gpu_launch); |
| 39 #endif | 44 #endif |
| 40 void EstablishGpuChannel(CauseForGpuLaunch cause_for_gpu_launch, | 45 void EstablishGpuChannel(CauseForGpuLaunch cause_for_gpu_launch, |
| 41 const base::Closure& callback); | 46 const base::Closure& callback); |
| 42 GpuChannelHost* GetGpuChannel(); | 47 GpuChannelHost* GetGpuChannel(); |
| 43 int GetGpuChannelId() { return gpu_client_id_; } | 48 int GetGpuChannelId() { return gpu_client_id_; } |
| 44 | 49 |
| 45 // Used to skip GpuChannelHost tests when there can be no GPU process. | 50 // Used to skip GpuChannelHost tests when there can be no GPU process. |
| 46 static bool CanUseForTesting(); | 51 static bool CanUseForTesting(); |
| 47 | 52 |
| 48 private: | 53 private: |
| 49 struct CreateRequest; | 54 struct CreateRequest; |
| 50 class EstablishRequest; | 55 class EstablishRequest; |
| 51 | 56 |
| 52 BrowserGpuChannelHostFactory(); | 57 BrowserGpuChannelHostFactory(); |
| 53 ~BrowserGpuChannelHostFactory() override; | 58 ~BrowserGpuChannelHostFactory() override; |
| 54 | 59 |
| 55 void GpuChannelEstablished(); | 60 void GpuChannelEstablished(); |
| 56 void CreateViewCommandBufferOnIO( | 61 void CreateViewCommandBufferOnIO( |
| 57 CreateRequest* request, | 62 CreateRequest* request, |
| 58 int32 surface_id, | 63 int32_t surface_id, |
| 59 const GPUCreateCommandBufferConfig& init_params); | 64 const GPUCreateCommandBufferConfig& init_params); |
| 60 static void CommandBufferCreatedOnIO(CreateRequest* request, | 65 static void CommandBufferCreatedOnIO(CreateRequest* request, |
| 61 CreateCommandBufferResult result); | 66 CreateCommandBufferResult result); |
| 62 static void AddFilterOnIO(int gpu_host_id, | 67 static void AddFilterOnIO(int gpu_host_id, |
| 63 scoped_refptr<IPC::MessageFilter> filter); | 68 scoped_refptr<IPC::MessageFilter> filter); |
| 64 static void InitializeShaderDiskCacheOnIO(int gpu_client_id, | 69 static void InitializeShaderDiskCacheOnIO(int gpu_client_id, |
| 65 const base::FilePath& cache_dir); | 70 const base::FilePath& cache_dir); |
| 66 | 71 |
| 67 const int gpu_client_id_; | 72 const int gpu_client_id_; |
| 68 const uint64_t gpu_client_tracing_id_; | 73 const uint64_t gpu_client_tracing_id_; |
| 69 scoped_ptr<base::WaitableEvent> shutdown_event_; | 74 scoped_ptr<base::WaitableEvent> shutdown_event_; |
| 70 scoped_refptr<GpuChannelHost> gpu_channel_; | 75 scoped_refptr<GpuChannelHost> gpu_channel_; |
| 71 scoped_ptr<BrowserGpuMemoryBufferManager> gpu_memory_buffer_manager_; | 76 scoped_ptr<BrowserGpuMemoryBufferManager> gpu_memory_buffer_manager_; |
| 72 int gpu_host_id_; | 77 int gpu_host_id_; |
| 73 scoped_refptr<EstablishRequest> pending_request_; | 78 scoped_refptr<EstablishRequest> pending_request_; |
| 74 std::vector<base::Closure> established_callbacks_; | 79 std::vector<base::Closure> established_callbacks_; |
| 75 | 80 |
| 76 static BrowserGpuChannelHostFactory* instance_; | 81 static BrowserGpuChannelHostFactory* instance_; |
| 77 | 82 |
| 78 DISALLOW_COPY_AND_ASSIGN(BrowserGpuChannelHostFactory); | 83 DISALLOW_COPY_AND_ASSIGN(BrowserGpuChannelHostFactory); |
| 79 }; | 84 }; |
| 80 | 85 |
| 81 } // namespace content | 86 } // namespace content |
| 82 | 87 |
| 83 #endif // CONTENT_BROWSER_GPU_BROWSER_GPU_CHANNEL_HOST_FACTORY_H_ | 88 #endif // CONTENT_BROWSER_GPU_BROWSER_GPU_CHANNEL_HOST_FACTORY_H_ |
| OLD | NEW |