Explicitly add python-numpy dependency to install-build-deps.
[chromium-blink-merge.git] / cc / surfaces / surface_aggregator.h
blob696504199f6b7844883cdc7ad7bfab1ccd9697c5
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
3 // found in the LICENSE file.
5 #ifndef CC_SURFACES_SURFACE_AGGREGATOR_H_
6 #define CC_SURFACES_SURFACE_AGGREGATOR_H_
8 #include <set>
10 #include "base/containers/hash_tables.h"
11 #include "base/containers/scoped_ptr_hash_map.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "cc/quads/render_pass.h"
14 #include "cc/resources/transferable_resource.h"
15 #include "cc/surfaces/surface_id.h"
16 #include "cc/surfaces/surfaces_export.h"
18 namespace cc {
20 class CompositorFrame;
21 class DelegatedFrameData;
22 class ResourceProvider;
23 class Surface;
24 class SurfaceDrawQuad;
25 class SurfaceManager;
27 class CC_SURFACES_EXPORT SurfaceAggregator {
28 public:
29 typedef base::hash_map<SurfaceId, int> SurfaceIndexMap;
31 SurfaceAggregator(SurfaceManager* manager, ResourceProvider* provider);
32 ~SurfaceAggregator();
34 scoped_ptr<CompositorFrame> Aggregate(SurfaceId surface_id);
35 SurfaceIndexMap& previous_contained_surfaces() {
36 return previous_contained_surfaces_;
39 private:
40 RenderPassId RemapPassId(RenderPassId surface_local_pass_id,
41 SurfaceId surface_id);
43 void HandleSurfaceQuad(const SurfaceDrawQuad* surface_quad,
44 float opacity,
45 RenderPass* dest_pass);
46 void CopySharedQuadState(const SharedQuadState* source_sqs,
47 const gfx::Transform& content_to_target_transform,
48 RenderPass* dest_render_pass);
49 void CopyQuadsToPass(const QuadList& source_quad_list,
50 const SharedQuadStateList& source_shared_quad_state_list,
51 const gfx::Transform& content_to_target_transform,
52 float opacity,
53 RenderPass* dest_pass,
54 SurfaceId surface_id);
55 void CopyPasses(const DelegatedFrameData* frame_data, Surface* surface);
57 // Remove Surfaces that were referenced before but aren't currently
58 // referenced from the ResourceProvider.
59 void RemoveUnreferencedChildren();
61 bool TakeResources(Surface* surface,
62 const DelegatedFrameData* frame_data,
63 RenderPassList* render_pass_list);
64 int ChildIdForSurface(Surface* surface);
65 gfx::Rect DamageRectForSurface(const Surface* surface,
66 const RenderPass& source);
68 SurfaceManager* manager_;
69 ResourceProvider* provider_;
71 class RenderPassIdAllocator;
72 typedef base::ScopedPtrHashMap<SurfaceId, RenderPassIdAllocator>
73 RenderPassIdAllocatorMap;
74 RenderPassIdAllocatorMap render_pass_allocator_map_;
75 int next_render_pass_id_;
77 typedef base::hash_map<SurfaceId, int> SurfaceToResourceChildIdMap;
78 SurfaceToResourceChildIdMap surface_id_to_resource_child_id_;
80 // The following state is only valid for the duration of one Aggregate call
81 // and is only stored on the class to avoid having to pass through every
82 // function call.
84 // This is the set of surfaces referenced in the aggregation so far, used to
85 // detect cycles.
86 typedef std::set<SurfaceId> SurfaceSet;
87 SurfaceSet referenced_surfaces_;
89 // For each Surface used in the last aggregation, gives the frame_index at
90 // that time.
91 SurfaceIndexMap previous_contained_surfaces_;
92 SurfaceIndexMap contained_surfaces_;
94 // This is the pass list for the aggregated frame.
95 RenderPassList* dest_pass_list_;
97 // Resource list for the aggregated frame.
98 TransferableResourceArray* dest_resource_list_;
100 DISALLOW_COPY_AND_ASSIGN(SurfaceAggregator);
103 } // namespace cc
105 #endif // CC_SURFACES_SURFACE_AGGREGATOR_H_