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 "cc/damage_tracker.h" | 7 #include "cc/damage_tracker.h" |
8 | 8 |
9 #include "cc/layer_impl.h" | 9 #include "cc/layer_impl.h" |
10 #include "cc/layer_tree_host_common.h" | 10 #include "cc/layer_tree_host_common.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 : m_forceFullDamageNextUpdate(false), | 25 : m_forceFullDamageNextUpdate(false), |
26 m_currentRectHistory(new RectMap), | 26 m_currentRectHistory(new RectMap), |
27 m_nextRectHistory(new RectMap) | 27 m_nextRectHistory(new RectMap) |
28 { | 28 { |
29 } | 29 } |
30 | 30 |
31 DamageTracker::~DamageTracker() | 31 DamageTracker::~DamageTracker() |
32 { | 32 { |
33 } | 33 } |
34 | 34 |
35 static inline void expandRectWithFilters(FloatRect& rect, const WebKit::WebFilte
rOperations& filters) | 35 static inline void expandRectWithFilters(gfx::RectF& rect, const WebKit::WebFilt
erOperations& filters) |
36 { | 36 { |
37 int top, right, bottom, left; | 37 int top, right, bottom, left; |
38 filters.getOutsets(top, right, bottom, left); | 38 filters.getOutsets(top, right, bottom, left); |
39 rect.move(-left, -top); | 39 rect.Inset(-left, -top, -right, -bottom); |
40 rect.expand(left + right, top + bottom); | |
41 } | 40 } |
42 | 41 |
43 static inline void expandDamageRectInsideRectWithFilters(FloatRect& damageRect,
const FloatRect& preFilterRect, const WebKit::WebFilterOperations& filters) | 42 static inline void expandDamageRectInsideRectWithFilters(gfx::RectF& damageRect,
const gfx::RectF& preFilterRect, const WebKit::WebFilterOperations& filters) |
44 { | 43 { |
45 FloatRect expandedDamageRect = damageRect; | 44 gfx::RectF expandedDamageRect = damageRect; |
46 expandRectWithFilters(expandedDamageRect, filters); | 45 expandRectWithFilters(expandedDamageRect, filters); |
47 FloatRect filterRect = preFilterRect; | 46 gfx::RectF filterRect = preFilterRect; |
48 expandRectWithFilters(filterRect, filters); | 47 expandRectWithFilters(filterRect, filters); |
49 | 48 |
50 expandedDamageRect.intersect(filterRect); | 49 expandedDamageRect.Intersect(filterRect); |
51 damageRect.unite(expandedDamageRect); | 50 damageRect.Union(expandedDamageRect); |
52 } | 51 } |
53 | 52 |
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) | 53 void DamageTracker::updateDamageTrackingState(const std::vector<LayerImpl*>& lay
erList, int targetSurfaceLayerID, bool targetSurfacePropertyChangedOnlyFromDesce
ndant, const gfx::Rect& targetSurfaceContentRect, LayerImpl* targetSurfaceMaskLa
yer, const WebKit::WebFilterOperations& filters, SkImageFilter* filter) |
55 { | 54 { |
56 // | 55 // |
57 // This function computes the "damage rect" of a target surface, and updates
the state | 56 // 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 | 57 // 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 | 58 // 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. | 59 // scissor what is actually drawn, to save GPU computation and bandwidth. |
61 // | 60 // |
62 // The surface's damage rect is computed as the union of all possible change
s that | 61 // 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: | 62 // 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 | 63 // - any changes for existing layers/surfaces that contribute to the targe
t surface |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 // 2. The "next" map starts out empty, and as the algorithm progresses,
every | 111 // 2. The "next" map starts out empty, and as the algorithm progresses,
every |
113 // layer/surface that contributes to the surface is added to the map
. | 112 // layer/surface that contributes to the surface is added to the map
. |
114 // | 113 // |
115 // 3. After the damage rect is computed, the two maps are swapped, so t
hat the | 114 // 3. After the damage rect is computed, the two maps are swapped, so t
hat the |
116 // damage tracker is ready for the next frame. | 115 // damage tracker is ready for the next frame. |
117 // | 116 // |
118 | 117 |
119 // These functions cannot be bypassed with early-exits, even if we know what
the | 118 // These functions cannot be bypassed with early-exits, even if we know what
the |
120 // damage will be for this frame, because we need to update the damage track
er state | 119 // damage will be for this frame, because we need to update the damage track
er state |
121 // to correctly track the next frame. | 120 // to correctly track the next frame. |
122 FloatRect damageFromActiveLayers = trackDamageFromActiveLayers(layerList, ta
rgetSurfaceLayerID); | 121 gfx::RectF damageFromActiveLayers = trackDamageFromActiveLayers(layerList, t
argetSurfaceLayerID); |
123 FloatRect damageFromSurfaceMask = trackDamageFromSurfaceMask(targetSurfaceMa
skLayer); | 122 gfx::RectF damageFromSurfaceMask = trackDamageFromSurfaceMask(targetSurfaceM
askLayer); |
124 FloatRect damageFromLeftoverRects = trackDamageFromLeftoverRects(); | 123 gfx::RectF damageFromLeftoverRects = trackDamageFromLeftoverRects(); |
125 | 124 |
126 FloatRect damageRectForThisUpdate; | 125 gfx::RectF damageRectForThisUpdate; |
127 | 126 |
128 if (m_forceFullDamageNextUpdate || targetSurfacePropertyChangedOnlyFromDesce
ndant) { | 127 if (m_forceFullDamageNextUpdate || targetSurfacePropertyChangedOnlyFromDesce
ndant) { |
129 damageRectForThisUpdate = targetSurfaceContentRect; | 128 damageRectForThisUpdate = targetSurfaceContentRect; |
130 m_forceFullDamageNextUpdate = false; | 129 m_forceFullDamageNextUpdate = false; |
131 } else { | 130 } else { |
132 // FIXME: can we clamp this damage to the surface's content rect? (affec
ts performance, but not correctness) | 131 // FIXME: can we clamp this damage to the surface's content rect? (affec
ts performance, but not correctness) |
133 damageRectForThisUpdate = damageFromActiveLayers; | 132 damageRectForThisUpdate = damageFromActiveLayers; |
134 damageRectForThisUpdate.uniteIfNonZero(damageFromSurfaceMask); | 133 damageRectForThisUpdate.Union(damageFromSurfaceMask); |
135 damageRectForThisUpdate.uniteIfNonZero(damageFromLeftoverRects); | 134 damageRectForThisUpdate.Union(damageFromLeftoverRects); |
136 | 135 |
137 if (filters.hasFilterThatMovesPixels()) { | 136 if (filters.hasFilterThatMovesPixels()) { |
138 expandRectWithFilters(damageRectForThisUpdate, filters); | 137 expandRectWithFilters(damageRectForThisUpdate, filters); |
139 } else if (filter) { | 138 } else if (filter) { |
140 // TODO(senorblanco): Once SkImageFilter reports its outsets, use | 139 // TODO(senorblanco): Once SkImageFilter reports its outsets, use |
141 // those here to limit damage. | 140 // those here to limit damage. |
142 damageRectForThisUpdate = targetSurfaceContentRect; | 141 damageRectForThisUpdate = targetSurfaceContentRect; |
143 } | 142 } |
144 } | 143 } |
145 | 144 |
146 // Damage accumulates until we are notified that we actually did draw on tha
t frame. | 145 // Damage accumulates until we are notified that we actually did draw on tha
t frame. |
147 m_currentDamageRect.uniteIfNonZero(damageRectForThisUpdate); | 146 m_currentDamageRect.Union(damageRectForThisUpdate); |
148 | 147 |
149 // The next history map becomes the current map for the next frame. Note thi
s must | 148 // The next history map becomes the current map for the next frame. Note thi
s must |
150 // happen every frame to correctly track changes, even if damage accumulates
over | 149 // happen every frame to correctly track changes, even if damage accumulates
over |
151 // multiple frames before actually being drawn. | 150 // multiple frames before actually being drawn. |
152 swap(m_currentRectHistory, m_nextRectHistory); | 151 swap(m_currentRectHistory, m_nextRectHistory); |
153 } | 152 } |
154 | 153 |
155 FloatRect DamageTracker::removeRectFromCurrentFrame(int layerID, bool& layerIsNe
w) | 154 gfx::RectF DamageTracker::removeRectFromCurrentFrame(int layerID, bool& layerIsN
ew) |
156 { | 155 { |
157 RectMap::iterator iter = m_currentRectHistory->find(layerID); | 156 RectMap::iterator iter = m_currentRectHistory->find(layerID); |
158 layerIsNew = iter == m_currentRectHistory->end(); | 157 layerIsNew = iter == m_currentRectHistory->end(); |
159 if (layerIsNew) | 158 if (layerIsNew) |
160 return FloatRect(); | 159 return gfx::RectF(); |
161 | 160 |
162 FloatRect ret = iter->second; | 161 gfx::RectF ret = iter->second; |
163 m_currentRectHistory->erase(iter); | 162 m_currentRectHistory->erase(iter); |
164 return ret; | 163 return ret; |
165 } | 164 } |
166 | 165 |
167 void DamageTracker::saveRectForNextFrame(int layerID, const FloatRect& targetSpa
ceRect) | 166 void DamageTracker::saveRectForNextFrame(int layerID, const gfx::RectF& targetSp
aceRect) |
168 { | 167 { |
169 // This layer should not yet exist in next frame's history. | 168 // This layer should not yet exist in next frame's history. |
170 DCHECK(layerID > 0); | 169 DCHECK(layerID > 0); |
171 DCHECK(m_nextRectHistory->find(layerID) == m_nextRectHistory->end()); | 170 DCHECK(m_nextRectHistory->find(layerID) == m_nextRectHistory->end()); |
172 (*m_nextRectHistory)[layerID] = targetSpaceRect; | 171 (*m_nextRectHistory)[layerID] = targetSpaceRect; |
173 } | 172 } |
174 | 173 |
175 FloatRect DamageTracker::trackDamageFromActiveLayers(const std::vector<LayerImpl
*>& layerList, int targetSurfaceLayerID) | 174 gfx::RectF DamageTracker::trackDamageFromActiveLayers(const std::vector<LayerImp
l*>& layerList, int targetSurfaceLayerID) |
176 { | 175 { |
177 FloatRect damageRect = FloatRect(); | 176 gfx::RectF damageRect = gfx::RectF(); |
178 | 177 |
179 for (unsigned layerIndex = 0; layerIndex < layerList.size(); ++layerIndex) { | 178 for (unsigned layerIndex = 0; layerIndex < layerList.size(); ++layerIndex) { |
180 // Visit layers in back-to-front order. | 179 // Visit layers in back-to-front order. |
181 LayerImpl* layer = layerList[layerIndex]; | 180 LayerImpl* layer = layerList[layerIndex]; |
182 | 181 |
183 if (LayerTreeHostCommon::renderSurfaceContributesToTarget<LayerImpl>(lay
er, targetSurfaceLayerID)) | 182 if (LayerTreeHostCommon::renderSurfaceContributesToTarget<LayerImpl>(lay
er, targetSurfaceLayerID)) |
184 extendDamageForRenderSurface(layer, damageRect); | 183 extendDamageForRenderSurface(layer, damageRect); |
185 else | 184 else |
186 extendDamageForLayer(layer, damageRect); | 185 extendDamageForLayer(layer, damageRect); |
187 } | 186 } |
188 | 187 |
189 return damageRect; | 188 return damageRect; |
190 } | 189 } |
191 | 190 |
192 FloatRect DamageTracker::trackDamageFromSurfaceMask(LayerImpl* targetSurfaceMask
Layer) | 191 gfx::RectF DamageTracker::trackDamageFromSurfaceMask(LayerImpl* targetSurfaceMas
kLayer) |
193 { | 192 { |
194 FloatRect damageRect = FloatRect(); | 193 gfx::RectF damageRect = gfx::RectF(); |
195 | 194 |
196 if (!targetSurfaceMaskLayer) | 195 if (!targetSurfaceMaskLayer) |
197 return damageRect; | 196 return damageRect; |
198 | 197 |
199 // Currently, if there is any change to the mask, we choose to damage the en
tire | 198 // Currently, if there is any change to the mask, we choose to damage the en
tire |
200 // surface. This could potentially be optimized later, but it is not expecte
d to be a | 199 // surface. This could potentially be optimized later, but it is not expecte
d to be a |
201 // common case. | 200 // common case. |
202 if (targetSurfaceMaskLayer->layerPropertyChanged() || !targetSurfaceMaskLaye
r->updateRect().isEmpty()) | 201 if (targetSurfaceMaskLayer->layerPropertyChanged() || !targetSurfaceMaskLaye
r->updateRect().IsEmpty()) |
203 damageRect = FloatRect(FloatPoint::zero(), FloatSize(targetSurfaceMaskLa
yer->bounds())); | 202 damageRect = gfx::RectF(gfx::PointF(), targetSurfaceMaskLayer->bounds())
; |
204 | 203 |
205 return damageRect; | 204 return damageRect; |
206 } | 205 } |
207 | 206 |
208 FloatRect DamageTracker::trackDamageFromLeftoverRects() | 207 gfx::RectF DamageTracker::trackDamageFromLeftoverRects() |
209 { | 208 { |
210 // After computing damage for all active layers, any leftover items in the c
urrent | 209 // After computing damage for all active layers, any leftover items in the c
urrent |
211 // rect history correspond to layers/surfaces that no longer exist. So, thes
e regions | 210 // rect history correspond to layers/surfaces that no longer exist. So, thes
e regions |
212 // are now exposed on the target surface. | 211 // are now exposed on the target surface. |
213 | 212 |
214 FloatRect damageRect = FloatRect(); | 213 gfx::RectF damageRect = gfx::RectF(); |
215 | 214 |
216 for (RectMap::iterator it = m_currentRectHistory->begin(); it != m_currentRe
ctHistory->end(); ++it) | 215 for (RectMap::iterator it = m_currentRectHistory->begin(); it != m_currentRe
ctHistory->end(); ++it) |
217 damageRect.unite(it->second); | 216 damageRect.Union(it->second); |
218 | 217 |
219 m_currentRectHistory->clear(); | 218 m_currentRectHistory->clear(); |
220 | 219 |
221 return damageRect; | 220 return damageRect; |
222 } | 221 } |
223 | 222 |
224 static bool layerNeedsToRedrawOntoItsTargetSurface(LayerImpl* layer) | 223 static bool layerNeedsToRedrawOntoItsTargetSurface(LayerImpl* layer) |
225 { | 224 { |
226 // If the layer does NOT own a surface but has SurfacePropertyChanged, | 225 // If the layer does NOT own a surface but has SurfacePropertyChanged, |
227 // this means that its target surface is affected and needs to be redrawn. | 226 // this means that its target surface is affected and needs to be redrawn. |
228 // However, if the layer DOES own a surface, then the SurfacePropertyChanged
| 227 // However, if the layer DOES own a surface, then the SurfacePropertyChanged
|
229 // flag should not be used here, because that flag represents whether the | 228 // flag should not be used here, because that flag represents whether the |
230 // layer's surface has changed. | 229 // layer's surface has changed. |
231 if (layer->renderSurface()) | 230 if (layer->renderSurface()) |
232 return layer->layerPropertyChanged(); | 231 return layer->layerPropertyChanged(); |
233 return layer->layerPropertyChanged() || layer->layerSurfacePropertyChanged()
; | 232 return layer->layerPropertyChanged() || layer->layerSurfacePropertyChanged()
; |
234 } | 233 } |
235 | 234 |
236 void DamageTracker::extendDamageForLayer(LayerImpl* layer, FloatRect& targetDama
geRect) | 235 void DamageTracker::extendDamageForLayer(LayerImpl* layer, gfx::RectF& targetDam
ageRect) |
237 { | 236 { |
238 // There are two ways that a layer can damage a region of the target surface
: | 237 // There are two ways that a layer can damage a region of the target surface
: |
239 // 1. Property change (e.g. opacity, position, transforms): | 238 // 1. Property change (e.g. opacity, position, transforms): |
240 // - the entire region of the layer itself damages the surface. | 239 // - the entire region of the layer itself damages the surface. |
241 // - the old layer region also damages the surface, because this regi
on is now exposed. | 240 // - the old layer region also damages the surface, because this regi
on is now exposed. |
242 // - note that in many cases the old and new layer rects may overlap,
which is fine. | 241 // - note that in many cases the old and new layer rects may overlap,
which is fine. |
243 // | 242 // |
244 // 2. Repaint/update: If a region of the layer that was repainted/updated,
that | 243 // 2. Repaint/update: If a region of the layer that was repainted/updated,
that |
245 // region damages the surface. | 244 // region damages the surface. |
246 // | 245 // |
247 // Property changes take priority over update rects. | 246 // Property changes take priority over update rects. |
248 // | 247 // |
249 // This method is called when we want to consider how a layer contributes to
its | 248 // This method is called when we want to consider how a layer contributes to
its |
250 // targetRenderSurface, even if that layer owns the targetRenderSurface itse
lf. | 249 // targetRenderSurface, even if that layer owns the targetRenderSurface itse
lf. |
251 // To consider how a layer's targetSurface contributes to the ancestorSurfac
e, | 250 // To consider how a layer's targetSurface contributes to the ancestorSurfac
e, |
252 // extendDamageForRenderSurface() must be called instead. | 251 // extendDamageForRenderSurface() must be called instead. |
253 | 252 |
254 bool layerIsNew = false; | 253 bool layerIsNew = false; |
255 FloatRect oldRectInTargetSpace = removeRectFromCurrentFrame(layer->id(), lay
erIsNew); | 254 gfx::RectF oldRectInTargetSpace = removeRectFromCurrentFrame(layer->id(), la
yerIsNew); |
256 | 255 |
257 FloatRect rectInTargetSpace = MathUtil::mapClippedRect(layer->drawTransform(
), FloatRect(FloatPoint::zero(), layer->contentBounds())); | 256 gfx::RectF rectInTargetSpace = MathUtil::mapClippedRect(layer->drawTransform
(), gfx::RectF(FloatPoint(), layer->contentBounds())); |
258 saveRectForNextFrame(layer->id(), rectInTargetSpace); | 257 saveRectForNextFrame(layer->id(), rectInTargetSpace); |
259 | 258 |
260 if (layerIsNew || layerNeedsToRedrawOntoItsTargetSurface(layer)) { | 259 if (layerIsNew || layerNeedsToRedrawOntoItsTargetSurface(layer)) { |
261 // If a layer is new or has changed, then its entire layer rect affects
the target surface. | 260 // If a layer is new or has changed, then its entire layer rect affects
the target surface. |
262 targetDamageRect.uniteIfNonZero(rectInTargetSpace); | 261 targetDamageRect.Union(rectInTargetSpace); |
263 | 262 |
264 // The layer's old region is now exposed on the target surface, too. | 263 // The layer's old region is now exposed on the target surface, too. |
265 // Note oldRectInTargetSpace is already in target space. | 264 // Note oldRectInTargetSpace is already in target space. |
266 targetDamageRect.uniteIfNonZero(oldRectInTargetSpace); | 265 targetDamageRect.Union(oldRectInTargetSpace); |
267 } else if (!layer->updateRect().isEmpty()) { | 266 } else if (!layer->updateRect().IsEmpty()) { |
268 // If the layer properties haven't changed, then the the target surface
is only | 267 // If the layer properties haven't changed, then the the target surface
is only |
269 // affected by the layer's update area, which could be empty. | 268 // affected by the layer's update area, which could be empty. |
270 FloatRect updateContentRect = layer->layerRectToContentRect(layer->updat
eRect()); | 269 gfx::RectF updateContentRect = layer->layerRectToContentRect(layer->upda
teRect()); |
271 FloatRect updateRectInTargetSpace = MathUtil::mapClippedRect(layer->draw
Transform(), updateContentRect); | 270 gfx::RectF updateRectInTargetSpace = MathUtil::mapClippedRect(layer->dra
wTransform(), updateContentRect); |
272 targetDamageRect.uniteIfNonZero(updateRectInTargetSpace); | 271 targetDamageRect.Union(updateRectInTargetSpace); |
273 } | 272 } |
274 } | 273 } |
275 | 274 |
276 void DamageTracker::extendDamageForRenderSurface(LayerImpl* layer, FloatRect& ta
rgetDamageRect) | 275 void DamageTracker::extendDamageForRenderSurface(LayerImpl* layer, gfx::RectF& t
argetDamageRect) |
277 { | 276 { |
278 // There are two ways a "descendant surface" can damage regions of the "targ
et surface": | 277 // There are two ways a "descendant surface" can damage regions of the "targ
et surface": |
279 // 1. Property change: | 278 // 1. Property change: |
280 // - a surface's geometry can change because of | 279 // - a surface's geometry can change because of |
281 // - changes to descendants (i.e. the subtree) that affect the su
rface's content rect | 280 // - changes to descendants (i.e. the subtree) that affect the su
rface's content rect |
282 // - changes to ancestor layers that propagate their property cha
nges to their entire subtree. | 281 // - changes to ancestor layers that propagate their property cha
nges to their entire subtree. |
283 // - just like layers, both the old surface rect and new surface rect
will | 282 // - just like layers, both the old surface rect and new surface rect
will |
284 // damage the target surface in this case. | 283 // damage the target surface in this case. |
285 // | 284 // |
286 // 2. Damage rect: This surface may have been damaged by its own layerList
as well, and that damage | 285 // 2. Damage rect: This surface may have been damaged by its own layerList
as well, and that damage |
287 // should propagate to the target surface. | 286 // should propagate to the target surface. |
288 // | 287 // |
289 | 288 |
290 RenderSurfaceImpl* renderSurface = layer->renderSurface(); | 289 RenderSurfaceImpl* renderSurface = layer->renderSurface(); |
291 | 290 |
292 bool surfaceIsNew = false; | 291 bool surfaceIsNew = false; |
293 FloatRect oldSurfaceRect = removeRectFromCurrentFrame(layer->id(), surfaceIs
New); | 292 gfx::RectF oldSurfaceRect = removeRectFromCurrentFrame(layer->id(), surfaceI
sNew); |
294 | 293 |
295 FloatRect surfaceRectInTargetSpace = renderSurface->drawableContentRect(); /
/ already includes replica if it exists. | 294 gfx::RectF surfaceRectInTargetSpace = renderSurface->drawableContentRect();
// already includes replica if it exists. |
296 saveRectForNextFrame(layer->id(), surfaceRectInTargetSpace); | 295 saveRectForNextFrame(layer->id(), surfaceRectInTargetSpace); |
297 | 296 |
298 FloatRect damageRectInLocalSpace; | 297 gfx::RectF damageRectInLocalSpace; |
299 if (surfaceIsNew || renderSurface->surfacePropertyChanged() || layer->layerS
urfacePropertyChanged()) { | 298 if (surfaceIsNew || renderSurface->surfacePropertyChanged() || layer->layerS
urfacePropertyChanged()) { |
300 // The entire surface contributes damage. | 299 // The entire surface contributes damage. |
301 damageRectInLocalSpace = renderSurface->contentRect(); | 300 damageRectInLocalSpace = renderSurface->contentRect(); |
302 | 301 |
303 // The surface's old region is now exposed on the target surface, too. | 302 // The surface's old region is now exposed on the target surface, too. |
304 targetDamageRect.uniteIfNonZero(oldSurfaceRect); | 303 targetDamageRect.Union(oldSurfaceRect); |
305 } else { | 304 } else { |
306 // Only the surface's damageRect will damage the target surface. | 305 // Only the surface's damageRect will damage the target surface. |
307 damageRectInLocalSpace = renderSurface->damageTracker()->currentDamageRe
ct(); | 306 damageRectInLocalSpace = renderSurface->damageTracker()->currentDamageRe
ct(); |
308 } | 307 } |
309 | 308 |
310 // If there was damage, transform it to target space, and possibly contribut
e its reflection if needed. | 309 // If there was damage, transform it to target space, and possibly contribut
e its reflection if needed. |
311 if (!damageRectInLocalSpace.isEmpty()) { | 310 if (!damageRectInLocalSpace.IsEmpty()) { |
312 const WebTransformationMatrix& drawTransform = renderSurface->drawTransf
orm(); | 311 const WebTransformationMatrix& drawTransform = renderSurface->drawTransf
orm(); |
313 FloatRect damageRectInTargetSpace = MathUtil::mapClippedRect(drawTransfo
rm, damageRectInLocalSpace); | 312 gfx::RectF damageRectInTargetSpace = MathUtil::mapClippedRect(drawTransf
orm, damageRectInLocalSpace); |
314 targetDamageRect.uniteIfNonZero(damageRectInTargetSpace); | 313 targetDamageRect.Union(damageRectInTargetSpace); |
315 | 314 |
316 if (layer->replicaLayer()) { | 315 if (layer->replicaLayer()) { |
317 const WebTransformationMatrix& replicaDrawTransform = renderSurface-
>replicaDrawTransform(); | 316 const WebTransformationMatrix& replicaDrawTransform = renderSurface-
>replicaDrawTransform(); |
318 targetDamageRect.uniteIfNonZero(MathUtil::mapClippedRect(replicaDraw
Transform, damageRectInLocalSpace)); | 317 targetDamageRect.Union(MathUtil::mapClippedRect(replicaDrawTransform
, damageRectInLocalSpace)); |
319 } | 318 } |
320 } | 319 } |
321 | 320 |
322 // If there was damage on the replica's mask, then the target surface receiv
es that damage as well. | 321 // If there was damage on the replica's mask, then the target surface receiv
es that damage as well. |
323 if (layer->replicaLayer() && layer->replicaLayer()->maskLayer()) { | 322 if (layer->replicaLayer() && layer->replicaLayer()->maskLayer()) { |
324 LayerImpl* replicaMaskLayer = layer->replicaLayer()->maskLayer(); | 323 LayerImpl* replicaMaskLayer = layer->replicaLayer()->maskLayer(); |
325 | 324 |
326 bool replicaIsNew = false; | 325 bool replicaIsNew = false; |
327 removeRectFromCurrentFrame(replicaMaskLayer->id(), replicaIsNew); | 326 removeRectFromCurrentFrame(replicaMaskLayer->id(), replicaIsNew); |
328 | 327 |
329 const WebTransformationMatrix& replicaDrawTransform = renderSurface->rep
licaDrawTransform(); | 328 const WebTransformationMatrix& replicaDrawTransform = renderSurface->rep
licaDrawTransform(); |
330 FloatRect replicaMaskLayerRect = MathUtil::mapClippedRect(replicaDrawTra
nsform, FloatRect(FloatPoint::zero(), FloatSize(replicaMaskLayer->bounds().width
(), replicaMaskLayer->bounds().height()))); | 329 gfx::RectF replicaMaskLayerRect = MathUtil::mapClippedRect(replicaDrawTr
ansform, gfx::RectF(FloatPoint(), FloatSize(replicaMaskLayer->bounds().width(),
replicaMaskLayer->bounds().height()))); |
331 saveRectForNextFrame(replicaMaskLayer->id(), replicaMaskLayerRect); | 330 saveRectForNextFrame(replicaMaskLayer->id(), replicaMaskLayerRect); |
332 | 331 |
333 // In the current implementation, a change in the replica mask damages t
he entire replica region. | 332 // In the current implementation, a change in the replica mask damages t
he entire replica region. |
334 if (replicaIsNew || replicaMaskLayer->layerPropertyChanged() || !replica
MaskLayer->updateRect().isEmpty()) | 333 if (replicaIsNew || replicaMaskLayer->layerPropertyChanged() || !replica
MaskLayer->updateRect().IsEmpty()) |
335 targetDamageRect.uniteIfNonZero(replicaMaskLayerRect); | 334 targetDamageRect.Union(replicaMaskLayerRect); |
336 } | 335 } |
337 | 336 |
338 // 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 | 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 |
339 // 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 | 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 |
340 // 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 | 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 |
341 // this layer this frame. | 340 // this layer this frame. |
342 if (layer->backgroundFilters().hasFilterThatMovesPixels()) | 341 if (layer->backgroundFilters().hasFilterThatMovesPixels()) |
343 expandDamageRectInsideRectWithFilters(targetDamageRect, surfaceRectInTar
getSpace, layer->backgroundFilters()); | 342 expandDamageRectInsideRectWithFilters(targetDamageRect, surfaceRectInTar
getSpace, layer->backgroundFilters()); |
344 } | 343 } |
345 | 344 |
346 } // namespace cc | 345 } // namespace cc |
347 | 346 |
OLD | NEW |