Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(785)

Side by Side Diff: cc/damage_tracker.cc

Issue 11264056: cc: Use gfx:: Geometry types for positions, bounds, and related things. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: some missed intstuff Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 havent changed, then the the target surface i s only 267 // If the layer properties havent changed, then the the target surface i s 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->updateRect(); 269 gfx::RectF updateContentRect = layer->updateRect();
271 float widthScale = layer->contentBounds().width() / static_cast<float>(l ayer->bounds().width()); 270 float widthScale = layer->contentBounds().width() / static_cast<float>(l ayer->bounds().width());
272 float heightScale = layer->contentBounds().height() / static_cast<float> (layer->bounds().height()); 271 float heightScale = layer->contentBounds().height() / static_cast<float> (layer->bounds().height());
273 updateContentRect.scale(widthScale, heightScale); 272 updateContentRect.Scale(widthScale, heightScale);
274 273
275 FloatRect updateRectInTargetSpace = MathUtil::mapClippedRect(layer->draw Transform(), updateContentRect); 274 gfx::RectF updateRectInTargetSpace = MathUtil::mapClippedRect(layer->dra wTransform(), updateContentRect);
276 targetDamageRect.uniteIfNonZero(updateRectInTargetSpace); 275 targetDamageRect.Union(updateRectInTargetSpace);
277 } 276 }
278 } 277 }
279 278
280 void DamageTracker::extendDamageForRenderSurface(LayerImpl* layer, FloatRect& ta rgetDamageRect) 279 void DamageTracker::extendDamageForRenderSurface(LayerImpl* layer, gfx::RectF& t argetDamageRect)
281 { 280 {
282 // There are two ways a "descendant surface" can damage regions of the "targ et surface": 281 // There are two ways a "descendant surface" can damage regions of the "targ et surface":
283 // 1. Property change: 282 // 1. Property change:
284 // - a surface's geometry can change because of 283 // - a surface's geometry can change because of
285 // - changes to descendants (i.e. the subtree) that affect the su rface's content rect 284 // - changes to descendants (i.e. the subtree) that affect the su rface's content rect
286 // - changes to ancestor layers that propagate their property cha nges to their entire subtree. 285 // - changes to ancestor layers that propagate their property cha nges to their entire subtree.
287 // - just like layers, both the old surface rect and new surface rect will 286 // - just like layers, both the old surface rect and new surface rect will
288 // damage the target surface in this case. 287 // damage the target surface in this case.
289 // 288 //
290 // 2. Damage rect: This surface may have been damaged by its own layerList as well, and that damage 289 // 2. Damage rect: This surface may have been damaged by its own layerList as well, and that damage
291 // should propagate to the target surface. 290 // should propagate to the target surface.
292 // 291 //
293 292
294 RenderSurfaceImpl* renderSurface = layer->renderSurface(); 293 RenderSurfaceImpl* renderSurface = layer->renderSurface();
295 294
296 bool surfaceIsNew = false; 295 bool surfaceIsNew = false;
297 FloatRect oldSurfaceRect = removeRectFromCurrentFrame(layer->id(), surfaceIs New); 296 gfx::RectF oldSurfaceRect = removeRectFromCurrentFrame(layer->id(), surfaceI sNew);
298 297
299 FloatRect surfaceRectInTargetSpace = renderSurface->drawableContentRect(); / / already includes replica if it exists. 298 gfx::RectF surfaceRectInTargetSpace = renderSurface->drawableContentRect(); // already includes replica if it exists.
300 saveRectForNextFrame(layer->id(), surfaceRectInTargetSpace); 299 saveRectForNextFrame(layer->id(), surfaceRectInTargetSpace);
301 300
302 FloatRect damageRectInLocalSpace; 301 gfx::RectF damageRectInLocalSpace;
303 if (surfaceIsNew || renderSurface->surfacePropertyChanged() || layer->layerS urfacePropertyChanged()) { 302 if (surfaceIsNew || renderSurface->surfacePropertyChanged() || layer->layerS urfacePropertyChanged()) {
304 // The entire surface contributes damage. 303 // The entire surface contributes damage.
305 damageRectInLocalSpace = renderSurface->contentRect(); 304 damageRectInLocalSpace = renderSurface->contentRect();
306 305
307 // The surface's old region is now exposed on the target surface, too. 306 // The surface's old region is now exposed on the target surface, too.
308 targetDamageRect.uniteIfNonZero(oldSurfaceRect); 307 targetDamageRect.Union(oldSurfaceRect);
309 } else { 308 } else {
310 // Only the surface's damageRect will damage the target surface. 309 // Only the surface's damageRect will damage the target surface.
311 damageRectInLocalSpace = renderSurface->damageTracker()->currentDamageRe ct(); 310 damageRectInLocalSpace = renderSurface->damageTracker()->currentDamageRe ct();
312 } 311 }
313 312
314 // If there was damage, transform it to target space, and possibly contribut e its reflection if needed. 313 // If there was damage, transform it to target space, and possibly contribut e its reflection if needed.
315 if (!damageRectInLocalSpace.isEmpty()) { 314 if (!damageRectInLocalSpace.IsEmpty()) {
316 const WebTransformationMatrix& drawTransform = renderSurface->drawTransf orm(); 315 const WebTransformationMatrix& drawTransform = renderSurface->drawTransf orm();
317 FloatRect damageRectInTargetSpace = MathUtil::mapClippedRect(drawTransfo rm, damageRectInLocalSpace); 316 gfx::RectF damageRectInTargetSpace = MathUtil::mapClippedRect(drawTransf orm, damageRectInLocalSpace);
318 targetDamageRect.uniteIfNonZero(damageRectInTargetSpace); 317 targetDamageRect.Union(damageRectInTargetSpace);
319 318
320 if (layer->replicaLayer()) { 319 if (layer->replicaLayer()) {
321 const WebTransformationMatrix& replicaDrawTransform = renderSurface- >replicaDrawTransform(); 320 const WebTransformationMatrix& replicaDrawTransform = renderSurface- >replicaDrawTransform();
322 targetDamageRect.uniteIfNonZero(MathUtil::mapClippedRect(replicaDraw Transform, damageRectInLocalSpace)); 321 targetDamageRect.Union(MathUtil::mapClippedRect(replicaDrawTransform , damageRectInLocalSpace));
323 } 322 }
324 } 323 }
325 324
326 // If there was damage on the replica's mask, then the target surface receiv es that damage as well. 325 // If there was damage on the replica's mask, then the target surface receiv es that damage as well.
327 if (layer->replicaLayer() && layer->replicaLayer()->maskLayer()) { 326 if (layer->replicaLayer() && layer->replicaLayer()->maskLayer()) {
328 LayerImpl* replicaMaskLayer = layer->replicaLayer()->maskLayer(); 327 LayerImpl* replicaMaskLayer = layer->replicaLayer()->maskLayer();
329 328
330 bool replicaIsNew = false; 329 bool replicaIsNew = false;
331 removeRectFromCurrentFrame(replicaMaskLayer->id(), replicaIsNew); 330 removeRectFromCurrentFrame(replicaMaskLayer->id(), replicaIsNew);
332 331
333 const WebTransformationMatrix& replicaDrawTransform = renderSurface->rep licaDrawTransform(); 332 const WebTransformationMatrix& replicaDrawTransform = renderSurface->rep licaDrawTransform();
334 FloatRect replicaMaskLayerRect = MathUtil::mapClippedRect(replicaDrawTra nsform, FloatRect(FloatPoint::zero(), FloatSize(replicaMaskLayer->bounds().width (), replicaMaskLayer->bounds().height()))); 333 gfx::RectF replicaMaskLayerRect = MathUtil::mapClippedRect(replicaDrawTr ansform, gfx::RectF(FloatPoint(), FloatSize(replicaMaskLayer->bounds().width(), replicaMaskLayer->bounds().height())));
335 saveRectForNextFrame(replicaMaskLayer->id(), replicaMaskLayerRect); 334 saveRectForNextFrame(replicaMaskLayer->id(), replicaMaskLayerRect);
336 335
337 // In the current implementation, a change in the replica mask damages t he entire replica region. 336 // In the current implementation, a change in the replica mask damages t he entire replica region.
338 if (replicaIsNew || replicaMaskLayer->layerPropertyChanged() || !replica MaskLayer->updateRect().isEmpty()) 337 if (replicaIsNew || replicaMaskLayer->layerPropertyChanged() || !replica MaskLayer->updateRect().IsEmpty())
339 targetDamageRect.uniteIfNonZero(replicaMaskLayerRect); 338 targetDamageRect.Union(replicaMaskLayerRect);
340 } 339 }
341 340
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 341 // 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
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 342 // 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
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 343 // 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
345 // this layer this frame. 344 // this layer this frame.
346 if (layer->backgroundFilters().hasFilterThatMovesPixels()) 345 if (layer->backgroundFilters().hasFilterThatMovesPixels())
347 expandDamageRectInsideRectWithFilters(targetDamageRect, surfaceRectInTar getSpace, layer->backgroundFilters()); 346 expandDamageRectInsideRectWithFilters(targetDamageRect, surfaceRectInTar getSpace, layer->backgroundFilters());
348 } 347 }
349 348
350 } // namespace cc 349 } // namespace cc
351 350
OLDNEW
« no previous file with comments | « cc/damage_tracker.h ('k') | cc/damage_tracker_unittest.cc » ('j') | cc/layer_quad.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698