surface_aggregator.h revision 03b57e008b61dfcb1fbad3aea950ae0e001748b0
15d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved. 25d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// found in the LICENSE file. 45d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 55d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#ifndef CC_SURFACES_SURFACE_AGGREGATOR_H_ 65d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#define CC_SURFACES_SURFACE_AGGREGATOR_H_ 75d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 85d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include <set> 95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 10116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "base/containers/hash_tables.h" 115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/containers/scoped_ptr_hash_map.h" 125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/memory/scoped_ptr.h" 135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "cc/quads/render_pass.h" 14116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "cc/resources/transferable_resource.h" 15f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#include "cc/surfaces/surface_id.h" 165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "cc/surfaces/surfaces_export.h" 175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace cc { 195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class CompositorFrame; 215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class DelegatedFrameData; 22116680a4aac90f2aa7413d9095a592090648e557Ben Murdochclass ResourceProvider; 23116680a4aac90f2aa7413d9095a592090648e557Ben Murdochclass Surface; 245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class SurfaceDrawQuad; 255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class SurfaceManager; 265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class CC_SURFACES_EXPORT SurfaceAggregator { 285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) public: 29116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch SurfaceAggregator(SurfaceManager* manager, ResourceProvider* provider); 305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ~SurfaceAggregator(); 315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) scoped_ptr<CompositorFrame> Aggregate( 3303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) SurfaceId surface_id, 3403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) std::set<SurfaceId>* contained_surfaces); 355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) private: 3703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) RenderPassId RemapPassId(RenderPassId surface_local_pass_id, 3803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) SurfaceId surface_id); 395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void HandleSurfaceQuad(const SurfaceDrawQuad* surface_quad, 415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) RenderPass* dest_pass); 42010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) void CopySharedQuadState(const SharedQuadState* source_sqs, 435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const gfx::Transform& content_to_target_transform, 44010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) RenderPass* dest_render_pass); 455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void CopyQuadsToPass(const QuadList& source_quad_list, 465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const SharedQuadStateList& source_shared_quad_state_list, 475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const gfx::Transform& content_to_target_transform, 485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) RenderPass* dest_pass, 49116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch SurfaceId surface_id); 50116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch void CopyPasses(const RenderPassList& source_pass_list, SurfaceId surface_id); 51116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 525f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) bool TakeResources(Surface* surface, 535f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) const DelegatedFrameData* frame_data, 545f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) RenderPassList* render_pass_list); 55116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch int ChildIdForSurface(Surface* surface); 565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SurfaceManager* manager_; 58116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch ResourceProvider* provider_; 595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) class RenderPassIdAllocator; 61116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch typedef base::ScopedPtrHashMap<SurfaceId, RenderPassIdAllocator> 625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) RenderPassIdAllocatorMap; 635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) RenderPassIdAllocatorMap render_pass_allocator_map_; 645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 65116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch typedef base::hash_map<SurfaceId, int> SurfaceToResourceChildIdMap; 66116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch SurfaceToResourceChildIdMap surface_id_to_resource_child_id_; 67116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // The following state is only valid for the duration of one Aggregate call 695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // and is only stored on the class to avoid having to pass through every 705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // function call. 715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // This is the set of surfaces referenced in the aggregation so far, used to 735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // detect cycles. 74116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch typedef std::set<SurfaceId> SurfaceSet; 75116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch SurfaceSet referenced_surfaces_; 765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 7703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) // This is the set of surfaces that were used in the last draw. 7803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) SurfaceSet* contained_surfaces_; 7903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) 805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // This is the pass list for the aggregated frame. 815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) RenderPassList* dest_pass_list_; 825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 83116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // Resource list for the aggregated frame. 84116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch TransferableResourceArray* dest_resource_list_; 85116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(SurfaceAggregator); 875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}; 885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} // namespace cc 905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#endif // CC_SURFACES_SURFACE_AGGREGATOR_H_ 92