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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "cc/base/filter_operations.h" | 12 #include "cc/base/filter_operations.h" |
13 #include "cc/base/math_util.h" | 13 #include "cc/base/math_util.h" |
14 #include "cc/layers/heads_up_display_layer_impl.h" | 14 #include "cc/layers/heads_up_display_layer_impl.h" |
15 #include "cc/layers/layer_impl.h" | 15 #include "cc/layers/layer_impl.h" |
16 #include "cc/layers/render_surface_impl.h" | 16 #include "cc/layers/render_surface_impl.h" |
17 #include "cc/trees/effect_node.h" | 17 #include "cc/trees/effect_node.h" |
18 #include "cc/trees/layer_tree_host_common.h" | 18 #include "cc/trees/layer_tree_host_common.h" |
19 #include "cc/trees/layer_tree_impl.h" | 19 #include "cc/trees/layer_tree_impl.h" |
20 #include "ui/gfx/geometry/rect_conversions.h" | 20 #include "ui/gfx/geometry/rect_conversions.h" |
21 | 21 |
22 namespace cc { | 22 namespace cc { |
23 | 23 |
24 std::unique_ptr<DamageTracker> DamageTracker::Create() { | 24 std::unique_ptr<DamageTracker> DamageTracker::Create() { |
25 return base::WrapUnique(new DamageTracker()); | 25 return base::WrapUnique(new DamageTracker()); |
26 } | 26 } |
27 | 27 |
28 DamageTracker::DamageTracker() | 28 DamageTracker::DamageTracker() |
29 : mailboxId_(0) {} | 29 : mailboxId_(0), |
30 has_property_change_on_contributing_render_surface_(false) {} | |
30 | 31 |
31 DamageTracker::~DamageTracker() {} | 32 DamageTracker::~DamageTracker() {} |
32 | 33 |
33 void DamageTracker::UpdateDamageTracking( | 34 void DamageTracker::UpdateDamageTracking( |
34 LayerTreeImpl* layer_tree_impl, | 35 LayerTreeImpl* layer_tree_impl, |
35 const RenderSurfaceList& render_surface_list) { | 36 const RenderSurfaceList& render_surface_list) { |
36 // | 37 // |
37 // This function computes the "damage rect" of each target surface, and | 38 // This function computes the "damage rect" of each target surface, and |
38 // updates the state that is used to correctly track damage across frames. The | 39 // updates the state that is used to correctly track damage across frames. The |
39 // damage rect is the region of the surface that may have changed and needs to | 40 // damage rect is the region of the surface that may have changed and needs to |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
251 !target_surface_mask_layer->update_rect().IsEmpty()) { | 252 !target_surface_mask_layer->update_rect().IsEmpty()) { |
252 damage.Union(gfx::Rect(target_surface_mask_layer->bounds())); | 253 damage.Union(gfx::Rect(target_surface_mask_layer->bounds())); |
253 } | 254 } |
254 | 255 |
255 return damage; | 256 return damage; |
256 } | 257 } |
257 | 258 |
258 void DamageTracker::PrepareForUpdate() { | 259 void DamageTracker::PrepareForUpdate() { |
259 mailboxId_++; | 260 mailboxId_++; |
260 damage_for_this_update_ = DamageAccumulator(); | 261 damage_for_this_update_ = DamageAccumulator(); |
262 has_property_change_on_contributing_render_surface_ = false; | |
261 } | 263 } |
262 | 264 |
263 DamageTracker::DamageAccumulator DamageTracker::TrackDamageFromLeftoverRects() { | 265 DamageTracker::DamageAccumulator DamageTracker::TrackDamageFromLeftoverRects() { |
264 // After computing damage for all active layers, any leftover items in the | 266 // After computing damage for all active layers, any leftover items in the |
265 // current rect history correspond to layers/surfaces that no longer exist. | 267 // current rect history correspond to layers/surfaces that no longer exist. |
266 // So, these regions are now exposed on the target surface. | 268 // So, these regions are now exposed on the target surface. |
267 | 269 |
268 DamageAccumulator damage; | 270 DamageAccumulator damage; |
269 SortedRectMapForLayers::iterator layer_cur_pos = | 271 SortedRectMapForLayers::iterator layer_cur_pos = |
270 rect_history_for_layers_.begin(); | 272 rect_history_for_layers_.begin(); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
414 | 416 |
415 bool surface_is_new = false; | 417 bool surface_is_new = false; |
416 SurfaceRectMapData& data = | 418 SurfaceRectMapData& data = |
417 RectDataForSurface(render_surface->id(), &surface_is_new); | 419 RectDataForSurface(render_surface->id(), &surface_is_new); |
418 gfx::Rect old_surface_rect = data.rect_; | 420 gfx::Rect old_surface_rect = data.rect_; |
419 | 421 |
420 gfx::Rect surface_rect_in_target_space = | 422 gfx::Rect surface_rect_in_target_space = |
421 gfx::ToEnclosingRect(render_surface->DrawableContentRect()); | 423 gfx::ToEnclosingRect(render_surface->DrawableContentRect()); |
422 data.Update(surface_rect_in_target_space, mailboxId_); | 424 data.Update(surface_rect_in_target_space, mailboxId_); |
423 | 425 |
426 has_property_change_on_contributing_render_surface_ |= | |
weiliangc
2017/06/07 21:19:01
The flag for not able to use the texture should be
wutao
2017/06/09 02:31:32
This is a very good point.
Do you mean damage_for_
| |
427 render_surface->SurfacePropertyChanged() || | |
weiliangc
2017/06/07 21:19:01
SurfacePropertyChanged() seems to be ok for reusin
wutao
2017/06/09 02:31:32
Acknowledged.
| |
428 render_surface->ContributingRenderSurfacePropertyChanged(); | |
429 | |
424 if (surface_is_new || render_surface->SurfacePropertyChanged()) { | 430 if (surface_is_new || render_surface->SurfacePropertyChanged()) { |
425 // The entire surface contributes damage. | 431 // The entire surface contributes damage. |
426 damage_for_this_update_.Union(surface_rect_in_target_space); | 432 damage_for_this_update_.Union(surface_rect_in_target_space); |
427 | 433 |
428 // The surface's old region is now exposed on the target surface, too. | 434 // The surface's old region is now exposed on the target surface, too. |
429 damage_for_this_update_.Union(old_surface_rect); | 435 damage_for_this_update_.Union(old_surface_rect); |
430 } else { | 436 } else { |
431 // Only the surface's damage_rect will damage the target surface. | 437 // Only the surface's damage_rect will damage the target surface. |
432 gfx::Rect damage_rect_in_local_space; | 438 gfx::Rect damage_rect_in_local_space; |
433 bool is_valid_rect = render_surface->damage_tracker()->GetDamageRectIfValid( | 439 bool is_valid_rect = render_surface->damage_tracker()->GetDamageRectIfValid( |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
472 } | 478 } |
473 | 479 |
474 rect->set_x(x_); | 480 rect->set_x(x_); |
475 rect->set_y(y_); | 481 rect->set_y(y_); |
476 rect->set_width(width.ValueOrDie()); | 482 rect->set_width(width.ValueOrDie()); |
477 rect->set_height(height.ValueOrDie()); | 483 rect->set_height(height.ValueOrDie()); |
478 return true; | 484 return true; |
479 } | 485 } |
480 | 486 |
481 } // namespace cc | 487 } // namespace cc |
OLD | NEW |