| 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 #ifndef CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_OVERLAY_MAC_H_ | 5 #ifndef CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_OVERLAY_MAC_H_ |
| 6 #define CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_OVERLAY_MAC_H_ | 6 #define CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_OVERLAY_MAC_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #import "base/mac/scoped_nsobject.h" | 11 #import "base/mac/scoped_nsobject.h" |
| 12 #include "base/timer/timer.h" | 12 #include "base/timer/timer.h" |
| 13 #include "content/common/gpu/gpu_command_buffer_stub.h" | 13 #include "content/common/gpu/gpu_command_buffer_stub.h" |
| 14 #include "content/common/gpu/image_transport_surface.h" | 14 #include "content/common/gpu/image_transport_surface.h" |
| 15 #include "ui/base/cocoa/remote_layer_api.h" | 15 #include "ui/base/cocoa/remote_layer_api.h" |
| 16 #include "ui/events/latency_info.h" | 16 #include "ui/events/latency_info.h" |
| 17 #include "ui/gl/gl_surface.h" | 17 #include "ui/gl/gl_surface.h" |
| 18 #include "ui/gl/gpu_switching_observer.h" | 18 #include "ui/gl/gpu_switching_observer.h" |
| 19 | 19 |
| 20 @class AVSampleBufferDisplayLayer; |
| 20 @class CAContext; | 21 @class CAContext; |
| 21 @class CALayer; | 22 @class CALayer; |
| 22 | 23 |
| 23 namespace content { | 24 namespace content { |
| 24 | 25 |
| 25 class CALayerTree; | 26 class CALayerTree; |
| 26 class CALayerPartialDamageTree; | 27 class CALayerPartialDamageTree; |
| 27 | 28 |
| 28 class ImageTransportSurfaceOverlayMac : public gfx::GLSurface, | 29 class ImageTransportSurfaceOverlayMac : public gfx::GLSurface, |
| 29 public ui::GpuSwitchingObserver { | 30 public ui::GpuSwitchingObserver { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 private: | 70 private: |
| 70 class PendingSwap; | 71 class PendingSwap; |
| 71 class OverlayPlane; | 72 class OverlayPlane; |
| 72 | 73 |
| 73 ~ImageTransportSurfaceOverlayMac() override; | 74 ~ImageTransportSurfaceOverlayMac() override; |
| 74 | 75 |
| 75 void SetLatencyInfo(const std::vector<ui::LatencyInfo>& latency_info); | 76 void SetLatencyInfo(const std::vector<ui::LatencyInfo>& latency_info); |
| 76 void BufferPresented(int32_t surface_id, | 77 void BufferPresented(int32_t surface_id, |
| 77 const base::TimeTicks& vsync_timebase, | 78 const base::TimeTicks& vsync_timebase, |
| 78 const base::TimeDelta& vsync_interval); | 79 const base::TimeDelta& vsync_interval); |
| 79 void SendAcceleratedSurfaceBuffersSwapped( | |
| 80 int32_t surface_id, | |
| 81 CAContextID ca_context_id, | |
| 82 const gfx::ScopedRefCountedIOSurfaceMachPort& io_surface, | |
| 83 const gfx::Size& size, | |
| 84 float scale_factor, | |
| 85 std::vector<ui::LatencyInfo> latency_info); | |
| 86 gfx::SwapResult SwapBuffersInternal(const gfx::Rect& pixel_damage_rect); | 80 gfx::SwapResult SwapBuffersInternal(const gfx::Rect& pixel_damage_rect); |
| 87 | 81 |
| 88 // Returns true if the front of |pending_swaps_| has completed, or has timed | 82 // Returns true if the front of |pending_swaps_| has completed, or has timed |
| 89 // out by |now|. | 83 // out by |now|. |
| 90 bool IsFirstPendingSwapReadyToDisplay( | 84 bool IsFirstPendingSwapReadyToDisplay( |
| 91 const base::TimeTicks& now); | 85 const base::TimeTicks& now); |
| 92 // Sets the CALayer contents to the IOSurface for the front of | 86 // Sets the CALayer contents to the IOSurface for the front of |
| 93 // |pending_swaps_|, and removes it from the queue. | 87 // |pending_swaps_|, and removes it from the queue. |
| 94 void DisplayFirstPendingSwapImmediately(); | 88 void DisplayFirstPendingSwapImmediately(); |
| 95 // Force that all of |pending_swaps_| displayed immediately, and the list be | 89 // Force that all of |pending_swaps_| displayed immediately, and the list be |
| (...skipping 16 matching lines...) Expand all Loading... |
| 112 | 106 |
| 113 GpuChannelManager* manager_; | 107 GpuChannelManager* manager_; |
| 114 base::WeakPtr<GpuCommandBufferStub> stub_; | 108 base::WeakPtr<GpuCommandBufferStub> stub_; |
| 115 gpu::SurfaceHandle handle_; | 109 gpu::SurfaceHandle handle_; |
| 116 std::vector<ui::LatencyInfo> latency_info_; | 110 std::vector<ui::LatencyInfo> latency_info_; |
| 117 | 111 |
| 118 bool use_remote_layer_api_; | 112 bool use_remote_layer_api_; |
| 119 base::scoped_nsobject<CAContext> ca_context_; | 113 base::scoped_nsobject<CAContext> ca_context_; |
| 120 base::scoped_nsobject<CALayer> ca_root_layer_; | 114 base::scoped_nsobject<CALayer> ca_root_layer_; |
| 121 | 115 |
| 116 base::scoped_nsobject<CAContext> detached_ca_context_; |
| 117 base::scoped_nsobject<AVSampleBufferDisplayLayer> detached_av_layer_; |
| 118 |
| 122 gfx::Size pixel_size_; | 119 gfx::Size pixel_size_; |
| 123 float scale_factor_; | 120 float scale_factor_; |
| 124 | 121 |
| 125 // The renderer ID that all contexts made current to this surface should be | 122 // The renderer ID that all contexts made current to this surface should be |
| 126 // targeting. | 123 // targeting. |
| 127 GLint gl_renderer_id_; | 124 GLint gl_renderer_id_; |
| 128 | 125 |
| 129 // Planes that have been scheduled, but have not had a subsequent SwapBuffers | 126 // Planes that have been scheduled, but have not had a subsequent SwapBuffers |
| 130 // call made yet. | 127 // call made yet. |
| 131 scoped_ptr<CALayerPartialDamageTree> pending_partial_damage_tree_; | 128 scoped_ptr<CALayerPartialDamageTree> pending_partial_damage_tree_; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 149 base::TimeTicks vsync_timebase_; | 146 base::TimeTicks vsync_timebase_; |
| 150 base::TimeDelta vsync_interval_; | 147 base::TimeDelta vsync_interval_; |
| 151 | 148 |
| 152 base::Timer display_pending_swap_timer_; | 149 base::Timer display_pending_swap_timer_; |
| 153 base::WeakPtrFactory<ImageTransportSurfaceOverlayMac> weak_factory_; | 150 base::WeakPtrFactory<ImageTransportSurfaceOverlayMac> weak_factory_; |
| 154 }; | 151 }; |
| 155 | 152 |
| 156 } // namespace content | 153 } // namespace content |
| 157 | 154 |
| 158 #endif // CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_OVERLAY_MAC_H_ | 155 #endif // CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_OVERLAY_MAC_H_ |
| OLD | NEW |