| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <CoreGraphics/CoreGraphics.h> | 8 #include <CoreGraphics/CoreGraphics.h> |
| 9 #include <IOSurface/IOSurface.h> | 9 #include <IOSurface/IOSurface.h> |
| 10 #include <OpenGL/CGLRenderers.h> | 10 #include <OpenGL/CGLRenderers.h> |
| 11 #include <OpenGL/CGLTypes.h> | 11 #include <OpenGL/CGLTypes.h> |
| 12 #include <OpenGL/gl.h> | 12 #include <OpenGL/gl.h> |
| 13 | 13 |
| 14 // This type consistently causes problem on Mac, and needs to be dealt with | 14 // This type consistently causes problem on Mac, and needs to be dealt with |
| 15 // in a systemic way. | 15 // in a systemic way. |
| 16 // http://crbug.com/517208 | 16 // http://crbug.com/517208 |
| 17 #ifndef GL_OES_EGL_image | 17 #ifndef GL_OES_EGL_image |
| 18 typedef void* GLeglImageOES; | 18 typedef void* GLeglImageOES; |
| 19 #endif | 19 #endif |
| 20 | 20 |
| 21 #include "base/command_line.h" | 21 #include "base/command_line.h" |
| 22 #include "base/mac/scoped_cftyperef.h" | 22 #include "base/mac/scoped_cftyperef.h" |
| 23 #include "content/common/gpu/gpu_messages.h" | 23 #include "content/common/gpu/gpu_messages.h" |
| 24 #include "ui/accelerated_widget_mac/io_surface_context.h" | 24 #include "ui/accelerated_widget_mac/io_surface_context.h" |
| 25 #include "ui/accelerated_widget_mac/surface_handle_types.h" | |
| 26 #include "ui/base/cocoa/animation_utils.h" | 25 #include "ui/base/cocoa/animation_utils.h" |
| 27 #include "ui/base/cocoa/remote_layer_api.h" | 26 #include "ui/base/cocoa/remote_layer_api.h" |
| 28 #include "ui/base/ui_base_switches.h" | 27 #include "ui/base/ui_base_switches.h" |
| 29 #include "ui/gfx/geometry/dip_util.h" | 28 #include "ui/gfx/geometry/dip_util.h" |
| 30 #include "ui/gfx/transform.h" | 29 #include "ui/gfx/transform.h" |
| 31 #include "ui/gl/gl_context.h" | 30 #include "ui/gl/gl_context.h" |
| 32 #include "ui/gl/gl_fence.h" | 31 #include "ui/gl/gl_fence.h" |
| 33 #include "ui/gl/gl_image_io_surface.h" | 32 #include "ui/gl/gl_image_io_surface.h" |
| 34 #include "ui/gl/gpu_switching_manager.h" | 33 #include "ui/gl/gpu_switching_manager.h" |
| 35 #include "ui/gl/scoped_api.h" | 34 #include "ui/gl/scoped_api.h" |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 latency_info.AddLatencyNumberWithTimestamp( | 449 latency_info.AddLatencyNumberWithTimestamp( |
| 451 ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, 0, swap_time, 1); | 450 ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, 0, swap_time, 1); |
| 452 latency_info.AddLatencyNumberWithTimestamp( | 451 latency_info.AddLatencyNumberWithTimestamp( |
| 453 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0, | 452 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0, |
| 454 swap_time, 1); | 453 swap_time, 1); |
| 455 } | 454 } |
| 456 | 455 |
| 457 // Send acknowledgement to the browser. | 456 // Send acknowledgement to the browser. |
| 458 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; | 457 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; |
| 459 if (use_remote_layer_api_) { | 458 if (use_remote_layer_api_) { |
| 460 params.surface_handle = | 459 params.ca_context_id = [ca_context_ contextId]; |
| 461 ui::SurfaceHandleFromCAContextID([ca_context_ contextId]); | |
| 462 } else { | 460 } else { |
| 463 params.surface_handle = | 461 params.io_surface.reset( |
| 464 ui::SurfaceHandleFromIOSurfaceID(current_root_plane_->io_surface_id); | 462 IOSurfaceCreateMachPort(current_root_plane_->io_surface)); |
| 465 } | 463 } |
| 466 params.size = swap->pixel_size; | 464 params.size = swap->pixel_size; |
| 467 params.scale_factor = swap->scale_factor; | 465 params.scale_factor = swap->scale_factor; |
| 468 params.latency_info.swap(swap->latency_info); | 466 params.latency_info.swap(swap->latency_info); |
| 469 helper_->SendAcceleratedSurfaceBuffersSwapped(params); | 467 helper_->SendAcceleratedSurfaceBuffersSwapped(params); |
| 470 | 468 |
| 471 // Remove this from the queue, and reset any callback timers. | 469 // Remove this from the queue, and reset any callback timers. |
| 472 pending_swaps_.pop_front(); | 470 pending_swaps_.pop_front(); |
| 473 } | 471 } |
| 474 | 472 |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 // Compute the previous vsync time. | 850 // Compute the previous vsync time. |
| 853 base::TimeTicks previous_vsync = | 851 base::TimeTicks previous_vsync = |
| 854 vsync_interval_ * ((from - vsync_timebase_) / vsync_interval_) + | 852 vsync_interval_ * ((from - vsync_timebase_) / vsync_interval_) + |
| 855 vsync_timebase_; | 853 vsync_timebase_; |
| 856 | 854 |
| 857 // Return |interval_fraction| through the next vsync. | 855 // Return |interval_fraction| through the next vsync. |
| 858 return previous_vsync + (1 + interval_fraction) * vsync_interval_; | 856 return previous_vsync + (1 + interval_fraction) * vsync_interval_; |
| 859 } | 857 } |
| 860 | 858 |
| 861 } // namespace content | 859 } // namespace content |
| OLD | NEW |