| OLD | NEW | 
|    1 // Copyright 2014 The Chromium Authors. All rights reserved. |    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 |    2 // Use of this source code is governed by a BSD-style license that can be | 
|    3 // found in the LICENSE file. |    3 // found in the LICENSE file. | 
|    4  |    4  | 
|    5 #include "cc/surfaces/surface_aggregator.h" |    5 #include "cc/surfaces/surface_aggregator.h" | 
|    6  |    6  | 
|    7 #include <map> |    7 #include <map> | 
|    8  |    8  | 
|    9 #include "base/bind.h" |    9 #include "base/bind.h" | 
|   10 #include "base/containers/hash_tables.h" |   10 #include "base/containers/hash_tables.h" | 
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  146       quad->IterateResources(remap); |  146       quad->IterateResources(remap); | 
|  147   } |  147   } | 
|  148  |  148  | 
|  149   if (!invalid_frame) |  149   if (!invalid_frame) | 
|  150     provider_->DeclareUsedResourcesFromChild(child_id, referenced_resources); |  150     provider_->DeclareUsedResourcesFromChild(child_id, referenced_resources); | 
|  151  |  151  | 
|  152   return invalid_frame; |  152   return invalid_frame; | 
|  153 } |  153 } | 
|  154  |  154  | 
|  155 gfx::Rect SurfaceAggregator::DamageRectForSurface(const Surface* surface, |  155 gfx::Rect SurfaceAggregator::DamageRectForSurface(const Surface* surface, | 
|  156                                                   const RenderPass& source) { |  156                                                   const RenderPass& source, | 
 |  157                                                   const gfx::Rect& full_rect) { | 
|  157   int previous_index = previous_contained_surfaces_[surface->surface_id()]; |  158   int previous_index = previous_contained_surfaces_[surface->surface_id()]; | 
|  158   if (previous_index == surface->frame_index()) |  159   if (previous_index == surface->frame_index()) | 
|  159     return gfx::Rect(); |  160     return gfx::Rect(); | 
|  160   else if (previous_index == surface->frame_index() - 1) |  161   else if (previous_index == surface->frame_index() - 1) | 
|  161     return source.damage_rect; |  162     return source.damage_rect; | 
|  162   return gfx::Rect(surface->size()); |  163   return full_rect; | 
|  163 } |  164 } | 
|  164  |  165  | 
|  165 void SurfaceAggregator::HandleSurfaceQuad(const SurfaceDrawQuad* surface_quad, |  166 void SurfaceAggregator::HandleSurfaceQuad(const SurfaceDrawQuad* surface_quad, | 
|  166                                           float opacity, |  167                                           float opacity, | 
|  167                                           RenderPass* dest_pass) { |  168                                           RenderPass* dest_pass) { | 
|  168   SurfaceId surface_id = surface_quad->surface_id; |  169   SurfaceId surface_id = surface_quad->surface_id; | 
|  169   // If this surface's id is already in our referenced set then it creates |  170   // If this surface's id is already in our referenced set then it creates | 
|  170   // a cycle in the graph and should be dropped. |  171   // a cycle in the graph and should be dropped. | 
|  171   if (referenced_surfaces_.count(surface_id)) |  172   if (referenced_surfaces_.count(surface_id)) | 
|  172     return; |  173     return; | 
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  260                  gfx::Vector2dF(), |  261                  gfx::Vector2dF(), | 
|  261                  gfx::Size(), |  262                  gfx::Size(), | 
|  262                  FilterOperations(), |  263                  FilterOperations(), | 
|  263                  gfx::Vector2dF(), |  264                  gfx::Vector2dF(), | 
|  264                  FilterOperations()); |  265                  FilterOperations()); | 
|  265   } |  266   } | 
|  266   dest_pass->damage_rect = |  267   dest_pass->damage_rect = | 
|  267       gfx::UnionRects(dest_pass->damage_rect, |  268       gfx::UnionRects(dest_pass->damage_rect, | 
|  268                       MathUtil::MapEnclosingClippedRect( |  269                       MathUtil::MapEnclosingClippedRect( | 
|  269                           surface_quad->quadTransform(), |  270                           surface_quad->quadTransform(), | 
|  270                           DamageRectForSurface(surface, last_pass))); |  271                           DamageRectForSurface(surface, last_pass, | 
 |  272                                                surface_quad->visible_rect))); | 
