| 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 GPU_IPC_SERVICE_IMAGE_TRANSPORT_SURFACE_OVERLAY_MAC_H_ | 5 #ifndef GPU_IPC_SERVICE_IMAGE_TRANSPORT_SURFACE_OVERLAY_MAC_H_ |
| 6 #define GPU_IPC_SERVICE_IMAGE_TRANSPORT_SURFACE_OVERLAY_MAC_H_ | 6 #define GPU_IPC_SERVICE_IMAGE_TRANSPORT_SURFACE_OVERLAY_MAC_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 bool Resize(const gfx::Size& size, | 38 bool Resize(const gfx::Size& size, |
| 39 float scale_factor, | 39 float scale_factor, |
| 40 bool has_alpha) override; | 40 bool has_alpha) override; |
| 41 bool IsOffscreen() override; | 41 bool IsOffscreen() override; |
| 42 gfx::SwapResult SwapBuffers() override; | 42 gfx::SwapResult SwapBuffers() override; |
| 43 gfx::SwapResult PostSubBuffer(int x, int y, int width, int height) override; | 43 gfx::SwapResult PostSubBuffer(int x, int y, int width, int height) override; |
| 44 bool SupportsPostSubBuffer() override; | 44 bool SupportsPostSubBuffer() override; |
| 45 gfx::Size GetSize() override; | 45 gfx::Size GetSize() override; |
| 46 void* GetHandle() override; | 46 void* GetHandle() override; |
| 47 bool OnMakeCurrent(gfx::GLContext* context) override; | 47 bool OnMakeCurrent(gfx::GLContext* context) override; |
| 48 bool SetBackbufferAllocation(bool allocated) override; | |
| 49 bool ScheduleOverlayPlane(int z_order, | 48 bool ScheduleOverlayPlane(int z_order, |
| 50 gfx::OverlayTransform transform, | 49 gfx::OverlayTransform transform, |
| 51 gl::GLImage* image, | 50 gl::GLImage* image, |
| 52 const gfx::Rect& bounds_rect, | 51 const gfx::Rect& bounds_rect, |
| 53 const gfx::RectF& crop_rect) override; | 52 const gfx::RectF& crop_rect) override; |
| 54 bool ScheduleCALayer(gl::GLImage* contents_image, | 53 bool ScheduleCALayer(gl::GLImage* contents_image, |
| 55 const gfx::RectF& contents_rect, | 54 const gfx::RectF& contents_rect, |
| 56 float opacity, | 55 float opacity, |
| 57 unsigned background_color, | 56 unsigned background_color, |
| 58 unsigned edge_aa_mask, | 57 unsigned edge_aa_mask, |
| 59 const gfx::RectF& rect, | 58 const gfx::RectF& rect, |
| 60 bool is_clipped, | 59 bool is_clipped, |
| 61 const gfx::RectF& clip_rect, | 60 const gfx::RectF& clip_rect, |
| 62 const gfx::Transform& transform, | 61 const gfx::Transform& transform, |
| 63 int sorting_context_id) override; | 62 int sorting_context_id) override; |
| 64 bool IsSurfaceless() const override; | 63 bool IsSurfaceless() const override; |
| 65 | 64 |
| 66 // ui::GpuSwitchingObserver implementation. | 65 // ui::GpuSwitchingObserver implementation. |
| 67 void OnGpuSwitched() override; | 66 void OnGpuSwitched() override; |
| 68 | 67 |
| 69 private: | 68 private: |
| 70 class PendingSwap; | |
| 71 class OverlayPlane; | |
| 72 | |
| 73 ~ImageTransportSurfaceOverlayMac() override; | 69 ~ImageTransportSurfaceOverlayMac() override; |
| 74 | 70 |
| 75 void SetLatencyInfo(const std::vector<ui::LatencyInfo>& latency_info); | 71 void SetLatencyInfo(const std::vector<ui::LatencyInfo>& latency_info); |
| 76 void BufferPresented(int32_t surface_id, | 72 void BufferPresented(int32_t surface_id, |
| 77 const base::TimeTicks& vsync_timebase, | 73 const base::TimeTicks& vsync_timebase, |
| 78 const base::TimeDelta& vsync_interval); | 74 const base::TimeDelta& vsync_interval); |
| 79 void SendAcceleratedSurfaceBuffersSwapped( | 75 void SendAcceleratedSurfaceBuffersSwapped( |
| 80 int32_t surface_id, | 76 int32_t surface_id, |
| 81 CAContextID ca_context_id, | 77 CAContextID ca_context_id, |
| 82 const gfx::ScopedRefCountedIOSurfaceMachPort& io_surface, | 78 const gfx::ScopedRefCountedIOSurfaceMachPort& io_surface, |
| 83 const gfx::Size& size, | 79 const gfx::Size& size, |
| 84 float scale_factor, | 80 float scale_factor, |
| 85 std::vector<ui::LatencyInfo> latency_info); | 81 std::vector<ui::LatencyInfo> latency_info); |
| 86 gfx::SwapResult SwapBuffersInternal(const gfx::Rect& pixel_damage_rect); | 82 gfx::SwapResult SwapBuffersInternal(const gfx::Rect& pixel_damage_rect); |
| 87 | 83 |
| 88 // Returns true if the front of |pending_swaps_| has completed, or has timed | |
| 89 // out by |now|. | |
| 90 bool IsFirstPendingSwapReadyToDisplay( | |
| 91 const base::TimeTicks& now); | |
| 92 // Sets the CALayer contents to the IOSurface for the front of | |
| 93 // |pending_swaps_|, and removes it from the queue. | |
| 94 void DisplayFirstPendingSwapImmediately(); | |
| 95 // Force that all of |pending_swaps_| displayed immediately, and the list be | |
| 96 // cleared. | |
| 97 void DisplayAndClearAllPendingSwaps(); | |
| 98 // Callback issued during the next vsync period ofter a SwapBuffers call, | |
| 99 // to check if the swap is completed, and display the frame. Note that if | |
| 100 // another SwapBuffers happens before this callback, the pending swap will | |
| 101 // be tested at that time, too. | |
| 102 void CheckPendingSwapsCallback(); | |
| 103 // Function to post the above callback. The argument |now| is passed as an | |
| 104 // argument to avoid redundant calls to base::TimeTicks::Now. | |
| 105 void PostCheckPendingSwapsCallbackIfNeeded(const base::TimeTicks& now); | |
| 106 | |
| 107 // Return the time of |interval_fraction| of the way through the next | |
| 108 // vsync period that starts after |from|. If the vsync parameters are not | |
| 109 // valid then return |from|. | |
| 110 base::TimeTicks GetNextVSyncTimeAfter( | |
| 111 const base::TimeTicks& from, double interval_fraction); | |
| 112 | |
| 113 GpuChannelManager* manager_; | 84 GpuChannelManager* manager_; |
| 114 base::WeakPtr<GpuCommandBufferStub> stub_; | 85 base::WeakPtr<GpuCommandBufferStub> stub_; |
| 115 SurfaceHandle handle_; | 86 SurfaceHandle handle_; |
| 116 std::vector<ui::LatencyInfo> latency_info_; | 87 std::vector<ui::LatencyInfo> latency_info_; |
| 117 | 88 |
| 118 bool use_remote_layer_api_; | 89 bool use_remote_layer_api_; |
| 119 base::scoped_nsobject<CAContext> ca_context_; | 90 base::scoped_nsobject<CAContext> ca_context_; |
| 120 base::scoped_nsobject<CALayer> ca_root_layer_; | 91 base::scoped_nsobject<CALayer> ca_root_layer_; |
| 121 | 92 |
| 122 gfx::Size pixel_size_; | 93 gfx::Size pixel_size_; |
| 123 float scale_factor_; | 94 float scale_factor_; |
| 124 | 95 |
| 125 // The renderer ID that all contexts made current to this surface should be | 96 // The renderer ID that all contexts made current to this surface should be |
| 126 // targeting. | 97 // targeting. |
| 127 GLint gl_renderer_id_; | 98 GLint gl_renderer_id_; |
| 128 | 99 |
| 129 // Planes that have been scheduled, but have not had a subsequent SwapBuffers | 100 // Planes that have been scheduled, but have not had a subsequent SwapBuffers |
| 130 // call made yet. | 101 // call made yet. |
| 131 scoped_ptr<CALayerPartialDamageTree> pending_partial_damage_tree_; | 102 scoped_ptr<CALayerPartialDamageTree> pending_partial_damage_tree_; |
| 132 scoped_ptr<CALayerTree> pending_ca_layer_tree_; | 103 scoped_ptr<CALayerTree> pending_ca_layer_tree_; |
| 133 | 104 |
| 134 // A queue of all frames that have been created by SwapBuffersInternal but | |
| 135 // have not yet been displayed. This queue is checked at the beginning of | |
| 136 // every swap and also by a callback. | |
| 137 std::deque<linked_ptr<PendingSwap>> pending_swaps_; | |
| 138 | |
| 139 // The planes that are currently being displayed on the screen. | 105 // The planes that are currently being displayed on the screen. |
| 140 scoped_ptr<CALayerPartialDamageTree> current_partial_damage_tree_; | 106 scoped_ptr<CALayerPartialDamageTree> current_partial_damage_tree_; |
| 141 scoped_ptr<CALayerTree> current_ca_layer_tree_; | 107 scoped_ptr<CALayerTree> current_ca_layer_tree_; |
| 142 | 108 |
| 143 // The time of the last swap was issued. If this is more than two vsyncs, then | |
| 144 // use the simpler non-smooth animation path. | |
| 145 base::TimeTicks last_swap_time_; | |
| 146 | |
| 147 // The vsync information provided by the browser. | 109 // The vsync information provided by the browser. |
| 148 bool vsync_parameters_valid_; | 110 bool vsync_parameters_valid_; |
| 149 base::TimeTicks vsync_timebase_; | 111 base::TimeTicks vsync_timebase_; |
| 150 base::TimeDelta vsync_interval_; | 112 base::TimeDelta vsync_interval_; |
| 151 | |
| 152 base::Timer display_pending_swap_timer_; | |
| 153 base::WeakPtrFactory<ImageTransportSurfaceOverlayMac> weak_factory_; | |
| 154 }; | 113 }; |
| 155 | 114 |
| 156 } // namespace gpu | 115 } // namespace gpu |
| 157 | 116 |
| 158 #endif // GPU_IPC_SERVICE_IMAGE_TRANSPORT_SURFACE_OVERLAY_MAC_H_ | 117 #endif // GPU_IPC_SERVICE_IMAGE_TRANSPORT_SURFACE_OVERLAY_MAC_H_ |
| OLD | NEW |