| 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" |
| 11 #include "CCMathUtil.h" | 11 #include "CCMathUtil.h" |
| 12 #include "CCRenderSurface.h" | 12 #include "CCRenderSurface.h" |
| 13 #include <public/WebFilterOperations.h> | 13 #include <public/WebFilterOperations.h> |
| 14 | 14 |
| 15 using WebKit::WebTransformationMatrix; | 15 using WebKit::WebTransformationMatrix; |
| 16 | 16 |
| 17 namespace cc { | 17 namespace cc { |
| 18 | 18 |
| 19 scoped_ptr<CCDamageTracker> CCDamageTracker::create() | 19 scoped_ptr<DamageTracker> DamageTracker::create() |
| 20 { | 20 { |
| 21 return make_scoped_ptr(new CCDamageTracker()); | 21 return make_scoped_ptr(new DamageTracker()); |
| 22 } | 22 } |
| 23 | 23 |
| 24 CCDamageTracker::CCDamageTracker() | 24 DamageTracker::DamageTracker() |
| 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 CCDamageTracker::~CCDamageTracker() | 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(FloatRect& rect, const WebKit::WebFilte
rOperations& 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.move(-left, -top); |
| 40 rect.expand(left + right, top + bottom); | 40 rect.expand(left + right, top + bottom); |
| 41 } | 41 } |
| 42 | 42 |
| 43 static inline void expandDamageRectInsideRectWithFilters(FloatRect& damageRect,
const FloatRect& preFilterRect, const WebKit::WebFilterOperations& filters) | 43 static inline void expandDamageRectInsideRectWithFilters(FloatRect& damageRect,
const FloatRect& preFilterRect, const WebKit::WebFilterOperations& filters) |
| 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 CCDamageTracker::updateDamageTrackingState(const std::vector<CCLayerImpl*>&
layerList, int targetSurfaceLayerID, bool targetSurfacePropertyChangedOnlyFromD
escendant, const IntRect& targetSurfaceContentRect, CCLayerImpl* targetSurfaceMa
skLayer, 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) |
| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 140 |
| 141 // Damage accumulates until we are notified that we actually did draw on tha
t frame. | 141 // Damage accumulates until we are notified that we actually did draw on tha
t frame. |
| 142 m_currentDamageRect.uniteIfNonZero(damageRectForThisUpdate); | 142 m_currentDamageRect.uniteIfNonZero(damageRectForThisUpdate); |
| 143 | 143 |
| 144 // The next history map becomes the current map for the next frame. Note thi
s must | 144 // 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 | 145 // happen every frame to correctly track changes, even if damage accumulates
over |
| 146 // multiple frames before actually being drawn. | 146 // multiple frames before actually being drawn. |
| 147 swap(m_currentRectHistory, m_nextRectHistory); | 147 swap(m_currentRectHistory, m_nextRectHistory); |
| 148 } | 148 } |
| 149 | 149 |
| 150 FloatRect CCDamageTracker::removeRectFromCurrentFrame(int layerID, bool& layerIs
New) | 150 FloatRect DamageTracker::removeRectFromCurrentFrame(int layerID, bool& layerIsNe
w) |
| 151 { | 151 { |
| 152 RectMap::iterator iter = m_currentRectHistory->find(layerID); | 152 RectMap::iterator iter = m_currentRectHistory->find(layerID); |
| 153 layerIsNew = iter == m_currentRectHistory->end(); | 153 layerIsNew = iter == m_currentRectHistory->end(); |
| 154 if (layerIsNew) | 154 if (layerIsNew) |
| 155 return FloatRect(); | 155 return FloatRect(); |
| 156 | 156 |
| 157 FloatRect ret = iter->second; | 157 FloatRect ret = iter->second; |
| 158 m_currentRectHistory->erase(iter); | 158 m_currentRectHistory->erase(iter); |
| 159 return ret; | 159 return ret; |
| 160 } | 160 } |
| 161 | 161 |
| 162 void CCDamageTracker::saveRectForNextFrame(int layerID, const FloatRect& targetS
paceRect) | 162 void DamageTracker::saveRectForNextFrame(int layerID, const FloatRect& targetSpa
ceRect) |
| 163 { | 163 { |
| 164 // This layer should not yet exist in next frame's history. | 164 // This layer should not yet exist in next frame's history. |
| 165 ASSERT(layerID > 0); | 165 ASSERT(layerID > 0); |
| 166 ASSERT(m_nextRectHistory->find(layerID) == m_nextRectHistory->end()); | 166 ASSERT(m_nextRectHistory->find(layerID) == m_nextRectHistory->end()); |
| 167 (*m_nextRectHistory)[layerID] = targetSpaceRect; | 167 (*m_nextRectHistory)[layerID] = targetSpaceRect; |
| 168 } | 168 } |
| 169 | 169 |
| 170 FloatRect CCDamageTracker::trackDamageFromActiveLayers(const std::vector<CCLayer
Impl*>& layerList, int targetSurfaceLayerID) | 170 FloatRect DamageTracker::trackDamageFromActiveLayers(const std::vector<LayerImpl
*>& layerList, int targetSurfaceLayerID) |
| 171 { | 171 { |
| 172 FloatRect damageRect = FloatRect(); | 172 FloatRect damageRect = FloatRect(); |
| 173 | 173 |
| 174 for (unsigned layerIndex = 0; layerIndex < layerList.size(); ++layerIndex) { | 174 for (unsigned layerIndex = 0; layerIndex < layerList.size(); ++layerIndex) { |
| 175 // Visit layers in back-to-front order. | 175 // Visit layers in back-to-front order. |
| 176 CCLayerImpl* layer = layerList[layerIndex]; | 176 LayerImpl* layer = layerList[layerIndex]; |
| 177 | 177 |
| 178 if (CCLayerTreeHostCommon::renderSurfaceContributesToTarget<CCLayerImpl>
(layer, targetSurfaceLayerID)) | 178 if (LayerTreeHostCommon::renderSurfaceContributesToTarget<LayerImpl>(lay
er, targetSurfaceLayerID)) |
| 179 extendDamageForRenderSurface(layer, damageRect); | 179 extendDamageForRenderSurface(layer, damageRect); |
| 180 else | 180 else |
| 181 extendDamageForLayer(layer, damageRect); | 181 extendDamageForLayer(layer, damageRect); |
| 182 } | 182 } |
| 183 | 183 |
| 184 return damageRect; | 184 return damageRect; |
| 185 } | 185 } |
| 186 | 186 |
| 187 FloatRect CCDamageTracker::trackDamageFromSurfaceMask(CCLayerImpl* targetSurface
MaskLayer) | 187 FloatRect DamageTracker::trackDamageFromSurfaceMask(LayerImpl* targetSurfaceMask
Layer) |
| 188 { | 188 { |
| 189 FloatRect damageRect = FloatRect(); | 189 FloatRect damageRect = FloatRect(); |
| 190 | 190 |
| 191 if (!targetSurfaceMaskLayer) | 191 if (!targetSurfaceMaskLayer) |
| 192 return damageRect; | 192 return damageRect; |
| 193 | 193 |
| 194 // Currently, if there is any change to the mask, we choose to damage the en
tire | 194 // Currently, if there is any change to the mask, we choose to damage the en
tire |
| 195 // surface. This could potentially be optimized later, but it is not expecte
d to be a | 195 // surface. This could potentially be optimized later, but it is not expecte
d to be a |
| 196 // common case. | 196 // common case. |
| 197 if (targetSurfaceMaskLayer->layerPropertyChanged() || !targetSurfaceMaskLaye
r->updateRect().isEmpty()) | 197 if (targetSurfaceMaskLayer->layerPropertyChanged() || !targetSurfaceMaskLaye
r->updateRect().isEmpty()) |
| 198 damageRect = FloatRect(FloatPoint::zero(), FloatSize(targetSurfaceMaskLa
yer->bounds())); | 198 damageRect = FloatRect(FloatPoint::zero(), FloatSize(targetSurfaceMaskLa
yer->bounds())); |
| 199 | 199 |
| 200 return damageRect; | 200 return damageRect; |
| 201 } | 201 } |
| 202 | 202 |
| 203 FloatRect CCDamageTracker::trackDamageFromLeftoverRects() | 203 FloatRect DamageTracker::trackDamageFromLeftoverRects() |
| 204 { | 204 { |
| 205 // After computing damage for all active layers, any leftover items in the c
urrent | 205 // After computing damage for all active layers, any leftover items in the c
urrent |
| 206 // rect history correspond to layers/surfaces that no longer exist. So, thes
e regions | 206 // rect history correspond to layers/surfaces that no longer exist. So, thes
e regions |
| 207 // are now exposed on the target surface. | 207 // are now exposed on the target surface. |
| 208 | 208 |
| 209 FloatRect damageRect = FloatRect(); | 209 FloatRect damageRect = FloatRect(); |
| 210 | 210 |
| 211 for (RectMap::iterator it = m_currentRectHistory->begin(); it != m_currentRe
ctHistory->end(); ++it) | 211 for (RectMap::iterator it = m_currentRectHistory->begin(); it != m_currentRe
ctHistory->end(); ++it) |
| 212 damageRect.unite(it->second); | 212 damageRect.unite(it->second); |
| 213 | 213 |
| 214 m_currentRectHistory->clear(); | 214 m_currentRectHistory->clear(); |
| 215 | 215 |
| 216 return damageRect; | 216 return damageRect; |
| 217 } | 217 } |
| 218 | 218 |
| 219 static bool layerNeedsToRedrawOntoItsTargetSurface(CCLayerImpl* layer) | 219 static bool layerNeedsToRedrawOntoItsTargetSurface(LayerImpl* layer) |
| 220 { | 220 { |
| 221 // If the layer does NOT own a surface but has SurfacePropertyChanged, | 221 // If the layer does NOT own a surface but has SurfacePropertyChanged, |
| 222 // this means that its target surface is affected and needs to be redrawn. | 222 // this means that its target surface is affected and needs to be redrawn. |
| 223 // However, if the layer DOES own a surface, then the SurfacePropertyChanged
| 223 // However, if the layer DOES own a surface, then the SurfacePropertyChanged
|
| 224 // flag should not be used here, because that flag represents whether the | 224 // flag should not be used here, because that flag represents whether the |
| 225 // layer's surface has changed. | 225 // layer's surface has changed. |
| 226 if (layer->renderSurface()) | 226 if (layer->renderSurface()) |
| 227 return layer->layerPropertyChanged(); | 227 return layer->layerPropertyChanged(); |
| 228 return layer->layerPropertyChanged() || layer->layerSurfacePropertyChanged()
; | 228 return layer->layerPropertyChanged() || layer->layerSurfacePropertyChanged()
; |
| 229 } | 229 } |
| 230 | 230 |
| 231 void CCDamageTracker::extendDamageForLayer(CCLayerImpl* layer, FloatRect& target
DamageRect) | 231 void DamageTracker::extendDamageForLayer(LayerImpl* layer, FloatRect& targetDama
geRect) |
| 232 { | 232 { |
| 233 // There are two ways that a layer can damage a region of the target surface
: | 233 // There are two ways that a layer can damage a region of the target surface
: |
| 234 // 1. Property change (e.g. opacity, position, transforms): | 234 // 1. Property change (e.g. opacity, position, transforms): |
| 235 // - the entire region of the layer itself damages the surface. | 235 // - the entire region of the layer itself damages the surface. |
| 236 // - the old layer region also damages the surface, because this regi
on is now exposed. | 236 // - the old layer region also damages the surface, because this regi
on is now exposed. |
| 237 // - note that in many cases the old and new layer rects may overlap,
which is fine. | 237 // - note that in many cases the old and new layer rects may overlap,
which is fine. |
| 238 // | 238 // |
| 239 // 2. Repaint/update: If a region of the layer that was repainted/updated,
that | 239 // 2. Repaint/update: If a region of the layer that was repainted/updated,
that |
| 240 // region damages the surface. | 240 // region damages the surface. |
| 241 // | 241 // |
| 242 // Property changes take priority over update rects. | 242 // Property changes take priority over update rects. |
| 243 // | 243 // |
| 244 // This method is called when we want to consider how a layer contributes to
its | 244 // This method is called when we want to consider how a layer contributes to
its |
| 245 // targetRenderSurface, even if that layer owns the targetRenderSurface itse
lf. | 245 // targetRenderSurface, even if that layer owns the targetRenderSurface itse
lf. |
| 246 // To consider how a layer's targetSurface contributes to the ancestorSurfac
e, | 246 // To consider how a layer's targetSurface contributes to the ancestorSurfac
e, |
| 247 // extendDamageForRenderSurface() must be called instead. | 247 // extendDamageForRenderSurface() must be called instead. |
| 248 | 248 |
| 249 bool layerIsNew = false; | 249 bool layerIsNew = false; |
| 250 FloatRect oldRectInTargetSpace = removeRectFromCurrentFrame(layer->id(), lay
erIsNew); | 250 FloatRect oldRectInTargetSpace = removeRectFromCurrentFrame(layer->id(), lay
erIsNew); |
| 251 | 251 |
| 252 FloatRect rectInTargetSpace = CCMathUtil::mapClippedRect(layer->drawTransfor
m(), FloatRect(FloatPoint::zero(), layer->contentBounds())); | 252 FloatRect rectInTargetSpace = MathUtil::mapClippedRect(layer->drawTransform(
), FloatRect(FloatPoint::zero(), layer->contentBounds())); |
| 253 saveRectForNextFrame(layer->id(), rectInTargetSpace); | 253 saveRectForNextFrame(layer->id(), rectInTargetSpace); |
| 254 | 254 |
| 255 if (layerIsNew || layerNeedsToRedrawOntoItsTargetSurface(layer)) { | 255 if (layerIsNew || layerNeedsToRedrawOntoItsTargetSurface(layer)) { |
| 256 // If a layer is new or has changed, then its entire layer rect affects
the target surface. | 256 // If a layer is new or has changed, then its entire layer rect affects
the target surface. |
| 257 targetDamageRect.uniteIfNonZero(rectInTargetSpace); | 257 targetDamageRect.uniteIfNonZero(rectInTargetSpace); |
| 258 | 258 |
| 259 // The layer's old region is now exposed on the target surface, too. | 259 // The layer's old region is now exposed on the target surface, too. |
| 260 // Note oldRectInTargetSpace is already in target space. | 260 // Note oldRectInTargetSpace is already in target space. |
| 261 targetDamageRect.uniteIfNonZero(oldRectInTargetSpace); | 261 targetDamageRect.uniteIfNonZero(oldRectInTargetSpace); |
| 262 } else if (!layer->updateRect().isEmpty()) { | 262 } else if (!layer->updateRect().isEmpty()) { |
| 263 // If the layer properties havent changed, then the the target surface i
s only | 263 // If the layer properties havent changed, then the the target surface i
s only |
| 264 // affected by the layer's update area, which could be empty. | 264 // affected by the layer's update area, which could be empty. |
| 265 FloatRect updateContentRect = layer->updateRect(); | 265 FloatRect updateContentRect = layer->updateRect(); |
| 266 float widthScale = layer->contentBounds().width() / static_cast<float>(l
ayer->bounds().width()); | 266 float widthScale = layer->contentBounds().width() / static_cast<float>(l
ayer->bounds().width()); |
| 267 float heightScale = layer->contentBounds().height() / static_cast<float>
(layer->bounds().height()); | 267 float heightScale = layer->contentBounds().height() / static_cast<float>
(layer->bounds().height()); |
| 268 updateContentRect.scale(widthScale, heightScale); | 268 updateContentRect.scale(widthScale, heightScale); |
| 269 | 269 |
| 270 FloatRect updateRectInTargetSpace = CCMathUtil::mapClippedRect(layer->dr
awTransform(), updateContentRect); | 270 FloatRect updateRectInTargetSpace = MathUtil::mapClippedRect(layer->draw
Transform(), updateContentRect); |
| 271 targetDamageRect.uniteIfNonZero(updateRectInTargetSpace); | 271 targetDamageRect.uniteIfNonZero(updateRectInTargetSpace); |
| 272 } | 272 } |
| 273 } | 273 } |
| 274 | 274 |
| 275 void CCDamageTracker::extendDamageForRenderSurface(CCLayerImpl* layer, FloatRect
& targetDamageRect) | 275 void DamageTracker::extendDamageForRenderSurface(LayerImpl* layer, FloatRect& ta
rgetDamageRect) |
| 276 { | 276 { |
| 277 // 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": |
| 278 // 1. Property change: | 278 // 1. Property change: |
| 279 // - a surface's geometry can change because of | 279 // - a surface's geometry can change because of |
| 280 // - 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 |
| 281 // - 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. |
| 282 // - 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 |
| 283 // damage the target surface in this case. | 283 // damage the target surface in this case. |
| 284 // | 284 // |
| 285 // 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 |
| 286 // should propagate to the target surface. | 286 // should propagate to the target surface. |
| 287 // | 287 // |
| 288 | 288 |
| 289 CCRenderSurface* renderSurface = layer->renderSurface(); | 289 RenderSurfaceImpl* renderSurface = layer->renderSurface(); |
| 290 | 290 |
| 291 bool surfaceIsNew = false; | 291 bool surfaceIsNew = false; |
| 292 FloatRect oldSurfaceRect = removeRectFromCurrentFrame(layer->id(), surfaceIs
New); | 292 FloatRect oldSurfaceRect = removeRectFromCurrentFrame(layer->id(), surfaceIs
New); |
| 293 | 293 |
| 294 FloatRect surfaceRectInTargetSpace = renderSurface->drawableContentRect(); /
/ already includes replica if it exists. | 294 FloatRect surfaceRectInTargetSpace = renderSurface->drawableContentRect(); /
/ already includes replica if it exists. |
| 295 saveRectForNextFrame(layer->id(), surfaceRectInTargetSpace); | 295 saveRectForNextFrame(layer->id(), surfaceRectInTargetSpace); |
| 296 | 296 |
| 297 FloatRect damageRectInLocalSpace; | 297 FloatRect damageRectInLocalSpace; |
| 298 if (surfaceIsNew || renderSurface->surfacePropertyChanged() || layer->layerS
urfacePropertyChanged()) { | 298 if (surfaceIsNew || renderSurface->surfacePropertyChanged() || layer->layerS
urfacePropertyChanged()) { |
| 299 // The entire surface contributes damage. | 299 // The entire surface contributes damage. |
| 300 damageRectInLocalSpace = renderSurface->contentRect(); | 300 damageRectInLocalSpace = renderSurface->contentRect(); |
| 301 | 301 |
| 302 // 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. |
| 303 targetDamageRect.uniteIfNonZero(oldSurfaceRect); | 303 targetDamageRect.uniteIfNonZero(oldSurfaceRect); |
| 304 } else { | 304 } else { |
| 305 // Only the surface's damageRect will damage the target surface. | 305 // Only the surface's damageRect will damage the target surface. |
| 306 damageRectInLocalSpace = renderSurface->damageTracker()->currentDamageRe
ct(); | 306 damageRectInLocalSpace = renderSurface->damageTracker()->currentDamageRe
ct(); |
| 307 } | 307 } |
| 308 | 308 |
| 309 // 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. |
| 310 if (!damageRectInLocalSpace.isEmpty()) { | 310 if (!damageRectInLocalSpace.isEmpty()) { |
| 311 const WebTransformationMatrix& drawTransform = renderSurface->drawTransf
orm(); | 311 const WebTransformationMatrix& drawTransform = renderSurface->drawTransf
orm(); |
| 312 FloatRect damageRectInTargetSpace = CCMathUtil::mapClippedRect(drawTrans
form, damageRectInLocalSpace); | 312 FloatRect damageRectInTargetSpace = MathUtil::mapClippedRect(drawTransfo
rm, damageRectInLocalSpace); |
| 313 targetDamageRect.uniteIfNonZero(damageRectInTargetSpace); | 313 targetDamageRect.uniteIfNonZero(damageRectInTargetSpace); |
| 314 | 314 |
| 315 if (layer->replicaLayer()) { | 315 if (layer->replicaLayer()) { |
| 316 const WebTransformationMatrix& replicaDrawTransform = renderSurface-
>replicaDrawTransform(); | 316 const WebTransformationMatrix& replicaDrawTransform = renderSurface-
>replicaDrawTransform(); |
| 317 targetDamageRect.uniteIfNonZero(CCMathUtil::mapClippedRect(replicaDr
awTransform, damageRectInLocalSpace)); | 317 targetDamageRect.uniteIfNonZero(MathUtil::mapClippedRect(replicaDraw
Transform, damageRectInLocalSpace)); |
| 318 } | 318 } |
| 319 } | 319 } |
| 320 | 320 |
| 321 // 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. |
| 322 if (layer->replicaLayer() && layer->replicaLayer()->maskLayer()) { | 322 if (layer->replicaLayer() && layer->replicaLayer()->maskLayer()) { |
| 323 CCLayerImpl* replicaMaskLayer = layer->replicaLayer()->maskLayer(); | 323 LayerImpl* replicaMaskLayer = layer->replicaLayer()->maskLayer(); |
| 324 | 324 |
| 325 bool replicaIsNew = false; | 325 bool replicaIsNew = false; |
| 326 removeRectFromCurrentFrame(replicaMaskLayer->id(), replicaIsNew); | 326 removeRectFromCurrentFrame(replicaMaskLayer->id(), replicaIsNew); |
| 327 | 327 |
| 328 const WebTransformationMatrix& replicaDrawTransform = renderSurface->rep
licaDrawTransform(); | 328 const WebTransformationMatrix& replicaDrawTransform = renderSurface->rep
licaDrawTransform(); |
| 329 FloatRect replicaMaskLayerRect = CCMathUtil::mapClippedRect(replicaDrawT
ransform, FloatRect(FloatPoint::zero(), FloatSize(replicaMaskLayer->bounds().wid
th(), replicaMaskLayer->bounds().height()))); | 329 FloatRect replicaMaskLayerRect = MathUtil::mapClippedRect(replicaDrawTra
nsform, FloatRect(FloatPoint::zero(), FloatSize(replicaMaskLayer->bounds().width
(), replicaMaskLayer->bounds().height()))); |
| 330 saveRectForNextFrame(replicaMaskLayer->id(), replicaMaskLayerRect); | 330 saveRectForNextFrame(replicaMaskLayer->id(), replicaMaskLayerRect); |
| 331 | 331 |
| 332 // 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. |
| 333 if (replicaIsNew || replicaMaskLayer->layerPropertyChanged() || !replica
MaskLayer->updateRect().isEmpty()) | 333 if (replicaIsNew || replicaMaskLayer->layerPropertyChanged() || !replica
MaskLayer->updateRect().isEmpty()) |
| 334 targetDamageRect.uniteIfNonZero(replicaMaskLayerRect); | 334 targetDamageRect.uniteIfNonZero(replicaMaskLayerRect); |
| 335 } | 335 } |
| 336 | 336 |
| 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 | 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 |
| 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 | 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 |
| 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 | 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 |
| 340 // this layer this frame. | 340 // this layer this frame. |
| 341 if (layer->backgroundFilters().hasFilterThatMovesPixels()) | 341 if (layer->backgroundFilters().hasFilterThatMovesPixels()) |
| 342 expandDamageRectInsideRectWithFilters(targetDamageRect, surfaceRectInTar
getSpace, layer->backgroundFilters()); | 342 expandDamageRectInsideRectWithFilters(targetDamageRect, surfaceRectInTar
getSpace, layer->backgroundFilters()); |
| 343 } | 343 } |
| 344 | 344 |
| 345 } // namespace cc | 345 } // namespace cc |
| 346 | 346 |
| OLD | NEW |