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