| 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 | 9 |
| 10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
| 11 #include "base/containers/scoped_ptr_hash_map.h" | 11 #include "base/containers/scoped_ptr_hash_map.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "cc/quads/draw_quad.h" | 13 #include "cc/quads/draw_quad.h" |
| 14 #include "cc/quads/render_pass.h" | 14 #include "cc/quads/render_pass.h" |
| 15 #include "cc/resources/transferable_resource.h" | 15 #include "cc/resources/transferable_resource.h" |
| 16 #include "cc/surfaces/surface_id.h" | 16 #include "cc/surfaces/surface_id.h" |
| 17 #include "cc/surfaces/surfaces_export.h" | 17 #include "cc/surfaces/surfaces_export.h" |
| 18 | 18 |
| 19 namespace cc { | 19 namespace cc { |
| 20 | 20 |
| 21 class CompositorFrame; | 21 class CompositorFrame; |
| 22 class DelegatedFrameData; | 22 class DelegatedFrameData; |
| 23 class ResourceProvider; | 23 class ResourceProvider; |
| 24 class Surface; | 24 class Surface; |
| 25 class SurfaceDrawQuad; | 25 class SurfaceDrawQuad; |
| 26 class SurfaceManager; | 26 class SurfaceManager; |
| 27 | 27 |
| 28 class CC_SURFACES_EXPORT SurfaceAggregatorClient { |
| 29 public: |
| 30 virtual ~SurfaceAggregatorClient() {} |
| 31 |
| 32 virtual void AddSurface(Surface* surface) = 0; |
| 33 virtual void RemoveSurface(Surface* surface) = 0; |
| 34 }; |
| 35 |
| 28 class CC_SURFACES_EXPORT SurfaceAggregator { | 36 class CC_SURFACES_EXPORT SurfaceAggregator { |
| 29 public: | 37 public: |
| 30 typedef base::hash_map<SurfaceId, int> SurfaceIndexMap; | 38 typedef base::hash_map<SurfaceId, int> SurfaceIndexMap; |
| 31 | 39 |
| 32 SurfaceAggregator(SurfaceManager* manager, | 40 SurfaceAggregator(SurfaceAggregatorClient* client, |
| 41 SurfaceManager* manager, |
| 33 ResourceProvider* provider, | 42 ResourceProvider* provider, |
| 34 bool aggregate_only_damaged); | 43 bool aggregate_only_damaged); |
| 35 ~SurfaceAggregator(); | 44 ~SurfaceAggregator(); |
| 36 | 45 |
| 37 scoped_ptr<CompositorFrame> Aggregate(SurfaceId surface_id); | 46 scoped_ptr<CompositorFrame> Aggregate(SurfaceId surface_id); |
| 38 void ReleaseResources(SurfaceId surface_id); | 47 void ReleaseResources(SurfaceId surface_id); |
| 39 SurfaceIndexMap& previous_contained_surfaces() { | 48 SurfaceIndexMap& previous_contained_surfaces() { |
| 40 return previous_contained_surfaces_; | 49 return previous_contained_surfaces_; |
| 41 } | 50 } |
| 42 void SetFullDamageForSurface(SurfaceId surface_id); | 51 void SetFullDamageForSurface(SurfaceId surface_id); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 72 const base::hash_map<ResourceId, ResourceId>& resource_to_child_map, | 81 const base::hash_map<ResourceId, ResourceId>& resource_to_child_map, |
| 73 const gfx::Transform& target_transform, | 82 const gfx::Transform& target_transform, |
| 74 const ClipData& clip_rect, | 83 const ClipData& clip_rect, |
| 75 RenderPass* dest_pass, | 84 RenderPass* dest_pass, |
| 76 SurfaceId surface_id); | 85 SurfaceId surface_id); |
| 77 gfx::Rect PrewalkTree(SurfaceId surface_id); | 86 gfx::Rect PrewalkTree(SurfaceId surface_id); |
| 78 void CopyPasses(const DelegatedFrameData* frame_data, Surface* surface); | 87 void CopyPasses(const DelegatedFrameData* frame_data, Surface* surface); |
| 79 | 88 |
| 80 // Remove Surfaces that were referenced before but aren't currently | 89 // Remove Surfaces that were referenced before but aren't currently |
| 81 // referenced from the ResourceProvider. | 90 // referenced from the ResourceProvider. |
| 82 void RemoveUnreferencedChildren(); | 91 // Also notifies SurfaceAggregatorClient of newly added and removed |
| 92 // child surfaces. |
| 93 void ProcessAddedAndRemovedSurfaces(); |
| 83 | 94 |
| 84 int ChildIdForSurface(Surface* surface); | 95 int ChildIdForSurface(Surface* surface); |
| 85 gfx::Rect DamageRectForSurface(const Surface* surface, | 96 gfx::Rect DamageRectForSurface(const Surface* surface, |
| 86 const RenderPass& source, | 97 const RenderPass& source, |
| 87 const gfx::Rect& full_rect); | 98 const gfx::Rect& full_rect) const; |
| 88 | 99 |
| 100 SurfaceAggregatorClient* client_; // Outlives this class. |
| 89 SurfaceManager* manager_; | 101 SurfaceManager* manager_; |
| 90 ResourceProvider* provider_; | 102 ResourceProvider* provider_; |
| 91 | 103 |
| 92 class RenderPassIdAllocator; | 104 class RenderPassIdAllocator; |
| 93 typedef base::ScopedPtrHashMap<SurfaceId, scoped_ptr<RenderPassIdAllocator>> | 105 typedef base::ScopedPtrHashMap<SurfaceId, scoped_ptr<RenderPassIdAllocator>> |
| 94 RenderPassIdAllocatorMap; | 106 RenderPassIdAllocatorMap; |
| 95 RenderPassIdAllocatorMap render_pass_allocator_map_; | 107 RenderPassIdAllocatorMap render_pass_allocator_map_; |
| 96 int next_render_pass_id_; | 108 int next_render_pass_id_; |
| 97 const bool aggregate_only_damaged_; | 109 const bool aggregate_only_damaged_; |
| 98 | 110 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 128 | 140 |
| 129 // Resource list for the aggregated frame. | 141 // Resource list for the aggregated frame. |
| 130 TransferableResourceArray* dest_resource_list_; | 142 TransferableResourceArray* dest_resource_list_; |
| 131 | 143 |
| 132 DISALLOW_COPY_AND_ASSIGN(SurfaceAggregator); | 144 DISALLOW_COPY_AND_ASSIGN(SurfaceAggregator); |
| 133 }; | 145 }; |
| 134 | 146 |
| 135 } // namespace cc | 147 } // namespace cc |
| 136 | 148 |
| 137 #endif // CC_SURFACES_SURFACE_AGGREGATOR_H_ | 149 #endif // CC_SURFACES_SURFACE_AGGREGATOR_H_ |
| OLD | NEW |