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

Side by Side Diff: content/browser/renderer_host/render_widget_helper_mac.mm

Issue 301973010: Remove IOSurfaceSupport (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/renderer_host/render_widget_helper.h" 5 #include "content/browser/renderer_host/render_widget_helper.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 #include <IOSurface/IOSurfaceAPI.h>
8 9
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "content/browser/compositor/browser_compositor_view_mac.h" 11 #include "content/browser/compositor/browser_compositor_view_mac.h"
11 #include "content/browser/gpu/gpu_process_host.h" 12 #include "content/browser/gpu/gpu_process_host.h"
12 #include "content/browser/gpu/gpu_surface_tracker.h" 13 #include "content/browser/gpu/gpu_surface_tracker.h"
13 #include "content/common/gpu/gpu_messages.h" 14 #include "content/common/gpu/gpu_messages.h"
14 15
15 namespace { 16 namespace {
16 17
17 void OnNativeSurfaceBuffersSwappedOnUIThread( 18 void OnNativeSurfaceBuffersSwappedOnUIThread(
19 base::ScopedCFTypeRef<IOSurfaceRef> io_surface,
18 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { 20 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) {
19 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 21 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
20 gfx::AcceleratedWidget native_widget = 22 gfx::AcceleratedWidget native_widget =
21 content::GpuSurfaceTracker::Get()->AcquireNativeWidget(params.surface_id); 23 content::GpuSurfaceTracker::Get()->AcquireNativeWidget(params.surface_id);
22 [native_widget gotAcceleratedIOSurfaceFrame:params.surface_handle 24 [native_widget gotAcceleratedIOSurfaceFrame:params.surface_handle
23 withPixelSize:params.size 25 withPixelSize:params.size
24 withScaleFactor:params.scale_factor]; 26 withScaleFactor:params.scale_factor];
25 } 27 }
26 28
27 } // namespace 29 } // namespace
28 30
29 namespace content { 31 namespace content {
30 32
31 void RenderWidgetHelper::OnNativeSurfaceBuffersSwappedOnIOThread( 33 void RenderWidgetHelper::OnNativeSurfaceBuffersSwappedOnIOThread(
32 GpuProcessHost* gpu_process_host, 34 GpuProcessHost* gpu_process_host,
33 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { 35 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) {
34 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 36 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
35 37
36 // Immediately acknowledge this frame on the IO thread instead of the UI 38 // Immediately acknowledge this frame on the IO thread instead of the UI
37 // thread. The UI thread will wait on the GPU process. If the UI thread 39 // thread. The UI thread will wait on the GPU process. If the UI thread
38 // were to be responsible for acking swaps, then there would be a cycle 40 // were to be responsible for acking swaps, then there would be a cycle
39 // and a potential deadlock. 41 // and a potential deadlock.
40 // TODO(ccameron): This immediate ack circumvents GPU back-pressure that 42 // TODO(ccameron): This immediate ack circumvents GPU back-pressure that
41 // is necessary to throttle renderers. Fix that. 43 // is necessary to throttle renderers. Fix that.
42 // TODO(ccameron): It is possible that the IOSurface will be deleted or
43 // reused soon as it is acked. Take out a reference to the IOSurface here,
44 // to ensure the IOSurface does not disappear before routing to the UI
45 // thread.
46 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; 44 AcceleratedSurfaceMsg_BufferPresented_Params ack_params;
47 ack_params.sync_point = 0; 45 ack_params.sync_point = 0;
48 ack_params.renderer_id = 0; 46 ack_params.renderer_id = 0;
49 gpu_process_host->Send(new AcceleratedSurfaceMsg_BufferPresented( 47 gpu_process_host->Send(new AcceleratedSurfaceMsg_BufferPresented(
50 params.route_id, ack_params)); 48 params.route_id, ack_params));
51 49
50 // Open the IOSurface handle before returning, to ensure that it is not
51 // closed as soon as the frame is acknowledged.
52 base::ScopedCFTypeRef<IOSurfaceRef> io_surface(IOSurfaceLookup(
53 static_cast<uint32>(params.surface_handle)));
54
52 BrowserThread::PostTask( 55 BrowserThread::PostTask(
53 BrowserThread::UI, 56 BrowserThread::UI,
54 FROM_HERE, 57 FROM_HERE,
55 base::Bind(&OnNativeSurfaceBuffersSwappedOnUIThread, params)); 58 base::Bind(&OnNativeSurfaceBuffersSwappedOnUIThread, io_surface, params));
56 } 59 }
57 60
58 } // namespace content 61 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698