OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "CCOcclusionTracker.h" | 7 #include "CCOcclusionTracker.h" |
8 | 8 |
9 #include "CCLayerImpl.h" | 9 #include "CCLayerImpl.h" |
10 #include "CCMathUtil.h" | 10 #include "CCMathUtil.h" |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 reduceOcclusionBelowSurface(oldTarget, unoccludedSurfaceRect, oldSurface
->drawTransform(), newTarget, m_stack.last().occlusionInTarget, m_stack.last().o
cclusionInScreen); | 238 reduceOcclusionBelowSurface(oldTarget, unoccludedSurfaceRect, oldSurface
->drawTransform(), newTarget, m_stack.last().occlusionInTarget, m_stack.last().o
cclusionInScreen); |
239 if (oldTarget->hasReplica()) | 239 if (oldTarget->hasReplica()) |
240 reduceOcclusionBelowSurface(oldTarget, unoccludedReplicaRect, oldSur
face->replicaDrawTransform(), newTarget, m_stack.last().occlusionInTarget, m_sta
ck.last().occlusionInScreen); | 240 reduceOcclusionBelowSurface(oldTarget, unoccludedReplicaRect, oldSur
face->replicaDrawTransform(), newTarget, m_stack.last().occlusionInTarget, m_sta
ck.last().occlusionInScreen); |
241 } | 241 } |
242 } | 242 } |
243 | 243 |
244 // FIXME: Remove usePaintTracking when paint tracking is on for paint culling. | 244 // FIXME: Remove usePaintTracking when paint tracking is on for paint culling. |
245 template<typename LayerType> | 245 template<typename LayerType> |
246 static inline void addOcclusionBehindLayer(Region& region, const LayerType* laye
r, const WebTransformationMatrix& transform, const Region& opaqueContents, const
IntRect& clipRectInTarget, const IntSize& minimumTrackingSize, Vector<IntRect>*
occludingScreenSpaceRects) | 246 static inline void addOcclusionBehindLayer(Region& region, const LayerType* laye
r, const WebTransformationMatrix& transform, const Region& opaqueContents, const
IntRect& clipRectInTarget, const IntSize& minimumTrackingSize, Vector<IntRect>*
occludingScreenSpaceRects) |
247 { | 247 { |
248 ASSERT(layer->visibleContentRect().contains(opaqueContents.bounds())); | 248 DCHECK(layer->visibleContentRect().contains(opaqueContents.bounds())); |
249 | 249 |
250 bool clipped; | 250 bool clipped; |
251 FloatQuad visibleTransformedQuad = CCMathUtil::mapQuad(transform, FloatQuad(
layer->visibleContentRect()), clipped); | 251 FloatQuad visibleTransformedQuad = CCMathUtil::mapQuad(transform, FloatQuad(
layer->visibleContentRect()), clipped); |
252 // FIXME: Find a rect interior to each transformed quad. | 252 // FIXME: Find a rect interior to each transformed quad. |
253 if (clipped || !visibleTransformedQuad.isRectilinear()) | 253 if (clipped || !visibleTransformedQuad.isRectilinear()) |
254 return; | 254 return; |
255 | 255 |
256 Vector<WebCore::IntRect> contentRects = opaqueContents.rects(); | 256 Vector<WebCore::IntRect> contentRects = opaqueContents.rects(); |
257 for (size_t i = 0; i < contentRects.size(); ++i) { | 257 for (size_t i = 0; i < contentRects.size(); ++i) { |
258 // We've already checked for clipping in the mapQuad call above, these c
alls should not clip anything further. | 258 // We've already checked for clipping in the mapQuad call above, these c
alls should not clip anything further. |
259 IntRect transformedRect = enclosedIntRect(CCMathUtil::mapClippedRect(tra
nsform, FloatRect(contentRects[i]))); | 259 IntRect transformedRect = enclosedIntRect(CCMathUtil::mapClippedRect(tra
nsform, FloatRect(contentRects[i]))); |
260 transformedRect.intersect(clipRectInTarget); | 260 transformedRect.intersect(clipRectInTarget); |
261 if (transformedRect.width() >= minimumTrackingSize.width() || transforme
dRect.height() >= minimumTrackingSize.height()) { | 261 if (transformedRect.width() >= minimumTrackingSize.width() || transforme
dRect.height() >= minimumTrackingSize.height()) { |
262 if (occludingScreenSpaceRects) | 262 if (occludingScreenSpaceRects) |
263 occludingScreenSpaceRects->append(transformedRect); | 263 occludingScreenSpaceRects->append(transformedRect); |
264 region.unite(transformedRect); | 264 region.unite(transformedRect); |
265 } | 265 } |
266 } | 266 } |
267 } | 267 } |
268 | 268 |
269 template<typename LayerType, typename RenderSurfaceType> | 269 template<typename LayerType, typename RenderSurfaceType> |
270 void CCOcclusionTrackerBase<LayerType, RenderSurfaceType>::markOccludedBehindLay
er(const LayerType* layer) | 270 void CCOcclusionTrackerBase<LayerType, RenderSurfaceType>::markOccludedBehindLay
er(const LayerType* layer) |
271 { | 271 { |
272 ASSERT(!m_stack.isEmpty()); | 272 DCHECK(!m_stack.isEmpty()); |
273 ASSERT(layer->renderTarget() == m_stack.last().target); | 273 DCHECK(layer->renderTarget() == m_stack.last().target); |
274 if (m_stack.isEmpty()) | 274 if (m_stack.isEmpty()) |
275 return; | 275 return; |
276 | 276 |
277 if (!layerOpacityKnown(layer) || layer->drawOpacity() < 1) | 277 if (!layerOpacityKnown(layer) || layer->drawOpacity() < 1) |
278 return; | 278 return; |
279 | 279 |
280 if (layerIsInUnsorted3dRenderingContext(layer)) | 280 if (layerIsInUnsorted3dRenderingContext(layer)) |
281 return; | 281 return; |
282 | 282 |
283 Region opaqueContents = layer->visibleContentOpaqueRegion(); | 283 Region opaqueContents = layer->visibleContentOpaqueRegion(); |
(...skipping 26 matching lines...) Expand all Loading... |
310 IntRect targetRect = intersection(enclosingIntRect(transformedRect), clipRec
tInTarget); | 310 IntRect targetRect = intersection(enclosingIntRect(transformedRect), clipRec
tInTarget); |
311 return targetRect.isEmpty() || occlusion.contains(targetRect); | 311 return targetRect.isEmpty() || occlusion.contains(targetRect); |
312 } | 312 } |
313 | 313 |
314 template<typename LayerType, typename RenderSurfaceType> | 314 template<typename LayerType, typename RenderSurfaceType> |
315 bool CCOcclusionTrackerBase<LayerType, RenderSurfaceType>::occluded(const LayerT
ype* layer, const IntRect& contentRect, bool* hasOcclusionFromOutsideTargetSurfa
ce) const | 315 bool CCOcclusionTrackerBase<LayerType, RenderSurfaceType>::occluded(const LayerT
ype* layer, const IntRect& contentRect, bool* hasOcclusionFromOutsideTargetSurfa
ce) const |
316 { | 316 { |
317 if (hasOcclusionFromOutsideTargetSurface) | 317 if (hasOcclusionFromOutsideTargetSurface) |
318 *hasOcclusionFromOutsideTargetSurface = false; | 318 *hasOcclusionFromOutsideTargetSurface = false; |
319 | 319 |
320 ASSERT(!m_stack.isEmpty()); | 320 DCHECK(!m_stack.isEmpty()); |
321 if (m_stack.isEmpty()) | 321 if (m_stack.isEmpty()) |
322 return false; | 322 return false; |
323 if (contentRect.isEmpty()) | 323 if (contentRect.isEmpty()) |
324 return true; | 324 return true; |
325 | 325 |
326 ASSERT(layer->renderTarget() == m_stack.last().target); | 326 DCHECK(layer->renderTarget() == m_stack.last().target); |
327 | 327 |
328 if (layerTransformsToTargetKnown(layer) && testContentRectOccluded(contentRe
ct, layer->drawTransform(), layerClipRectInTarget(layer), m_stack.last().occlusi
onInTarget)) | 328 if (layerTransformsToTargetKnown(layer) && testContentRectOccluded(contentRe
ct, layer->drawTransform(), layerClipRectInTarget(layer), m_stack.last().occlusi
onInTarget)) |
329 return true; | 329 return true; |
330 | 330 |
331 if (layerTransformsToScreenKnown(layer) && testContentRectOccluded(contentRe
ct, layer->screenSpaceTransform(), m_rootTargetRect, m_stack.last().occlusionInS
creen)) { | 331 if (layerTransformsToScreenKnown(layer) && testContentRectOccluded(contentRe
ct, layer->screenSpaceTransform(), m_rootTargetRect, m_stack.last().occlusionInS
creen)) { |
332 if (hasOcclusionFromOutsideTargetSurface) | 332 if (hasOcclusionFromOutsideTargetSurface) |
333 *hasOcclusionFromOutsideTargetSurface = true; | 333 *hasOcclusionFromOutsideTargetSurface = true; |
334 return true; | 334 return true; |
335 } | 335 } |
336 | 336 |
(...skipping 18 matching lines...) Expand all Loading... |
355 FloatRect transformedRect = CCMathUtil::mapClippedRect(contentSpaceTransform
, FloatRect(contentRect)); | 355 FloatRect transformedRect = CCMathUtil::mapClippedRect(contentSpaceTransform
, FloatRect(contentRect)); |
356 IntRect shrunkRect = rectSubtractRegion(intersection(enclosingIntRect(transf
ormedRect), clipRectInTarget), occlusion); | 356 IntRect shrunkRect = rectSubtractRegion(intersection(enclosingIntRect(transf
ormedRect), clipRectInTarget), occlusion); |
357 IntRect unoccludedRect = enclosingIntRect(CCMathUtil::projectClippedRect(con
tentSpaceTransform.inverse(), FloatRect(shrunkRect))); | 357 IntRect unoccludedRect = enclosingIntRect(CCMathUtil::projectClippedRect(con
tentSpaceTransform.inverse(), FloatRect(shrunkRect))); |
358 // The rect back in content space is a bounding box and may extend outside o
f the original contentRect, so clamp it to the contentRectBounds. | 358 // The rect back in content space is a bounding box and may extend outside o
f the original contentRect, so clamp it to the contentRectBounds. |
359 return intersection(unoccludedRect, contentRect); | 359 return intersection(unoccludedRect, contentRect); |
360 } | 360 } |
361 | 361 |
362 template<typename LayerType, typename RenderSurfaceType> | 362 template<typename LayerType, typename RenderSurfaceType> |
363 IntRect CCOcclusionTrackerBase<LayerType, RenderSurfaceType>::unoccludedContentR
ect(const LayerType* layer, const IntRect& contentRect, bool* hasOcclusionFromOu
tsideTargetSurface) const | 363 IntRect CCOcclusionTrackerBase<LayerType, RenderSurfaceType>::unoccludedContentR
ect(const LayerType* layer, const IntRect& contentRect, bool* hasOcclusionFromOu
tsideTargetSurface) const |
364 { | 364 { |
365 ASSERT(!m_stack.isEmpty()); | 365 DCHECK(!m_stack.isEmpty()); |
366 if (m_stack.isEmpty()) | 366 if (m_stack.isEmpty()) |
367 return contentRect; | 367 return contentRect; |
368 if (contentRect.isEmpty()) | 368 if (contentRect.isEmpty()) |
369 return contentRect; | 369 return contentRect; |
370 | 370 |
371 ASSERT(layer->renderTarget() == m_stack.last().target); | 371 DCHECK(layer->renderTarget() == m_stack.last().target); |
372 | 372 |
373 // We want to return a rect that contains all the visible parts of |contentR
ect| in both screen space and in the target surface. | 373 // We want to return a rect that contains all the visible parts of |contentR
ect| in both screen space and in the target surface. |
374 // So we find the visible parts of |contentRect| in each space, and take the
intersection. | 374 // So we find the visible parts of |contentRect| in each space, and take the
intersection. |
375 | 375 |
376 IntRect unoccludedInScreen = contentRect; | 376 IntRect unoccludedInScreen = contentRect; |
377 if (layerTransformsToScreenKnown(layer)) | 377 if (layerTransformsToScreenKnown(layer)) |
378 unoccludedInScreen = computeUnoccludedContentRect(contentRect, layer->sc
reenSpaceTransform(), m_rootTargetRect, m_stack.last().occlusionInScreen); | 378 unoccludedInScreen = computeUnoccludedContentRect(contentRect, layer->sc
reenSpaceTransform(), m_rootTargetRect, m_stack.last().occlusionInScreen); |
379 | 379 |
380 IntRect unoccludedInTarget = contentRect; | 380 IntRect unoccludedInTarget = contentRect; |
381 if (layerTransformsToTargetKnown(layer)) | 381 if (layerTransformsToTargetKnown(layer)) |
382 unoccludedInTarget = computeUnoccludedContentRect(contentRect, layer->dr
awTransform(), layerClipRectInTarget(layer), m_stack.last().occlusionInTarget); | 382 unoccludedInTarget = computeUnoccludedContentRect(contentRect, layer->dr
awTransform(), layerClipRectInTarget(layer), m_stack.last().occlusionInTarget); |
383 | 383 |
384 if (hasOcclusionFromOutsideTargetSurface) | 384 if (hasOcclusionFromOutsideTargetSurface) |
385 *hasOcclusionFromOutsideTargetSurface = (intersection(unoccludedInScreen
, unoccludedInTarget) != unoccludedInTarget); | 385 *hasOcclusionFromOutsideTargetSurface = (intersection(unoccludedInScreen
, unoccludedInTarget) != unoccludedInTarget); |
386 | 386 |
387 return intersection(unoccludedInScreen, unoccludedInTarget); | 387 return intersection(unoccludedInScreen, unoccludedInTarget); |
388 } | 388 } |
389 | 389 |
390 template<typename LayerType, typename RenderSurfaceType> | 390 template<typename LayerType, typename RenderSurfaceType> |
391 IntRect CCOcclusionTrackerBase<LayerType, RenderSurfaceType>::unoccludedContribu
tingSurfaceContentRect(const LayerType* layer, bool forReplica, const IntRect& c
ontentRect, bool* hasOcclusionFromOutsideTargetSurface) const | 391 IntRect CCOcclusionTrackerBase<LayerType, RenderSurfaceType>::unoccludedContribu
tingSurfaceContentRect(const LayerType* layer, bool forReplica, const IntRect& c
ontentRect, bool* hasOcclusionFromOutsideTargetSurface) const |
392 { | 392 { |
393 ASSERT(!m_stack.isEmpty()); | 393 DCHECK(!m_stack.isEmpty()); |
394 // The layer is a contributing renderTarget so it should have a surface. | 394 // The layer is a contributing renderTarget so it should have a surface. |
395 ASSERT(layer->renderSurface()); | 395 DCHECK(layer->renderSurface()); |
396 // The layer is a contributing renderTarget so its target should be itself. | 396 // The layer is a contributing renderTarget so its target should be itself. |
397 ASSERT(layer->renderTarget() == layer); | 397 DCHECK(layer->renderTarget() == layer); |
398 // The layer should not be the root, else what is is contributing to? | 398 // The layer should not be the root, else what is is contributing to? |
399 ASSERT(layer->parent()); | 399 DCHECK(layer->parent()); |
400 // This should be called while the layer is still considered the current tar
get in the occlusion tracker. | 400 // This should be called while the layer is still considered the current tar
get in the occlusion tracker. |
401 ASSERT(layer == m_stack.last().target); | 401 DCHECK(layer == m_stack.last().target); |
402 | 402 |
403 if (contentRect.isEmpty()) | 403 if (contentRect.isEmpty()) |
404 return contentRect; | 404 return contentRect; |
405 | 405 |
406 RenderSurfaceType* surface = layer->renderSurface(); | 406 RenderSurfaceType* surface = layer->renderSurface(); |
407 | 407 |
408 IntRect surfaceClipRect = surface->clipRect(); | 408 IntRect surfaceClipRect = surface->clipRect(); |
409 if (surfaceClipRect.isEmpty()) { | 409 if (surfaceClipRect.isEmpty()) { |
410 LayerType* contributingSurfaceRenderTarget = layer->parent()->renderTarg
et(); | 410 LayerType* contributingSurfaceRenderTarget = layer->parent()->renderTarg
et(); |
411 surfaceClipRect = intersection(contributingSurfaceRenderTarget->renderSu
rface()->contentRect(), enclosingIntRect(surface->drawableContentRect())); | 411 surfaceClipRect = intersection(contributingSurfaceRenderTarget->renderSu
rface()->contentRect(), enclosingIntRect(surface->drawableContentRect())); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 template void CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface>::finishedRend
erTarget(const CCLayerImpl* finishedTarget); | 470 template void CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface>::finishedRend
erTarget(const CCLayerImpl* finishedTarget); |
471 template void CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface>::leaveToRende
rTarget(const CCLayerImpl* newTarget); | 471 template void CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface>::leaveToRende
rTarget(const CCLayerImpl* newTarget); |
472 template void CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface>::markOccluded
BehindLayer(const CCLayerImpl*); | 472 template void CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface>::markOccluded
BehindLayer(const CCLayerImpl*); |
473 template bool CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface>::occluded(con
st CCLayerImpl*, const IntRect& contentRect, bool* hasOcclusionFromOutsideTarget
Surface) const; | 473 template bool CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface>::occluded(con
st CCLayerImpl*, const IntRect& contentRect, bool* hasOcclusionFromOutsideTarget
Surface) const; |
474 template IntRect CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface>::unocclude
dContentRect(const CCLayerImpl*, const IntRect& contentRect, bool* hasOcclusionF
romOutsideTargetSurface) const; | 474 template IntRect CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface>::unocclude
dContentRect(const CCLayerImpl*, const IntRect& contentRect, bool* hasOcclusionF
romOutsideTargetSurface) const; |
475 template IntRect CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface>::unocclude
dContributingSurfaceContentRect(const CCLayerImpl*, bool forReplica, const IntRe
ct& contentRect, bool* hasOcclusionFromOutsideTargetSurface) const; | 475 template IntRect CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface>::unocclude
dContributingSurfaceContentRect(const CCLayerImpl*, bool forReplica, const IntRe
ct& contentRect, bool* hasOcclusionFromOutsideTargetSurface) const; |
476 template IntRect CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface>::layerClip
RectInTarget(const CCLayerImpl*) const; | 476 template IntRect CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface>::layerClip
RectInTarget(const CCLayerImpl*) const; |
477 | 477 |
478 | 478 |
479 } // namespace cc | 479 } // namespace cc |
OLD | NEW |