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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 | 355 |
356 // Take the enclosingIntRect at each step, as we want to contain any unocclu
ded partial pixels in the resulting IntRect. | 356 // Take the enclosingIntRect at each step, as we want to contain any unocclu
ded partial pixels in the resulting IntRect. |
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* renderTarget, const IntRect& contentRect, const WebKit::Web
TransformationMatrix& drawTransform, bool transformsToTargetKnown, const IntRect
& clipRectInTarget, bool* hasOcclusionFromOutsideTargetSurface) const |
366 { | 366 { |
367 ASSERT(!m_stack.isEmpty()); | 367 ASSERT(!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 ASSERT(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(renderTarget) && transformsToTargetKnown) |
380 unoccludedInScreen = computeUnoccludedContentRect(contentRect, layer->sc
reenSpaceTransform(), m_rootTargetRect, m_stack.last().occlusionInScreen); | 380 unoccludedInScreen = computeUnoccludedContentRect(contentRect, drawTrans
form * renderTarget->renderSurface()->screenSpaceTransform(), m_rootTargetRect,
m_stack.last().occlusionInScreen); |
381 | 381 |
382 IntRect unoccludedInTarget = contentRect; | 382 IntRect unoccludedInTarget = contentRect; |
383 if (layerTransformsToTargetKnown(layer)) | 383 if (transformsToTargetKnown) |
384 unoccludedInTarget = computeUnoccludedContentRect(contentRect, layer->dr
awTransform(), layerClipRectInTarget(layer), m_stack.last().occlusionInTarget); | 384 unoccludedInTarget = computeUnoccludedContentRect(contentRect, drawTrans
form, clipRectInTarget, 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 { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 | 454 |
455 // Declare the possible functions here for the linker. | 455 // Declare the possible functions here for the linker. |
456 template CCOcclusionTrackerBase<LayerChromium, RenderSurfaceChromium>::CCOcclusi
onTrackerBase(IntRect rootTargetRect, bool recordMetricsForFrame); | 456 template CCOcclusionTrackerBase<LayerChromium, RenderSurfaceChromium>::CCOcclusi
onTrackerBase(IntRect rootTargetRect, bool recordMetricsForFrame); |
457 template void CCOcclusionTrackerBase<LayerChromium, RenderSurfaceChromium>::ente
rLayer(const CCLayerIteratorPosition<LayerChromium>&); | 457 template void CCOcclusionTrackerBase<LayerChromium, RenderSurfaceChromium>::ente
rLayer(const CCLayerIteratorPosition<LayerChromium>&); |
458 template void CCOcclusionTrackerBase<LayerChromium, RenderSurfaceChromium>::leav
eLayer(const CCLayerIteratorPosition<LayerChromium>&); | 458 template void CCOcclusionTrackerBase<LayerChromium, RenderSurfaceChromium>::leav
eLayer(const CCLayerIteratorPosition<LayerChromium>&); |
459 template void CCOcclusionTrackerBase<LayerChromium, RenderSurfaceChromium>::ente
rRenderTarget(const LayerChromium* newTarget); | 459 template void CCOcclusionTrackerBase<LayerChromium, RenderSurfaceChromium>::ente
rRenderTarget(const LayerChromium* newTarget); |
460 template void CCOcclusionTrackerBase<LayerChromium, RenderSurfaceChromium>::fini
shedRenderTarget(const LayerChromium* finishedTarget); | 460 template void CCOcclusionTrackerBase<LayerChromium, RenderSurfaceChromium>::fini
shedRenderTarget(const LayerChromium* finishedTarget); |
461 template void CCOcclusionTrackerBase<LayerChromium, RenderSurfaceChromium>::leav
eToRenderTarget(const LayerChromium* newTarget); | 461 template void CCOcclusionTrackerBase<LayerChromium, RenderSurfaceChromium>::leav
eToRenderTarget(const LayerChromium* newTarget); |
462 template void CCOcclusionTrackerBase<LayerChromium, RenderSurfaceChromium>::mark
OccludedBehindLayer(const LayerChromium*); | 462 template void CCOcclusionTrackerBase<LayerChromium, RenderSurfaceChromium>::mark
OccludedBehindLayer(const LayerChromium*); |
463 template bool CCOcclusionTrackerBase<LayerChromium, RenderSurfaceChromium>::occl
uded(const LayerChromium*, const IntRect& contentRect, bool* hasOcclusionFromOut
sideTargetSurface) const; | 463 template bool CCOcclusionTrackerBase<LayerChromium, RenderSurfaceChromium>::occl
uded(const LayerChromium*, const IntRect& contentRect, bool* hasOcclusionFromOut
sideTargetSurface) const; |
464 template IntRect CCOcclusionTrackerBase<LayerChromium, RenderSurfaceChromium>::u
noccludedContentRect(const LayerChromium*, const IntRect& contentRect, bool* has
OcclusionFromOutsideTargetSurface) const; | 464 template IntRect CCOcclusionTrackerBase<LayerChromium, RenderSurfaceChromium>::u
noccludedContentRect(const LayerChromium*, const IntRect& contentRect, const Web
Kit::WebTransformationMatrix& drawTransform, bool transformsToTargetKnown, const
IntRect& clipRectInTarget, bool* hasOcclusionFromOutsideTargetSurface = 0) cons
t; |
465 template IntRect CCOcclusionTrackerBase<LayerChromium, RenderSurfaceChromium>::u
noccludedContributingSurfaceContentRect(const LayerChromium*, bool forReplica, c
onst IntRect& contentRect, bool* hasOcclusionFromOutsideTargetSurface) const; | 465 template IntRect CCOcclusionTrackerBase<LayerChromium, RenderSurfaceChromium>::u
noccludedContributingSurfaceContentRect(const LayerChromium*, bool forReplica, c
onst IntRect& contentRect, bool* hasOcclusionFromOutsideTargetSurface) const; |
466 template IntRect CCOcclusionTrackerBase<LayerChromium, RenderSurfaceChromium>::l
ayerClipRectInTarget(const LayerChromium*) const; | 466 template IntRect CCOcclusionTrackerBase<LayerChromium, RenderSurfaceChromium>::l
ayerClipRectInTarget(const LayerChromium*) const; |
467 | 467 |
468 template CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface>::CCOcclusionTracke
rBase(IntRect rootTargetRect, bool recordMetricsForFrame); | 468 template CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface>::CCOcclusionTracke
rBase(IntRect rootTargetRect, bool recordMetricsForFrame); |
469 template void CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface>::enterLayer(c
onst CCLayerIteratorPosition<CCLayerImpl>&); | 469 template void CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface>::enterLayer(c
onst CCLayerIteratorPosition<CCLayerImpl>&); |
470 template void CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface>::leaveLayer(c
onst CCLayerIteratorPosition<CCLayerImpl>&); | 470 template void CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface>::leaveLayer(c
onst CCLayerIteratorPosition<CCLayerImpl>&); |
471 template void CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface>::enterRenderT
arget(const CCLayerImpl* newTarget); | 471 template void CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface>::enterRenderT
arget(const CCLayerImpl* newTarget); |
472 template void CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface>::finishedRend
erTarget(const CCLayerImpl* finishedTarget); | 472 template void CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface>::finishedRend
erTarget(const CCLayerImpl* finishedTarget); |
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, const WebKit::WebTr
ansformationMatrix& drawTransform, bool transformsToTargetKnown, const IntRect&
clipRectInTarget, bool* hasOcclusionFromOutsideTargetSurface = 0) 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 |