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/gpu/gpu_child_thread.h" | 5 #include "content/gpu/gpu_child_thread.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/threading/worker_pool.h" | 9 #include "base/threading/worker_pool.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 return handled; | 74 return handled; |
75 } | 75 } |
76 | 76 |
77 protected: | 77 protected: |
78 ~GpuMemoryBufferMessageFilter() override {} | 78 ~GpuMemoryBufferMessageFilter() override {} |
79 | 79 |
80 void OnCreateGpuMemoryBuffer( | 80 void OnCreateGpuMemoryBuffer( |
81 const GpuMsg_CreateGpuMemoryBuffer_Params& params) { | 81 const GpuMsg_CreateGpuMemoryBuffer_Params& params) { |
82 TRACE_EVENT2("gpu", "GpuMemoryBufferMessageFilter::OnCreateGpuMemoryBuffer", | 82 TRACE_EVENT2("gpu", "GpuMemoryBufferMessageFilter::OnCreateGpuMemoryBuffer", |
83 "id", params.id.id, "client_id", params.client_id); | 83 "id", params.id.id, "client_id", params.client_id); |
| 84 |
| 85 DCHECK(gpu_memory_buffer_factory_); |
84 sender_->Send(new GpuHostMsg_GpuMemoryBufferCreated( | 86 sender_->Send(new GpuHostMsg_GpuMemoryBufferCreated( |
85 gpu_memory_buffer_factory_->CreateGpuMemoryBuffer( | 87 gpu_memory_buffer_factory_->CreateGpuMemoryBuffer( |
86 params.id, params.size, params.format, params.usage, | 88 params.id, params.size, params.format, params.usage, |
87 params.client_id, params.surface_handle))); | 89 params.client_id, params.surface_handle))); |
88 } | 90 } |
89 | 91 |
90 GpuMemoryBufferFactory* const gpu_memory_buffer_factory_; | 92 GpuMemoryBufferFactory* const gpu_memory_buffer_factory_; |
91 IPC::Sender* sender_; | 93 IPC::Sender* sender_; |
92 }; | 94 }; |
93 | 95 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 g_thread_safe_sender.Get() = thread_safe_sender(); | 161 g_thread_safe_sender.Get() = thread_safe_sender(); |
160 } | 162 } |
161 | 163 |
162 GpuChildThread::~GpuChildThread() { | 164 GpuChildThread::~GpuChildThread() { |
163 while (!deferred_messages_.empty()) { | 165 while (!deferred_messages_.empty()) { |
164 delete deferred_messages_.front(); | 166 delete deferred_messages_.front(); |
165 deferred_messages_.pop(); | 167 deferred_messages_.pop(); |
166 } | 168 } |
167 } | 169 } |
168 | 170 |
169 // static | |
170 gfx::GpuMemoryBufferType GpuChildThread::GetGpuMemoryBufferFactoryType() { | |
171 std::vector<gfx::GpuMemoryBufferType> supported_types; | |
172 GpuMemoryBufferFactory::GetSupportedTypes(&supported_types); | |
173 DCHECK(!supported_types.empty()); | |
174 // Note: We always use the preferred type. | |
175 return supported_types[0]; | |
176 } | |
177 | |
178 void GpuChildThread::Shutdown() { | 171 void GpuChildThread::Shutdown() { |
179 ChildThreadImpl::Shutdown(); | 172 ChildThreadImpl::Shutdown(); |
180 logging::SetLogMessageHandler(NULL); | 173 logging::SetLogMessageHandler(NULL); |
181 } | 174 } |
182 | 175 |
183 void GpuChildThread::Init(const base::Time& process_start_time) { | 176 void GpuChildThread::Init(const base::Time& process_start_time) { |
184 process_start_time_ = process_start_time; | 177 process_start_time_ = process_start_time; |
185 } | 178 } |
186 | 179 |
187 bool GpuChildThread::Send(IPC::Message* msg) { | 180 bool GpuChildThread::Send(IPC::Message* msg) { |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 } | 361 } |
369 } | 362 } |
370 | 363 |
371 void GpuChildThread::OnGpuSwitched() { | 364 void GpuChildThread::OnGpuSwitched() { |
372 DVLOG(1) << "GPU: GPU has switched"; | 365 DVLOG(1) << "GPU: GPU has switched"; |
373 // Notify observers in the GPU process. | 366 // Notify observers in the GPU process. |
374 ui::GpuSwitchingManager::GetInstance()->NotifyGpuSwitched(); | 367 ui::GpuSwitchingManager::GetInstance()->NotifyGpuSwitched(); |
375 } | 368 } |
376 | 369 |
377 } // namespace content | 370 } // namespace content |
OLD | NEW |