| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/trees/occlusion_tracker.h" | 5 #include "cc/trees/occlusion_tracker.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "cc/base/math_util.h" | 9 #include "cc/base/math_util.h" |
| 10 #include "cc/debug/overdraw_metrics.h" | 10 #include "cc/debug/overdraw_metrics.h" |
| 11 #include "cc/layers/layer.h" | 11 #include "cc/layers/layer.h" |
| 12 #include "cc/layers/layer_impl.h" | 12 #include "cc/layers/layer_impl.h" |
| 13 #include "cc/layers/render_surface.h" | 13 #include "cc/layers/render_surface.h" |
| 14 #include "cc/layers/render_surface_impl.h" | 14 #include "cc/layers/render_surface_impl.h" |
| 15 #include "ui/gfx/quad_f.h" | 15 #include "ui/gfx/quad_f.h" |
| 16 #include "ui/gfx/rect_conversions.h" | 16 #include "ui/gfx/rect_conversions.h" |
| 17 | 17 |
| 18 namespace cc { | 18 namespace cc { |
| 19 | 19 |
| 20 template <typename LayerType, typename RenderSurfaceType> | 20 template <typename LayerType> |
| 21 OcclusionTrackerBase<LayerType, RenderSurfaceType>::OcclusionTrackerBase( | 21 OcclusionTracker<LayerType>::OcclusionTracker( |
| 22 const gfx::Rect& screen_space_clip_rect, bool record_metrics_for_frame) | 22 const gfx::Rect& screen_space_clip_rect, |
| 23 bool record_metrics_for_frame) |
| 23 : screen_space_clip_rect_(screen_space_clip_rect), | 24 : screen_space_clip_rect_(screen_space_clip_rect), |
| 24 overdraw_metrics_(OverdrawMetrics::Create(record_metrics_for_frame)), | 25 overdraw_metrics_(OverdrawMetrics::Create(record_metrics_for_frame)), |
| 25 occluding_screen_space_rects_(NULL), | 26 occluding_screen_space_rects_(NULL), |
| 26 non_occluding_screen_space_rects_(NULL) {} | 27 non_occluding_screen_space_rects_(NULL) {} |
| 27 | 28 |
| 28 template <typename LayerType, typename RenderSurfaceType> | 29 template <typename LayerType> |
| 29 OcclusionTrackerBase<LayerType, RenderSurfaceType>::~OcclusionTrackerBase() {} | 30 OcclusionTracker<LayerType>::~OcclusionTracker() {} |
| 30 | 31 |
| 31 template <typename LayerType, typename RenderSurfaceType> | 32 template <typename LayerType> |
| 32 void OcclusionTrackerBase<LayerType, RenderSurfaceType>::EnterLayer( | 33 void OcclusionTracker<LayerType>::EnterLayer( |
| 33 const LayerIteratorPosition<LayerType>& layer_iterator) { | 34 const LayerIteratorPosition<LayerType>& layer_iterator) { |
| 34 LayerType* render_target = layer_iterator.target_render_surface_layer; | 35 LayerType* render_target = layer_iterator.target_render_surface_layer; |
| 35 | 36 |
| 36 if (layer_iterator.represents_itself) | 37 if (layer_iterator.represents_itself) |
| 37 EnterRenderTarget(render_target); | 38 EnterRenderTarget(render_target); |
| 38 else if (layer_iterator.represents_target_render_surface) | 39 else if (layer_iterator.represents_target_render_surface) |
| 39 FinishedRenderTarget(render_target); | 40 FinishedRenderTarget(render_target); |
| 40 } | 41 } |
| 41 | 42 |
| 42 template <typename LayerType, typename RenderSurfaceType> | 43 template <typename LayerType> |
| 43 void OcclusionTrackerBase<LayerType, RenderSurfaceType>::LeaveLayer( | 44 void OcclusionTracker<LayerType>::LeaveLayer( |
| 44 const LayerIteratorPosition<LayerType>& layer_iterator) { | 45 const LayerIteratorPosition<LayerType>& layer_iterator) { |
| 45 LayerType* render_target = layer_iterator.target_render_surface_layer; | 46 LayerType* render_target = layer_iterator.target_render_surface_layer; |
| 46 | 47 |
| 47 if (layer_iterator.represents_itself) | 48 if (layer_iterator.represents_itself) |
| 48 MarkOccludedBehindLayer(layer_iterator.current_layer); | 49 MarkOccludedBehindLayer(layer_iterator.current_layer); |
| 49 // TODO(danakj): This should be done when entering the contributing surface, | 50 // TODO(danakj): This should be done when entering the contributing surface, |
| 50 // but in a way that the surface's own occlusion won't occlude itself. | 51 // but in a way that the surface's own occlusion won't occlude itself. |
| 51 else if (layer_iterator.represents_contributing_render_surface) | 52 else if (layer_iterator.represents_contributing_render_surface) |
| 52 LeaveToRenderTarget(render_target); | 53 LeaveToRenderTarget(render_target); |
| 53 } | 54 } |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 static inline bool LayerIsInUnsorted3dRenderingContext(const LayerImpl* layer) { | 139 static inline bool LayerIsInUnsorted3dRenderingContext(const LayerImpl* layer) { |
| 139 return false; | 140 return false; |
| 140 } | 141 } |
| 141 | 142 |
| 142 template <typename LayerType> | 143 template <typename LayerType> |
| 143 static inline bool LayerIsHidden(const LayerType* layer) { | 144 static inline bool LayerIsHidden(const LayerType* layer) { |
| 144 return layer->hide_layer_and_subtree() || | 145 return layer->hide_layer_and_subtree() || |
| 145 (layer->parent() && LayerIsHidden(layer->parent())); | 146 (layer->parent() && LayerIsHidden(layer->parent())); |
| 146 } | 147 } |
| 147 | 148 |
| 148 template <typename LayerType, typename RenderSurfaceType> | 149 template <typename LayerType> |
| 149 void OcclusionTrackerBase<LayerType, RenderSurfaceType>::EnterRenderTarget( | 150 void OcclusionTracker<LayerType>::EnterRenderTarget( |
| 150 const LayerType* new_target) { | 151 const LayerType* new_target) { |
| 151 if (!stack_.empty() && stack_.back().target == new_target) | 152 if (!stack_.empty() && stack_.back().target == new_target) |
| 152 return; | 153 return; |
| 153 | 154 |
| 154 const LayerType* old_target = NULL; | 155 const LayerType* old_target = NULL; |
| 155 const RenderSurfaceType* old_occlusion_immune_ancestor = NULL; | 156 const typename LayerType::RenderSurfaceType* old_occlusion_immune_ancestor = |
| 157 NULL; |
| 156 if (!stack_.empty()) { | 158 if (!stack_.empty()) { |
| 157 old_target = stack_.back().target; | 159 old_target = stack_.back().target; |
| 158 old_occlusion_immune_ancestor = | 160 old_occlusion_immune_ancestor = |
| 159 old_target->render_surface()->nearest_occlusion_immune_ancestor(); | 161 old_target->render_surface()->nearest_occlusion_immune_ancestor(); |
| 160 } | 162 } |
| 161 const RenderSurfaceType* new_occlusion_immune_ancestor = | 163 const typename LayerType::RenderSurfaceType* new_occlusion_immune_ancestor = |
| 162 new_target->render_surface()->nearest_occlusion_immune_ancestor(); | 164 new_target->render_surface()->nearest_occlusion_immune_ancestor(); |
| 163 | 165 |
| 164 stack_.push_back(StackObject(new_target)); | 166 stack_.push_back(StackObject(new_target)); |
| 165 | 167 |
| 166 // We copy the screen occlusion into the new RenderSurface subtree, but we | 168 // We copy the screen occlusion into the new RenderSurface subtree, but we |
| 167 // never copy in the occlusion from inside the target, since we are looking | 169 // never copy in the occlusion from inside the target, since we are looking |
| 168 // at a new RenderSurface target. | 170 // at a new RenderSurface target. |
| 169 | 171 |
| 170 // If entering an unoccluded subtree, do not carry forward the outside | 172 // If entering an unoccluded subtree, do not carry forward the outside |
| 171 // occlusion calculated so far. | 173 // occlusion calculated so far. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 191 have_transform_from_screen_to_new_target && | 193 have_transform_from_screen_to_new_target && |
| 192 !entering_root_target; | 194 !entering_root_target; |
| 193 if (!copy_outside_occlusion_forward) | 195 if (!copy_outside_occlusion_forward) |
| 194 return; | 196 return; |
| 195 | 197 |
| 196 int last_index = stack_.size() - 1; | 198 int last_index = stack_.size() - 1; |
| 197 gfx::Transform old_target_to_new_target_transform( | 199 gfx::Transform old_target_to_new_target_transform( |
| 198 inverse_new_target_screen_space_transform, | 200 inverse_new_target_screen_space_transform, |
| 199 old_target->render_surface()->screen_space_transform()); | 201 old_target->render_surface()->screen_space_transform()); |
| 200 stack_[last_index].occlusion_from_outside_target = | 202 stack_[last_index].occlusion_from_outside_target = |
| 201 TransformSurfaceOpaqueRegion<RenderSurfaceType>( | 203 TransformSurfaceOpaqueRegion<typename LayerType::RenderSurfaceType>( |
| 202 stack_[last_index - 1].occlusion_from_outside_target, | 204 stack_[last_index - 1].occlusion_from_outside_target, |
| 203 false, | 205 false, |
| 204 gfx::Rect(), | 206 gfx::Rect(), |
| 205 old_target_to_new_target_transform); | 207 old_target_to_new_target_transform); |
| 206 stack_[last_index].occlusion_from_outside_target.Union( | 208 stack_[last_index].occlusion_from_outside_target.Union( |
| 207 TransformSurfaceOpaqueRegion<RenderSurfaceType>( | 209 TransformSurfaceOpaqueRegion<typename LayerType::RenderSurfaceType>( |
| 208 stack_[last_index - 1].occlusion_from_inside_target, | 210 stack_[last_index - 1].occlusion_from_inside_target, |
| 209 false, | 211 false, |
| 210 gfx::Rect(), | 212 gfx::Rect(), |
| 211 old_target_to_new_target_transform)); | 213 old_target_to_new_target_transform)); |
| 212 } | 214 } |
| 213 | 215 |
| 214 template <typename LayerType, typename RenderSurfaceType> | 216 template <typename LayerType> |
| 215 void OcclusionTrackerBase<LayerType, RenderSurfaceType>::FinishedRenderTarget( | 217 void OcclusionTracker<LayerType>::FinishedRenderTarget( |
| 216 const LayerType* finished_target) { | 218 const LayerType* finished_target) { |
| 217 // Make sure we know about the target surface. | 219 // Make sure we know about the target surface. |
| 218 EnterRenderTarget(finished_target); | 220 EnterRenderTarget(finished_target); |
| 219 | 221 |
| 220 RenderSurfaceType* surface = finished_target->render_surface(); | 222 typename LayerType::RenderSurfaceType* surface = |
| 223 finished_target->render_surface(); |
| 221 | 224 |
| 222 // Readbacks always happen on render targets so we only need to check | 225 // Readbacks always happen on render targets so we only need to check |
| 223 // for readbacks here. | 226 // for readbacks here. |
| 224 bool target_is_only_for_copy_request = | 227 bool target_is_only_for_copy_request = |
| 225 finished_target->HasCopyRequest() && LayerIsHidden(finished_target); | 228 finished_target->HasCopyRequest() && LayerIsHidden(finished_target); |
| 226 | 229 |
| 227 // If the occlusion within the surface can not be applied to things outside of | 230 // If the occlusion within the surface can not be applied to things outside of |
| 228 // the surface's subtree, then clear the occlusion here so it won't be used. | 231 // the surface's subtree, then clear the occlusion here so it won't be used. |
| 229 if (finished_target->mask_layer() || !SurfaceOpacityKnown(surface) || | 232 if (finished_target->mask_layer() || !SurfaceOpacityKnown(surface) || |
| 230 surface->draw_opacity() < 1 || | 233 surface->draw_opacity() < 1 || |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 int shrink_bottom = | 290 int shrink_bottom = |
| 288 occlusion_rect.bottom() == affected_area_in_target.bottom() ? | 291 occlusion_rect.bottom() == affected_area_in_target.bottom() ? |
| 289 0 : outset_top; | 292 0 : outset_top; |
| 290 | 293 |
| 291 occlusion_rect.Inset(shrink_left, shrink_top, shrink_right, shrink_bottom); | 294 occlusion_rect.Inset(shrink_left, shrink_top, shrink_right, shrink_bottom); |
| 292 | 295 |
| 293 occlusion_from_inside_target->Union(occlusion_rect); | 296 occlusion_from_inside_target->Union(occlusion_rect); |
| 294 } | 297 } |
| 295 } | 298 } |
| 296 | 299 |
| 297 template <typename LayerType, typename RenderSurfaceType> | 300 template <typename LayerType> |
| 298 void OcclusionTrackerBase<LayerType, RenderSurfaceType>::LeaveToRenderTarget( | 301 void OcclusionTracker<LayerType>::LeaveToRenderTarget( |
| 299 const LayerType* new_target) { | 302 const LayerType* new_target) { |
| 300 int last_index = stack_.size() - 1; | 303 int last_index = stack_.size() - 1; |
| 301 bool surface_will_be_at_top_after_pop = | 304 bool surface_will_be_at_top_after_pop = |
| 302 stack_.size() > 1 && stack_[last_index - 1].target == new_target; | 305 stack_.size() > 1 && stack_[last_index - 1].target == new_target; |
| 303 | 306 |
| 304 // We merge the screen occlusion from the current RenderSurfaceImpl subtree | 307 // We merge the screen occlusion from the current RenderSurfaceImpl subtree |
| 305 // out to its parent target RenderSurfaceImpl. The target occlusion can be | 308 // out to its parent target RenderSurfaceImpl. The target occlusion can be |
| 306 // merged out as well but needs to be transformed to the new target. | 309 // merged out as well but needs to be transformed to the new target. |
| 307 | 310 |
| 308 const LayerType* old_target = stack_[last_index].target; | 311 const LayerType* old_target = stack_[last_index].target; |
| 309 const RenderSurfaceType* old_surface = old_target->render_surface(); | 312 const typename LayerType::RenderSurfaceType* old_surface = |
| 313 old_target->render_surface(); |
| 310 | 314 |
| 311 Region old_occlusion_from_inside_target_in_new_target = | 315 Region old_occlusion_from_inside_target_in_new_target = |
| 312 TransformSurfaceOpaqueRegion<RenderSurfaceType>( | 316 TransformSurfaceOpaqueRegion<typename LayerType::RenderSurfaceType>( |
| 313 stack_[last_index].occlusion_from_inside_target, | 317 stack_[last_index].occlusion_from_inside_target, |
| 314 old_surface->is_clipped(), | 318 old_surface->is_clipped(), |
| 315 old_surface->clip_rect(), | 319 old_surface->clip_rect(), |
| 316 old_surface->draw_transform()); | 320 old_surface->draw_transform()); |
| 317 if (old_target->has_replica() && !old_target->replica_has_mask()) { | 321 if (old_target->has_replica() && !old_target->replica_has_mask()) { |
| 318 old_occlusion_from_inside_target_in_new_target.Union( | 322 old_occlusion_from_inside_target_in_new_target.Union( |
| 319 TransformSurfaceOpaqueRegion<RenderSurfaceType>( | 323 TransformSurfaceOpaqueRegion<typename LayerType::RenderSurfaceType>( |
| 320 stack_[last_index].occlusion_from_inside_target, | 324 stack_[last_index].occlusion_from_inside_target, |
| 321 old_surface->is_clipped(), | 325 old_surface->is_clipped(), |
| 322 old_surface->clip_rect(), | 326 old_surface->clip_rect(), |
| 323 old_surface->replica_draw_transform())); | 327 old_surface->replica_draw_transform())); |
| 324 } | 328 } |
| 325 | 329 |
| 326 Region old_occlusion_from_outside_target_in_new_target = | 330 Region old_occlusion_from_outside_target_in_new_target = |
| 327 TransformSurfaceOpaqueRegion<RenderSurfaceType>( | 331 TransformSurfaceOpaqueRegion<typename LayerType::RenderSurfaceType>( |
| 328 stack_[last_index].occlusion_from_outside_target, | 332 stack_[last_index].occlusion_from_outside_target, |
| 329 false, | 333 false, |
| 330 gfx::Rect(), | 334 gfx::Rect(), |
| 331 old_surface->draw_transform()); | 335 old_surface->draw_transform()); |
| 332 | 336 |
| 333 gfx::Rect unoccluded_surface_rect; | 337 gfx::Rect unoccluded_surface_rect; |
| 334 gfx::Rect unoccluded_replica_rect; | 338 gfx::Rect unoccluded_replica_rect; |
| 335 if (old_target->background_filters().HasFilterThatMovesPixels()) { | 339 if (old_target->background_filters().HasFilterThatMovesPixels()) { |
| 336 unoccluded_surface_rect = UnoccludedContributingSurfaceContentRect( | 340 unoccluded_surface_rect = UnoccludedContributingSurfaceContentRect( |
| 337 old_target, false, old_surface->content_rect()); | 341 old_target, false, old_surface->content_rect()); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 old_surface->replica_draw_transform(), | 390 old_surface->replica_draw_transform(), |
| 387 new_target, | 391 new_target, |
| 388 &stack_.back().occlusion_from_inside_target); | 392 &stack_.back().occlusion_from_inside_target); |
| 389 ReduceOcclusionBelowSurface(old_target, | 393 ReduceOcclusionBelowSurface(old_target, |
| 390 unoccluded_replica_rect, | 394 unoccluded_replica_rect, |
| 391 old_surface->replica_draw_transform(), | 395 old_surface->replica_draw_transform(), |
| 392 new_target, | 396 new_target, |
| 393 &stack_.back().occlusion_from_outside_target); | 397 &stack_.back().occlusion_from_outside_target); |
| 394 } | 398 } |
| 395 | 399 |
| 396 template <typename LayerType, typename RenderSurfaceType> | 400 template <typename LayerType> |
| 397 void OcclusionTrackerBase<LayerType, RenderSurfaceType>:: | 401 void OcclusionTracker<LayerType>::MarkOccludedBehindLayer( |
| 398 MarkOccludedBehindLayer(const LayerType* layer) { | 402 const LayerType* layer) { |
| 399 DCHECK(!stack_.empty()); | 403 DCHECK(!stack_.empty()); |
| 400 DCHECK_EQ(layer->render_target(), stack_.back().target); | 404 DCHECK_EQ(layer->render_target(), stack_.back().target); |
| 401 if (stack_.empty()) | 405 if (stack_.empty()) |
| 402 return; | 406 return; |
| 403 | 407 |
| 404 if (!layer->DrawsContent()) | 408 if (!layer->DrawsContent()) |
| 405 return; | 409 return; |
| 406 | 410 |
| 407 if (!LayerOpacityKnown(layer) || layer->draw_opacity() < 1) | 411 if (!LayerOpacityKnown(layer) || layer->draw_opacity() < 1) |
| 408 return; | 412 return; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 gfx::QuadF(transformed_rect), | 493 gfx::QuadF(transformed_rect), |
| 490 &clipped); | 494 &clipped); |
| 491 // TODO(danakj): Store the quad in the debug info instead of the bounding | 495 // TODO(danakj): Store the quad in the debug info instead of the bounding |
| 492 // box. | 496 // box. |
| 493 gfx::Rect screen_space_rect = | 497 gfx::Rect screen_space_rect = |
| 494 gfx::ToEnclosedRect(screen_space_quad.BoundingBox()); | 498 gfx::ToEnclosedRect(screen_space_quad.BoundingBox()); |
| 495 non_occluding_screen_space_rects_->push_back(screen_space_rect); | 499 non_occluding_screen_space_rects_->push_back(screen_space_rect); |
| 496 } | 500 } |
| 497 } | 501 } |
| 498 | 502 |
| 499 template <typename LayerType, typename RenderSurfaceType> | 503 template <typename LayerType> |
| 500 bool OcclusionTrackerBase<LayerType, RenderSurfaceType>::Occluded( | 504 bool OcclusionTracker<LayerType>::Occluded( |
| 501 const LayerType* render_target, | 505 const LayerType* render_target, |
| 502 const gfx::Rect& content_rect, | 506 const gfx::Rect& content_rect, |
| 503 const gfx::Transform& draw_transform, | 507 const gfx::Transform& draw_transform, |
| 504 bool impl_draw_transform_is_unknown) const { | 508 bool impl_draw_transform_is_unknown) const { |
| 505 DCHECK(!stack_.empty()); | 509 DCHECK(!stack_.empty()); |
| 506 if (stack_.empty()) | 510 if (stack_.empty()) |
| 507 return false; | 511 return false; |
| 508 if (content_rect.IsEmpty()) | 512 if (content_rect.IsEmpty()) |
| 509 return true; | 513 return true; |
| 510 if (impl_draw_transform_is_unknown) | 514 if (impl_draw_transform_is_unknown) |
| (...skipping 26 matching lines...) Expand all Loading... |
| 537 unoccluded_region_in_target_surface.bounds(); | 541 unoccluded_region_in_target_surface.bounds(); |
| 538 unoccluded_region_in_target_surface.Subtract( | 542 unoccluded_region_in_target_surface.Subtract( |
| 539 stack_.back().occlusion_from_outside_target); | 543 stack_.back().occlusion_from_outside_target); |
| 540 | 544 |
| 541 gfx::RectF unoccluded_rect_in_target_surface = | 545 gfx::RectF unoccluded_rect_in_target_surface = |
| 542 unoccluded_region_in_target_surface.bounds(); | 546 unoccluded_region_in_target_surface.bounds(); |
| 543 | 547 |
| 544 return unoccluded_rect_in_target_surface.IsEmpty(); | 548 return unoccluded_rect_in_target_surface.IsEmpty(); |
| 545 } | 549 } |
| 546 | 550 |
| 547 template <typename LayerType, typename RenderSurfaceType> | 551 template <typename LayerType> |
| 548 gfx::Rect OcclusionTrackerBase<LayerType, RenderSurfaceType>:: | 552 gfx::Rect OcclusionTracker<LayerType>::UnoccludedContentRect( |
| 549 UnoccludedContentRect( | 553 const LayerType* render_target, |
| 550 const LayerType* render_target, | 554 const gfx::Rect& content_rect, |
| 551 const gfx::Rect& content_rect, | 555 const gfx::Transform& draw_transform, |
| 552 const gfx::Transform& draw_transform, | 556 bool impl_draw_transform_is_unknown) const { |
| 553 bool impl_draw_transform_is_unknown) const { | |
| 554 DCHECK(!stack_.empty()); | 557 DCHECK(!stack_.empty()); |
| 555 if (stack_.empty()) | 558 if (stack_.empty()) |
| 556 return content_rect; | 559 return content_rect; |
| 557 if (content_rect.IsEmpty()) | 560 if (content_rect.IsEmpty()) |
| 558 return content_rect; | 561 return content_rect; |
| 559 if (impl_draw_transform_is_unknown) | 562 if (impl_draw_transform_is_unknown) |
| 560 return content_rect; | 563 return content_rect; |
| 561 | 564 |
| 562 // For tests with no render target. | 565 // For tests with no render target. |
| 563 if (!render_target) | 566 if (!render_target) |
| (...skipping 23 matching lines...) Expand all Loading... |
| 587 | 590 |
| 588 gfx::Rect unoccluded_rect_in_target_surface = | 591 gfx::Rect unoccluded_rect_in_target_surface = |
| 589 unoccluded_region_in_target_surface.bounds(); | 592 unoccluded_region_in_target_surface.bounds(); |
| 590 gfx::Rect unoccluded_rect = MathUtil::ProjectEnclosingClippedRect( | 593 gfx::Rect unoccluded_rect = MathUtil::ProjectEnclosingClippedRect( |
| 591 inverse_draw_transform, unoccluded_rect_in_target_surface); | 594 inverse_draw_transform, unoccluded_rect_in_target_surface); |
| 592 unoccluded_rect.Intersect(content_rect); | 595 unoccluded_rect.Intersect(content_rect); |
| 593 | 596 |
| 594 return unoccluded_rect; | 597 return unoccluded_rect; |
| 595 } | 598 } |
| 596 | 599 |
| 597 template <typename LayerType, typename RenderSurfaceType> | 600 template <typename LayerType> |
| 598 gfx::Rect OcclusionTrackerBase<LayerType, RenderSurfaceType>:: | 601 gfx::Rect OcclusionTracker<LayerType>::UnoccludedContributingSurfaceContentRect( |
| 599 UnoccludedContributingSurfaceContentRect( | 602 const LayerType* layer, |
| 600 const LayerType* layer, | 603 bool for_replica, |
| 601 bool for_replica, | 604 const gfx::Rect& content_rect) const { |
| 602 const gfx::Rect& content_rect) const { | |
| 603 DCHECK(!stack_.empty()); | 605 DCHECK(!stack_.empty()); |
| 604 // The layer is a contributing render_target so it should have a surface. | 606 // The layer is a contributing render_target so it should have a surface. |
| 605 DCHECK(layer->render_surface()); | 607 DCHECK(layer->render_surface()); |
| 606 // The layer is a contributing render_target so its target should be itself. | 608 // The layer is a contributing render_target so its target should be itself. |
| 607 DCHECK_EQ(layer->render_target(), layer); | 609 DCHECK_EQ(layer->render_target(), layer); |
| 608 // The layer should not be the root, else what is is contributing to? | 610 // The layer should not be the root, else what is is contributing to? |
| 609 DCHECK(layer->parent()); | 611 DCHECK(layer->parent()); |
| 610 // This should be called while the layer is still considered the current | 612 // This should be called while the layer is still considered the current |
| 611 // target in the occlusion tracker. | 613 // target in the occlusion tracker. |
| 612 DCHECK_EQ(layer, stack_.back().target); | 614 DCHECK_EQ(layer, stack_.back().target); |
| 613 | 615 |
| 614 if (content_rect.IsEmpty()) | 616 if (content_rect.IsEmpty()) |
| 615 return content_rect; | 617 return content_rect; |
| 616 | 618 |
| 617 const RenderSurfaceType* surface = layer->render_surface(); | 619 const typename LayerType::RenderSurfaceType* surface = |
| 620 layer->render_surface(); |
| 618 const LayerType* contributing_surface_render_target = | 621 const LayerType* contributing_surface_render_target = |
| 619 layer->parent()->render_target(); | 622 layer->parent()->render_target(); |
| 620 | 623 |
| 621 if (!SurfaceTransformsToTargetKnown(surface)) | 624 if (!SurfaceTransformsToTargetKnown(surface)) |
| 622 return content_rect; | 625 return content_rect; |
| 623 | 626 |
| 624 gfx::Transform draw_transform = | 627 gfx::Transform draw_transform = |
| 625 for_replica ? surface->replica_draw_transform() | 628 for_replica ? surface->replica_draw_transform() |
| 626 : surface->draw_transform(); | 629 : surface->draw_transform(); |
| 627 gfx::Transform inverse_draw_transform(gfx::Transform::kSkipInitialization); | 630 gfx::Transform inverse_draw_transform(gfx::Transform::kSkipInitialization); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 gfx::Rect unoccluded_rect_in_target_surface = | 662 gfx::Rect unoccluded_rect_in_target_surface = |
| 660 unoccluded_region_in_target_surface.bounds(); | 663 unoccluded_region_in_target_surface.bounds(); |
| 661 gfx::Rect unoccluded_rect = MathUtil::ProjectEnclosingClippedRect( | 664 gfx::Rect unoccluded_rect = MathUtil::ProjectEnclosingClippedRect( |
| 662 inverse_draw_transform, unoccluded_rect_in_target_surface); | 665 inverse_draw_transform, unoccluded_rect_in_target_surface); |
| 663 unoccluded_rect.Intersect(content_rect); | 666 unoccluded_rect.Intersect(content_rect); |
| 664 | 667 |
| 665 return unoccluded_rect; | 668 return unoccluded_rect; |
| 666 } | 669 } |
| 667 | 670 |
| 668 // Instantiate (and export) templates here for the linker. | 671 // Instantiate (and export) templates here for the linker. |
| 669 template class OcclusionTrackerBase<Layer, RenderSurface>; | 672 template class OcclusionTracker<Layer>; |
| 670 template class OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>; | 673 template class OcclusionTracker<LayerImpl>; |
| 671 | 674 |
| 672 } // namespace cc | 675 } // namespace cc |
| OLD | NEW |