| 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 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 bool SupportsPostSubBuffer() override; | 39 bool SupportsPostSubBuffer() override; |
| 40 gfx::Size GetSize() override; | 40 gfx::Size GetSize() override; |
| 41 void* GetHandle() override; | 41 void* GetHandle() override; |
| 42 bool OnMakeCurrent(gfx::GLContext* context) override; | 42 bool OnMakeCurrent(gfx::GLContext* context) override; |
| 43 bool SetBackbufferAllocation(bool allocated) override; | 43 bool SetBackbufferAllocation(bool allocated) override; |
| 44 bool ScheduleOverlayPlane(int z_order, | 44 bool ScheduleOverlayPlane(int z_order, |
| 45 gfx::OverlayTransform transform, | 45 gfx::OverlayTransform transform, |
| 46 gl::GLImage* image, | 46 gl::GLImage* image, |
| 47 const gfx::Rect& bounds_rect, | 47 const gfx::Rect& bounds_rect, |
| 48 const gfx::RectF& crop_rect) override; | 48 const gfx::RectF& crop_rect) override; |
| 49 bool ScheduleCALayer(gl::GLImage* contents_image, |
| 50 const gfx::RectF& contents_rect, |
| 51 float opacity, |
| 52 unsigned background_color, |
| 53 const gfx::SizeF& bounds_size, |
| 54 const gfx::Transform& transform) override; |
| 49 bool IsSurfaceless() const override; | 55 bool IsSurfaceless() const override; |
| 50 | 56 |
| 51 // ImageTransportSurface implementation | 57 // ImageTransportSurface implementation |
| 52 void OnBufferPresented( | 58 void OnBufferPresented( |
| 53 const AcceleratedSurfaceMsg_BufferPresented_Params& params) override; | 59 const AcceleratedSurfaceMsg_BufferPresented_Params& params) override; |
| 54 void SetLatencyInfo(const std::vector<ui::LatencyInfo>&) override; | 60 void SetLatencyInfo(const std::vector<ui::LatencyInfo>&) override; |
| 55 | 61 |
| 56 // ui::GpuSwitchingObserver implementation. | 62 // ui::GpuSwitchingObserver implementation. |
| 57 void OnGpuSwitched() override; | 63 void OnGpuSwitched() override; |
| 58 | 64 |
| 59 private: | 65 private: |
| 60 class PendingSwap; | 66 class PendingSwap; |
| 61 class OverlayPlane; | 67 class OverlayPlane; |
| 62 | 68 |
| 63 ~ImageTransportSurfaceOverlayMac() override; | 69 ~ImageTransportSurfaceOverlayMac() override; |
| 64 | 70 |
| 65 gfx::SwapResult SwapBuffersInternal(const gfx::Rect& pixel_damage_rect); | 71 gfx::SwapResult SwapBuffersInternal(const gfx::Rect& pixel_damage_rect); |
| 66 | 72 |
| 67 void UpdateRootAndPartialDamagePlanes( | 73 void UpdateRootAndPartialDamagePlanes( |
| 68 const linked_ptr<OverlayPlane>& new_root_plane, | 74 const linked_ptr<OverlayPlane>& new_root_plane, |
| 69 const gfx::RectF& dip_damage_rect); | 75 const gfx::RectF& pixel_damage_rect); |
| 70 void UpdateOverlayPlanes( | 76 void UpdateOverlayPlanes( |
| 71 const std::vector<linked_ptr<OverlayPlane>>& new_overlay_planes); | 77 const std::vector<linked_ptr<OverlayPlane>>& new_overlay_planes); |
| 72 void UpdateCALayerTree(); | 78 void UpdateCALayerTree(); |
| 73 | 79 |
| 74 // Returns true if the front of |pending_swaps_| has completed, or has timed | 80 // Returns true if the front of |pending_swaps_| has completed, or has timed |
| 75 // out by |now|. | 81 // out by |now|. |
| 76 bool IsFirstPendingSwapReadyToDisplay( | 82 bool IsFirstPendingSwapReadyToDisplay( |
| 77 const base::TimeTicks& now); | 83 const base::TimeTicks& now); |
| 78 // Sets the CALayer contents to the IOSurface for the front of | 84 // Sets the CALayer contents to the IOSurface for the front of |
| 79 // |pending_swaps_|, and removes it from the queue. | 85 // |pending_swaps_|, and removes it from the queue. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 132 |
| 127 // The time of the last swap was issued. If this is more than two vsyncs, then | 133 // The time of the last swap was issued. If this is more than two vsyncs, then |
| 128 // use the simpler non-smooth animation path. | 134 // use the simpler non-smooth animation path. |
| 129 base::TimeTicks last_swap_time_; | 135 base::TimeTicks last_swap_time_; |
| 130 | 136 |
| 131 // The vsync information provided by the browser. | 137 // The vsync information provided by the browser. |
| 132 bool vsync_parameters_valid_; | 138 bool vsync_parameters_valid_; |
| 133 base::TimeTicks vsync_timebase_; | 139 base::TimeTicks vsync_timebase_; |
| 134 base::TimeDelta vsync_interval_; | 140 base::TimeDelta vsync_interval_; |
| 135 | 141 |
| 142 // Calls to ScheduleCALayer come in back-to-front. This is reset to 1 at each |
| 143 // swap and increments with each call to ScheduleCALayer. |
| 144 int next_ca_layer_z_order_; |
| 145 |
| 136 base::Timer display_pending_swap_timer_; | 146 base::Timer display_pending_swap_timer_; |
| 137 base::WeakPtrFactory<ImageTransportSurfaceOverlayMac> weak_factory_; | 147 base::WeakPtrFactory<ImageTransportSurfaceOverlayMac> weak_factory_; |
| 138 }; | 148 }; |
| 139 | 149 |
| 140 } // namespace content | 150 } // namespace content |
| 141 | 151 |
| 142 #endif // CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_OVERLAY_MAC_H_ | 152 #endif // CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_OVERLAY_MAC_H_ |
| OLD | NEW |