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

Side by Side Diff: content/common/gpu/image_transport_surface_overlay_mac.mm

Issue 1711533002: Decouple browser-specific GPU IPC messages from GPU service IPCs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Mac Created 4 years, 10 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/common/gpu/image_transport_surface_overlay_mac.h" 5 #include "content/common/gpu/image_transport_surface_overlay_mac.h"
6 6
7 #include <CoreGraphics/CoreGraphics.h> 7 #include <CoreGraphics/CoreGraphics.h>
8 #include <IOSurface/IOSurface.h> 8 #include <IOSurface/IOSurface.h>
9 #include <OpenGL/CGLRenderers.h> 9 #include <OpenGL/CGLRenderers.h>
10 #include <OpenGL/CGLTypes.h> 10 #include <OpenGL/CGLTypes.h>
11 #include <OpenGL/gl.h> 11 #include <OpenGL/gl.h>
12 #include <stddef.h> 12 #include <stddef.h>
13 13
14 #include <algorithm> 14 #include <algorithm>
15 15
16 // This type consistently causes problem on Mac, and needs to be dealt with 16 // This type consistently causes problem on Mac, and needs to be dealt with
17 // in a systemic way. 17 // in a systemic way.
18 // http://crbug.com/517208 18 // http://crbug.com/517208
19 #ifndef GL_OES_EGL_image 19 #ifndef GL_OES_EGL_image
20 typedef void* GLeglImageOES; 20 typedef void* GLeglImageOES;
21 #endif 21 #endif
22 22
23 #include "base/mac/scoped_cftyperef.h" 23 #include "base/mac/scoped_cftyperef.h"
24 #include "base/trace_event/trace_event.h" 24 #include "base/trace_event/trace_event.h"
25 #include "content/common/gpu/accelerated_surface_buffers_swapped_params_mac.h"
26 #include "content/common/gpu/buffer_presented_params_mac.h"
25 #include "content/common/gpu/ca_layer_partial_damage_tree_mac.h" 27 #include "content/common/gpu/ca_layer_partial_damage_tree_mac.h"
26 #include "content/common/gpu/ca_layer_tree_mac.h" 28 #include "content/common/gpu/ca_layer_tree_mac.h"
27 #include "content/common/gpu/gpu_messages.h" 29 #include "content/common/gpu/gpu_messages.h"
piman 2016/02/24 00:58:37 nit: Is this still needed?
Fady Samuel 2016/02/24 01:42:30 Done.
28 #include "ui/accelerated_widget_mac/io_surface_context.h" 30 #include "ui/accelerated_widget_mac/io_surface_context.h"
29 #include "ui/base/cocoa/animation_utils.h" 31 #include "ui/base/cocoa/animation_utils.h"
30 #include "ui/base/cocoa/remote_layer_api.h" 32 #include "ui/base/cocoa/remote_layer_api.h"
31 #include "ui/gfx/geometry/rect_conversions.h" 33 #include "ui/gfx/geometry/rect_conversions.h"
32 #include "ui/gfx/transform.h" 34 #include "ui/gfx/transform.h"
33 #include "ui/gl/gl_context.h" 35 #include "ui/gl/gl_context.h"
34 #include "ui/gl/gl_fence.h" 36 #include "ui/gl/gl_fence.h"
35 #include "ui/gl/gl_image_io_surface.h" 37 #include "ui/gl/gl_image_io_surface.h"
36 #include "ui/gl/gpu_switching_manager.h" 38 #include "ui/gl/gpu_switching_manager.h"
37 #include "ui/gl/scoped_api.h" 39 #include "ui/gl/scoped_api.h"
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 base::TimeTicks swap_time = base::TimeTicks::Now(); 304 base::TimeTicks swap_time = base::TimeTicks::Now();
303 for (auto latency_info : swap->latency_info) { 305 for (auto latency_info : swap->latency_info) {
304 latency_info.AddLatencyNumberWithTimestamp( 306 latency_info.AddLatencyNumberWithTimestamp(
305 ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, 0, swap_time, 1); 307 ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, 0, swap_time, 1);
306 latency_info.AddLatencyNumberWithTimestamp( 308 latency_info.AddLatencyNumberWithTimestamp(
307 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0, 309 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0,
308 swap_time, 1); 310 swap_time, 1);
309 } 311 }
310 312
311 // Send acknowledgement to the browser. 313 // Send acknowledgement to the browser.
312 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; 314 AcceleratedSurfaceBuffersSwappedParams params;
313 if (use_remote_layer_api_) { 315 if (use_remote_layer_api_) {
314 params.ca_context_id = [ca_context_ contextId]; 316 params.ca_context_id = [ca_context_ contextId];
315 } else if (current_partial_damage_tree_) { 317 } else if (current_partial_damage_tree_) {
316 params.io_surface.reset(IOSurfaceCreateMachPort( 318 params.io_surface.reset(IOSurfaceCreateMachPort(
317 current_partial_damage_tree_->RootLayerIOSurface())); 319 current_partial_damage_tree_->RootLayerIOSurface()));
318 } 320 }
319 params.size = swap->pixel_size; 321 params.size = swap->pixel_size;
320 params.scale_factor = swap->scale_factor; 322 params.scale_factor = swap->scale_factor;
321 params.latency_info.swap(swap->latency_info); 323 params.latency_info.swap(swap->latency_info);
322 helper_->SendAcceleratedSurfaceBuffersSwapped(params); 324 helper_->SendAcceleratedSurfaceBuffersSwapped(params);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 return pending_ca_layer_tree_->ScheduleCALayer( 449 return pending_ca_layer_tree_->ScheduleCALayer(
448 is_clipped, gfx::ToEnclosingRect(clip_rect), sorting_context_id, 450 is_clipped, gfx::ToEnclosingRect(clip_rect), sorting_context_id,
449 transform, io_surface, contents_rect, gfx::ToEnclosingRect(rect), 451 transform, io_surface, contents_rect, gfx::ToEnclosingRect(rect),
450 background_color, edge_aa_mask, opacity); 452 background_color, edge_aa_mask, opacity);
451 } 453 }
452 454
453 bool ImageTransportSurfaceOverlayMac::IsSurfaceless() const { 455 bool ImageTransportSurfaceOverlayMac::IsSurfaceless() const {
454 return true; 456 return true;
455 } 457 }
456 458
457 void ImageTransportSurfaceOverlayMac::OnBufferPresented( 459 void ImageTransportSurfaceOverlayMac::BufferPresented(
458 const AcceleratedSurfaceMsg_BufferPresented_Params& params) { 460 const BufferPresentedParams& params) {
459 vsync_timebase_ = params.vsync_timebase; 461 vsync_timebase_ = params.vsync_timebase;
460 vsync_interval_ = params.vsync_interval; 462 vsync_interval_ = params.vsync_interval;
461 vsync_parameters_valid_ = (vsync_interval_ != base::TimeDelta()); 463 vsync_parameters_valid_ = (vsync_interval_ != base::TimeDelta());
462 464
463 // Compute |vsync_timebase_| to be the first vsync after time zero. 465 // Compute |vsync_timebase_| to be the first vsync after time zero.
464 if (vsync_parameters_valid_) { 466 if (vsync_parameters_valid_) {
465 vsync_timebase_ -= 467 vsync_timebase_ -=
466 vsync_interval_ * 468 vsync_interval_ *
467 ((vsync_timebase_ - base::TimeTicks()) / vsync_interval_); 469 ((vsync_timebase_ - base::TimeTicks()) / vsync_interval_);
468 } 470 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 // Compute the previous vsync time. 516 // Compute the previous vsync time.
515 base::TimeTicks previous_vsync = 517 base::TimeTicks previous_vsync =
516 vsync_interval_ * ((from - vsync_timebase_) / vsync_interval_) + 518 vsync_interval_ * ((from - vsync_timebase_) / vsync_interval_) +
517 vsync_timebase_; 519 vsync_timebase_;
518 520
519 // Return |interval_fraction| through the next vsync. 521 // Return |interval_fraction| through the next vsync.
520 return previous_vsync + (1 + interval_fraction) * vsync_interval_; 522 return previous_vsync + (1 + interval_fraction) * vsync_interval_;
521 } 523 }
522 524
523 } // namespace content 525 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698