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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "CCDamageTracker.h" | 7 #include "CCDamageTracker.h" |
8 | 8 |
9 #include "CCLayerImpl.h" | 9 #include "CCLayerImpl.h" |
10 #include "CCLayerTreeHostCommon.h" | 10 #include "CCLayerTreeHostCommon.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 { | 44 { |
45 FloatRect expandedDamageRect = damageRect; | 45 FloatRect expandedDamageRect = damageRect; |
46 expandRectWithFilters(expandedDamageRect, filters); | 46 expandRectWithFilters(expandedDamageRect, filters); |
47 FloatRect filterRect = preFilterRect; | 47 FloatRect filterRect = preFilterRect; |
48 expandRectWithFilters(filterRect, filters); | 48 expandRectWithFilters(filterRect, filters); |
49 | 49 |
50 expandedDamageRect.intersect(filterRect); | 50 expandedDamageRect.intersect(filterRect); |
51 damageRect.unite(expandedDamageRect); | 51 damageRect.unite(expandedDamageRect); |
52 } | 52 } |
53 | 53 |
54 void DamageTracker::updateDamageTrackingState(const std::vector<LayerImpl*>& lay
erList, int targetSurfaceLayerID, bool targetSurfacePropertyChangedOnlyFromDesce
ndant, const IntRect& targetSurfaceContentRect, LayerImpl* targetSurfaceMaskLaye
r, const WebKit::WebFilterOperations& filters) | 54 void DamageTracker::updateDamageTrackingState(const std::vector<LayerImpl*>& lay
erList, int targetSurfaceLayerID, bool targetSurfacePropertyChangedOnlyFromDesce
ndant, const IntRect& targetSurfaceContentRect, LayerImpl* targetSurfaceMaskLaye
r, const WebKit::WebFilterOperations& filters, SkImageFilter* filter) |
55 { | 55 { |
56 // | 56 // |
57 // This function computes the "damage rect" of a target surface, and updates
the state | 57 // This function computes the "damage rect" of a target surface, and updates
the state |
58 // that is used to correctly track damage across frames. The damage rect is
the region | 58 // that is used to correctly track damage across frames. The damage rect is
the region |
59 // of the surface that may have changed and needs to be redrawn. This can be
used to | 59 // of the surface that may have changed and needs to be redrawn. This can be
used to |
60 // scissor what is actually drawn, to save GPU computation and bandwidth. | 60 // scissor what is actually drawn, to save GPU computation and bandwidth. |
61 // | 61 // |
62 // The surface's damage rect is computed as the union of all possible change
s that | 62 // The surface's damage rect is computed as the union of all possible change
s that |
63 // have happened to the surface since the last frame was drawn. This include
s: | 63 // have happened to the surface since the last frame was drawn. This include
s: |
64 // - any changes for existing layers/surfaces that contribute to the targe
t surface | 64 // - any changes for existing layers/surfaces that contribute to the targe
t surface |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 127 |
128 if (m_forceFullDamageNextUpdate || targetSurfacePropertyChangedOnlyFromDesce
ndant) { | 128 if (m_forceFullDamageNextUpdate || targetSurfacePropertyChangedOnlyFromDesce
ndant) { |
129 damageRectForThisUpdate = targetSurfaceContentRect; | 129 damageRectForThisUpdate = targetSurfaceContentRect; |
130 m_forceFullDamageNextUpdate = false; | 130 m_forceFullDamageNextUpdate = false; |
131 } else { | 131 } else { |
132 // FIXME: can we clamp this damage to the surface's content rect? (affec
ts performance, but not correctness) | 132 // FIXME: can we clamp this damage to the surface's content rect? (affec
ts performance, but not correctness) |
133 damageRectForThisUpdate = damageFromActiveLayers; | 133 damageRectForThisUpdate = damageFromActiveLayers; |
134 damageRectForThisUpdate.uniteIfNonZero(damageFromSurfaceMask); | 134 damageRectForThisUpdate.uniteIfNonZero(damageFromSurfaceMask); |
135 damageRectForThisUpdate.uniteIfNonZero(damageFromLeftoverRects); | 135 damageRectForThisUpdate.uniteIfNonZero(damageFromLeftoverRects); |
136 | 136 |
137 if (filters.hasFilterThatMovesPixels()) | 137 if (filters.hasFilterThatMovesPixels()) { |
138 expandRectWithFilters(damageRectForThisUpdate, filters); | 138 expandRectWithFilters(damageRectForThisUpdate, filters); |
| 139 } else if (filter) { |
| 140 // TODO(senorblanco): Once SkImageFilter reports its outsets, use |
| 141 // those here to limit damage. |
| 142 damageRectForThisUpdate = targetSurfaceContentRect; |
| 143 } |
139 } | 144 } |
140 | 145 |
141 // Damage accumulates until we are notified that we actually did draw on tha
t frame. | 146 // Damage accumulates until we are notified that we actually did draw on tha
t frame. |
142 m_currentDamageRect.uniteIfNonZero(damageRectForThisUpdate); | 147 m_currentDamageRect.uniteIfNonZero(damageRectForThisUpdate); |
143 | 148 |
144 // The next history map becomes the current map for the next frame. Note thi
s must | 149 // The next history map becomes the current map for the next frame. Note thi
s must |
145 // happen every frame to correctly track changes, even if damage accumulates
over | 150 // happen every frame to correctly track changes, even if damage accumulates
over |
146 // multiple frames before actually being drawn. | 151 // multiple frames before actually being drawn. |
147 swap(m_currentRectHistory, m_nextRectHistory); | 152 swap(m_currentRectHistory, m_nextRectHistory); |
148 } | 153 } |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 // If the layer has a background filter, this may cause pixels in our surfac
e to be expanded, so we will need to expand any damage | 342 // If the layer has a background filter, this may cause pixels in our surfac
e to be expanded, so we will need to expand any damage |
338 // at or below this layer. We expand the damage from this layer too, as we n
eed to readback those pixels from the surface with only | 343 // at or below this layer. We expand the damage from this layer too, as we n
eed to readback those pixels from the surface with only |
339 // the contents of layers below this one in them. This means we need to redr
aw any pixels in the surface being used for the blur in | 344 // the contents of layers below this one in them. This means we need to redr
aw any pixels in the surface being used for the blur in |
340 // this layer this frame. | 345 // this layer this frame. |
341 if (layer->backgroundFilters().hasFilterThatMovesPixels()) | 346 if (layer->backgroundFilters().hasFilterThatMovesPixels()) |
342 expandDamageRectInsideRectWithFilters(targetDamageRect, surfaceRectInTar
getSpace, layer->backgroundFilters()); | 347 expandDamageRectInsideRectWithFilters(targetDamageRect, surfaceRectInTar
getSpace, layer->backgroundFilters()); |
343 } | 348 } |
344 | 349 |
345 } // namespace cc | 350 } // namespace cc |
346 | 351 |
OLD | NEW |