Change DtmfSenderHandler to handle events on the signaling thread.
[chromium-blink-merge.git] / cc / surfaces / surface_aggregator.h
blob31d35ddc7f4e67e1cfbcec2c1fcb090b30b71243
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 RenderPass* dest_pass);
45 void CopySharedQuadState(const SharedQuadState* source_sqs,
46 const gfx::Transform& content_to_target_transform,
47 RenderPass* dest_render_pass);
48 void CopyQuadsToPass(const QuadList& source_quad_list,
49 const SharedQuadStateList& source_shared_quad_state_list,
50 const gfx::Transform& content_to_target_transform,
51 RenderPass* dest_pass,
52 SurfaceId surface_id);
53 void CopyPasses(const DelegatedFrameData* frame_data, Surface* surface);
55 bool TakeResources(Surface* surface,
56 const DelegatedFrameData* frame_data,
57 RenderPassList* render_pass_list);
58 int ChildIdForSurface(Surface* surface);
59 gfx::Rect DamageRectForSurface(const Surface* surface,
60 const RenderPass& source);
62 SurfaceManager* manager_;
63 ResourceProvider* provider_;
65 class RenderPassIdAllocator;
66 typedef base::ScopedPtrHashMap<SurfaceId, RenderPassIdAllocator>
67 RenderPassIdAllocatorMap;
68 RenderPassIdAllocatorMap render_pass_allocator_map_;
69 int next_render_pass_id_;
71 typedef base::hash_map<SurfaceId, int> SurfaceToResourceChildIdMap;
72 SurfaceToResourceChildIdMap surface_id_to_resource_child_id_;
74 // The following state is only valid for the duration of one Aggregate call
75 // and is only stored on the class to avoid having to pass through every
76 // function call.
78 // This is the set of surfaces referenced in the aggregation so far, used to
79 // detect cycles.
80 typedef std::set<SurfaceId> SurfaceSet;
81 SurfaceSet referenced_surfaces_;
83 // For each Surface used in the last aggregation, gives the frame_index at
84 // that time.
85 SurfaceIndexMap previous_contained_surfaces_;
86 SurfaceIndexMap contained_surfaces_;
88 // This is the pass list for the aggregated frame.
89 RenderPassList* dest_pass_list_;
91 // Resource list for the aggregated frame.
92 TransferableResourceArray* dest_resource_list_;
94 DISALLOW_COPY_AND_ASSIGN(SurfaceAggregator);
97 } // namespace cc
99 #endif // CC_SURFACES_SURFACE_AGGREGATOR_H_