| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 MathUtil::MapEnclosedRectWith2dAxisAlignedTransform(transform, | 111 MathUtil::MapEnclosedRectWith2dAxisAlignedTransform(transform, |
| 112 region.GetRect(i)); | 112 region.GetRect(i)); |
| 113 if (have_clip_rect) | 113 if (have_clip_rect) |
| 114 transformed_rect.Intersect(clip_rect_in_new_target); | 114 transformed_rect.Intersect(clip_rect_in_new_target); |
| 115 transformed_region.Union(transformed_rect); | 115 transformed_region.Union(transformed_rect); |
| 116 } | 116 } |
| 117 return transformed_region; | 117 return transformed_region; |
| 118 } | 118 } |
| 119 | 119 |
| 120 void OcclusionTracker::EnterRenderTarget(const LayerImpl* new_target) { | 120 void OcclusionTracker::EnterRenderTarget(const LayerImpl* new_target) { |
| 121 DCHECK(new_target->has_render_surface()); | 121 DCHECK(new_target->GetRenderSurface()); |
| 122 RenderSurfaceImpl* new_target_surface = new_target->render_surface(); | 122 RenderSurfaceImpl* new_target_surface = new_target->GetRenderSurface(); |
| 123 if (!stack_.empty() && stack_.back().target == new_target_surface) | 123 if (!stack_.empty() && stack_.back().target == new_target_surface) |
| 124 return; | 124 return; |
| 125 | 125 |
| 126 const RenderSurfaceImpl* old_target_surface = NULL; | 126 const RenderSurfaceImpl* old_target_surface = NULL; |
| 127 const RenderSurfaceImpl* old_occlusion_immune_ancestor = NULL; | 127 const RenderSurfaceImpl* old_occlusion_immune_ancestor = NULL; |
| 128 if (!stack_.empty()) { | 128 if (!stack_.empty()) { |
| 129 old_target_surface = stack_.back().target; | 129 old_target_surface = stack_.back().target; |
| 130 old_occlusion_immune_ancestor = | 130 old_occlusion_immune_ancestor = |
| 131 old_target_surface->nearest_occlusion_immune_ancestor(); | 131 old_target_surface->nearest_occlusion_immune_ancestor(); |
| 132 } | 132 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 stack_[last_index].occlusion_from_outside_target.Union( | 174 stack_[last_index].occlusion_from_outside_target.Union( |
| 175 TransformSurfaceOpaqueRegion( | 175 TransformSurfaceOpaqueRegion( |
| 176 stack_[last_index - 1].occlusion_from_inside_target, false, | 176 stack_[last_index - 1].occlusion_from_inside_target, false, |
| 177 gfx::Rect(), old_target_to_new_target_transform)); | 177 gfx::Rect(), old_target_to_new_target_transform)); |
| 178 } | 178 } |
| 179 | 179 |
| 180 void OcclusionTracker::FinishedRenderTarget(const LayerImpl* finished_target) { | 180 void OcclusionTracker::FinishedRenderTarget(const LayerImpl* finished_target) { |
| 181 // Make sure we know about the target surface. | 181 // Make sure we know about the target surface. |
| 182 EnterRenderTarget(finished_target); | 182 EnterRenderTarget(finished_target); |
| 183 | 183 |
| 184 RenderSurfaceImpl* surface = finished_target->render_surface(); | 184 RenderSurfaceImpl* surface = finished_target->GetRenderSurface(); |
| 185 | 185 |
| 186 // Readbacks always happen on render targets so we only need to check | 186 // Readbacks always happen on render targets so we only need to check |
| 187 // for readbacks here. | 187 // for readbacks here. |
| 188 bool target_is_only_for_copy_request = | 188 bool target_is_only_for_copy_request = |
| 189 surface->HasCopyRequest() && finished_target->IsHidden(); | 189 surface->HasCopyRequest() && finished_target->IsHidden(); |
| 190 | 190 |
| 191 // If the occlusion within the surface can not be applied to things outside of | 191 // If the occlusion within the surface can not be applied to things outside of |
| 192 // the surface's subtree, then clear the occlusion here so it won't be used. | 192 // the surface's subtree, then clear the occlusion here so it won't be used. |
| 193 if (surface->MaskLayer() || surface->draw_opacity() < 1 || | 193 if (surface->MaskLayer() || surface->draw_opacity() < 1 || |
| 194 !surface->UsesDefaultBlendMode() || target_is_only_for_copy_request || | 194 !surface->UsesDefaultBlendMode() || target_is_only_for_copy_request || |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 | 248 |
| 249 occlusion_rect.Inset(shrink_left, shrink_top, shrink_right, shrink_bottom); | 249 occlusion_rect.Inset(shrink_left, shrink_top, shrink_right, shrink_bottom); |
| 250 | 250 |
| 251 occlusion_from_inside_target->Union(occlusion_rect); | 251 occlusion_from_inside_target->Union(occlusion_rect); |
| 252 } | 252 } |
| 253 } | 253 } |
| 254 | 254 |
| 255 void OcclusionTracker::LeaveToRenderTarget(const LayerImpl* new_target) { | 255 void OcclusionTracker::LeaveToRenderTarget(const LayerImpl* new_target) { |
| 256 DCHECK(!stack_.empty()); | 256 DCHECK(!stack_.empty()); |
| 257 size_t last_index = stack_.size() - 1; | 257 size_t last_index = stack_.size() - 1; |
| 258 DCHECK(new_target->has_render_surface()); | 258 DCHECK(new_target->GetRenderSurface()); |
| 259 RenderSurfaceImpl* new_surface = new_target->render_surface(); | 259 RenderSurfaceImpl* new_surface = new_target->GetRenderSurface(); |
| 260 bool surface_will_be_at_top_after_pop = | 260 bool surface_will_be_at_top_after_pop = |
| 261 stack_.size() > 1 && stack_[last_index - 1].target == new_surface; | 261 stack_.size() > 1 && stack_[last_index - 1].target == new_surface; |
| 262 | 262 |
| 263 // We merge the screen occlusion from the current RenderSurfaceImpl subtree | 263 // We merge the screen occlusion from the current RenderSurfaceImpl subtree |
| 264 // out to its parent target RenderSurfaceImpl. The target occlusion can be | 264 // out to its parent target RenderSurfaceImpl. The target occlusion can be |
| 265 // merged out as well but needs to be transformed to the new target. | 265 // merged out as well but needs to be transformed to the new target. |
| 266 | 266 |
| 267 const RenderSurfaceImpl* old_surface = stack_[last_index].target; | 267 const RenderSurfaceImpl* old_surface = stack_[last_index].target; |
| 268 | 268 |
| 269 SimpleEnclosedRegion old_occlusion_from_inside_target_in_new_target = | 269 SimpleEnclosedRegion old_occlusion_from_inside_target_in_new_target = |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 DCHECK(layer_tree->RootRenderSurface() == stack_.back().target); | 370 DCHECK(layer_tree->RootRenderSurface() == stack_.back().target); |
| 371 const SimpleEnclosedRegion& occluded = | 371 const SimpleEnclosedRegion& occluded = |
| 372 stack_.back().occlusion_from_inside_target; | 372 stack_.back().occlusion_from_inside_target; |
| 373 Region visible_region(screen_space_clip_rect_); | 373 Region visible_region(screen_space_clip_rect_); |
| 374 for (size_t i = 0; i < occluded.GetRegionComplexity(); ++i) | 374 for (size_t i = 0; i < occluded.GetRegionComplexity(); ++i) |
| 375 visible_region.Subtract(occluded.GetRect(i)); | 375 visible_region.Subtract(occluded.GetRect(i)); |
| 376 return visible_region; | 376 return visible_region; |
| 377 } | 377 } |
| 378 | 378 |
| 379 } // namespace cc | 379 } // namespace cc |
| OLD | NEW |