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