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

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

Issue 1416493010: Clean up Mac swap acknowledgement code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update latency info Created 5 years, 1 month 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"
(...skipping 25 matching lines...) Expand all
36 36
37 namespace content { 37 namespace content {
38 38
39 namespace { 39 namespace {
40 40
41 // One of the linux specific headers defines this as a macro. 41 // One of the linux specific headers defines this as a macro.
42 #ifdef DestroyAll 42 #ifdef DestroyAll
43 #undef DestroyAll 43 #undef DestroyAll
44 #endif 44 #endif
45 45
46 #if defined(OS_MACOSX)
47 void OnSurfaceDisplayedCallback(int output_surface_id) {
48 content::ImageTransportFactory::GetInstance()->OnSurfaceDisplayed(
49 output_surface_id);
50 }
51 #endif
52
53 base::LazyInstance<IDMap<GpuProcessHostUIShim> > g_hosts_by_id = 46 base::LazyInstance<IDMap<GpuProcessHostUIShim> > g_hosts_by_id =
54 LAZY_INSTANCE_INITIALIZER; 47 LAZY_INSTANCE_INITIALIZER;
55 48
56 void SendOnIOThreadTask(int host_id, IPC::Message* msg) { 49 void SendOnIOThreadTask(int host_id, IPC::Message* msg) {
57 GpuProcessHost* host = GpuProcessHost::FromID(host_id); 50 GpuProcessHost* host = GpuProcessHost::FromID(host_id);
58 if (host) 51 if (host)
59 host->Send(msg); 52 host->Send(msg);
60 else 53 else
61 delete msg; 54 delete msg;
62 } 55 }
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 // On Mac with delegated rendering, accelerated surfaces are not necessarily 233 // On Mac with delegated rendering, accelerated surfaces are not necessarily
241 // associated with a RenderWidgetHostViewBase. 234 // associated with a RenderWidgetHostViewBase.
242 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; 235 AcceleratedSurfaceMsg_BufferPresented_Params ack_params;
243 236
244 // If the frame was intended for an NSView that the gfx::AcceleratedWidget is 237 // If the frame was intended for an NSView that the gfx::AcceleratedWidget is
245 // no longer attached to, do not pass the frame along to the widget. Just ack 238 // no longer attached to, do not pass the frame along to the widget. Just ack
246 // it to the GPU process immediately, so we can proceed to the next frame. 239 // it to the GPU process immediately, so we can proceed to the next frame.
247 bool should_not_show_frame = 240 bool should_not_show_frame =
248 content::ImageTransportFactory::GetInstance() 241 content::ImageTransportFactory::GetInstance()
249 ->SurfaceShouldNotShowFramesAfterSuspendForRecycle(params.surface_id); 242 ->SurfaceShouldNotShowFramesAfterSuspendForRecycle(params.surface_id);
250 if (should_not_show_frame) { 243 if (!should_not_show_frame) {
251 OnSurfaceDisplayedCallback(params.surface_id);
252 } else {
253 gfx::AcceleratedWidget native_widget = 244 gfx::AcceleratedWidget native_widget =
254 content::GpuSurfaceTracker::Get()->AcquireNativeWidget( 245 content::GpuSurfaceTracker::Get()->AcquireNativeWidget(
255 params.surface_id); 246 params.surface_id);
256 base::ScopedCFTypeRef<IOSurfaceRef> io_surface; 247 base::ScopedCFTypeRef<IOSurfaceRef> io_surface;
257 CAContextID ca_context_id = 0; 248 CAContextID ca_context_id = 0;
258 249
259 switch (ui::GetSurfaceHandleType(params.surface_handle)) { 250 switch (ui::GetSurfaceHandleType(params.surface_handle)) {
260 case ui::kSurfaceHandleTypeIOSurface: { 251 case ui::kSurfaceHandleTypeIOSurface: {
261 IOSurfaceID io_surface_id = 252 IOSurfaceID io_surface_id =
262 ui::IOSurfaceIDFromSurfaceHandle(params.surface_handle); 253 ui::IOSurfaceIDFromSurfaceHandle(params.surface_handle);
263 io_surface.reset( 254 io_surface.reset(
264 BrowserIOSurfaceManager::GetInstance()->AcquireIOSurface( 255 BrowserIOSurfaceManager::GetInstance()->AcquireIOSurface(
265 gfx::GenericSharedMemoryId(io_surface_id))); 256 gfx::GenericSharedMemoryId(io_surface_id)));
266 break; 257 break;
267 } 258 }
268 case ui::kSurfaceHandleTypeCAContext: { 259 case ui::kSurfaceHandleTypeCAContext: {
269 ca_context_id = ui::CAContextIDFromSurfaceHandle(params.surface_handle); 260 ca_context_id = ui::CAContextIDFromSurfaceHandle(params.surface_handle);
270 break; 261 break;
271 } 262 }
272 default: 263 default:
273 DLOG(ERROR) << "Unrecognized accelerated frame type."; 264 DLOG(ERROR) << "Unrecognized accelerated frame type.";
274 return; 265 return;
275 } 266 }
276 ui::AcceleratedWidgetMacGotAcceleratedFrame( 267
277 native_widget, ca_context_id, io_surface, params.latency_info, 268 ui::AcceleratedWidgetMacGotFrame(native_widget, ca_context_id, io_surface,
278 params.size, params.scale_factor, params.damage_rect, 269 params.size, params.scale_factor,
279 base::Bind(&OnSurfaceDisplayedCallback, params.surface_id), 270 &ack_params.vsync_timebase,
280 &ack_params.disable_throttling, &ack_params.renderer_id, 271 &ack_params.vsync_interval);
281 &ack_params.vsync_timebase, &ack_params.vsync_interval);
282 } 272 }
273
274 content::ImageTransportFactory::GetInstance()->OnGpuSwapBuffersCompleted(
275 params.surface_id, params.latency_info, gfx::SwapResult::SWAP_ACK);
276
283 Send(new AcceleratedSurfaceMsg_BufferPresented(params.route_id, ack_params)); 277 Send(new AcceleratedSurfaceMsg_BufferPresented(params.route_id, ack_params));
284 } 278 }
285 #endif 279 #endif
286 280
287 void GpuProcessHostUIShim::OnVideoMemoryUsageStatsReceived( 281 void GpuProcessHostUIShim::OnVideoMemoryUsageStatsReceived(
288 const GPUVideoMemoryUsageStats& video_memory_usage_stats) { 282 const GPUVideoMemoryUsageStats& video_memory_usage_stats) {
289 GpuDataManagerImpl::GetInstance()->UpdateVideoMemoryUsageStats( 283 GpuDataManagerImpl::GetInstance()->UpdateVideoMemoryUsageStats(
290 video_memory_usage_stats); 284 video_memory_usage_stats);
291 } 285 }
292 286
293 void GpuProcessHostUIShim::OnAddSubscription( 287 void GpuProcessHostUIShim::OnAddSubscription(
294 int32 process_id, unsigned int target) { 288 int32 process_id, unsigned int target) {
295 RenderProcessHost* rph = RenderProcessHost::FromID(process_id); 289 RenderProcessHost* rph = RenderProcessHost::FromID(process_id);
296 if (rph) { 290 if (rph) {
297 rph->OnAddSubscription(target); 291 rph->OnAddSubscription(target);
298 } 292 }
299 } 293 }
300 294
301 void GpuProcessHostUIShim::OnRemoveSubscription( 295 void GpuProcessHostUIShim::OnRemoveSubscription(
302 int32 process_id, unsigned int target) { 296 int32 process_id, unsigned int target) {
303 RenderProcessHost* rph = RenderProcessHost::FromID(process_id); 297 RenderProcessHost* rph = RenderProcessHost::FromID(process_id);
304 if (rph) { 298 if (rph) {
305 rph->OnRemoveSubscription(target); 299 rph->OnRemoveSubscription(target);
306 } 300 }
307 } 301 }
308 302
309 } // namespace content 303 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698