| 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_AGGREGATOR_H_ | 5 #ifndef CC_SURFACES_SURFACE_AGGREGATOR_H_ |
| 6 #define CC_SURFACES_SURFACE_AGGREGATOR_H_ | 6 #define CC_SURFACES_SURFACE_AGGREGATOR_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <unordered_map> |
| 10 #include <unordered_set> |
| 9 | 11 |
| 10 #include "base/containers/hash_tables.h" | |
| 11 #include "base/containers/scoped_ptr_hash_map.h" | |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "cc/quads/draw_quad.h" | 14 #include "cc/quads/draw_quad.h" |
| 15 #include "cc/quads/render_pass.h" | 15 #include "cc/quads/render_pass.h" |
| 16 #include "cc/resources/transferable_resource.h" | 16 #include "cc/resources/transferable_resource.h" |
| 17 #include "cc/surfaces/surface_id.h" | 17 #include "cc/surfaces/surface_id.h" |
| 18 #include "cc/surfaces/surfaces_export.h" | 18 #include "cc/surfaces/surfaces_export.h" |
| 19 | 19 |
| 20 namespace cc { | 20 namespace cc { |
| 21 | 21 |
| 22 class CompositorFrame; | 22 class CompositorFrame; |
| 23 class DelegatedFrameData; | 23 class DelegatedFrameData; |
| 24 class ResourceProvider; | 24 class ResourceProvider; |
| 25 class Surface; | 25 class Surface; |
| 26 class SurfaceDrawQuad; | 26 class SurfaceDrawQuad; |
| 27 class SurfaceManager; | 27 class SurfaceManager; |
| 28 | 28 |
| 29 class CC_SURFACES_EXPORT SurfaceAggregatorClient { | 29 class CC_SURFACES_EXPORT SurfaceAggregatorClient { |
| 30 public: | 30 public: |
| 31 virtual ~SurfaceAggregatorClient() {} | 31 virtual ~SurfaceAggregatorClient() {} |
| 32 | 32 |
| 33 virtual void AddSurface(Surface* surface) = 0; | 33 virtual void AddSurface(Surface* surface) = 0; |
| 34 virtual void RemoveSurface(Surface* surface) = 0; | 34 virtual void RemoveSurface(Surface* surface) = 0; |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 class CC_SURFACES_EXPORT SurfaceAggregator { | 37 class CC_SURFACES_EXPORT SurfaceAggregator { |
| 38 public: | 38 public: |
| 39 typedef base::hash_map<SurfaceId, int> SurfaceIndexMap; | 39 typedef std::unordered_map<SurfaceId, int, SurfaceIdHash> SurfaceIndexMap; |
| 40 | 40 |
| 41 SurfaceAggregator(SurfaceAggregatorClient* client, | 41 SurfaceAggregator(SurfaceAggregatorClient* client, |
| 42 SurfaceManager* manager, | 42 SurfaceManager* manager, |
| 43 ResourceProvider* provider, | 43 ResourceProvider* provider, |
| 44 bool aggregate_only_damaged); | 44 bool aggregate_only_damaged); |
| 45 ~SurfaceAggregator(); | 45 ~SurfaceAggregator(); |
| 46 | 46 |
| 47 scoped_ptr<CompositorFrame> Aggregate(SurfaceId surface_id); | 47 scoped_ptr<CompositorFrame> Aggregate(SurfaceId surface_id); |
| 48 void ReleaseResources(SurfaceId surface_id); | 48 void ReleaseResources(SurfaceId surface_id); |
| 49 SurfaceIndexMap& previous_contained_surfaces() { | 49 SurfaceIndexMap& previous_contained_surfaces() { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 const gfx::Transform& target_transform, | 81 const gfx::Transform& target_transform, |
| 82 const ClipData& clip_rect, | 82 const ClipData& clip_rect, |
| 83 RenderPass* dest_pass); | 83 RenderPass* dest_pass); |
| 84 SharedQuadState* CopySharedQuadState(const SharedQuadState* source_sqs, | 84 SharedQuadState* CopySharedQuadState(const SharedQuadState* source_sqs, |
| 85 const gfx::Transform& target_transform, | 85 const gfx::Transform& target_transform, |
| 86 const ClipData& clip_rect, | 86 const ClipData& clip_rect, |
| 87 RenderPass* dest_render_pass); | 87 RenderPass* dest_render_pass); |
| 88 void CopyQuadsToPass( | 88 void CopyQuadsToPass( |
| 89 const QuadList& source_quad_list, | 89 const QuadList& source_quad_list, |
| 90 const SharedQuadStateList& source_shared_quad_state_list, | 90 const SharedQuadStateList& source_shared_quad_state_list, |
| 91 const base::hash_map<ResourceId, ResourceId>& resource_to_child_map, | 91 const std::unordered_map<ResourceId, ResourceId>& resource_to_child_map, |
| 92 const gfx::Transform& target_transform, | 92 const gfx::Transform& target_transform, |
| 93 const ClipData& clip_rect, | 93 const ClipData& clip_rect, |
| 94 RenderPass* dest_pass, | 94 RenderPass* dest_pass, |
| 95 SurfaceId surface_id); | 95 SurfaceId surface_id); |
| 96 gfx::Rect PrewalkTree(SurfaceId surface_id, PrewalkResult* result); | 96 gfx::Rect PrewalkTree(SurfaceId surface_id, PrewalkResult* result); |
| 97 void CopyUndrawnSurfaces(PrewalkResult* prewalk); | 97 void CopyUndrawnSurfaces(PrewalkResult* prewalk); |
| 98 void CopyPasses(const DelegatedFrameData* frame_data, Surface* surface); | 98 void CopyPasses(const DelegatedFrameData* frame_data, Surface* surface); |
| 99 | 99 |
| 100 // Remove Surfaces that were referenced before but aren't currently | 100 // Remove Surfaces that were referenced before but aren't currently |
| 101 // referenced from the ResourceProvider. | 101 // referenced from the ResourceProvider. |
| 102 // Also notifies SurfaceAggregatorClient of newly added and removed | 102 // Also notifies SurfaceAggregatorClient of newly added and removed |
| 103 // child surfaces. | 103 // child surfaces. |
| 104 void ProcessAddedAndRemovedSurfaces(); | 104 void ProcessAddedAndRemovedSurfaces(); |
| 105 | 105 |
| 106 int ChildIdForSurface(Surface* surface); | 106 int ChildIdForSurface(Surface* surface); |
| 107 gfx::Rect DamageRectForSurface(const Surface* surface, | 107 gfx::Rect DamageRectForSurface(const Surface* surface, |
| 108 const RenderPass& source, | 108 const RenderPass& source, |
| 109 const gfx::Rect& full_rect) const; | 109 const gfx::Rect& full_rect) const; |
| 110 | 110 |
| 111 SurfaceAggregatorClient* client_; // Outlives this class. | 111 SurfaceAggregatorClient* client_; // Outlives this class. |
| 112 SurfaceManager* manager_; | 112 SurfaceManager* manager_; |
| 113 ResourceProvider* provider_; | 113 ResourceProvider* provider_; |
| 114 | 114 |
| 115 class RenderPassIdAllocator; | 115 class RenderPassIdAllocator; |
| 116 typedef base::ScopedPtrHashMap<SurfaceId, scoped_ptr<RenderPassIdAllocator>> | 116 typedef std::unordered_map<SurfaceId, |
| 117 RenderPassIdAllocatorMap; | 117 scoped_ptr<RenderPassIdAllocator>, |
| 118 SurfaceIdHash> RenderPassIdAllocatorMap; |
| 118 RenderPassIdAllocatorMap render_pass_allocator_map_; | 119 RenderPassIdAllocatorMap render_pass_allocator_map_; |
| 119 int next_render_pass_id_; | 120 int next_render_pass_id_; |
| 120 const bool aggregate_only_damaged_; | 121 const bool aggregate_only_damaged_; |
| 121 | 122 |
| 122 typedef base::hash_map<SurfaceId, int> SurfaceToResourceChildIdMap; | 123 typedef std::unordered_map<SurfaceId, int, SurfaceIdHash> |
| 124 SurfaceToResourceChildIdMap; |
| 123 SurfaceToResourceChildIdMap surface_id_to_resource_child_id_; | 125 SurfaceToResourceChildIdMap surface_id_to_resource_child_id_; |
| 124 | 126 |
| 125 // The following state is only valid for the duration of one Aggregate call | 127 // The following state is only valid for the duration of one Aggregate call |
| 126 // and is only stored on the class to avoid having to pass through every | 128 // and is only stored on the class to avoid having to pass through every |
| 127 // function call. | 129 // function call. |
| 128 | 130 |
| 129 // This is the set of surfaces referenced in the aggregation so far, used to | 131 // This is the set of surfaces referenced in the aggregation so far, used to |
| 130 // detect cycles. | 132 // detect cycles. |
| 131 typedef std::set<SurfaceId> SurfaceSet; | 133 typedef std::set<SurfaceId> SurfaceSet; |
| 132 SurfaceSet referenced_surfaces_; | 134 SurfaceSet referenced_surfaces_; |
| 133 | 135 |
| 134 // For each Surface used in the last aggregation, gives the frame_index at | 136 // For each Surface used in the last aggregation, gives the frame_index at |
| 135 // that time. | 137 // that time. |
| 136 SurfaceIndexMap previous_contained_surfaces_; | 138 SurfaceIndexMap previous_contained_surfaces_; |
| 137 SurfaceIndexMap contained_surfaces_; | 139 SurfaceIndexMap contained_surfaces_; |
| 138 | 140 |
| 139 // After surface validation, every Surface in this set is valid. | 141 // After surface validation, every Surface in this set is valid. |
| 140 base::hash_set<SurfaceId> valid_surfaces_; | 142 std::unordered_set<SurfaceId, SurfaceIdHash> valid_surfaces_; |
| 141 | 143 |
| 142 // This is the pass list for the aggregated frame. | 144 // This is the pass list for the aggregated frame. |
| 143 RenderPassList* dest_pass_list_; | 145 RenderPassList* dest_pass_list_; |
| 144 | 146 |
| 145 // The root damage rect of the currently-aggregating frame. | 147 // The root damage rect of the currently-aggregating frame. |
| 146 gfx::Rect root_damage_rect_; | 148 gfx::Rect root_damage_rect_; |
| 147 | 149 |
| 148 // True if the frame that's currently being aggregated has copy requests. | 150 // True if the frame that's currently being aggregated has copy requests. |
| 149 // This is valid during Aggregate after PrewalkTree is called. | 151 // This is valid during Aggregate after PrewalkTree is called. |
| 150 bool has_copy_requests_; | 152 bool has_copy_requests_; |
| 151 | 153 |
| 152 // Resource list for the aggregated frame. | 154 // Resource list for the aggregated frame. |
| 153 TransferableResourceArray* dest_resource_list_; | 155 TransferableResourceArray* dest_resource_list_; |
| 154 | 156 |
| 155 DISALLOW_COPY_AND_ASSIGN(SurfaceAggregator); | 157 DISALLOW_COPY_AND_ASSIGN(SurfaceAggregator); |
| 156 }; | 158 }; |
| 157 | 159 |
| 158 } // namespace cc | 160 } // namespace cc |
| 159 | 161 |
| 160 #endif // CC_SURFACES_SURFACE_AGGREGATOR_H_ | 162 #endif // CC_SURFACES_SURFACE_AGGREGATOR_H_ |
| OLD | NEW |