| 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 #if USE(ACCELERATED_COMPOSITING) | 7 #if USE(ACCELERATED_COMPOSITING) |
| 8 | 8 |
| 9 #include "CCDamageTracker.h" | 9 #include "CCDamageTracker.h" |
| 10 | 10 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 m_currentDamageRect.uniteIfNonZero(damageRectForThisUpdate); | 144 m_currentDamageRect.uniteIfNonZero(damageRectForThisUpdate); |
| 145 | 145 |
| 146 // The next history map becomes the current map for the next frame. Note thi
s must | 146 // The next history map becomes the current map for the next frame. Note thi
s must |
| 147 // happen every frame to correctly track changes, even if damage accumulates
over | 147 // happen every frame to correctly track changes, even if damage accumulates
over |
| 148 // multiple frames before actually being drawn. | 148 // multiple frames before actually being drawn. |
| 149 swap(m_currentRectHistory, m_nextRectHistory); | 149 swap(m_currentRectHistory, m_nextRectHistory); |
| 150 } | 150 } |
| 151 | 151 |
| 152 FloatRect CCDamageTracker::removeRectFromCurrentFrame(int layerID, bool& layerIs
New) | 152 FloatRect CCDamageTracker::removeRectFromCurrentFrame(int layerID, bool& layerIs
New) |
| 153 { | 153 { |
| 154 layerIsNew = !m_currentRectHistory->contains(layerID); | 154 RectMap::iterator iter = m_currentRectHistory->find(layerID); |
| 155 layerIsNew = iter == m_currentRectHistory->end(); |
| 156 if (layerIsNew) |
| 157 return FloatRect(); |
| 155 | 158 |
| 156 // take() will remove the entry from the map, or if not found, return a defa
ult (empty) rect. | 159 FloatRect ret = iter->second; |
| 157 return m_currentRectHistory->take(layerID); | 160 m_currentRectHistory->erase(iter); |
| 161 return ret; |
| 158 } | 162 } |
| 159 | 163 |
| 160 void CCDamageTracker::saveRectForNextFrame(int layerID, const FloatRect& targetS
paceRect) | 164 void CCDamageTracker::saveRectForNextFrame(int layerID, const FloatRect& targetS
paceRect) |
| 161 { | 165 { |
| 162 // This layer should not yet exist in next frame's history. | 166 // This layer should not yet exist in next frame's history. |
| 163 ASSERT(layerID > 0); | 167 ASSERT(layerID > 0); |
| 164 ASSERT(m_nextRectHistory->find(layerID) == m_nextRectHistory->end()); | 168 ASSERT(m_nextRectHistory->find(layerID) == m_nextRectHistory->end()); |
| 165 m_nextRectHistory->set(layerID, targetSpaceRect); | 169 (*m_nextRectHistory)[layerID] = targetSpaceRect; |
| 166 } | 170 } |
| 167 | 171 |
| 168 FloatRect CCDamageTracker::trackDamageFromActiveLayers(const std::vector<CCLayer
Impl*>& layerList, int targetSurfaceLayerID) | 172 FloatRect CCDamageTracker::trackDamageFromActiveLayers(const std::vector<CCLayer
Impl*>& layerList, int targetSurfaceLayerID) |
| 169 { | 173 { |
| 170 FloatRect damageRect = FloatRect(); | 174 FloatRect damageRect = FloatRect(); |
| 171 | 175 |
| 172 for (unsigned layerIndex = 0; layerIndex < layerList.size(); ++layerIndex) { | 176 for (unsigned layerIndex = 0; layerIndex < layerList.size(); ++layerIndex) { |
| 173 // Visit layers in back-to-front order. | 177 // Visit layers in back-to-front order. |
| 174 CCLayerImpl* layer = layerList[layerIndex]; | 178 CCLayerImpl* layer = layerList[layerIndex]; |
| 175 | 179 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 200 | 204 |
| 201 FloatRect CCDamageTracker::trackDamageFromLeftoverRects() | 205 FloatRect CCDamageTracker::trackDamageFromLeftoverRects() |
| 202 { | 206 { |
| 203 // After computing damage for all active layers, any leftover items in the c
urrent | 207 // After computing damage for all active layers, any leftover items in the c
urrent |
| 204 // rect history correspond to layers/surfaces that no longer exist. So, thes
e regions | 208 // rect history correspond to layers/surfaces that no longer exist. So, thes
e regions |
| 205 // are now exposed on the target surface. | 209 // are now exposed on the target surface. |
| 206 | 210 |
| 207 FloatRect damageRect = FloatRect(); | 211 FloatRect damageRect = FloatRect(); |
| 208 | 212 |
| 209 for (RectMap::iterator it = m_currentRectHistory->begin(); it != m_currentRe
ctHistory->end(); ++it) | 213 for (RectMap::iterator it = m_currentRectHistory->begin(); it != m_currentRe
ctHistory->end(); ++it) |
| 210 #if WTF_NEW_HASHMAP_ITERATORS_INTERFACE | |
| 211 damageRect.unite(it->value); | |
| 212 #else | |
| 213 damageRect.unite(it->second); | 214 damageRect.unite(it->second); |
| 214 #endif | |
| 215 | 215 |
| 216 m_currentRectHistory->clear(); | 216 m_currentRectHistory->clear(); |
| 217 | 217 |
| 218 return damageRect; | 218 return damageRect; |
| 219 } | 219 } |
| 220 | 220 |
| 221 static bool layerNeedsToRedrawOntoItsTargetSurface(CCLayerImpl* layer) | 221 static bool layerNeedsToRedrawOntoItsTargetSurface(CCLayerImpl* layer) |
| 222 { | 222 { |
| 223 // If the layer does NOT own a surface but has SurfacePropertyChanged, | 223 // If the layer does NOT own a surface but has SurfacePropertyChanged, |
| 224 // this means that its target surface is affected and needs to be redrawn. | 224 // this means that its target surface is affected and needs to be redrawn. |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 // 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 // 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 |
| 341 // 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 // 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 |
| 342 // this layer this frame. | 342 // this layer this frame. |
| 343 if (layer->backgroundFilters().hasFilterThatMovesPixels()) | 343 if (layer->backgroundFilters().hasFilterThatMovesPixels()) |
| 344 expandDamageRectInsideRectWithFilters(targetDamageRect, surfaceRectInTar
getSpace, layer->backgroundFilters()); | 344 expandDamageRectInsideRectWithFilters(targetDamageRect, surfaceRectInTar
getSpace, layer->backgroundFilters()); |
| 345 } | 345 } |
| 346 | 346 |
| 347 } // namespace cc | 347 } // namespace cc |
| 348 | 348 |
| 349 #endif // USE(ACCELERATED_COMPOSITING) | 349 #endif // USE(ACCELERATED_COMPOSITING) |
| OLD | NEW |