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" |
11 #include "cc/layers/layer_impl.h" | 11 #include "cc/layers/layer_impl.h" |
12 #include "cc/layers/render_surface_impl.h" | 12 #include "cc/layers/render_surface_impl.h" |
13 #include "cc/output/filter_operations.h" | 13 #include "cc/output/filter_operations.h" |
14 #include "cc/trees/layer_tree_host_common.h" | 14 #include "cc/trees/layer_tree_host_common.h" |
15 #include "cc/trees/layer_tree_impl.h" | 15 #include "cc/trees/layer_tree_impl.h" |
16 #include "ui/gfx/geometry/rect_conversions.h" | 16 #include "ui/gfx/geometry/rect_conversions.h" |
| 17 #include "ui/gfx/geometry/size_conversions.h" |
17 | 18 |
18 namespace cc { | 19 namespace cc { |
19 | 20 |
20 scoped_ptr<DamageTracker> DamageTracker::Create() { | 21 scoped_ptr<DamageTracker> DamageTracker::Create() { |
21 return make_scoped_ptr(new DamageTracker()); | 22 return make_scoped_ptr(new DamageTracker()); |
22 } | 23 } |
23 | 24 |
24 DamageTracker::DamageTracker() | 25 DamageTracker::DamageTracker() |
25 : mailboxId_(0) {} | 26 : mailboxId_(0) {} |
26 | 27 |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 gfx::Rect damage_rect; | 203 gfx::Rect damage_rect; |
203 | 204 |
204 if (!target_surface_mask_layer) | 205 if (!target_surface_mask_layer) |
205 return damage_rect; | 206 return damage_rect; |
206 | 207 |
207 // Currently, if there is any change to the mask, we choose to damage the | 208 // Currently, if there is any change to the mask, we choose to damage the |
208 // entire surface. This could potentially be optimized later, but it is not | 209 // entire surface. This could potentially be optimized later, but it is not |
209 // expected to be a common case. | 210 // expected to be a common case. |
210 if (target_surface_mask_layer->LayerPropertyChanged() || | 211 if (target_surface_mask_layer->LayerPropertyChanged() || |
211 !target_surface_mask_layer->update_rect().IsEmpty()) { | 212 !target_surface_mask_layer->update_rect().IsEmpty()) { |
212 damage_rect = gfx::Rect(target_surface_mask_layer->bounds()); | 213 damage_rect = gfx::Rect( |
| 214 gfx::ToCeiledSize(target_surface_mask_layer->bounds())); |
213 } | 215 } |
214 | 216 |
215 return damage_rect; | 217 return damage_rect; |
216 } | 218 } |
217 | 219 |
218 void DamageTracker::PrepareRectHistoryForUpdate() { | 220 void DamageTracker::PrepareRectHistoryForUpdate() { |
219 mailboxId_++; | 221 mailboxId_++; |
220 } | 222 } |
221 | 223 |
222 gfx::Rect DamageTracker::TrackDamageFromLeftoverRects() { | 224 gfx::Rect DamageTracker::TrackDamageFromLeftoverRects() { |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 if (layer->replica_layer() && layer->replica_layer()->mask_layer()) { | 373 if (layer->replica_layer() && layer->replica_layer()->mask_layer()) { |
372 LayerImpl* replica_mask_layer = layer->replica_layer()->mask_layer(); | 374 LayerImpl* replica_mask_layer = layer->replica_layer()->mask_layer(); |
373 | 375 |
374 bool replica_is_new = false; | 376 bool replica_is_new = false; |
375 RectMapData& data = | 377 RectMapData& data = |
376 RectDataForLayer(replica_mask_layer->id(), &replica_is_new); | 378 RectDataForLayer(replica_mask_layer->id(), &replica_is_new); |
377 | 379 |
378 const gfx::Transform& replica_draw_transform = | 380 const gfx::Transform& replica_draw_transform = |
379 render_surface->replica_draw_transform(); | 381 render_surface->replica_draw_transform(); |
380 gfx::Rect replica_mask_layer_rect = MathUtil::MapEnclosingClippedRect( | 382 gfx::Rect replica_mask_layer_rect = MathUtil::MapEnclosingClippedRect( |
381 replica_draw_transform, gfx::Rect(replica_mask_layer->bounds())); | 383 replica_draw_transform, |
| 384 gfx::Rect(gfx::ToCeiledSize(replica_mask_layer->bounds()))); |
382 data.Update(replica_mask_layer_rect, mailboxId_); | 385 data.Update(replica_mask_layer_rect, mailboxId_); |
383 | 386 |
384 // In the current implementation, a change in the replica mask damages the | 387 // In the current implementation, a change in the replica mask damages the |
385 // entire replica region. | 388 // entire replica region. |
386 if (replica_is_new || | 389 if (replica_is_new || |
387 replica_mask_layer->LayerPropertyChanged() || | 390 replica_mask_layer->LayerPropertyChanged() || |
388 !replica_mask_layer->update_rect().IsEmpty()) | 391 !replica_mask_layer->update_rect().IsEmpty()) |
389 target_damage_rect->Union(replica_mask_layer_rect); | 392 target_damage_rect->Union(replica_mask_layer_rect); |
390 } | 393 } |
391 | 394 |
392 // If the layer has a background filter, this may cause pixels in our surface | 395 // If the layer has a background filter, this may cause pixels in our surface |
393 // to be expanded, so we will need to expand any damage at or below this | 396 // to be expanded, so we will need to expand any damage at or below this |
394 // layer. We expand the damage from this layer too, as we need to readback | 397 // layer. We expand the damage from this layer too, as we need to readback |
395 // those pixels from the surface with only the contents of layers below this | 398 // those pixels from the surface with only the contents of layers below this |
396 // one in them. This means we need to redraw any pixels in the surface being | 399 // one in them. This means we need to redraw any pixels in the surface being |
397 // used for the blur in this layer this frame. | 400 // used for the blur in this layer this frame. |
398 if (layer->background_filters().HasFilterThatMovesPixels()) { | 401 if (layer->background_filters().HasFilterThatMovesPixels()) { |
399 ExpandDamageRectInsideRectWithFilters(target_damage_rect, | 402 ExpandDamageRectInsideRectWithFilters(target_damage_rect, |
400 surface_rect_in_target_space, | 403 surface_rect_in_target_space, |
401 layer->background_filters()); | 404 layer->background_filters()); |
402 } | 405 } |
403 } | 406 } |
404 | 407 |
405 } // namespace cc | 408 } // namespace cc |
OLD | NEW |