OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/damage_tracker.h" | 5 #include "cc/trees/damage_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/layers/heads_up_display_layer_impl.h" | 10 #include "cc/layers/heads_up_display_layer_impl.h" |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 // ancestor surface, ExtendDamageForRenderSurface() must be called instead. | 280 // ancestor surface, ExtendDamageForRenderSurface() must be called instead. |
281 | 281 |
282 bool layer_is_new = false; | 282 bool layer_is_new = false; |
283 RectMapData& data = RectDataForLayer(layer->id(), &layer_is_new); | 283 RectMapData& data = RectDataForLayer(layer->id(), &layer_is_new); |
284 gfx::Rect old_rect_in_target_space = data.rect_; | 284 gfx::Rect old_rect_in_target_space = data.rect_; |
285 | 285 |
286 gfx::Rect rect_in_target_space = MathUtil::MapEnclosingClippedRect( | 286 gfx::Rect rect_in_target_space = MathUtil::MapEnclosingClippedRect( |
287 layer->draw_transform(), gfx::Rect(layer->content_bounds())); | 287 layer->draw_transform(), gfx::Rect(layer->content_bounds())); |
288 data.Update(rect_in_target_space, mailboxId_); | 288 data.Update(rect_in_target_space, mailboxId_); |
289 | 289 |
| 290 gfx::RectF damage_rect = |
| 291 gfx::UnionRects(layer->update_rect(), layer->damage_rect()); |
| 292 |
290 if (layer_is_new || layer->LayerPropertyChanged()) { | 293 if (layer_is_new || layer->LayerPropertyChanged()) { |
291 // If a layer is new or has changed, then its entire layer rect affects the | 294 // If a layer is new or has changed, then its entire layer rect affects the |
292 // target surface. | 295 // target surface. |
293 target_damage_rect->Union(rect_in_target_space); | 296 target_damage_rect->Union(rect_in_target_space); |
294 | 297 |
295 // The layer's old region is now exposed on the target surface, too. | 298 // The layer's old region is now exposed on the target surface, too. |
296 // Note old_rect_in_target_space is already in target space. | 299 // Note old_rect_in_target_space is already in target space. |
297 target_damage_rect->Union(old_rect_in_target_space); | 300 target_damage_rect->Union(old_rect_in_target_space); |
298 } else if (!layer->update_rect().IsEmpty()) { | 301 } else if (!damage_rect.IsEmpty()) { |
299 // If the layer properties haven't changed, then the the target surface is | 302 // If the layer properties haven't changed, then the the target surface is |
300 // only affected by the layer's update area, which could be empty. | 303 // only affected by the layer's damaged area, which could be empty. |
301 gfx::Rect update_content_rect = | 304 gfx::Rect damage_content_rect = layer->LayerRectToContentRect(damage_rect); |
302 layer->LayerRectToContentRect(layer->update_rect()); | 305 gfx::Rect damage_rect_in_target_space = MathUtil::MapEnclosingClippedRect( |
303 gfx::Rect update_rect_in_target_space = MathUtil::MapEnclosingClippedRect( | 306 layer->draw_transform(), damage_content_rect); |
304 layer->draw_transform(), update_content_rect); | 307 target_damage_rect->Union(damage_rect_in_target_space); |
305 target_damage_rect->Union(update_rect_in_target_space); | |
306 } | 308 } |
307 } | 309 } |
308 | 310 |
309 void DamageTracker::ExtendDamageForRenderSurface( | 311 void DamageTracker::ExtendDamageForRenderSurface( |
310 LayerImpl* layer, | 312 LayerImpl* layer, |
311 gfx::Rect* target_damage_rect) { | 313 gfx::Rect* target_damage_rect) { |
312 // There are two ways a "descendant surface" can damage regions of the "target | 314 // There are two ways a "descendant surface" can damage regions of the "target |
313 // surface": | 315 // surface": |
314 // 1. Property change: | 316 // 1. Property change: |
315 // - a surface's geometry can change because of | 317 // - a surface's geometry can change because of |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 // one in them. This means we need to redraw any pixels in the surface being | 396 // one in them. This means we need to redraw any pixels in the surface being |
395 // used for the blur in this layer this frame. | 397 // used for the blur in this layer this frame. |
396 if (layer->background_filters().HasFilterThatMovesPixels()) { | 398 if (layer->background_filters().HasFilterThatMovesPixels()) { |
397 ExpandDamageRectInsideRectWithFilters(target_damage_rect, | 399 ExpandDamageRectInsideRectWithFilters(target_damage_rect, |
398 surface_rect_in_target_space, | 400 surface_rect_in_target_space, |
399 layer->background_filters()); | 401 layer->background_filters()); |
400 } | 402 } |
401 } | 403 } |
402 | 404 |
403 } // namespace cc | 405 } // namespace cc |
OLD | NEW |