| 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/browser/gpu/gpu_process_host_ui_shim.h" | 5 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| 11 #include "base/id_map.h" | 11 #include "base/id_map.h" |
| 12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/trace_event/trace_event.h" | 14 #include "base/trace_event/trace_event.h" |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "content/browser/compositor/gpu_process_transport_factory.h" | 16 #include "content/browser/compositor/gpu_process_transport_factory.h" |
| 17 #include "content/browser/gpu/compositor_util.h" | 17 #include "content/browser/gpu/compositor_util.h" |
| 18 #include "content/browser/gpu/gpu_data_manager_impl.h" | 18 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 19 #include "content/browser/gpu/gpu_process_host.h" | 19 #include "content/browser/gpu/gpu_process_host.h" |
| 20 #include "content/browser/gpu/gpu_surface_tracker.h" | 20 #include "content/browser/gpu/gpu_surface_tracker.h" |
| 21 #include "content/browser/renderer_host/render_process_host_impl.h" | 21 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 22 #include "content/browser/renderer_host/render_view_host_impl.h" | 22 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 23 #include "content/browser/renderer_host/render_widget_helper.h" | 23 #include "content/browser/renderer_host/render_widget_helper.h" |
| 24 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 24 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 25 #include "content/common/gpu/gpu_messages.h" | 25 #include "content/common/gpu/gpu_browser_messages.h" |
| 26 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
| 27 | 27 |
| 28 #if defined(OS_MACOSX) | 28 #if defined(OS_MACOSX) |
| 29 #include "ui/accelerated_widget_mac/accelerated_widget_mac.h" | 29 #include "ui/accelerated_widget_mac/accelerated_widget_mac.h" |
| 30 #endif | 30 #endif |
| 31 | 31 |
| 32 #if defined(USE_OZONE) | 32 #if defined(USE_OZONE) |
| 33 #include "ui/ozone/public/gpu_platform_support_host.h" | 33 #include "ui/ozone/public/gpu_platform_support_host.h" |
| 34 #include "ui/ozone/public/ozone_platform.h" | 34 #include "ui/ozone/public/ozone_platform.h" |
| 35 #endif | 35 #endif |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 } | 154 } |
| 155 | 155 |
| 156 void GpuProcessHostUIShim::StopGpuProcess(const base::Closure& callback) { | 156 void GpuProcessHostUIShim::StopGpuProcess(const base::Closure& callback) { |
| 157 close_callback_ = callback; | 157 close_callback_ = callback; |
| 158 | 158 |
| 159 BrowserThread::PostTask( | 159 BrowserThread::PostTask( |
| 160 BrowserThread::IO, FROM_HERE, base::Bind(&StopGpuProcessOnIO, host_id_)); | 160 BrowserThread::IO, FROM_HERE, base::Bind(&StopGpuProcessOnIO, host_id_)); |
| 161 } | 161 } |
| 162 | 162 |
| 163 void GpuProcessHostUIShim::SimulateRemoveAllContext() { | 163 void GpuProcessHostUIShim::SimulateRemoveAllContext() { |
| 164 Send(new GpuMsg_Clean()); | 164 Send(new GpuBrowserMsg_Clean()); |
| 165 } | 165 } |
| 166 | 166 |
| 167 void GpuProcessHostUIShim::SimulateCrash() { | 167 void GpuProcessHostUIShim::SimulateCrash() { |
| 168 Send(new GpuMsg_Crash()); | 168 Send(new GpuBrowserMsg_Crash()); |
| 169 } | 169 } |
| 170 | 170 |
| 171 void GpuProcessHostUIShim::SimulateHang() { | 171 void GpuProcessHostUIShim::SimulateHang() { |
| 172 Send(new GpuMsg_Hang()); | 172 Send(new GpuBrowserMsg_Hang()); |
| 173 } | 173 } |
| 174 | 174 |
| 175 GpuProcessHostUIShim::~GpuProcessHostUIShim() { | 175 GpuProcessHostUIShim::~GpuProcessHostUIShim() { |
| 176 DCHECK(CalledOnValidThread()); | 176 DCHECK(CalledOnValidThread()); |
| 177 if (!close_callback_.is_null()) | 177 if (!close_callback_.is_null()) |
| 178 base::ResetAndReturn(&close_callback_).Run(); | 178 base::ResetAndReturn(&close_callback_).Run(); |
| 179 g_hosts_by_id.Pointer()->Remove(host_id_); | 179 g_hosts_by_id.Pointer()->Remove(host_id_); |
| 180 } | 180 } |
| 181 | 181 |
| 182 bool GpuProcessHostUIShim::OnControlMessageReceived( | 182 bool GpuProcessHostUIShim::OnControlMessageReceived( |
| 183 const IPC::Message& message) { | 183 const IPC::Message& message) { |
| 184 DCHECK(CalledOnValidThread()); | 184 DCHECK(CalledOnValidThread()); |
| 185 | 185 |
| 186 IPC_BEGIN_MESSAGE_MAP(GpuProcessHostUIShim, message) | 186 IPC_BEGIN_MESSAGE_MAP(GpuProcessHostUIShim, message) |
| 187 IPC_MESSAGE_HANDLER(GpuHostMsg_OnLogMessage, | 187 IPC_MESSAGE_HANDLER(GpuBrowserHostMsg_OnLogMessage, OnLogMessage) |
| 188 OnLogMessage) | |
| 189 #if defined(OS_MACOSX) | 188 #if defined(OS_MACOSX) |
| 190 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, | 189 IPC_MESSAGE_HANDLER(GpuBrowserHostMsg_AcceleratedSurfaceBuffersSwapped, |
| 191 OnAcceleratedSurfaceBuffersSwapped) | 190 OnAcceleratedSurfaceBuffersSwapped) |
| 192 #endif | 191 #endif |
| 193 IPC_MESSAGE_HANDLER(GpuHostMsg_GraphicsInfoCollected, | 192 IPC_MESSAGE_HANDLER(GpuBrowserHostMsg_GraphicsInfoCollected, |
| 194 OnGraphicsInfoCollected) | 193 OnGraphicsInfoCollected) |
| 195 IPC_MESSAGE_HANDLER(GpuHostMsg_VideoMemoryUsageStats, | 194 IPC_MESSAGE_HANDLER(GpuBrowserHostMsg_VideoMemoryUsageStats, |
| 196 OnVideoMemoryUsageStatsReceived); | 195 OnVideoMemoryUsageStatsReceived); |
| 197 IPC_MESSAGE_HANDLER(GpuHostMsg_AddSubscription, OnAddSubscription); | 196 IPC_MESSAGE_HANDLER(GpuBrowserHostMsg_AddSubscription, OnAddSubscription); |
| 198 IPC_MESSAGE_HANDLER(GpuHostMsg_RemoveSubscription, OnRemoveSubscription); | 197 IPC_MESSAGE_HANDLER(GpuBrowserHostMsg_RemoveSubscription, |
| 198 OnRemoveSubscription); |
| 199 | 199 |
| 200 IPC_MESSAGE_UNHANDLED_ERROR() | 200 IPC_MESSAGE_UNHANDLED_ERROR() |
| 201 IPC_END_MESSAGE_MAP() | 201 IPC_END_MESSAGE_MAP() |
| 202 | 202 |
| 203 return true; | 203 return true; |
| 204 } | 204 } |
| 205 | 205 |
| 206 void GpuProcessHostUIShim::OnLogMessage( | 206 void GpuProcessHostUIShim::OnLogMessage( |
| 207 int level, | 207 int level, |
| 208 const std::string& header, | 208 const std::string& header, |
| 209 const std::string& message) { | 209 const std::string& message) { |
| 210 GpuDataManagerImpl::GetInstance()->AddLogMessage( | 210 GpuDataManagerImpl::GetInstance()->AddLogMessage( |
| 211 level, header, message); | 211 level, header, message); |
| 212 } | 212 } |
| 213 | 213 |
| 214 void GpuProcessHostUIShim::OnGraphicsInfoCollected( | 214 void GpuProcessHostUIShim::OnGraphicsInfoCollected( |
| 215 const gpu::GPUInfo& gpu_info) { | 215 const gpu::GPUInfo& gpu_info) { |
| 216 // OnGraphicsInfoCollected is sent back after the GPU process successfully | 216 // OnGraphicsInfoCollected is sent back after the GPU process successfully |
| 217 // initializes GL. | 217 // initializes GL. |
| 218 TRACE_EVENT0("test_gpu", "OnGraphicsInfoCollected"); | 218 TRACE_EVENT0("test_gpu", "OnGraphicsInfoCollected"); |
| 219 | 219 |
| 220 GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info); | 220 GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info); |
| 221 } | 221 } |
| 222 | 222 |
| 223 #if defined(OS_MACOSX) | 223 #if defined(OS_MACOSX) |
| 224 void GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped( | 224 void GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped( |
| 225 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { | 225 const GpuBrowserHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { |
| 226 TRACE_EVENT0("browser", | 226 TRACE_EVENT0("browser", |
| 227 "GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped"); | 227 "GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped"); |
| 228 if (!ui::LatencyInfo::Verify(params.latency_info, | 228 if (!ui::LatencyInfo::Verify( |
| 229 "GpuHostMsg_AcceleratedSurfaceBuffersSwapped")) { | 229 params.latency_info, |
| 230 | 230 "GpuBrowserHostMsg_AcceleratedSurfaceBuffersSwapped")) { |
| 231 TRACE_EVENT0("browser", "ui::LatencyInfo::Verify failed"); | 231 TRACE_EVENT0("browser", "ui::LatencyInfo::Verify failed"); |
| 232 return; | 232 return; |
| 233 } | 233 } |
| 234 | 234 |
| 235 // On Mac with delegated rendering, accelerated surfaces are not necessarily | 235 // On Mac with delegated rendering, accelerated surfaces are not necessarily |
| 236 // associated with a RenderWidgetHostViewBase. | 236 // associated with a RenderWidgetHostViewBase. |
| 237 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; | 237 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; |
| 238 | 238 |
| 239 // If the frame was intended for an NSView that the gfx::AcceleratedWidget is | 239 // If the frame was intended for an NSView that the gfx::AcceleratedWidget is |
| 240 // no longer attached to, do not pass the frame along to the widget. Just ack | 240 // no longer attached to, do not pass the frame along to the widget. Just ack |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 | 286 |
| 287 void GpuProcessHostUIShim::OnRemoveSubscription(int32_t process_id, | 287 void GpuProcessHostUIShim::OnRemoveSubscription(int32_t process_id, |
| 288 unsigned int target) { | 288 unsigned int target) { |
| 289 RenderProcessHost* rph = RenderProcessHost::FromID(process_id); | 289 RenderProcessHost* rph = RenderProcessHost::FromID(process_id); |
| 290 if (rph) { | 290 if (rph) { |
| 291 rph->OnRemoveSubscription(target); | 291 rph->OnRemoveSubscription(target); |
| 292 } | 292 } |
| 293 } | 293 } |
| 294 | 294 |
| 295 } // namespace content | 295 } // namespace content |
| OLD | NEW |