|  271  |  273  | 
|  272   referenced_surfaces_.erase(it); |  274   referenced_surfaces_.erase(it); | 
|  273 } |  275 } | 
|  274  |  276  | 
|  275 void SurfaceAggregator::CopySharedQuadState( |  277 void SurfaceAggregator::CopySharedQuadState( | 
|  276     const SharedQuadState* source_sqs, |  278     const SharedQuadState* source_sqs, | 
|  277     const gfx::Transform& content_to_target_transform, |  279     const gfx::Transform& content_to_target_transform, | 
|  278     RenderPass* dest_render_pass) { |  280     RenderPass* dest_render_pass) { | 
|  279   SharedQuadState* copy_shared_quad_state = |  281   SharedQuadState* copy_shared_quad_state = | 
|  280       dest_render_pass->CreateAndAppendSharedQuadState(); |  282       dest_render_pass->CreateAndAppendSharedQuadState(); | 
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  357  |  359  | 
|  358     size_t sqs_size = source.shared_quad_state_list.size(); |  360     size_t sqs_size = source.shared_quad_state_list.size(); | 
|  359     size_t dq_size = source.quad_list.size(); |  361     size_t dq_size = source.quad_list.size(); | 
|  360     scoped_ptr<RenderPass> copy_pass(RenderPass::Create(sqs_size, dq_size)); |  362     scoped_ptr<RenderPass> copy_pass(RenderPass::Create(sqs_size, dq_size)); | 
|  361  |  363  | 
|  362     MoveMatchingRequests(source.id, ©_requests, ©_pass->copy_requests); |  364     MoveMatchingRequests(source.id, ©_requests, ©_pass->copy_requests); | 
|  363  |  365  | 
|  364     RenderPassId remapped_pass_id = |  366     RenderPassId remapped_pass_id = | 
|  365         RemapPassId(source.id, surface->surface_id()); |  367         RemapPassId(source.id, surface->surface_id()); | 
|  366  |  368  | 
|  367     copy_pass->SetAll(remapped_pass_id, |  369     copy_pass->SetAll(remapped_pass_id, source.output_rect, | 
|  368                       source.output_rect, |  370                       DamageRectForSurface(surface, source, source.output_rect), | 
|  369                       DamageRectForSurface(surface, source), |  | 
|  370                       source.transform_to_root_target, |  371                       source.transform_to_root_target, | 
|  371                       source.has_transparent_background); |  372                       source.has_transparent_background); | 
|  372  |  373  | 
|  373     CopyQuadsToPass(source.quad_list, source.shared_quad_state_list, |  374     CopyQuadsToPass(source.quad_list, source.shared_quad_state_list, | 
|  374                     gfx::Transform(), 1.f, copy_pass.get(), |  375                     gfx::Transform(), 1.f, copy_pass.get(), | 
|  375                     surface->surface_id()); |  376                     surface->surface_id()); | 
|  376  |  377  | 
|  377     dest_pass_list_->push_back(copy_pass.Pass()); |  378     dest_pass_list_->push_back(copy_pass.Pass()); | 
|  378   } |  379   } | 
|  379 } |  380 } | 
| (...skipping 28 matching lines...) Expand all  Loading... | 
|  408   SurfaceSet::iterator it = referenced_surfaces_.insert(surface_id).first; |  409   SurfaceSet::iterator it = referenced_surfaces_.insert(surface_id).first; | 
|  409  |  410  | 
|  410   dest_resource_list_ = &frame->delegated_frame_data->resource_list; |  411   dest_resource_list_ = &frame->delegated_frame_data->resource_list; | 
|  411   dest_pass_list_ = &frame->delegated_frame_data->render_pass_list; |  412   dest_pass_list_ = &frame->delegated_frame_data->render_pass_list; | 
|  412  |  413  | 
|  413   CopyPasses(root_surface_frame->delegated_frame_data.get(), surface); |  414   CopyPasses(root_surface_frame->delegated_frame_data.get(), surface); | 
|  414  |  415  | 
|  415   referenced_surfaces_.erase(it); |  416   referenced_surfaces_.erase(it); | 
|  416   DCHECK(referenced_surfaces_.empty()); |  417   DCHECK(referenced_surfaces_.empty()); | 
|  417  |  418  | 
 |  419   if (dest_pass_list_->empty()) | 
 |  420     return nullptr; | 
 |  421  | 
|  418   dest_pass_list_ = NULL; |  422   dest_pass_list_ = NULL; | 
|  419   RemoveUnreferencedChildren(); |  423   RemoveUnreferencedChildren(); | 
|  420   contained_surfaces_.swap(previous_contained_surfaces_); |  424   contained_surfaces_.swap(previous_contained_surfaces_); | 
|  421   contained_surfaces_.clear(); |  425   contained_surfaces_.clear(); | 
|  422  |  426  | 
|  423   for (SurfaceIndexMap::iterator it = previous_contained_surfaces_.begin(); |  427   for (SurfaceIndexMap::iterator it = previous_contained_surfaces_.begin(); | 
|  424        it != previous_contained_surfaces_.end(); |  428        it != previous_contained_surfaces_.end(); | 
|  425        ++it) { |  429        ++it) { | 
|  426     Surface* surface = manager_->GetSurfaceForId(it->first); |  430     Surface* surface = manager_->GetSurfaceForId(it->first); | 
|  427     if (surface) |  431     if (surface) | 
|  428       surface->TakeLatencyInfo(&frame->metadata.latency_info); |  432       surface->TakeLatencyInfo(&frame->metadata.latency_info); | 
|  429   } |  433   } | 
|  430  |  434  | 
|  431   // TODO(jamesr): Aggregate all resource references into the returned frame's |  435   // TODO(jamesr): Aggregate all resource references into the returned frame's | 
|  432   // resource list. |  436   // resource list. | 
|  433  |  437  | 
|  434   return frame.Pass(); |  438   return frame.Pass(); | 
|  435 } |  439 } | 
|  436  |  440  | 
|  437 }  // namespace cc |  441 }  // namespace cc | 
| OLD | NEW |