| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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_test_common.h" | 5 #include "gpu/ipc/service/gpu_channel_test_common.h" |
| 6 | 6 |
| 7 #include "base/test/test_simple_task_runner.h" | 7 #include "base/test/test_simple_task_runner.h" |
| 8 #include "base/thread_task_runner_handle.h" | 8 #include "base/thread_task_runner_handle.h" |
| 9 #include "content/common/gpu/gpu_channel_manager_delegate.h" | |
| 10 #include "gpu/command_buffer/service/sync_point_manager.h" | 9 #include "gpu/command_buffer/service/sync_point_manager.h" |
| 10 #include "gpu/ipc/service/gpu_channel_manager_delegate.h" |
| 11 #include "ipc/ipc_test_sink.h" | 11 #include "ipc/ipc_test_sink.h" |
| 12 #include "url/gurl.h" | 12 #include "url/gurl.h" |
| 13 | 13 |
| 14 namespace content { | 14 namespace gpu { |
| 15 | 15 |
| 16 TestGpuChannelManagerDelegate::TestGpuChannelManagerDelegate() {} | 16 TestGpuChannelManagerDelegate::TestGpuChannelManagerDelegate() {} |
| 17 | 17 |
| 18 TestGpuChannelManagerDelegate::~TestGpuChannelManagerDelegate() {} | 18 TestGpuChannelManagerDelegate::~TestGpuChannelManagerDelegate() {} |
| 19 | 19 |
| 20 void TestGpuChannelManagerDelegate::SetActiveURL(const GURL& url) {} | 20 void TestGpuChannelManagerDelegate::SetActiveURL(const GURL& url) {} |
| 21 | 21 |
| 22 void TestGpuChannelManagerDelegate::AddSubscription(int32_t client_id, | 22 void TestGpuChannelManagerDelegate::AddSubscription(int32_t client_id, |
| 23 unsigned int target) {} | 23 unsigned int target) {} |
| 24 | 24 |
| 25 void TestGpuChannelManagerDelegate::DidCreateOffscreenContext( | 25 void TestGpuChannelManagerDelegate::DidCreateOffscreenContext( |
| 26 const GURL& active_url) {} | 26 const GURL& active_url) {} |
| 27 | 27 |
| 28 void TestGpuChannelManagerDelegate::DidDestroyChannel(int client_id) {} | 28 void TestGpuChannelManagerDelegate::DidDestroyChannel(int client_id) {} |
| 29 | 29 |
| 30 void TestGpuChannelManagerDelegate::DidDestroyOffscreenContext( | 30 void TestGpuChannelManagerDelegate::DidDestroyOffscreenContext( |
| 31 const GURL& active_url) {} | 31 const GURL& active_url) {} |
| 32 | 32 |
| 33 void TestGpuChannelManagerDelegate::DidLoseContext( | 33 void TestGpuChannelManagerDelegate::DidLoseContext( |
| 34 bool offscreen, | 34 bool offscreen, |
| 35 gpu::error::ContextLostReason reason, | 35 error::ContextLostReason reason, |
| 36 const GURL& active_url) {} | 36 const GURL& active_url) {} |
| 37 | 37 |
| 38 void TestGpuChannelManagerDelegate::GpuMemoryUmaStats( | 38 void TestGpuChannelManagerDelegate::GpuMemoryUmaStats( |
| 39 const gpu::GPUMemoryUmaStats& params) {} | 39 const GPUMemoryUmaStats& params) {} |
| 40 | 40 |
| 41 void TestGpuChannelManagerDelegate::RemoveSubscription(int32_t client_id, | 41 void TestGpuChannelManagerDelegate::RemoveSubscription(int32_t client_id, |
| 42 unsigned int target) {} | 42 unsigned int target) {} |
| 43 | 43 |
| 44 void TestGpuChannelManagerDelegate::StoreShaderToDisk( | 44 void TestGpuChannelManagerDelegate::StoreShaderToDisk( |
| 45 int32_t client_id, | 45 int32_t client_id, |
| 46 const std::string& key, | 46 const std::string& key, |
| 47 const std::string& shader) {} | 47 const std::string& shader) {} |
| 48 | 48 |
| 49 #if defined(OS_MACOSX) | 49 #if defined(OS_MACOSX) |
| 50 void TestGpuChannelManagerDelegate::SendAcceleratedSurfaceBuffersSwapped( | 50 void TestGpuChannelManagerDelegate::SendAcceleratedSurfaceBuffersSwapped( |
| 51 int32_t surface_id, | 51 int32_t surface_id, |
| 52 CAContextID ca_context_id, | 52 CAContextID ca_context_id, |
| 53 const gfx::ScopedRefCountedIOSurfaceMachPort& io_surface, | 53 const gfx::ScopedRefCountedIOSurfaceMachPort& io_surface, |
| 54 const gfx::Size& size, | 54 const gfx::Size& size, |
| 55 float scale_factor, | 55 float scale_factor, |
| 56 std::vector<ui::LatencyInfo> latency_info) {} | 56 std::vector<ui::LatencyInfo> latency_info) {} |
| 57 #endif | 57 #endif |
| 58 | 58 |
| 59 #if defined(OS_WIN) | 59 #if defined(OS_WIN) |
| 60 void TestGpuChannelManagerDelegate::SendAcceleratedSurfaceCreatedChildWindow( | 60 void TestGpuChannelManagerDelegate::SendAcceleratedSurfaceCreatedChildWindow( |
| 61 gpu::SurfaceHandle parent_window, | 61 SurfaceHandle parent_window, |
| 62 gpu::SurfaceHandle child_window) {} | 62 SurfaceHandle child_window) {} |
| 63 #endif | 63 #endif |
| 64 | 64 |
| 65 TestGpuChannelManager::TestGpuChannelManager( | 65 TestGpuChannelManager::TestGpuChannelManager( |
| 66 const gpu::GpuPreferences& gpu_preferences, | 66 const GpuPreferences& gpu_preferences, |
| 67 GpuChannelManagerDelegate* delegate, | 67 GpuChannelManagerDelegate* delegate, |
| 68 base::SingleThreadTaskRunner* task_runner, | 68 base::SingleThreadTaskRunner* task_runner, |
| 69 base::SingleThreadTaskRunner* io_task_runner, | 69 base::SingleThreadTaskRunner* io_task_runner, |
| 70 gpu::SyncPointManager* sync_point_manager, | 70 SyncPointManager* sync_point_manager, |
| 71 GpuMemoryBufferFactory* gpu_memory_buffer_factory) | 71 GpuMemoryBufferFactory* gpu_memory_buffer_factory) |
| 72 : GpuChannelManager(gpu_preferences, | 72 : GpuChannelManager(gpu_preferences, |
| 73 delegate, | 73 delegate, |
| 74 nullptr, | 74 nullptr, |
| 75 task_runner, | 75 task_runner, |
| 76 io_task_runner, | 76 io_task_runner, |
| 77 nullptr, | 77 nullptr, |
| 78 sync_point_manager, | 78 sync_point_manager, |
| 79 gpu_memory_buffer_factory) {} | 79 gpu_memory_buffer_factory) {} |
| 80 | 80 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 92 bool allow_real_time_streams) { | 92 bool allow_real_time_streams) { |
| 93 return make_scoped_ptr(new TestGpuChannel( | 93 return make_scoped_ptr(new TestGpuChannel( |
| 94 this, sync_point_manager(), share_group(), mailbox_manager(), | 94 this, sync_point_manager(), share_group(), mailbox_manager(), |
| 95 preempts ? preemption_flag() : nullptr, | 95 preempts ? preemption_flag() : nullptr, |
| 96 preempts ? nullptr : preemption_flag(), task_runner_.get(), | 96 preempts ? nullptr : preemption_flag(), task_runner_.get(), |
| 97 io_task_runner_.get(), client_id, client_tracing_id, | 97 io_task_runner_.get(), client_id, client_tracing_id, |
| 98 allow_view_command_buffers, allow_real_time_streams)); | 98 allow_view_command_buffers, allow_real_time_streams)); |
| 99 } | 99 } |
| 100 | 100 |
| 101 TestGpuChannel::TestGpuChannel(GpuChannelManager* gpu_channel_manager, | 101 TestGpuChannel::TestGpuChannel(GpuChannelManager* gpu_channel_manager, |
| 102 gpu::SyncPointManager* sync_point_manager, | 102 SyncPointManager* sync_point_manager, |
| 103 gfx::GLShareGroup* share_group, | 103 gfx::GLShareGroup* share_group, |
| 104 gpu::gles2::MailboxManager* mailbox_manager, | 104 gles2::MailboxManager* mailbox_manager, |
| 105 gpu::PreemptionFlag* preempting_flag, | 105 PreemptionFlag* preempting_flag, |
| 106 gpu::PreemptionFlag* preempted_flag, | 106 PreemptionFlag* preempted_flag, |
| 107 base::SingleThreadTaskRunner* task_runner, | 107 base::SingleThreadTaskRunner* task_runner, |
| 108 base::SingleThreadTaskRunner* io_task_runner, | 108 base::SingleThreadTaskRunner* io_task_runner, |
| 109 int client_id, | 109 int client_id, |
| 110 uint64_t client_tracing_id, | 110 uint64_t client_tracing_id, |
| 111 bool allow_view_command_buffers, | 111 bool allow_view_command_buffers, |
| 112 bool allow_real_time_streams) | 112 bool allow_real_time_streams) |
| 113 : GpuChannel(gpu_channel_manager, | 113 : GpuChannel(gpu_channel_manager, |
| 114 sync_point_manager, | 114 sync_point_manager, |
| 115 nullptr, | 115 nullptr, |
| 116 share_group, | 116 share_group, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 141 | 141 |
| 142 bool TestGpuChannel::Send(IPC::Message* msg) { | 142 bool TestGpuChannel::Send(IPC::Message* msg) { |
| 143 DCHECK(!msg->is_sync()); | 143 DCHECK(!msg->is_sync()); |
| 144 return sink_.Send(msg); | 144 return sink_.Send(msg); |
| 145 } | 145 } |
| 146 | 146 |
| 147 // TODO(sunnyps): Use a mock memory buffer factory when necessary. | 147 // TODO(sunnyps): Use a mock memory buffer factory when necessary. |
| 148 GpuChannelTestCommon::GpuChannelTestCommon() | 148 GpuChannelTestCommon::GpuChannelTestCommon() |
| 149 : task_runner_(new base::TestSimpleTaskRunner), | 149 : task_runner_(new base::TestSimpleTaskRunner), |
| 150 io_task_runner_(new base::TestSimpleTaskRunner), | 150 io_task_runner_(new base::TestSimpleTaskRunner), |
| 151 sync_point_manager_(new gpu::SyncPointManager(false)), | 151 sync_point_manager_(new SyncPointManager(false)), |
| 152 channel_manager_delegate_(new TestGpuChannelManagerDelegate()), | 152 channel_manager_delegate_(new TestGpuChannelManagerDelegate()), |
| 153 channel_manager_( | 153 channel_manager_( |
| 154 new TestGpuChannelManager(gpu_preferences_, | 154 new TestGpuChannelManager(gpu_preferences_, |
| 155 channel_manager_delegate_.get(), | 155 channel_manager_delegate_.get(), |
| 156 task_runner_.get(), | 156 task_runner_.get(), |
| 157 io_task_runner_.get(), | 157 io_task_runner_.get(), |
| 158 sync_point_manager_.get(), | 158 sync_point_manager_.get(), |
| 159 nullptr)) {} | 159 nullptr)) {} |
| 160 | 160 |
| 161 GpuChannelTestCommon::~GpuChannelTestCommon() { | 161 GpuChannelTestCommon::~GpuChannelTestCommon() { |
| 162 // Destroying channels causes tasks to run on the IO task runner. | 162 // Destroying channels causes tasks to run on the IO task runner. |
| 163 channel_manager_ = nullptr; | 163 channel_manager_ = nullptr; |
| 164 // Clear pending tasks to avoid refptr cycles that get flagged by ASAN. | 164 // Clear pending tasks to avoid refptr cycles that get flagged by ASAN. |
| 165 task_runner_->ClearPendingTasks(); | 165 task_runner_->ClearPendingTasks(); |
| 166 io_task_runner_->ClearPendingTasks(); | 166 io_task_runner_->ClearPendingTasks(); |
| 167 } | 167 } |
| 168 | 168 |
| 169 } // namespace content | 169 } // namespace gpu |
| OLD | NEW |