| 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 GPU_IPC_SERVICE_GPU_COMMAND_BUFFER_STUB_H_ | 5 #ifndef GPU_IPC_SERVICE_GPU_COMMAND_BUFFER_STUB_H_ |
| 6 #define GPU_IPC_SERVICE_GPU_COMMAND_BUFFER_STUB_H_ | 6 #define GPU_IPC_SERVICE_GPU_COMMAND_BUFFER_STUB_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <deque> | 11 #include <deque> |
| 12 #include <memory> | 12 #include <memory> |
| 13 #include <string> | 13 #include <string> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "base/observer_list.h" | 18 #include "base/observer_list.h" |
| 19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 20 #include "gpu/command_buffer/common/command_buffer_id.h" | 20 #include "gpu/command_buffer/common/command_buffer_id.h" |
| 21 #include "gpu/command_buffer/common/constants.h" | 21 #include "gpu/command_buffer/common/constants.h" |
| 22 #include "gpu/command_buffer/common/gpu_memory_allocation.h" | 22 #include "gpu/command_buffer/common/gpu_memory_allocation.h" |
| 23 #include "gpu/command_buffer/common/preemption_flag.h" |
| 23 #include "gpu/command_buffer/service/command_buffer_service.h" | 24 #include "gpu/command_buffer/service/command_buffer_service.h" |
| 24 #include "gpu/command_buffer/service/command_executor.h" | |
| 25 #include "gpu/command_buffer/service/context_group.h" | 25 #include "gpu/command_buffer/service/context_group.h" |
| 26 #include "gpu/gpu_export.h" | 26 #include "gpu/gpu_export.h" |
| 27 #include "gpu/ipc/common/surface_handle.h" | 27 #include "gpu/ipc/common/surface_handle.h" |
| 28 #include "gpu/ipc/service/gpu_memory_manager.h" | 28 #include "gpu/ipc/service/gpu_memory_manager.h" |
| 29 #include "gpu/ipc/service/image_transport_surface_delegate.h" | 29 #include "gpu/ipc/service/image_transport_surface_delegate.h" |
| 30 #include "ipc/ipc_listener.h" | 30 #include "ipc/ipc_listener.h" |
| 31 #include "ipc/ipc_sender.h" | 31 #include "ipc/ipc_sender.h" |
| 32 #include "ui/events/latency_info.h" | 32 #include "ui/events/latency_info.h" |
| 33 #include "ui/gfx/geometry/size.h" | 33 #include "ui/gfx/geometry/size.h" |
| 34 #include "ui/gfx/gpu_memory_buffer.h" | 34 #include "ui/gfx/gpu_memory_buffer.h" |
| 35 #include "ui/gfx/swap_result.h" | 35 #include "ui/gfx/swap_result.h" |
| 36 #include "ui/gl/gl_surface.h" | 36 #include "ui/gl/gl_surface.h" |
| 37 #include "ui/gl/gpu_preference.h" | 37 #include "ui/gl/gpu_preference.h" |
| 38 #include "url/gurl.h" | 38 #include "url/gurl.h" |
| 39 | 39 |
| 40 namespace gpu { | 40 namespace gpu { |
| 41 struct Mailbox; | 41 struct Mailbox; |
| 42 struct SyncToken; | 42 struct SyncToken; |
| 43 class CommandExecutor; |
| 44 class GpuScheduler; |
| 43 class SyncPointClient; | 45 class SyncPointClient; |
| 44 } | 46 } |
| 45 | 47 |
| 46 struct GPUCreateCommandBufferConfig; | 48 struct GPUCreateCommandBufferConfig; |
| 47 struct GpuCommandBufferMsg_CreateImage_Params; | 49 struct GpuCommandBufferMsg_CreateImage_Params; |
| 48 | 50 |
| 49 namespace gpu { | 51 namespace gpu { |
| 50 | 52 |
| 51 class GpuChannel; | 53 class GpuChannel; |
| 52 struct WaitForCommandState; | 54 struct WaitForCommandState; |
| 53 | 55 |
| 54 class GPU_EXPORT GpuCommandBufferStub | 56 class GPU_EXPORT GpuCommandBufferStub |
| 55 : public IPC::Listener, | 57 : public IPC::Listener, |
| 56 public IPC::Sender, | 58 public IPC::Sender, |
| 57 public ImageTransportSurfaceDelegate, | 59 public ImageTransportSurfaceDelegate, |
| 58 public base::SupportsWeakPtr<GpuCommandBufferStub> { | 60 public base::SupportsWeakPtr<GpuCommandBufferStub> { |
| 59 public: | 61 public: |
| 60 class DestructionObserver { | 62 class DestructionObserver { |
| 61 public: | 63 public: |
| 62 // Called in Destroy(), before the context/surface are released. | 64 // Called in Destroy(), before the context/surface are released. |
| 63 virtual void OnWillDestroyStub() = 0; | 65 virtual void OnWillDestroyStub() = 0; |
| 64 | 66 |
| 65 protected: | 67 protected: |
| 66 virtual ~DestructionObserver() {} | 68 virtual ~DestructionObserver() {} |
| 67 }; | 69 }; |
| 68 | 70 |
| 69 typedef base::Callback<void(const std::vector<ui::LatencyInfo>&)> | 71 typedef base::Callback<void(const std::vector<ui::LatencyInfo>&)> |
| 70 LatencyInfoCallback; | 72 LatencyInfoCallback; |
| 71 | 73 |
| 74 static gpu::CommandBufferId GetCommandBufferID(int32_t channel_id, |
| 75 int32_t route_id); |
| 76 static int32_t GetChannelID(gpu::CommandBufferId cmd_buffer_id); |
| 77 static int32_t GetRouteID(gpu::CommandBufferId cmd_buffer_id); |
| 78 |
| 72 static std::unique_ptr<GpuCommandBufferStub> Create( | 79 static std::unique_ptr<GpuCommandBufferStub> Create( |
| 73 GpuChannel* channel, | 80 GpuChannel* channel, |
| 74 GpuCommandBufferStub* share_group, | 81 GpuCommandBufferStub* share_group, |
| 75 const GPUCreateCommandBufferConfig& init_params, | 82 const GPUCreateCommandBufferConfig& init_params, |
| 76 int32_t route_id, | 83 int32_t route_id, |
| 77 std::unique_ptr<base::SharedMemory> shared_state_shm); | 84 std::unique_ptr<base::SharedMemory> shared_state_shm); |
| 78 | 85 |
| 79 ~GpuCommandBufferStub() override; | 86 ~GpuCommandBufferStub() override; |
| 80 | 87 |
| 81 // IPC::Listener implementation: | 88 // IPC::Listener implementation: |
| 82 bool OnMessageReceived(const IPC::Message& message) override; | 89 bool OnMessageReceived(const IPC::Message& message) override; |
| 83 | 90 |
| 84 // IPC::Sender implementation: | 91 // IPC::Sender implementation: |
| 85 bool Send(IPC::Message* msg) override; | 92 bool Send(IPC::Message* msg) override; |
| 86 | 93 |
| 87 // ImageTransportSurfaceDelegate implementation: | 94 // ImageTransportSurfaceDelegate implementation: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 98 | 105 |
| 99 gles2::MemoryTracker* GetMemoryTracker() const; | 106 gles2::MemoryTracker* GetMemoryTracker() const; |
| 100 | 107 |
| 101 // Whether this command buffer can currently handle IPC messages. | 108 // Whether this command buffer can currently handle IPC messages. |
| 102 bool IsScheduled(); | 109 bool IsScheduled(); |
| 103 | 110 |
| 104 // Whether there are commands in the buffer that haven't been processed. | 111 // Whether there are commands in the buffer that haven't been processed. |
| 105 bool HasUnprocessedCommands(); | 112 bool HasUnprocessedCommands(); |
| 106 | 113 |
| 107 gles2::GLES2Decoder* decoder() const { return decoder_.get(); } | 114 gles2::GLES2Decoder* decoder() const { return decoder_.get(); } |
| 108 CommandExecutor* scheduler() const { return executor_.get(); } | |
| 109 GpuChannel* channel() const { return channel_; } | 115 GpuChannel* channel() const { return channel_; } |
| 110 | 116 |
| 111 // Unique command buffer ID for this command buffer stub. | 117 // Unique command buffer ID for this command buffer stub. |
| 112 CommandBufferId command_buffer_id() const { return command_buffer_id_; } | 118 CommandBufferId command_buffer_id() const { return command_buffer_id_; } |
| 113 | 119 |
| 114 // Identifies the various GpuCommandBufferStubs in the GPU process belonging | 120 // Identifies the various GpuCommandBufferStubs in the GPU process belonging |
| 115 // to the same renderer process. | 121 // to the same renderer process. |
| 116 int32_t route_id() const { return route_id_; } | 122 int32_t route_id() const { return route_id_; } |
| 117 | 123 |
| 118 // Identifies the stream for this command buffer. | 124 // Identifies the stream for this command buffer. |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 void CheckCompleteWaits(); | 216 void CheckCompleteWaits(); |
| 211 void PullTextureUpdates(CommandBufferNamespace namespace_id, | 217 void PullTextureUpdates(CommandBufferNamespace namespace_id, |
| 212 CommandBufferId command_buffer_id, | 218 CommandBufferId command_buffer_id, |
| 213 uint32_t release); | 219 uint32_t release); |
| 214 | 220 |
| 215 // The lifetime of objects of this class is managed by a GpuChannel. The | 221 // The lifetime of objects of this class is managed by a GpuChannel. The |
| 216 // GpuChannels destroy all the GpuCommandBufferStubs that they own when they | 222 // GpuChannels destroy all the GpuCommandBufferStubs that they own when they |
| 217 // are destroyed. So a raw pointer is safe. | 223 // are destroyed. So a raw pointer is safe. |
| 218 GpuChannel* const channel_; | 224 GpuChannel* const channel_; |
| 219 | 225 |
| 226 GpuScheduler* scheduler_; |
| 220 // The group of contexts that share namespaces with this context. | 227 // The group of contexts that share namespaces with this context. |
| 221 scoped_refptr<gles2::ContextGroup> context_group_; | 228 scoped_refptr<gles2::ContextGroup> context_group_; |
| 222 | 229 |
| 223 bool initialized_; | 230 bool initialized_; |
| 224 const SurfaceHandle surface_handle_; | 231 const SurfaceHandle surface_handle_; |
| 225 bool use_virtualized_gl_context_; | 232 bool use_virtualized_gl_context_; |
| 226 const CommandBufferId command_buffer_id_; | 233 const CommandBufferId command_buffer_id_; |
| 227 const int32_t stream_id_; | 234 const int32_t stream_id_; |
| 228 const int32_t route_id_; | 235 const int32_t route_id_; |
| 229 uint32_t last_flush_count_; | 236 uint32_t last_flush_count_; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 249 | 256 |
| 250 std::unique_ptr<WaitForCommandState> wait_for_token_; | 257 std::unique_ptr<WaitForCommandState> wait_for_token_; |
| 251 std::unique_ptr<WaitForCommandState> wait_for_get_offset_; | 258 std::unique_ptr<WaitForCommandState> wait_for_get_offset_; |
| 252 | 259 |
| 253 DISALLOW_COPY_AND_ASSIGN(GpuCommandBufferStub); | 260 DISALLOW_COPY_AND_ASSIGN(GpuCommandBufferStub); |
| 254 }; | 261 }; |
| 255 | 262 |
| 256 } // namespace gpu | 263 } // namespace gpu |
| 257 | 264 |
| 258 #endif // GPU_IPC_SERVICE_GPU_COMMAND_BUFFER_STUB_H_ | 265 #endif // GPU_IPC_SERVICE_GPU_COMMAND_BUFFER_STUB_H_ |
| OLD | NEW |