| 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 #include "content/common/gpu/gpu_channel_manager.h" | 5 #include "content/common/gpu/gpu_channel_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 13 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "content/common/gpu/gpu_channel.h" | 15 #include "content/common/gpu/gpu_channel.h" |
| 16 #include "content/common/gpu/gpu_channel_manager_delegate.h" | 16 #include "content/common/gpu/gpu_channel_manager_delegate.h" |
| 17 #include "content/common/gpu/gpu_memory_buffer_factory.h" | 17 #include "content/common/gpu/gpu_memory_buffer_factory.h" |
| 18 #include "content/common/gpu/gpu_memory_manager.h" | 18 #include "content/common/gpu/gpu_memory_manager.h" |
| 19 #include "gpu/command_buffer/common/sync_token.h" | 19 #include "gpu/command_buffer/common/sync_token.h" |
| 20 #include "gpu/command_buffer/common/value_state.h" | 20 #include "gpu/command_buffer/common/value_state.h" |
| 21 #include "gpu/command_buffer/service/feature_info.h" | 21 #include "gpu/command_buffer/service/feature_info.h" |
| 22 #include "gpu/command_buffer/service/mailbox_manager.h" | 22 #include "gpu/command_buffer/service/mailbox_manager.h" |
| 23 #include "gpu/command_buffer/service/memory_program_cache.h" | 23 #include "gpu/command_buffer/service/memory_program_cache.h" |
| 24 #include "gpu/command_buffer/service/shader_translator_cache.h" | 24 #include "gpu/command_buffer/service/shader_translator_cache.h" |
| 25 #include "gpu/command_buffer/service/sync_point_manager.h" | 25 #include "gpu/command_buffer/service/sync_point_manager.h" |
| 26 #include "gpu/ipc/common/gpu_messages.h" | 26 #include "gpu/ipc/common/gpu_messages.h" |
| 27 #include "ui/gl/gl_bindings.h" | 27 #include "ui/gl/gl_bindings.h" |
| 28 #include "ui/gl/gl_share_group.h" | 28 #include "ui/gl/gl_share_group.h" |
| 29 | 29 |
| 30 #if defined(OS_MACOSX) | |
| 31 #include "content/common/gpu/buffer_presented_params_mac.h" | |
| 32 #endif | |
| 33 | |
| 34 namespace content { | 30 namespace content { |
| 35 | 31 |
| 36 namespace { | 32 namespace { |
| 37 #if defined(OS_ANDROID) | 33 #if defined(OS_ANDROID) |
| 38 // Amount of time we expect the GPU to stay powered up without being used. | 34 // Amount of time we expect the GPU to stay powered up without being used. |
| 39 const int kMaxGpuIdleTimeMs = 40; | 35 const int kMaxGpuIdleTimeMs = 40; |
| 40 // Maximum amount of time we keep pinging the GPU waiting for the client to | 36 // Maximum amount of time we keep pinging the GPU waiting for the client to |
| 41 // draw. | 37 // draw. |
| 42 const int kMaxKeepAliveTimeMs = 200; | 38 const int kMaxKeepAliveTimeMs = 200; |
| 43 #endif | 39 #endif |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 buffer_presented_callback_map_.end()); | 120 buffer_presented_callback_map_.end()); |
| 125 buffer_presented_callback_map_[surface_id] = callback; | 121 buffer_presented_callback_map_[surface_id] = callback; |
| 126 } | 122 } |
| 127 | 123 |
| 128 void GpuChannelManager::RemoveBufferPresentedCallback(int32_t surface_id) { | 124 void GpuChannelManager::RemoveBufferPresentedCallback(int32_t surface_id) { |
| 129 auto it = buffer_presented_callback_map_.find(surface_id); | 125 auto it = buffer_presented_callback_map_.find(surface_id); |
| 130 DCHECK(it != buffer_presented_callback_map_.end()); | 126 DCHECK(it != buffer_presented_callback_map_.end()); |
| 131 buffer_presented_callback_map_.erase(it); | 127 buffer_presented_callback_map_.erase(it); |
| 132 } | 128 } |
| 133 | 129 |
| 134 void GpuChannelManager::BufferPresented(const BufferPresentedParams& params) { | 130 void GpuChannelManager::BufferPresented(int32_t surface_id, |
| 135 auto it = buffer_presented_callback_map_.find(params.surface_id); | 131 const base::TimeTicks& vsync_timebase, |
| 132 const base::TimeDelta& vsync_interval) { |
| 133 auto it = buffer_presented_callback_map_.find(surface_id); |
| 136 if (it != buffer_presented_callback_map_.end()) | 134 if (it != buffer_presented_callback_map_.end()) |
| 137 it->second.Run(params); | 135 it->second.Run(surface_id, vsync_timebase, vsync_interval); |
| 138 } | 136 } |
| 139 #endif | 137 #endif |
| 140 | 138 |
| 141 GpuChannel* GpuChannelManager::LookupChannel(int32_t client_id) const { | 139 GpuChannel* GpuChannelManager::LookupChannel(int32_t client_id) const { |
| 142 const auto& it = gpu_channels_.find(client_id); | 140 const auto& it = gpu_channels_.find(client_id); |
| 143 return it != gpu_channels_.end() ? it->second : nullptr; | 141 return it != gpu_channels_.end() ? it->second : nullptr; |
| 144 } | 142 } |
| 145 | 143 |
| 146 scoped_ptr<GpuChannel> GpuChannelManager::CreateGpuChannel( | 144 scoped_ptr<GpuChannel> GpuChannelManager::CreateGpuChannel( |
| 147 int client_id, | 145 int client_id, |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 } | 300 } |
| 303 } | 301 } |
| 304 if (!stub || !stub->decoder()->MakeCurrent()) | 302 if (!stub || !stub->decoder()->MakeCurrent()) |
| 305 return; | 303 return; |
| 306 glFinish(); | 304 glFinish(); |
| 307 DidAccessGpu(); | 305 DidAccessGpu(); |
| 308 } | 306 } |
| 309 #endif | 307 #endif |
| 310 | 308 |
| 311 } // namespace content | 309 } // namespace content |
| OLD | NEW |