| 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> | 9 #include <unordered_map> |
| 10 #include <unordered_set> | 10 #include <unordered_set> |
| 11 | 11 |
| 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 { | |
| 30 public: | |
| 31 virtual ~SurfaceAggregatorClient() {} | |
| 32 | |
| 33 virtual void AddSurface(Surface* surface) = 0; | |
| 34 virtual void RemoveSurface(Surface* surface) = 0; | |
| 35 }; | |
| 36 | |
| 37 class CC_SURFACES_EXPORT SurfaceAggregator { | 29 class CC_SURFACES_EXPORT SurfaceAggregator { |
| 38 public: | 30 public: |
| 39 using SurfaceIndexMap = std::unordered_map<SurfaceId, int, SurfaceIdHash>; | 31 using SurfaceIndexMap = std::unordered_map<SurfaceId, int, SurfaceIdHash>; |
| 40 | 32 |
| 41 SurfaceAggregator(SurfaceAggregatorClient* client, | 33 SurfaceAggregator(SurfaceManager* manager, |
| 42 SurfaceManager* manager, | |
| 43 ResourceProvider* provider, | 34 ResourceProvider* provider, |
| 44 bool aggregate_only_damaged); | 35 bool aggregate_only_damaged); |
| 45 ~SurfaceAggregator(); | 36 ~SurfaceAggregator(); |
| 46 | 37 |
| 47 scoped_ptr<CompositorFrame> Aggregate(SurfaceId surface_id); | 38 scoped_ptr<CompositorFrame> Aggregate(SurfaceId surface_id); |
| 48 void ReleaseResources(SurfaceId surface_id); | 39 void ReleaseResources(SurfaceId surface_id); |
| 49 SurfaceIndexMap& previous_contained_surfaces() { | 40 SurfaceIndexMap& previous_contained_surfaces() { |
| 50 return previous_contained_surfaces_; | 41 return previous_contained_surfaces_; |
| 51 } | 42 } |
| 52 void SetFullDamageForSurface(SurfaceId surface_id); | 43 void SetFullDamageForSurface(SurfaceId surface_id); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 // referenced from the ResourceProvider. | 92 // referenced from the ResourceProvider. |
| 102 // Also notifies SurfaceAggregatorClient of newly added and removed | 93 // Also notifies SurfaceAggregatorClient of newly added and removed |
| 103 // child surfaces. | 94 // child surfaces. |
| 104 void ProcessAddedAndRemovedSurfaces(); | 95 void ProcessAddedAndRemovedSurfaces(); |
| 105 | 96 |
| 106 int ChildIdForSurface(Surface* surface); | 97 int ChildIdForSurface(Surface* surface); |
| 107 gfx::Rect DamageRectForSurface(const Surface* surface, | 98 gfx::Rect DamageRectForSurface(const Surface* surface, |
| 108 const RenderPass& source, | 99 const RenderPass& source, |
| 109 const gfx::Rect& full_rect) const; | 100 const gfx::Rect& full_rect) const; |
| 110 | 101 |
| 111 SurfaceAggregatorClient* client_; // Outlives this class. | |
| 112 SurfaceManager* manager_; | 102 SurfaceManager* manager_; |
| 113 ResourceProvider* provider_; | 103 ResourceProvider* provider_; |
| 114 | 104 |
| 115 class RenderPassIdAllocator; | 105 class RenderPassIdAllocator; |
| 116 using RenderPassIdAllocatorMap = | 106 using RenderPassIdAllocatorMap = |
| 117 std::unordered_map<SurfaceId, | 107 std::unordered_map<SurfaceId, |
| 118 scoped_ptr<RenderPassIdAllocator>, | 108 scoped_ptr<RenderPassIdAllocator>, |
| 119 SurfaceIdHash>; | 109 SurfaceIdHash>; |
| 120 RenderPassIdAllocatorMap render_pass_allocator_map_; | 110 RenderPassIdAllocatorMap render_pass_allocator_map_; |
| 121 int next_render_pass_id_; | 111 int next_render_pass_id_; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 144 |
| 155 // Resource list for the aggregated frame. | 145 // Resource list for the aggregated frame. |
| 156 TransferableResourceArray* dest_resource_list_; | 146 TransferableResourceArray* dest_resource_list_; |
| 157 | 147 |
| 158 DISALLOW_COPY_AND_ASSIGN(SurfaceAggregator); | 148 DISALLOW_COPY_AND_ASSIGN(SurfaceAggregator); |
| 159 }; | 149 }; |
| 160 | 150 |
| 161 } // namespace cc | 151 } // namespace cc |
| 162 | 152 |
| 163 #endif // CC_SURFACES_SURFACE_AGGREGATOR_H_ | 153 #endif // CC_SURFACES_SURFACE_AGGREGATOR_H_ |
| OLD | NEW |