| 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_GPU_COMMAND_BUFFER_STUB_H_ | 5 #ifndef CONTENT_COMMON_GPU_GPU_COMMAND_BUFFER_STUB_H_ |
| 6 #define CONTENT_COMMON_GPU_GPU_COMMAND_BUFFER_STUB_H_ | 6 #define CONTENT_COMMON_GPU_GPU_COMMAND_BUFFER_STUB_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/id_map.h" | 12 #include "base/id_map.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
| 15 #include "cc/debug/latency_info.h" |
| 15 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
| 16 #include "content/common/gpu/gpu_memory_allocation.h" | 17 #include "content/common/gpu/gpu_memory_allocation.h" |
| 17 #include "content/common/gpu/gpu_memory_manager.h" | 18 #include "content/common/gpu/gpu_memory_manager.h" |
| 18 #include "content/common/gpu/gpu_memory_manager_client.h" | 19 #include "content/common/gpu/gpu_memory_manager_client.h" |
| 19 #include "googleurl/src/gurl.h" | 20 #include "googleurl/src/gurl.h" |
| 20 #include "gpu/command_buffer/common/constants.h" | 21 #include "gpu/command_buffer/common/constants.h" |
| 21 #include "gpu/command_buffer/service/command_buffer_service.h" | 22 #include "gpu/command_buffer/service/command_buffer_service.h" |
| 22 #include "gpu/command_buffer/service/context_group.h" | 23 #include "gpu/command_buffer/service/context_group.h" |
| 23 #include "gpu/command_buffer/service/gpu_scheduler.h" | 24 #include "gpu/command_buffer/service/gpu_scheduler.h" |
| 24 #include "ipc/ipc_listener.h" | 25 #include "ipc/ipc_listener.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 51 public: | 52 public: |
| 52 class DestructionObserver { | 53 class DestructionObserver { |
| 53 public: | 54 public: |
| 54 // Called in Destroy(), before the context/surface are released. | 55 // Called in Destroy(), before the context/surface are released. |
| 55 virtual void OnWillDestroyStub(GpuCommandBufferStub* stub) = 0; | 56 virtual void OnWillDestroyStub(GpuCommandBufferStub* stub) = 0; |
| 56 | 57 |
| 57 protected: | 58 protected: |
| 58 virtual ~DestructionObserver() {} | 59 virtual ~DestructionObserver() {} |
| 59 }; | 60 }; |
| 60 | 61 |
| 62 typedef base::Callback<void(const cc::LatencyInfo&)> |
| 63 LatencyInfoCallback; |
| 64 |
| 61 GpuCommandBufferStub( | 65 GpuCommandBufferStub( |
| 62 GpuChannel* channel, | 66 GpuChannel* channel, |
| 63 GpuCommandBufferStub* share_group, | 67 GpuCommandBufferStub* share_group, |
| 64 const gfx::GLSurfaceHandle& handle, | 68 const gfx::GLSurfaceHandle& handle, |
| 65 gpu::gles2::MailboxManager* mailbox_manager, | 69 gpu::gles2::MailboxManager* mailbox_manager, |
| 66 gpu::gles2::ImageManager* image_manager, | 70 gpu::gles2::ImageManager* image_manager, |
| 67 const gfx::Size& size, | 71 const gfx::Size& size, |
| 68 const gpu::gles2::DisallowedFeatures& disallowed_features, | 72 const gpu::gles2::DisallowedFeatures& disallowed_features, |
| 69 const std::string& allowed_extensions, | 73 const std::string& allowed_extensions, |
| 70 const std::vector<int32>& attribs, | 74 const std::vector<int32>& attribs, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 | 127 |
| 124 void AddDestructionObserver(DestructionObserver* observer); | 128 void AddDestructionObserver(DestructionObserver* observer); |
| 125 void RemoveDestructionObserver(DestructionObserver* observer); | 129 void RemoveDestructionObserver(DestructionObserver* observer); |
| 126 | 130 |
| 127 // Associates a sync point to this stub. When the stub is destroyed, it will | 131 // Associates a sync point to this stub. When the stub is destroyed, it will |
| 128 // retire all sync points that haven't been previously retired. | 132 // retire all sync points that haven't been previously retired. |
| 129 void AddSyncPoint(uint32 sync_point); | 133 void AddSyncPoint(uint32 sync_point); |
| 130 | 134 |
| 131 void SetPreemptByFlag(scoped_refptr<gpu::PreemptionFlag> flag); | 135 void SetPreemptByFlag(scoped_refptr<gpu::PreemptionFlag> flag); |
| 132 | 136 |
| 137 void SetLatencyInfoCallback(const LatencyInfoCallback& callback); |
| 138 |
| 133 private: | 139 private: |
| 134 GpuMemoryManager* GetMemoryManager(); | 140 GpuMemoryManager* GetMemoryManager(); |
| 135 bool MakeCurrent(); | 141 bool MakeCurrent(); |
| 136 void Destroy(); | 142 void Destroy(); |
| 137 | 143 |
| 138 // Cleans up and sends reply if OnInitialize failed. | 144 // Cleans up and sends reply if OnInitialize failed. |
| 139 void OnInitializeFailed(IPC::Message* reply_message); | 145 void OnInitializeFailed(IPC::Message* reply_message); |
| 140 | 146 |
| 141 // Message handlers: | 147 // Message handlers: |
| 142 void OnInitialize(base::SharedMemoryHandle shared_state_shm, | 148 void OnInitialize(base::SharedMemoryHandle shared_state_shm, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 170 bool OnWaitSyncPoint(uint32 sync_point); | 176 bool OnWaitSyncPoint(uint32 sync_point); |
| 171 void OnSyncPointRetired(); | 177 void OnSyncPointRetired(); |
| 172 void OnSignalSyncPoint(uint32 sync_point, uint32 id); | 178 void OnSignalSyncPoint(uint32 sync_point, uint32 id); |
| 173 void OnSignalSyncPointAck(uint32 id); | 179 void OnSignalSyncPointAck(uint32 id); |
| 174 | 180 |
| 175 void OnReceivedClientManagedMemoryStats(const GpuManagedMemoryStats& stats); | 181 void OnReceivedClientManagedMemoryStats(const GpuManagedMemoryStats& stats); |
| 176 void OnSetClientHasMemoryAllocationChangedCallback(bool has_callback); | 182 void OnSetClientHasMemoryAllocationChangedCallback(bool has_callback); |
| 177 | 183 |
| 178 void OnCommandProcessed(); | 184 void OnCommandProcessed(); |
| 179 void OnParseError(); | 185 void OnParseError(); |
| 186 void OnSetLatencyInfo(const cc::LatencyInfo& latency_info); |
| 180 | 187 |
| 181 void ReportState(); | 188 void ReportState(); |
| 182 | 189 |
| 183 // Wrapper for GpuScheduler::PutChanged that sets the crash report URL. | 190 // Wrapper for GpuScheduler::PutChanged that sets the crash report URL. |
| 184 void PutChanged(); | 191 void PutChanged(); |
| 185 | 192 |
| 186 // Poll the command buffer to execute work. | 193 // Poll the command buffer to execute work. |
| 187 void PollWork(); | 194 void PollWork(); |
| 188 | 195 |
| 189 // Whether this command buffer needs to be polled again in the future. | 196 // Whether this command buffer needs to be polled again in the future. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 // A queue of sync points associated with this stub. | 244 // A queue of sync points associated with this stub. |
| 238 std::deque<uint32> sync_points_; | 245 std::deque<uint32> sync_points_; |
| 239 int sync_point_wait_count_; | 246 int sync_point_wait_count_; |
| 240 | 247 |
| 241 bool delayed_work_scheduled_; | 248 bool delayed_work_scheduled_; |
| 242 uint64 previous_messages_processed_; | 249 uint64 previous_messages_processed_; |
| 243 base::TimeTicks last_idle_time_; | 250 base::TimeTicks last_idle_time_; |
| 244 | 251 |
| 245 scoped_refptr<gpu::PreemptionFlag> preemption_flag_; | 252 scoped_refptr<gpu::PreemptionFlag> preemption_flag_; |
| 246 | 253 |
| 254 LatencyInfoCallback latency_info_callback_; |
| 255 |
| 247 GURL active_url_; | 256 GURL active_url_; |
| 248 size_t active_url_hash_; | 257 size_t active_url_hash_; |
| 249 | 258 |
| 250 size_t total_gpu_memory_; | 259 size_t total_gpu_memory_; |
| 251 | 260 |
| 252 DISALLOW_COPY_AND_ASSIGN(GpuCommandBufferStub); | 261 DISALLOW_COPY_AND_ASSIGN(GpuCommandBufferStub); |
| 253 }; | 262 }; |
| 254 | 263 |
| 255 } // namespace content | 264 } // namespace content |
| 256 | 265 |
| 257 #endif // CONTENT_COMMON_GPU_GPU_COMMAND_BUFFER_STUB_H_ | 266 #endif // CONTENT_COMMON_GPU_GPU_COMMAND_BUFFER_STUB_H_ |
| OLD | NEW |