| 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 "gpu/ipc/service/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/bind.h" | 23 #include "base/bind.h" |
| 24 #include "base/bind_helpers.h" | 24 #include "base/bind_helpers.h" |
| 25 #include "base/mac/scoped_cftyperef.h" | 25 #include "base/mac/scoped_cftyperef.h" |
| 26 #include "base/trace_event/trace_event.h" | 26 #include "base/trace_event/trace_event.h" |
| 27 #include "content/common/gpu/ca_layer_partial_damage_tree_mac.h" | 27 #include "gpu/ipc/service/ca_layer_partial_damage_tree_mac.h" |
| 28 #include "content/common/gpu/ca_layer_tree_mac.h" | 28 #include "gpu/ipc/service/ca_layer_tree_mac.h" |
| 29 #include "content/common/gpu/gpu_channel_manager.h" | 29 #include "gpu/ipc/service/gpu_channel_manager.h" |
| 30 #include "content/common/gpu/gpu_channel_manager_delegate.h" | 30 #include "gpu/ipc/service/gpu_channel_manager_delegate.h" |
| 31 #include "ui/accelerated_widget_mac/io_surface_context.h" | 31 #include "ui/accelerated_widget_mac/io_surface_context.h" |
| 32 #include "ui/base/cocoa/animation_utils.h" | 32 #include "ui/base/cocoa/animation_utils.h" |
| 33 #include "ui/base/cocoa/remote_layer_api.h" | 33 #include "ui/base/cocoa/remote_layer_api.h" |
| 34 #include "ui/gfx/geometry/rect_conversions.h" | 34 #include "ui/gfx/geometry/rect_conversions.h" |
| 35 #include "ui/gfx/transform.h" | 35 #include "ui/gfx/transform.h" |
| 36 #include "ui/gl/gl_context.h" | 36 #include "ui/gl/gl_context.h" |
| 37 #include "ui/gl/gl_fence.h" | 37 #include "ui/gl/gl_fence.h" |
| 38 #include "ui/gl/gl_image_io_surface.h" | 38 #include "ui/gl/gl_image_io_surface.h" |
| 39 #include "ui/gl/gpu_switching_manager.h" | 39 #include "ui/gl/gpu_switching_manager.h" |
| 40 #include "ui/gl/scoped_api.h" | 40 #include "ui/gl/scoped_api.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 70 | 70 |
| 71 void IOSurfaceContextNoOp(scoped_refptr<ui::IOSurfaceContext>) { | 71 void IOSurfaceContextNoOp(scoped_refptr<ui::IOSurfaceContext>) { |
| 72 } | 72 } |
| 73 | 73 |
| 74 } // namespace | 74 } // namespace |
| 75 | 75 |
| 76 @interface CALayer(Private) | 76 @interface CALayer(Private) |
| 77 -(void)setContentsChanged; | 77 -(void)setContentsChanged; |
| 78 @end | 78 @end |
| 79 | 79 |
| 80 namespace content { | 80 namespace gpu { |
| 81 | 81 |
| 82 scoped_refptr<gfx::GLSurface> ImageTransportSurfaceCreateNativeSurface( | 82 scoped_refptr<gfx::GLSurface> ImageTransportSurfaceCreateNativeSurface( |
| 83 GpuChannelManager* manager, | 83 GpuChannelManager* manager, |
| 84 GpuCommandBufferStub* stub, | 84 GpuCommandBufferStub* stub, |
| 85 gpu::SurfaceHandle handle) { | 85 SurfaceHandle handle) { |
| 86 return new ImageTransportSurfaceOverlayMac(manager, stub, handle); | 86 return new ImageTransportSurfaceOverlayMac(manager, stub, handle); |
| 87 } | 87 } |
| 88 | 88 |
| 89 class ImageTransportSurfaceOverlayMac::PendingSwap { | 89 class ImageTransportSurfaceOverlayMac::PendingSwap { |
| 90 public: | 90 public: |
| 91 PendingSwap() {} | 91 PendingSwap() {} |
| 92 ~PendingSwap() { DCHECK(!gl_fence); } | 92 ~PendingSwap() { DCHECK(!gl_fence); } |
| 93 | 93 |
| 94 gfx::Size pixel_size; | 94 gfx::Size pixel_size; |
| 95 float scale_factor; | 95 float scale_factor; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 109 base::TimeTicks earliest_display_time_allowed; | 109 base::TimeTicks earliest_display_time_allowed; |
| 110 | 110 |
| 111 // The time that this will wake up and draw, if a following swap does not | 111 // The time that this will wake up and draw, if a following swap does not |
| 112 // cause it to draw earlier. | 112 // cause it to draw earlier. |
| 113 base::TimeTicks target_display_time; | 113 base::TimeTicks target_display_time; |
| 114 }; | 114 }; |
| 115 | 115 |
| 116 ImageTransportSurfaceOverlayMac::ImageTransportSurfaceOverlayMac( | 116 ImageTransportSurfaceOverlayMac::ImageTransportSurfaceOverlayMac( |
| 117 GpuChannelManager* manager, | 117 GpuChannelManager* manager, |
| 118 GpuCommandBufferStub* stub, | 118 GpuCommandBufferStub* stub, |
| 119 gpu::SurfaceHandle handle) | 119 SurfaceHandle handle) |
| 120 : manager_(manager), | 120 : manager_(manager), |
| 121 stub_(stub->AsWeakPtr()), | 121 stub_(stub->AsWeakPtr()), |
| 122 handle_(handle), | 122 handle_(handle), |
| 123 use_remote_layer_api_(ui::RemoteLayerAPISupported()), | 123 use_remote_layer_api_(ui::RemoteLayerAPISupported()), |
| 124 scale_factor_(1), | 124 scale_factor_(1), |
| 125 gl_renderer_id_(0), | 125 gl_renderer_id_(0), |
| 126 vsync_parameters_valid_(false), | 126 vsync_parameters_valid_(false), |
| 127 display_pending_swap_timer_(true, false), | 127 display_pending_swap_timer_(true, false), |
| 128 weak_factory_(this) { | 128 weak_factory_(this) { |
| 129 manager_->AddBufferPresentedCallback( | 129 manager_->AddBufferPresentedCallback( |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 | 553 |
| 554 // Compute the previous vsync time. | 554 // Compute the previous vsync time. |
| 555 base::TimeTicks previous_vsync = | 555 base::TimeTicks previous_vsync = |
| 556 vsync_interval_ * ((from - vsync_timebase_) / vsync_interval_) + | 556 vsync_interval_ * ((from - vsync_timebase_) / vsync_interval_) + |
| 557 vsync_timebase_; | 557 vsync_timebase_; |
| 558 | 558 |
| 559 // Return |interval_fraction| through the next vsync. | 559 // Return |interval_fraction| through the next vsync. |
| 560 return previous_vsync + (1 + interval_fraction) * vsync_interval_; | 560 return previous_vsync + (1 + interval_fraction) * vsync_interval_; |
| 561 } | 561 } |
| 562 | 562 |
| 563 } // namespace content | 563 } // namespace gpu |
| OLD | NEW |