diff options
author | jbauman@chromium.org <jbauman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-25 00:21:37 +0000 |
---|---|---|
committer | jbauman@chromium.org <jbauman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-25 00:21:37 +0000 |
commit | 1442d7f4cb20dc35f0a138fce93186eaa688e4ea (patch) | |
tree | 1a7eae282a7736913e486088609345346a808e7b | |
parent | 86cfc58a8c741776ba1127190aa3e68dfecaa905 (diff) | |
download | chromium_src-1442d7f4cb20dc35f0a138fce93186eaa688e4ea.zip chromium_src-1442d7f4cb20dc35f0a138fce93186eaa688e4ea.tar.gz chromium_src-1442d7f4cb20dc35f0a138fce93186eaa688e4ea.tar.bz2 |
Make Surface::GetEligibleFrame const
The frame shouldn't be modified by the aggregator, or else it will be broken if GetEligibleFrame is called again.
Also modify ScopedPtrVector::const_iterator to make it const-correct.
BUG=
Review URL: https://codereview.chromium.org/417843003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285431 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | cc/base/scoped_ptr_vector.h | 2 | ||||
-rw-r--r-- | cc/surfaces/surface.cc | 4 | ||||
-rw-r--r-- | cc/surfaces/surface.h | 2 | ||||
-rw-r--r-- | cc/surfaces/surface_aggregator.cc | 33 | ||||
-rw-r--r-- | cc/surfaces/surface_aggregator.h | 4 | ||||
-rw-r--r-- | cc/surfaces/surface_aggregator_unittest.cc | 1 |
6 files changed, 27 insertions, 19 deletions
diff --git a/cc/base/scoped_ptr_vector.h b/cc/base/scoped_ptr_vector.h index 288cb6f..d220aaf 100644 --- a/cc/base/scoped_ptr_vector.h +++ b/cc/base/scoped_ptr_vector.h @@ -20,7 +20,7 @@ namespace cc { template <typename T> class ScopedPtrVector { public: - typedef typename std::vector<T*>::const_iterator const_iterator; + typedef typename std::vector<const T*>::const_iterator const_iterator; typedef typename std::vector<T*>::reverse_iterator reverse_iterator; typedef typename std::vector<T*>::const_reverse_iterator const_reverse_iterator; diff --git a/cc/surfaces/surface.cc b/cc/surfaces/surface.cc index bed727c..55c7392 100644 --- a/cc/surfaces/surface.cc +++ b/cc/surfaces/surface.cc @@ -38,6 +38,8 @@ void Surface::QueueFrame(scoped_ptr<CompositorFrame> frame) { } } -CompositorFrame* Surface::GetEligibleFrame() { return current_frame_.get(); } +const CompositorFrame* Surface::GetEligibleFrame() { + return current_frame_.get(); +} } // namespace cc diff --git a/cc/surfaces/surface.h b/cc/surfaces/surface.h index f62a897..403d2e5 100644 --- a/cc/surfaces/surface.h +++ b/cc/surfaces/surface.h @@ -28,7 +28,7 @@ class CC_SURFACES_EXPORT Surface { void QueueFrame(scoped_ptr<CompositorFrame> frame); // Returns the most recent frame that is eligible to be rendered. - CompositorFrame* GetEligibleFrame(); + const CompositorFrame* GetEligibleFrame(); SurfaceFactory* factory() { return factory_; } diff --git a/cc/surfaces/surface_aggregator.cc b/cc/surfaces/surface_aggregator.cc index d2a3a05..7ffa965 100644 --- a/cc/surfaces/surface_aggregator.cc +++ b/cc/surfaces/surface_aggregator.cc @@ -97,7 +97,9 @@ static ResourceProvider::ResourceId ResourceRemapHelper( } bool SurfaceAggregator::TakeResources(Surface* surface, - DelegatedFrameData* frame_data) { + const DelegatedFrameData* frame_data, + RenderPassList* render_pass_list) { + RenderPass::CopyAll(frame_data->render_pass_list, render_pass_list); if (!provider_) // TODO(jamesr): hack for unit tests that don't set up rp return false; @@ -114,12 +116,11 @@ bool SurfaceAggregator::TakeResources(Surface* surface, &invalid_frame, provider_->GetChildToParentMap(child_id), &referenced_resources); - const RenderPassList& referenced_passes = frame_data->render_pass_list; - for (RenderPassList::const_iterator it = referenced_passes.begin(); - it != referenced_passes.end(); + for (RenderPassList::iterator it = render_pass_list->begin(); + it != render_pass_list->end(); ++it) { - const QuadList& quad_list = (*it)->quad_list; - for (QuadList::const_iterator quad_it = quad_list.begin(); + QuadList& quad_list = (*it)->quad_list; + for (QuadList::iterator quad_it = quad_list.begin(); quad_it != quad_list.end(); ++quad_it) { (*quad_it)->IterateResources(remap); @@ -141,20 +142,21 @@ void SurfaceAggregator::HandleSurfaceQuad(const SurfaceDrawQuad* surface_quad, Surface* surface = manager_->GetSurfaceForId(surface_id); if (!surface) return; - CompositorFrame* frame = surface->GetEligibleFrame(); + const CompositorFrame* frame = surface->GetEligibleFrame(); if (!frame) return; - DelegatedFrameData* frame_data = frame->delegated_frame_data.get(); + const DelegatedFrameData* frame_data = frame->delegated_frame_data.get(); if (!frame_data) return; - bool invalid_frame = TakeResources(surface, frame_data); + RenderPassList render_pass_list; + bool invalid_frame = TakeResources(surface, frame_data, &render_pass_list); if (invalid_frame) return; SurfaceSet::iterator it = referenced_surfaces_.insert(surface_id).first; - const RenderPassList& referenced_passes = frame_data->render_pass_list; + const RenderPassList& referenced_passes = render_pass_list; for (size_t j = 0; j + 1 < referenced_passes.size(); ++j) { const RenderPass& source = *referenced_passes[j]; @@ -186,7 +188,7 @@ void SurfaceAggregator::HandleSurfaceQuad(const SurfaceDrawQuad* surface_quad, } // TODO(jamesr): Clean up last pass special casing. - const RenderPass& last_pass = *frame_data->render_pass_list.back(); + const RenderPass& last_pass = *render_pass_list.back(); const QuadList& quads = last_pass.quad_list; // TODO(jamesr): Make sure clipping is enforced. @@ -288,7 +290,7 @@ void SurfaceAggregator::CopyPasses(const RenderPassList& source_pass_list, scoped_ptr<CompositorFrame> SurfaceAggregator::Aggregate(SurfaceId surface_id) { Surface* surface = manager_->GetSurfaceForId(surface_id); DCHECK(surface); - CompositorFrame* root_surface_frame = surface->GetEligibleFrame(); + const CompositorFrame* root_surface_frame = surface->GetEligibleFrame(); if (!root_surface_frame) return scoped_ptr<CompositorFrame>(); TRACE_EVENT0("cc", "SurfaceAggregator::Aggregate"); @@ -298,8 +300,7 @@ scoped_ptr<CompositorFrame> SurfaceAggregator::Aggregate(SurfaceId surface_id) { DCHECK(root_surface_frame->delegated_frame_data); - const RenderPassList& source_pass_list = - root_surface_frame->delegated_frame_data->render_pass_list; + RenderPassList source_pass_list; SurfaceSet::iterator it = referenced_surfaces_.insert(surface_id).first; @@ -307,7 +308,9 @@ scoped_ptr<CompositorFrame> SurfaceAggregator::Aggregate(SurfaceId surface_id) { dest_pass_list_ = &frame->delegated_frame_data->render_pass_list; bool invalid_frame = - TakeResources(surface, root_surface_frame->delegated_frame_data.get()); + TakeResources(surface, + root_surface_frame->delegated_frame_data.get(), + &source_pass_list); DCHECK(!invalid_frame); CopyPasses(source_pass_list, surface_id); diff --git a/cc/surfaces/surface_aggregator.h b/cc/surfaces/surface_aggregator.h index 02dc478..ec36b4b 100644 --- a/cc/surfaces/surface_aggregator.h +++ b/cc/surfaces/surface_aggregator.h @@ -47,7 +47,9 @@ class CC_SURFACES_EXPORT SurfaceAggregator { SurfaceId surface_id); void CopyPasses(const RenderPassList& source_pass_list, SurfaceId surface_id); - bool TakeResources(Surface* surface, DelegatedFrameData* frame_data); + bool TakeResources(Surface* surface, + const DelegatedFrameData* frame_data, + RenderPassList* render_pass_list); int ChildIdForSurface(Surface* surface); SurfaceManager* manager_; diff --git a/cc/surfaces/surface_aggregator_unittest.cc b/cc/surfaces/surface_aggregator_unittest.cc index 435e239..6525157 100644 --- a/cc/surfaces/surface_aggregator_unittest.cc +++ b/cc/surfaces/surface_aggregator_unittest.cc @@ -814,6 +814,7 @@ void SubmitFrameWithResources(ResourceProvider::ResourceId* resource_ids, SurfaceId surface_id) { scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); scoped_ptr<RenderPass> pass = RenderPass::Create(); + pass->id = RenderPass::Id(1, 1); SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); for (size_t i = 0u; i < num_resource_ids; ++i) { TransferableResource resource; |