Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1818)

Side by Side Diff: content/browser/gpu/gpu_process_host_ui_shim.cc

Issue 1962493002: Make Mac swap code like other platforms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporate review feedback Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/renderer_host/render_process_host_impl.h" 20 #include "content/browser/renderer_host/render_process_host_impl.h"
21 #include "content/browser/renderer_host/render_view_host_impl.h" 21 #include "content/browser/renderer_host/render_view_host_impl.h"
22 #include "content/browser/renderer_host/render_widget_helper.h" 22 #include "content/browser/renderer_host/render_widget_helper.h"
23 #include "content/browser/renderer_host/render_widget_host_view_base.h" 23 #include "content/browser/renderer_host/render_widget_host_view_base.h"
24 #include "content/common/gpu_host_messages.h" 24 #include "content/common/gpu_host_messages.h"
25 #include "content/public/browser/browser_thread.h" 25 #include "content/public/browser/browser_thread.h"
26 #include "gpu/ipc/common/memory_stats.h" 26 #include "gpu/ipc/common/memory_stats.h"
27 #include "ui/gfx/swap_result.h" 27 #include "ui/gfx/swap_result.h"
28 28
29 #if defined(OS_MACOSX)
30 #include "content/browser/gpu/gpu_surface_tracker.h"
31 #include "content/common/accelerated_surface_buffers_swapped_params_mac.h"
32 #include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
33 #endif
34
35 #if defined(USE_OZONE) 29 #if defined(USE_OZONE)
36 #include "ui/ozone/public/gpu_platform_support_host.h" 30 #include "ui/ozone/public/gpu_platform_support_host.h"
37 #include "ui/ozone/public/ozone_platform.h" 31 #include "ui/ozone/public/ozone_platform.h"
38 #endif 32 #endif
39 33
40 namespace content { 34 namespace content {
41 35
42 namespace { 36 namespace {
43 37
44 // One of the linux specific headers defines this as a macro. 38 // One of the linux specific headers defines this as a macro.
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 base::ResetAndReturn(&close_callback_).Run(); 175 base::ResetAndReturn(&close_callback_).Run();
182 g_hosts_by_id.Pointer()->Remove(host_id_); 176 g_hosts_by_id.Pointer()->Remove(host_id_);
183 } 177 }
184 178
185 bool GpuProcessHostUIShim::OnControlMessageReceived( 179 bool GpuProcessHostUIShim::OnControlMessageReceived(
186 const IPC::Message& message) { 180 const IPC::Message& message) {
187 DCHECK(CalledOnValidThread()); 181 DCHECK(CalledOnValidThread());
188 182
189 IPC_BEGIN_MESSAGE_MAP(GpuProcessHostUIShim, message) 183 IPC_BEGIN_MESSAGE_MAP(GpuProcessHostUIShim, message)
190 IPC_MESSAGE_HANDLER(GpuHostMsg_OnLogMessage, OnLogMessage) 184 IPC_MESSAGE_HANDLER(GpuHostMsg_OnLogMessage, OnLogMessage)
191 #if defined(OS_MACOSX)
192 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped,
193 OnAcceleratedSurfaceBuffersSwapped)
194 #endif
195 IPC_MESSAGE_HANDLER(GpuHostMsg_GraphicsInfoCollected, 185 IPC_MESSAGE_HANDLER(GpuHostMsg_GraphicsInfoCollected,
196 OnGraphicsInfoCollected) 186 OnGraphicsInfoCollected)
197 IPC_MESSAGE_HANDLER(GpuHostMsg_VideoMemoryUsageStats, 187 IPC_MESSAGE_HANDLER(GpuHostMsg_VideoMemoryUsageStats,
198 OnVideoMemoryUsageStatsReceived); 188 OnVideoMemoryUsageStatsReceived);
199 189
200 IPC_MESSAGE_UNHANDLED_ERROR() 190 IPC_MESSAGE_UNHANDLED_ERROR()
201 IPC_END_MESSAGE_MAP() 191 IPC_END_MESSAGE_MAP()
202 192
203 return true; 193 return true;
204 } 194 }
205 195
206 void GpuProcessHostUIShim::OnLogMessage( 196 void GpuProcessHostUIShim::OnLogMessage(
207 int level, 197 int level,
208 const std::string& header, 198 const std::string& header,
209 const std::string& message) { 199 const std::string& message) {
210 GpuDataManagerImpl::GetInstance()->AddLogMessage( 200 GpuDataManagerImpl::GetInstance()->AddLogMessage(
211 level, header, message); 201 level, header, message);
212 } 202 }
213 203
214 void GpuProcessHostUIShim::OnGraphicsInfoCollected( 204 void GpuProcessHostUIShim::OnGraphicsInfoCollected(
215 const gpu::GPUInfo& gpu_info) { 205 const gpu::GPUInfo& gpu_info) {
216 // OnGraphicsInfoCollected is sent back after the GPU process successfully 206 // OnGraphicsInfoCollected is sent back after the GPU process successfully
217 // initializes GL. 207 // initializes GL.
218 TRACE_EVENT0("test_gpu", "OnGraphicsInfoCollected"); 208 TRACE_EVENT0("test_gpu", "OnGraphicsInfoCollected");
219 209
220 GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info); 210 GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info);
221 } 211 }
222 212
223 #if defined(OS_MACOSX)
224 void GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped(
225 const AcceleratedSurfaceBuffersSwappedParams& params) {
226 TRACE_EVENT0("browser",
227 "GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped");
228 if (!ui::LatencyInfo::Verify(params.latency_info,
229 "GpuHostMsg_AcceleratedSurfaceBuffersSwapped")) {
230 TRACE_EVENT0("browser", "ui::LatencyInfo::Verify failed");
231 return;
232 }
233
234 // On Mac with delegated rendering, accelerated surfaces are not necessarily
235 // associated with a RenderWidgetHostViewBase.
236 BufferPresentedParams ack_params;
237 ack_params.surface_handle = params.surface_handle;
238
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
241 // it to the GPU process immediately, so we can proceed to the next frame.
242 bool should_not_show_frame =
243 content::ImageTransportFactory::GetInstance()
244 ->SurfaceShouldNotShowFramesAfterSuspendForRecycle(
245 params.surface_handle);
246 if (!should_not_show_frame) {
247 gfx::AcceleratedWidget native_widget =
248 content::GpuSurfaceTracker::Get()->AcquireNativeWidget(
249 params.surface_handle);
250 base::ScopedCFTypeRef<IOSurfaceRef> io_surface;
251 CAContextID ca_context_id = params.ca_context_id;
252
253 DCHECK((params.ca_context_id == 0) ^
254 (params.io_surface.get() == MACH_PORT_NULL));
255 if (params.io_surface.get()) {
256 io_surface.reset(IOSurfaceLookupFromMachPort(params.io_surface));
257 }
258
259 ui::AcceleratedWidgetMacGotFrame(
260 native_widget, ca_context_id,
261 params.fullscreen_low_power_ca_context_valid,
262 params.fullscreen_low_power_ca_context_id, io_surface, params.size,
263 params.scale_factor, &ack_params.vsync_timebase,
264 &ack_params.vsync_interval);
265 } else {
266 TRACE_EVENT0("browser", "Skipping recycled surface frame");
267 }
268
269 content::ImageTransportFactory::GetInstance()->OnGpuSwapBuffersCompleted(
270 params.surface_handle, params.latency_info, gfx::SwapResult::SWAP_ACK);
271
272 Send(new AcceleratedSurfaceMsg_BufferPresented(ack_params));
273 }
274 #endif
275
276 void GpuProcessHostUIShim::OnVideoMemoryUsageStatsReceived( 213 void GpuProcessHostUIShim::OnVideoMemoryUsageStatsReceived(
277 const gpu::VideoMemoryUsageStats& video_memory_usage_stats) { 214 const gpu::VideoMemoryUsageStats& video_memory_usage_stats) {
278 GpuDataManagerImpl::GetInstance()->UpdateVideoMemoryUsageStats( 215 GpuDataManagerImpl::GetInstance()->UpdateVideoMemoryUsageStats(
279 video_memory_usage_stats); 216 video_memory_usage_stats);
280 } 217 }
281 218
282 } // namespace content 219 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/gpu/gpu_process_host_ui_shim.h ('k') | content/browser/renderer_host/compositor_impl_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698