| 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 <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <unordered_map> | 11 #include <unordered_map> |
| 12 #include <unordered_set> | 12 #include <unordered_set> |
| 13 | 13 |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "cc/quads/draw_quad.h" | 16 #include "cc/quads/draw_quad.h" |
| 17 #include "cc/quads/render_pass.h" | 17 #include "cc/quads/render_pass.h" |
| 18 #include "cc/resources/transferable_resource.h" | 18 #include "cc/resources/transferable_resource.h" |
| 19 #include "cc/surfaces/surface_id.h" | 19 #include "cc/surfaces/surface_id.h" |
| 20 #include "cc/surfaces/surfaces_export.h" | 20 #include "cc/surfaces/surfaces_export.h" |
| 21 #include "ui/gfx/color_space.h" |
| 21 | 22 |
| 22 namespace cc { | 23 namespace cc { |
| 23 | 24 |
| 24 class CompositorFrame; | 25 class CompositorFrame; |
| 25 class ResourceProvider; | 26 class ResourceProvider; |
| 26 class Surface; | 27 class Surface; |
| 27 class SurfaceDrawQuad; | 28 class SurfaceDrawQuad; |
| 28 class SurfaceManager; | 29 class SurfaceManager; |
| 29 | 30 |
| 30 class CC_SURFACES_EXPORT SurfaceAggregator { | 31 class CC_SURFACES_EXPORT SurfaceAggregator { |
| 31 public: | 32 public: |
| 32 using SurfaceIndexMap = std::unordered_map<SurfaceId, int, SurfaceIdHash>; | 33 using SurfaceIndexMap = std::unordered_map<SurfaceId, int, SurfaceIdHash>; |
| 33 | 34 |
| 34 SurfaceAggregator(SurfaceManager* manager, | 35 SurfaceAggregator(SurfaceManager* manager, |
| 35 ResourceProvider* provider, | 36 ResourceProvider* provider, |
| 36 bool aggregate_only_damaged); | 37 bool aggregate_only_damaged); |
| 37 ~SurfaceAggregator(); | 38 ~SurfaceAggregator(); |
| 38 | 39 |
| 39 CompositorFrame Aggregate(const SurfaceId& surface_id); | 40 CompositorFrame Aggregate(const SurfaceId& surface_id); |
| 40 void ReleaseResources(const SurfaceId& surface_id); | 41 void ReleaseResources(const SurfaceId& surface_id); |
| 41 SurfaceIndexMap& previous_contained_surfaces() { | 42 SurfaceIndexMap& previous_contained_surfaces() { |
| 42 return previous_contained_surfaces_; | 43 return previous_contained_surfaces_; |
| 43 } | 44 } |
| 44 void SetFullDamageForSurface(const SurfaceId& surface_id); | 45 void SetFullDamageForSurface(const SurfaceId& surface_id); |
| 45 void set_output_is_secure(bool secure) { output_is_secure_ = secure; } | 46 void set_output_is_secure(bool secure) { output_is_secure_ = secure; } |
| 46 | 47 |
| 48 // Set the color spaces for the created RenderPasses, which is propagated |
| 49 // to the output surface. |
| 50 void SetOutputColorSpace(const gfx::ColorSpace& output_color_space); |
| 51 |
| 47 private: | 52 private: |
| 48 struct ClipData { | 53 struct ClipData { |
| 49 ClipData() : is_clipped(false) {} | 54 ClipData() : is_clipped(false) {} |
| 50 ClipData(bool is_clipped, const gfx::Rect& rect) | 55 ClipData(bool is_clipped, const gfx::Rect& rect) |
| 51 : is_clipped(is_clipped), rect(rect) {} | 56 : is_clipped(is_clipped), rect(rect) {} |
| 52 | 57 |
| 53 bool is_clipped; | 58 bool is_clipped; |
| 54 gfx::Rect rect; | 59 gfx::Rect rect; |
| 55 }; | 60 }; |
| 56 | 61 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 // Every Surface has its own RenderPass ID namespace. This structure maps | 123 // Every Surface has its own RenderPass ID namespace. This structure maps |
| 119 // each source (SurfaceId, RenderPass id) to a unified ID namespace that's | 124 // each source (SurfaceId, RenderPass id) to a unified ID namespace that's |
| 120 // used in the aggregated frame. An entry is removed from the map if it's not | 125 // used in the aggregated frame. An entry is removed from the map if it's not |
| 121 // used for one output frame. | 126 // used for one output frame. |
| 122 using RenderPassIdAllocatorMap = | 127 using RenderPassIdAllocatorMap = |
| 123 std::map<std::pair<SurfaceId, int>, RenderPassInfo>; | 128 std::map<std::pair<SurfaceId, int>, RenderPassInfo>; |
| 124 RenderPassIdAllocatorMap render_pass_allocator_map_; | 129 RenderPassIdAllocatorMap render_pass_allocator_map_; |
| 125 int next_render_pass_id_; | 130 int next_render_pass_id_; |
| 126 const bool aggregate_only_damaged_; | 131 const bool aggregate_only_damaged_; |
| 127 bool output_is_secure_; | 132 bool output_is_secure_; |
| 133 gfx::ColorSpace output_color_space_; |
| 128 | 134 |
| 129 using SurfaceToResourceChildIdMap = | 135 using SurfaceToResourceChildIdMap = |
| 130 std::unordered_map<SurfaceId, int, SurfaceIdHash>; | 136 std::unordered_map<SurfaceId, int, SurfaceIdHash>; |
| 131 SurfaceToResourceChildIdMap surface_id_to_resource_child_id_; | 137 SurfaceToResourceChildIdMap surface_id_to_resource_child_id_; |
| 132 | 138 |
| 133 // The following state is only valid for the duration of one Aggregate call | 139 // The following state is only valid for the duration of one Aggregate call |
| 134 // and is only stored on the class to avoid having to pass through every | 140 // and is only stored on the class to avoid having to pass through every |
| 135 // function call. | 141 // function call. |
| 136 | 142 |
| 137 // This is the set of surfaces referenced in the aggregation so far, used to | 143 // This is the set of surfaces referenced in the aggregation so far, used to |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 TransferableResourceArray* dest_resource_list_; | 179 TransferableResourceArray* dest_resource_list_; |
| 174 | 180 |
| 175 base::WeakPtrFactory<SurfaceAggregator> weak_factory_; | 181 base::WeakPtrFactory<SurfaceAggregator> weak_factory_; |
| 176 | 182 |
| 177 DISALLOW_COPY_AND_ASSIGN(SurfaceAggregator); | 183 DISALLOW_COPY_AND_ASSIGN(SurfaceAggregator); |
| 178 }; | 184 }; |
| 179 | 185 |
| 180 } // namespace cc | 186 } // namespace cc |
| 181 | 187 |
| 182 #endif // CC_SURFACES_SURFACE_AGGREGATOR_H_ | 188 #endif // CC_SURFACES_SURFACE_AGGREGATOR_H_ |
| OLD | NEW |