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

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

Issue 396483003: Separate ResizeHelper from RenderWidgetHelper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make dtor order more robust Created 6 years, 5 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 #include <IOSurface/IOSurfaceAPI.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "content/browser/compositor/browser_compositor_view_mac.h" 11 #include "content/browser/compositor/browser_compositor_view_mac.h"
12 #include "content/browser/gpu/gpu_process_host.h" 12 #include "content/browser/gpu/gpu_process_host.h"
13 #include "content/browser/gpu/gpu_surface_tracker.h" 13 #include "content/browser/gpu/gpu_surface_tracker.h"
14 #include "content/common/gpu/gpu_messages.h" 14 #include "content/common/gpu/gpu_messages.h"
15 #include "content/common/gpu/surface_handle_types_mac.h" 15 #include "content/common/gpu/surface_handle_types_mac.h"
16 16
17 namespace { 17 namespace content {
18 18
19 void OnNativeSurfaceBuffersSwappedOnUIThread( 19 // static
20 base::ScopedCFTypeRef<IOSurfaceRef> io_surface, 20 void RenderWidgetHelper::OnNativeSurfaceBuffersSwappedOnUIThread(
21 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { 21 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) {
22 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 22 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
23 gfx::AcceleratedWidget native_widget = 23 gfx::AcceleratedWidget native_widget =
24 content::GpuSurfaceTracker::Get()->AcquireNativeWidget(params.surface_id); 24 content::GpuSurfaceTracker::Get()->AcquireNativeWidget(params.surface_id);
25 IOSurfaceID io_surface_id = content::IOSurfaceIDFromSurfaceHandle( 25 IOSurfaceID io_surface_id = content::IOSurfaceIDFromSurfaceHandle(
26 params.surface_handle); 26 params.surface_handle);
27 [native_widget gotAcceleratedIOSurfaceFrame:io_surface_id 27 [native_widget gotAcceleratedIOSurfaceFrame:io_surface_id
28 withOutputSurfaceID:params.surface_id 28 withOutputSurfaceID:params.surface_id
29 withLatencyInfo:params.latency_info 29 withLatencyInfo:params.latency_info
30 withPixelSize:params.size 30 withPixelSize:params.size
31 withScaleFactor:params.scale_factor]; 31 withScaleFactor:params.scale_factor];
32 } 32 }
33 33
34 } // namespace
35
36 namespace content {
37
38 void RenderWidgetHelper::OnNativeSurfaceBuffersSwappedOnIOThread(
39 GpuProcessHost* gpu_process_host,
40 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) {
41 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
42
43 // Immediately acknowledge this frame on the IO thread instead of the UI
44 // thread. The UI thread will wait on the GPU process. If the UI thread
45 // were to be responsible for acking swaps, then there would be a cycle
46 // and a potential deadlock.
47 // TODO(ccameron): This immediate ack circumvents GPU back-pressure that
48 // is necessary to throttle renderers. Fix that.
49 AcceleratedSurfaceMsg_BufferPresented_Params ack_params;
50 ack_params.sync_point = 0;
51 ack_params.renderer_id = 0;
52 gpu_process_host->Send(new AcceleratedSurfaceMsg_BufferPresented(
53 params.route_id, ack_params));
54
55 // Open the IOSurface handle before returning, to ensure that it is not
56 // closed as soon as the frame is acknowledged.
57 base::ScopedCFTypeRef<IOSurfaceRef> io_surface(IOSurfaceLookup(
58 static_cast<uint32>(params.surface_handle)));
59
60 BrowserThread::PostTask(
61 BrowserThread::UI,
62 FROM_HERE,
63 base::Bind(&OnNativeSurfaceBuffersSwappedOnUIThread, io_surface, params));
64 }
65
66 } // namespace content 34 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_helper.cc ('k') | content/browser/renderer_host/render_widget_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698