Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / cc / surfaces / surface_aggregator.h
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.
4
5 #ifndef CC_SURFACES_SURFACE_AGGREGATOR_H_
6 #define CC_SURFACES_SURFACE_AGGREGATOR_H_
7
8 #include <set>
9
10 #include "base/containers/scoped_ptr_hash_map.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "cc/quads/render_pass.h"
13 #include "cc/surfaces/surfaces_export.h"
14
15 namespace cc {
16
17 class CompositorFrame;
18 class DelegatedFrameData;
19 class SurfaceDrawQuad;
20 class SurfaceManager;
21
22 class CC_SURFACES_EXPORT SurfaceAggregator {
23  public:
24   explicit SurfaceAggregator(SurfaceManager* manager);
25   ~SurfaceAggregator();
26
27   scoped_ptr<CompositorFrame> Aggregate(int surface_id);
28
29  private:
30   DelegatedFrameData* GetReferencedDataForSurfaceID(int surface_id);
31   RenderPass::Id RemapPassId(RenderPass::Id surface_local_pass_id,
32                              int surface_id);
33
34   void HandleSurfaceQuad(const SurfaceDrawQuad* surface_quad,
35                          RenderPass* dest_pass);
36   void CopySharedQuadState(const SharedQuadState& source_sqs,
37                            const gfx::Transform& content_to_target_transform,
38                            SharedQuadStateList* dest_sqs_list);
39   void CopyQuadsToPass(const QuadList& source_quad_list,
40                        const SharedQuadStateList& source_shared_quad_state_list,
41                        const gfx::Transform& content_to_target_transform,
42                        RenderPass* dest_pass,
43                        int surface_id);
44   void CopyPasses(const RenderPassList& source_pass_list, int surface_id);
45
46   SurfaceManager* manager_;
47
48   class RenderPassIdAllocator;
49   typedef base::ScopedPtrHashMap<int, RenderPassIdAllocator>
50       RenderPassIdAllocatorMap;
51   RenderPassIdAllocatorMap render_pass_allocator_map_;
52
53   // The following state is only valid for the duration of one Aggregate call
54   // and is only stored on the class to avoid having to pass through every
55   // function call.
56
57   // This is the set of surfaces referenced in the aggregation so far, used to
58   // detect cycles.
59   std::set<int> referenced_surfaces_;
60
61   // This is the pass list for the aggregated frame.
62   RenderPassList* dest_pass_list_;
63
64   DISALLOW_COPY_AND_ASSIGN(SurfaceAggregator);
65 };
66
67 }  // namespace cc
68
69 #endif  // CC_SURFACES_SURFACE_AGGREGATOR_H_