| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CC_SURFACES_SURFACE_H_ | 5 #ifndef CC_SURFACES_SURFACE_H_ |
| 6 #define CC_SURFACES_SURFACE_H_ | 6 #define CC_SURFACES_SURFACE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <map> | 11 #include <map> |
| 12 #include <memory> | 12 #include <memory> |
| 13 #include <set> | 13 #include <set> |
| 14 #include <unordered_set> | 14 #include <unordered_set> |
| 15 #include <vector> | 15 #include <vector> |
| 16 | 16 |
| 17 #include "base/callback.h" | 17 #include "base/callback.h" |
| 18 #include "base/macros.h" | 18 #include "base/macros.h" |
| 19 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
| 20 #include "base/optional.h" | 20 #include "base/optional.h" |
| 21 #include "cc/output/copy_output_request.h" | 21 #include "cc/output/copy_output_request.h" |
| 22 #include "cc/surfaces/compositor_frame_sink_support.h" | 22 #include "cc/surfaces/compositor_frame_sink_support.h" |
| 23 #include "cc/surfaces/frame_sink_id.h" | 23 #include "cc/surfaces/frame_sink_id.h" |
| 24 #include "cc/surfaces/surface_id.h" | 24 #include "cc/surfaces/surface_info.h" |
| 25 #include "cc/surfaces/surface_sequence.h" | 25 #include "cc/surfaces/surface_sequence.h" |
| 26 #include "cc/surfaces/surfaces_export.h" | 26 #include "cc/surfaces/surfaces_export.h" |
| 27 #include "ui/gfx/geometry/size.h" | 27 #include "ui/gfx/geometry/size.h" |
| 28 | 28 |
| 29 namespace ui { | 29 namespace ui { |
| 30 class LatencyInfo; | 30 class LatencyInfo; |
| 31 } | 31 } |
| 32 | 32 |
| 33 namespace cc { | 33 namespace cc { |
| 34 | 34 |
| 35 class CompositorFrame; | 35 class CompositorFrame; |
| 36 class CopyOutputRequest; | 36 class CopyOutputRequest; |
| 37 | 37 |
| 38 class CC_SURFACES_EXPORT Surface { | 38 class CC_SURFACES_EXPORT Surface { |
| 39 public: | 39 public: |
| 40 using WillDrawCallback = | 40 using WillDrawCallback = |
| 41 base::RepeatingCallback<void(const LocalSurfaceId&, const gfx::Rect&)>; | 41 base::RepeatingCallback<void(const LocalSurfaceId&, const gfx::Rect&)>; |
| 42 | 42 |
| 43 Surface( | 43 Surface( |
| 44 const SurfaceId& id, | 44 const SurfaceInfo& surface_info, |
| 45 base::WeakPtr<CompositorFrameSinkSupport> compositor_frame_sink_support); | 45 base::WeakPtr<CompositorFrameSinkSupport> compositor_frame_sink_support); |
| 46 ~Surface(); | 46 ~Surface(); |
| 47 | 47 |
| 48 const SurfaceId& surface_id() const { return surface_id_; } | 48 const SurfaceId& surface_id() const { return surface_info_.id(); } |
| 49 const SurfaceId& previous_frame_surface_id() const { | 49 const SurfaceId& previous_frame_surface_id() const { |
| 50 return previous_frame_surface_id_; | 50 return previous_frame_surface_id_; |
| 51 } | 51 } |
| 52 | 52 |
| 53 void SetPreviousFrameSurface(Surface* surface); | 53 void SetPreviousFrameSurface(Surface* surface); |
| 54 | 54 |
| 55 // Returns false if |frame| is invalid. |
| 55 // |draw_callback| is called once to notify the client that the previously | 56 // |draw_callback| is called once to notify the client that the previously |
| 56 // submitted CompositorFrame is processed and that another frame can be | 57 // submitted CompositorFrame is processed and that another frame can be |
| 57 // submitted. | 58 // submitted. |
| 58 // |will_draw_callback| is called when |surface| is scheduled for a draw and | 59 // |will_draw_callback| is called when |surface| is scheduled for a draw and |
| 59 // there is visible damage. | 60 // there is visible damage. |
| 60 void QueueFrame(CompositorFrame frame, | 61 bool QueueFrame(CompositorFrame frame, |
| 61 const base::Closure& draw_callback, | 62 const base::Closure& draw_callback, |
| 62 const WillDrawCallback& will_draw_callback); | 63 const WillDrawCallback& will_draw_callback); |
| 63 void RequestCopyOfOutput(std::unique_ptr<CopyOutputRequest> copy_request); | 64 void RequestCopyOfOutput(std::unique_ptr<CopyOutputRequest> copy_request); |
| 64 | 65 |
| 65 // Notifies the Surface that a blocking SurfaceId now has an active frame. | 66 // Notifies the Surface that a blocking SurfaceId now has an active frame. |
| 66 void NotifySurfaceIdAvailable(const SurfaceId& surface_id); | 67 void NotifySurfaceIdAvailable(const SurfaceId& surface_id); |
| 67 | 68 |
| 68 // Called if a deadline has been hit and this surface is not yet active but | 69 // Called if a deadline has been hit and this surface is not yet active but |
| 69 // it's marked as respecting deadlines. | 70 // it's marked as respecting deadlines. |
| 70 void ActivatePendingFrameForDeadline(); | 71 void ActivatePendingFrameForDeadline(); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 void UnrefFrameResourcesAndRunDrawCallback( | 150 void UnrefFrameResourcesAndRunDrawCallback( |
| 150 base::Optional<FrameData> frame_data); | 151 base::Optional<FrameData> frame_data); |
| 151 void ClearCopyRequests(); | 152 void ClearCopyRequests(); |
| 152 | 153 |
| 153 void TakeLatencyInfoFromPendingFrame( | 154 void TakeLatencyInfoFromPendingFrame( |
| 154 std::vector<ui::LatencyInfo>* latency_info); | 155 std::vector<ui::LatencyInfo>* latency_info); |
| 155 static void TakeLatencyInfoFromFrame( | 156 static void TakeLatencyInfoFromFrame( |
| 156 CompositorFrame* frame, | 157 CompositorFrame* frame, |
| 157 std::vector<ui::LatencyInfo>* latency_info); | 158 std::vector<ui::LatencyInfo>* latency_info); |
| 158 | 159 |
| 159 const SurfaceId surface_id_; | 160 SurfaceInfo surface_info_; |
| 160 SurfaceId previous_frame_surface_id_; | 161 SurfaceId previous_frame_surface_id_; |
| 161 base::WeakPtr<CompositorFrameSinkSupport> compositor_frame_sink_support_; | 162 base::WeakPtr<CompositorFrameSinkSupport> compositor_frame_sink_support_; |
| 162 SurfaceManager* const surface_manager_; | 163 SurfaceManager* const surface_manager_; |
| 163 | 164 |
| 164 base::Optional<FrameData> pending_frame_data_; | 165 base::Optional<FrameData> pending_frame_data_; |
| 165 base::Optional<FrameData> active_frame_data_; | 166 base::Optional<FrameData> active_frame_data_; |
| 166 int frame_index_; | 167 int frame_index_; |
| 167 bool closed_ = false; | 168 bool closed_ = false; |
| 168 bool destroyed_; | 169 bool destroyed_; |
| 169 std::vector<SurfaceSequence> destruction_dependencies_; | 170 std::vector<SurfaceSequence> destruction_dependencies_; |
| 170 | 171 |
| 171 base::flat_set<SurfaceId> blocking_surfaces_; | 172 base::flat_set<SurfaceId> blocking_surfaces_; |
| 172 | 173 |
| 173 DISALLOW_COPY_AND_ASSIGN(Surface); | 174 DISALLOW_COPY_AND_ASSIGN(Surface); |
| 174 }; | 175 }; |
| 175 | 176 |
| 176 } // namespace cc | 177 } // namespace cc |
| 177 | 178 |
| 178 #endif // CC_SURFACES_SURFACE_H_ | 179 #endif // CC_SURFACES_SURFACE_H_ |
| OLD | NEW |