OLD | NEW |
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" | |
27 #include "content/common/gpu/ca_layer_partial_damage_tree_mac.h" | 25 #include "content/common/gpu/ca_layer_partial_damage_tree_mac.h" |
28 #include "content/common/gpu/ca_layer_tree_mac.h" | 26 #include "content/common/gpu/ca_layer_tree_mac.h" |
| 27 #include "content/common/gpu/gpu_messages.h" |
29 #include "ui/accelerated_widget_mac/io_surface_context.h" | 28 #include "ui/accelerated_widget_mac/io_surface_context.h" |
30 #include "ui/base/cocoa/animation_utils.h" | 29 #include "ui/base/cocoa/animation_utils.h" |
31 #include "ui/base/cocoa/remote_layer_api.h" | 30 #include "ui/base/cocoa/remote_layer_api.h" |
32 #include "ui/gfx/geometry/rect_conversions.h" | 31 #include "ui/gfx/geometry/rect_conversions.h" |
33 #include "ui/gfx/transform.h" | 32 #include "ui/gfx/transform.h" |
34 #include "ui/gl/gl_context.h" | 33 #include "ui/gl/gl_context.h" |
35 #include "ui/gl/gl_fence.h" | 34 #include "ui/gl/gl_fence.h" |
36 #include "ui/gl/gl_image_io_surface.h" | 35 #include "ui/gl/gl_image_io_surface.h" |
37 #include "ui/gl/gpu_switching_manager.h" | 36 #include "ui/gl/gpu_switching_manager.h" |
38 #include "ui/gl/scoped_api.h" | 37 #include "ui/gl/scoped_api.h" |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 base::TimeTicks swap_time = base::TimeTicks::Now(); | 302 base::TimeTicks swap_time = base::TimeTicks::Now(); |
304 for (auto latency_info : swap->latency_info) { | 303 for (auto latency_info : swap->latency_info) { |
305 latency_info.AddLatencyNumberWithTimestamp( | 304 latency_info.AddLatencyNumberWithTimestamp( |
306 ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, 0, swap_time, 1); | 305 ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, 0, swap_time, 1); |
307 latency_info.AddLatencyNumberWithTimestamp( | 306 latency_info.AddLatencyNumberWithTimestamp( |
308 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0, | 307 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0, |
309 swap_time, 1); | 308 swap_time, 1); |
310 } | 309 } |
311 | 310 |
312 // Send acknowledgement to the browser. | 311 // Send acknowledgement to the browser. |
313 AcceleratedSurfaceBuffersSwappedParams params; | 312 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; |
314 if (use_remote_layer_api_) { | 313 if (use_remote_layer_api_) { |
315 params.ca_context_id = [ca_context_ contextId]; | 314 params.ca_context_id = [ca_context_ contextId]; |
316 } else if (current_partial_damage_tree_) { | 315 } else if (current_partial_damage_tree_) { |
317 params.io_surface.reset(IOSurfaceCreateMachPort( | 316 params.io_surface.reset(IOSurfaceCreateMachPort( |
318 current_partial_damage_tree_->RootLayerIOSurface())); | 317 current_partial_damage_tree_->RootLayerIOSurface())); |
319 } | 318 } |
320 params.size = swap->pixel_size; | 319 params.size = swap->pixel_size; |
321 params.scale_factor = swap->scale_factor; | 320 params.scale_factor = swap->scale_factor; |
322 params.latency_info.swap(swap->latency_info); | 321 params.latency_info.swap(swap->latency_info); |
323 helper_->SendAcceleratedSurfaceBuffersSwapped(params); | 322 helper_->SendAcceleratedSurfaceBuffersSwapped(params); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 return pending_ca_layer_tree_->ScheduleCALayer( | 447 return pending_ca_layer_tree_->ScheduleCALayer( |
449 is_clipped, gfx::ToEnclosingRect(clip_rect), sorting_context_id, | 448 is_clipped, gfx::ToEnclosingRect(clip_rect), sorting_context_id, |
450 transform, io_surface, contents_rect, gfx::ToEnclosingRect(rect), | 449 transform, io_surface, contents_rect, gfx::ToEnclosingRect(rect), |
451 background_color, edge_aa_mask, opacity); | 450 background_color, edge_aa_mask, opacity); |
452 } | 451 } |
453 | 452 |
454 bool ImageTransportSurfaceOverlayMac::IsSurfaceless() const { | 453 bool ImageTransportSurfaceOverlayMac::IsSurfaceless() const { |
455 return true; | 454 return true; |
456 } | 455 } |
457 | 456 |
458 void ImageTransportSurfaceOverlayMac::BufferPresented( | 457 void ImageTransportSurfaceOverlayMac::OnBufferPresented( |
459 const BufferPresentedParams& params) { | 458 const AcceleratedSurfaceMsg_BufferPresented_Params& params) { |
460 vsync_timebase_ = params.vsync_timebase; | 459 vsync_timebase_ = params.vsync_timebase; |
461 vsync_interval_ = params.vsync_interval; | 460 vsync_interval_ = params.vsync_interval; |
462 vsync_parameters_valid_ = (vsync_interval_ != base::TimeDelta()); | 461 vsync_parameters_valid_ = (vsync_interval_ != base::TimeDelta()); |
463 | 462 |
464 // Compute |vsync_timebase_| to be the first vsync after time zero. | 463 // Compute |vsync_timebase_| to be the first vsync after time zero. |
465 if (vsync_parameters_valid_) { | 464 if (vsync_parameters_valid_) { |
466 vsync_timebase_ -= | 465 vsync_timebase_ -= |
467 vsync_interval_ * | 466 vsync_interval_ * |
468 ((vsync_timebase_ - base::TimeTicks()) / vsync_interval_); | 467 ((vsync_timebase_ - base::TimeTicks()) / vsync_interval_); |
469 } | 468 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 // Compute the previous vsync time. | 514 // Compute the previous vsync time. |
516 base::TimeTicks previous_vsync = | 515 base::TimeTicks previous_vsync = |
517 vsync_interval_ * ((from - vsync_timebase_) / vsync_interval_) + | 516 vsync_interval_ * ((from - vsync_timebase_) / vsync_interval_) + |
518 vsync_timebase_; | 517 vsync_timebase_; |
519 | 518 |
520 // Return |interval_fraction| through the next vsync. | 519 // Return |interval_fraction| through the next vsync. |
521 return previous_vsync + (1 + interval_fraction) * vsync_interval_; | 520 return previous_vsync + (1 + interval_fraction) * vsync_interval_; |
522 } | 521 } |
523 | 522 |
524 } // namespace content | 523 } // namespace content |
OLD | NEW |