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

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

Issue 1532813002: Replace IOSurfaceManager by directly passing IOSurface Mach ports over Chrome IPC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Windows compile Created 5 years 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 "content/browser/compositor/gpu_process_transport_factory.h" 15 #include "content/browser/compositor/gpu_process_transport_factory.h"
16 #include "content/browser/gpu/compositor_util.h" 16 #include "content/browser/gpu/compositor_util.h"
17 #include "content/browser/gpu/gpu_data_manager_impl.h" 17 #include "content/browser/gpu/gpu_data_manager_impl.h"
18 #include "content/browser/gpu/gpu_process_host.h" 18 #include "content/browser/gpu/gpu_process_host.h"
19 #include "content/browser/gpu/gpu_surface_tracker.h" 19 #include "content/browser/gpu/gpu_surface_tracker.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/gpu_messages.h" 24 #include "content/common/gpu/gpu_messages.h"
25 #include "content/public/browser/browser_thread.h" 25 #include "content/public/browser/browser_thread.h"
26 26
27 #if defined(OS_MACOSX) 27 #if defined(OS_MACOSX)
28 #include "content/browser/browser_io_surface_manager_mac.h"
29 #include "ui/accelerated_widget_mac/accelerated_widget_mac.h" 28 #include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
30 #endif 29 #endif
31 30
32 #if defined(USE_OZONE) 31 #if defined(USE_OZONE)
33 #include "ui/ozone/public/gpu_platform_support_host.h" 32 #include "ui/ozone/public/gpu_platform_support_host.h"
34 #include "ui/ozone/public/ozone_platform.h" 33 #include "ui/ozone/public/ozone_platform.h"
35 #endif 34 #endif
36 35
37 namespace content { 36 namespace content {
38 37
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 // no longer attached to, do not pass the frame along to the widget. Just ack 237 // no longer attached to, do not pass the frame along to the widget. Just ack
239 // it to the GPU process immediately, so we can proceed to the next frame. 238 // it to the GPU process immediately, so we can proceed to the next frame.
240 bool should_not_show_frame = 239 bool should_not_show_frame =
241 content::ImageTransportFactory::GetInstance() 240 content::ImageTransportFactory::GetInstance()
242 ->SurfaceShouldNotShowFramesAfterSuspendForRecycle(params.surface_id); 241 ->SurfaceShouldNotShowFramesAfterSuspendForRecycle(params.surface_id);
243 if (!should_not_show_frame) { 242 if (!should_not_show_frame) {
244 gfx::AcceleratedWidget native_widget = 243 gfx::AcceleratedWidget native_widget =
245 content::GpuSurfaceTracker::Get()->AcquireNativeWidget( 244 content::GpuSurfaceTracker::Get()->AcquireNativeWidget(
246 params.surface_id); 245 params.surface_id);
247 base::ScopedCFTypeRef<IOSurfaceRef> io_surface; 246 base::ScopedCFTypeRef<IOSurfaceRef> io_surface;
248 CAContextID ca_context_id = 0; 247 CAContextID ca_context_id = params.ca_context_id;
249 248
250 switch (ui::GetSurfaceHandleType(params.surface_handle)) { 249 DCHECK((params.ca_context_id == 0) ^
251 case ui::kSurfaceHandleTypeIOSurface: { 250 (params.io_surface.get() == MACH_PORT_NULL));
252 IOSurfaceID io_surface_id = 251 if (params.io_surface.get()) {
253 ui::IOSurfaceIDFromSurfaceHandle(params.surface_handle); 252 io_surface.reset(IOSurfaceLookupFromMachPort(params.io_surface));
254 io_surface.reset(
255 BrowserIOSurfaceManager::GetInstance()->AcquireIOSurface(
256 gfx::GenericSharedMemoryId(io_surface_id)));
257 break;
258 }
259 case ui::kSurfaceHandleTypeCAContext: {
260 ca_context_id = ui::CAContextIDFromSurfaceHandle(params.surface_handle);
261 break;
262 }
263 default:
264 DLOG(ERROR) << "Unrecognized accelerated frame type.";
265 return;
266 } 253 }
267 254
268 ui::AcceleratedWidgetMacGotFrame(native_widget, ca_context_id, io_surface, 255 ui::AcceleratedWidgetMacGotFrame(native_widget, ca_context_id, io_surface,
269 params.size, params.scale_factor, 256 params.size, params.scale_factor,
270 &ack_params.vsync_timebase, 257 &ack_params.vsync_timebase,
271 &ack_params.vsync_interval); 258 &ack_params.vsync_interval);
272 } 259 }
273 260
274 content::ImageTransportFactory::GetInstance()->OnGpuSwapBuffersCompleted( 261 content::ImageTransportFactory::GetInstance()->OnGpuSwapBuffersCompleted(
275 params.surface_id, params.latency_info, gfx::SwapResult::SWAP_ACK); 262 params.surface_id, params.latency_info, gfx::SwapResult::SWAP_ACK);
(...skipping 18 matching lines...) Expand all
294 281
295 void GpuProcessHostUIShim::OnRemoveSubscription( 282 void GpuProcessHostUIShim::OnRemoveSubscription(
296 int32 process_id, unsigned int target) { 283 int32 process_id, unsigned int target) {
297 RenderProcessHost* rph = RenderProcessHost::FromID(process_id); 284 RenderProcessHost* rph = RenderProcessHost::FromID(process_id);
298 if (rph) { 285 if (rph) {
299 rph->OnRemoveSubscription(target); 286 rph->OnRemoveSubscription(target);
300 } 287 }
301 } 288 }
302 289
303 } // namespace content 290 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698