| 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 |
| 11 #include "CCLayerImpl.h" | 11 #include "CCLayerImpl.h" |
| 12 #include "CCMathUtil.h" | 12 #include "CCMathUtil.h" |
| 13 #include "CCOverdrawMetrics.h" | 13 #include "CCOverdrawMetrics.h" |
| 14 #include "LayerChromium.h" | 14 #include "LayerChromium.h" |
| 15 #include <algorithm> | 15 #include <algorithm> |
| 16 | 16 |
| 17 using namespace std; | 17 using namespace std; |
| 18 using WebKit::WebTransformationMatrix; | 18 using WebKit::WebTransformationMatrix; |
| 19 | 19 |
| 20 namespace WebCore { | 20 namespace cc { |
| 21 | 21 |
| 22 template<typename LayerType, typename RenderSurfaceType> | 22 template<typename LayerType, typename RenderSurfaceType> |
| 23 CCOcclusionTrackerBase<LayerType, RenderSurfaceType>::CCOcclusionTrackerBase(Int
Rect rootTargetRect, bool recordMetricsForFrame) | 23 CCOcclusionTrackerBase<LayerType, RenderSurfaceType>::CCOcclusionTrackerBase(Int
Rect rootTargetRect, bool recordMetricsForFrame) |
| 24 : m_rootTargetRect(rootTargetRect) | 24 : m_rootTargetRect(rootTargetRect) |
| 25 , m_overdrawMetrics(CCOverdrawMetrics::create(recordMetricsForFrame)) | 25 , m_overdrawMetrics(CCOverdrawMetrics::create(recordMetricsForFrame)) |
| 26 , m_occludingScreenSpaceRects(0) | 26 , m_occludingScreenSpaceRects(0) |
| 27 { | 27 { |
| 28 } | 28 } |
| 29 | 29 |
| 30 template<typename LayerType, typename RenderSurfaceType> | 30 template<typename LayerType, typename RenderSurfaceType> |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 // apply |transform| to each rect within |region| in order to transform the
entire Region. | 120 // apply |transform| to each rect within |region| in order to transform the
entire Region. |
| 121 | 121 |
| 122 bool clipped; | 122 bool clipped; |
| 123 FloatQuad transformedBoundsQuad = CCMathUtil::mapQuad(transform, FloatQuad(r
egion.bounds()), clipped); | 123 FloatQuad transformedBoundsQuad = CCMathUtil::mapQuad(transform, FloatQuad(r
egion.bounds()), clipped); |
| 124 // FIXME: Find a rect interior to each transformed quad. | 124 // FIXME: Find a rect interior to each transformed quad. |
| 125 if (clipped || !transformedBoundsQuad.isRectilinear()) | 125 if (clipped || !transformedBoundsQuad.isRectilinear()) |
| 126 return Region(); | 126 return Region(); |
| 127 | 127 |
| 128 Region transformedRegion; | 128 Region transformedRegion; |
| 129 | 129 |
| 130 Vector<IntRect> rects = region.rects(); | 130 Vector<WebCore::IntRect> rects = region.rects(); |
| 131 for (size_t i = 0; i < rects.size(); ++i) { | 131 for (size_t i = 0; i < rects.size(); ++i) { |
| 132 // We've already checked for clipping in the mapQuad call above, these c
alls should not clip anything further. | 132 // We've already checked for clipping in the mapQuad call above, these c
alls should not clip anything further. |
| 133 IntRect transformedRect = enclosedIntRect(CCMathUtil::mapClippedRect(tra
nsform, FloatRect(rects[i]))); | 133 IntRect transformedRect = enclosedIntRect(CCMathUtil::mapClippedRect(tra
nsform, FloatRect(rects[i]))); |
| 134 if (!surface->clipRect().isEmpty()) | 134 if (!surface->clipRect().isEmpty()) |
| 135 transformedRect.intersect(surface->clipRect()); | 135 transformedRect.intersect(surface->clipRect()); |
| 136 transformedRegion.unite(transformedRect); | 136 transformedRegion.unite(transformedRect); |
| 137 } | 137 } |
| 138 return transformedRegion; | 138 return transformedRegion; |
| 139 } | 139 } |
| 140 | 140 |
| 141 static inline void reduceOcclusion(const IntRect& affectedArea, const IntRect& e
xpandedPixel, Region& occlusion) | 141 static inline void reduceOcclusion(const IntRect& affectedArea, const IntRect& e
xpandedPixel, Region& occlusion) |
| 142 { | 142 { |
| 143 if (affectedArea.isEmpty()) | 143 if (affectedArea.isEmpty()) |
| 144 return; | 144 return; |
| 145 | 145 |
| 146 Region affectedOcclusion = intersect(occlusion, affectedArea); | 146 Region affectedOcclusion = intersect(occlusion, affectedArea); |
| 147 Vector<IntRect> affectedOcclusionRects = affectedOcclusion.rects(); | 147 Vector<WebCore::IntRect> affectedOcclusionRects = affectedOcclusion.rects(); |
| 148 | 148 |
| 149 occlusion.subtract(affectedArea); | 149 occlusion.subtract(affectedArea); |
| 150 for (size_t j = 0; j < affectedOcclusionRects.size(); ++j) { | 150 for (size_t j = 0; j < affectedOcclusionRects.size(); ++j) { |
| 151 IntRect& occlusionRect = affectedOcclusionRects[j]; | 151 WebCore::IntRect& occlusionRect = affectedOcclusionRects[j]; |
| 152 | 152 |
| 153 // Shrink the rect by expanding the non-opaque pixels outside the rect. | 153 // Shrink the rect by expanding the non-opaque pixels outside the rect. |
| 154 | 154 |
| 155 // The expandedPixel is the IntRect for a single pixel after being | 155 // The expandedPixel is the IntRect for a single pixel after being |
| 156 // expanded by filters on the layer. The original pixel would be | 156 // expanded by filters on the layer. The original pixel would be |
| 157 // IntRect(0, 0, 1, 1), and the expanded pixel is the rect, relative | 157 // IntRect(0, 0, 1, 1), and the expanded pixel is the rect, relative |
| 158 // to this original rect, that the original pixel can influence after | 158 // to this original rect, that the original pixel can influence after |
| 159 // being filtered. | 159 // being filtered. |
| 160 // To convert the expandedPixel IntRect back to filter outsets: | 160 // To convert the expandedPixel IntRect back to filter outsets: |
| 161 // x = -leftOutset | 161 // x = -leftOutset |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 ASSERT(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<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 } |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, 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 WebCore | 481 } // namespace cc |
| 482 #endif // USE(ACCELERATED_COMPOSITING) | 482 #endif // USE(ACCELERATED_COMPOSITING) |
| OLD | NEW |