| 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_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_ | 5 #ifndef GPU_IPC_CLIENT_GPU_CHANNEL_HOST_H_ |
| 6 #define CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_ | 6 #define GPU_IPC_CLIENT_GPU_CHANNEL_HOST_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/atomic_sequence_num.h" | 14 #include "base/atomic_sequence_num.h" |
| 15 #include "base/containers/scoped_ptr_hash_map.h" | 15 #include "base/containers/scoped_ptr_hash_map.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
| 19 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
| 20 #include "base/process/process.h" | 20 #include "base/process/process.h" |
| 21 #include "base/synchronization/lock.h" | 21 #include "base/synchronization/lock.h" |
| 22 #include "content/common/content_export.h" | |
| 23 #include "gpu/config/gpu_info.h" | 22 #include "gpu/config/gpu_info.h" |
| 23 #include "gpu/gpu_export.h" |
| 24 #include "gpu/ipc/common/gpu_stream_constants.h" | 24 #include "gpu/ipc/common/gpu_stream_constants.h" |
| 25 #include "gpu/ipc/common/surface_handle.h" | 25 #include "gpu/ipc/common/surface_handle.h" |
| 26 #include "ipc/ipc_channel_handle.h" | 26 #include "ipc/ipc_channel_handle.h" |
| 27 #include "ipc/ipc_sync_channel.h" | 27 #include "ipc/ipc_sync_channel.h" |
| 28 #include "ipc/message_filter.h" | 28 #include "ipc/message_filter.h" |
| 29 #include "ipc/message_router.h" | 29 #include "ipc/message_router.h" |
| 30 #include "ui/events/latency_info.h" | 30 #include "ui/events/latency_info.h" |
| 31 #include "ui/gfx/geometry/size.h" | 31 #include "ui/gfx/geometry/size.h" |
| 32 #include "ui/gfx/gpu_memory_buffer.h" | 32 #include "ui/gfx/gpu_memory_buffer.h" |
| 33 #include "ui/gl/gpu_preference.h" | 33 #include "ui/gl/gpu_preference.h" |
| 34 | 34 |
| 35 class GURL; | 35 class GURL; |
| 36 | 36 |
| 37 namespace base { | 37 namespace base { |
| 38 class WaitableEvent; | 38 class WaitableEvent; |
| 39 } | 39 } |
| 40 | 40 |
| 41 namespace IPC { | 41 namespace IPC { |
| 42 class SyncMessageFilter; | 42 class SyncMessageFilter; |
| 43 } | 43 } |
| 44 | 44 |
| 45 namespace gpu { | 45 namespace gpu { |
| 46 class GpuMemoryBufferManager; | 46 class GpuMemoryBufferManager; |
| 47 } | 47 } |
| 48 | 48 |
| 49 namespace content { | 49 namespace gpu { |
| 50 class CommandBufferProxyImpl; | 50 class CommandBufferProxyImpl; |
| 51 class GpuChannelHost; | 51 class GpuChannelHost; |
| 52 | 52 |
| 53 class CONTENT_EXPORT GpuChannelHostFactory { | 53 class GPU_EXPORT GpuChannelHostFactory { |
| 54 public: | 54 public: |
| 55 virtual ~GpuChannelHostFactory() {} | 55 virtual ~GpuChannelHostFactory() {} |
| 56 | 56 |
| 57 virtual bool IsMainThread() = 0; | 57 virtual bool IsMainThread() = 0; |
| 58 virtual scoped_refptr<base::SingleThreadTaskRunner> | 58 virtual scoped_refptr<base::SingleThreadTaskRunner> |
| 59 GetIOThreadTaskRunner() = 0; | 59 GetIOThreadTaskRunner() = 0; |
| 60 virtual scoped_ptr<base::SharedMemory> AllocateSharedMemory(size_t size) = 0; | 60 virtual scoped_ptr<base::SharedMemory> AllocateSharedMemory(size_t size) = 0; |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 // Encapsulates an IPC channel between the client and one GPU process. | 63 // Encapsulates an IPC channel between the client and one GPU process. |
| 64 // On the GPU process side there's a corresponding GpuChannel. | 64 // On the GPU process side there's a corresponding GpuChannel. |
| 65 // Every method can be called on any thread with a message loop, except for the | 65 // Every method can be called on any thread with a message loop, except for the |
| 66 // IO thread. | 66 // IO thread. |
| 67 class GpuChannelHost : public IPC::Sender, | 67 class GPU_EXPORT GpuChannelHost |
| 68 public base::RefCountedThreadSafe<GpuChannelHost> { | 68 : public IPC::Sender, |
| 69 public base::RefCountedThreadSafe<GpuChannelHost> { |
| 69 public: | 70 public: |
| 70 // Must be called on the main thread (as defined by the factory). | 71 // Must be called on the main thread (as defined by the factory). |
| 71 static scoped_refptr<GpuChannelHost> Create( | 72 static scoped_refptr<GpuChannelHost> Create( |
| 72 GpuChannelHostFactory* factory, | 73 GpuChannelHostFactory* factory, |
| 73 int channel_id, | 74 int channel_id, |
| 74 const gpu::GPUInfo& gpu_info, | 75 const gpu::GPUInfo& gpu_info, |
| 75 const IPC::ChannelHandle& channel_handle, | 76 const IPC::ChannelHandle& channel_handle, |
| 76 base::WaitableEvent* shutdown_event, | 77 base::WaitableEvent* shutdown_event, |
| 77 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager); | 78 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager); |
| 78 | 79 |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 base::AtomicSequenceNumber next_stream_id_; | 288 base::AtomicSequenceNumber next_stream_id_; |
| 288 | 289 |
| 289 // Protects channel_ and stream_flush_info_. | 290 // Protects channel_ and stream_flush_info_. |
| 290 mutable base::Lock context_lock_; | 291 mutable base::Lock context_lock_; |
| 291 scoped_ptr<IPC::SyncChannel> channel_; | 292 scoped_ptr<IPC::SyncChannel> channel_; |
| 292 base::hash_map<int32_t, StreamFlushInfo> stream_flush_info_; | 293 base::hash_map<int32_t, StreamFlushInfo> stream_flush_info_; |
| 293 | 294 |
| 294 DISALLOW_COPY_AND_ASSIGN(GpuChannelHost); | 295 DISALLOW_COPY_AND_ASSIGN(GpuChannelHost); |
| 295 }; | 296 }; |
| 296 | 297 |
| 297 } // namespace content | 298 } // namespace gpu |
| 298 | 299 |
| 299 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_CHANNEL_HOST_H_ | 300 #endif // GPU_IPC_CLIENT_GPU_CHANNEL_HOST_H_ |
| OLD | NEW |