OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 boundsInLayerSpace.height() / static_cast<double>(
boundsInContentSpace.height())); | 187 boundsInLayerSpace.height() / static_cast<double>(
boundsInContentSpace.height())); |
188 | 188 |
189 // The draw transform expects the origin to be in the middle of the layer. | 189 // The draw transform expects the origin to be in the middle of the layer. |
190 transform.translate(-boundsInContentSpace.width() / 2.0, -boundsInContentSpa
ce.height() / 2.0); | 190 transform.translate(-boundsInContentSpace.width() / 2.0, -boundsInContentSpa
ce.height() / 2.0); |
191 | 191 |
192 return transform; | 192 return transform; |
193 } | 193 } |
194 | 194 |
195 // FIXME: Remove usePaintTracking when paint tracking is on for paint culling. | 195 // FIXME: Remove usePaintTracking when paint tracking is on for paint culling. |
196 template<typename LayerType> | 196 template<typename LayerType> |
197 static inline Region computeOcclusionBehindLayer(const LayerType* layer, const T
ransformationMatrix& transform, bool usePaintTracking) | 197 static inline Region computeOcclusionBehindLayer(const LayerType* layer, const T
ransformationMatrix& transform, const Region& opaqueContents, bool usePaintTrack
ing) |
198 { | 198 { |
199 Region opaqueRegion; | 199 ASSERT(layer->visibleLayerRect().contains(opaqueContents.bounds())); |
200 | 200 |
201 FloatQuad unoccludedQuad = transform.mapQuad(FloatQuad(layer->visibleLayerRe
ct())); | 201 FloatQuad unoccludedQuad = transform.mapQuad(FloatQuad(layer->visibleLayerRe
ct())); |
202 bool isPaintedAxisAligned = unoccludedQuad.isRectilinear(); | 202 bool isPaintedAxisAligned = unoccludedQuad.isRectilinear(); |
203 if (!isPaintedAxisAligned) | 203 if (!isPaintedAxisAligned) |
204 return opaqueRegion; | 204 return Region(); |
205 | 205 |
206 if (layer->opaque()) | 206 Region transformedOpaqueContents; |
207 opaqueRegion = enclosedIntRect(unoccludedQuad.boundingBox()); | 207 if (usePaintTracking && transform.isIdentity()) |
208 else if (usePaintTracking && transform.isIdentity()) | 208 transformedOpaqueContents = opaqueContents; |
209 opaqueRegion = layer->visibleContentOpaqueRegion(); | |
210 else if (usePaintTracking) { | 209 else if (usePaintTracking) { |
211 Region contentRegion = layer->visibleContentOpaqueRegion(); | 210 Vector<IntRect> contentRects = opaqueContents.rects(); |
212 Vector<IntRect> contentRects = contentRegion.rects(); | |
213 for (size_t i = 0; i < contentRects.size(); ++i) | 211 for (size_t i = 0; i < contentRects.size(); ++i) |
214 opaqueRegion.unite(enclosedIntRect(transform.mapRect(FloatRect(conte
ntRects[i])))); | 212 transformedOpaqueContents.unite(enclosedIntRect(transform.mapRect(Fl
oatRect(contentRects[i])))); |
215 } | 213 } |
216 return opaqueRegion; | 214 |
| 215 return transformedOpaqueContents; |
217 } | 216 } |
218 | 217 |
219 template<typename LayerType, typename RenderSurfaceType> | 218 template<typename LayerType, typename RenderSurfaceType> |
220 void CCOcclusionTrackerBase<LayerType, RenderSurfaceType>::markOccludedBehindLay
er(const LayerType* layer) | 219 void CCOcclusionTrackerBase<LayerType, RenderSurfaceType>::markOccludedBehindLay
er(const LayerType* layer) |
221 { | 220 { |
222 ASSERT(!m_stack.isEmpty()); | 221 ASSERT(!m_stack.isEmpty()); |
223 ASSERT(layer->targetRenderSurface() == m_stack.last().surface); | 222 ASSERT(layer->targetRenderSurface() == m_stack.last().surface); |
224 if (m_stack.isEmpty()) | 223 if (m_stack.isEmpty()) |
225 return; | 224 return; |
226 | 225 |
227 if (!layerOpacityKnown(layer) || layer->drawOpacity() < 1) | 226 if (!layerOpacityKnown(layer) || layer->drawOpacity() < 1) |
228 return; | 227 return; |
229 | 228 |
| 229 Region opaqueContents = layer->visibleContentOpaqueRegion(); |
| 230 if (opaqueContents.isEmpty()) |
| 231 return; |
| 232 |
230 // FIXME: Remove m_usePaintTracking when paint tracking is on for paint cull
ing. | 233 // FIXME: Remove m_usePaintTracking when paint tracking is on for paint cull
ing. |
231 if (layerTransformsToScreenKnown(layer)) | 234 if (layerTransformsToScreenKnown(layer)) |
232 m_stack.last().occlusionInScreen.unite(computeOcclusionBehindLayer<Layer
Type>(layer, contentToScreenSpaceTransform<LayerType>(layer), m_usePaintTracking
)); | 235 m_stack.last().occlusionInScreen.unite(computeOcclusionBehindLayer<Layer
Type>(layer, contentToScreenSpaceTransform<LayerType>(layer), opaqueContents, m_
usePaintTracking)); |
233 if (layerTransformsToTargetKnown(layer)) | 236 if (layerTransformsToTargetKnown(layer)) |
234 m_stack.last().occlusionInTarget.unite(computeOcclusionBehindLayer<Layer
Type>(layer, contentToTargetSurfaceTransform<LayerType>(layer), m_usePaintTracki
ng)); | 237 m_stack.last().occlusionInTarget.unite(computeOcclusionBehindLayer<Layer
Type>(layer, contentToTargetSurfaceTransform<LayerType>(layer), opaqueContents,
m_usePaintTracking)); |
235 } | 238 } |
236 | 239 |
237 static inline bool testContentRectOccluded(const IntRect& contentRect, const Tra
nsformationMatrix& contentSpaceTransform, const IntRect& scissorRect, const Regi
on& occlusion) | 240 static inline bool testContentRectOccluded(const IntRect& contentRect, const Tra
nsformationMatrix& contentSpaceTransform, const IntRect& scissorRect, const Regi
on& occlusion) |
238 { | 241 { |
239 FloatRect transformedRect = contentSpaceTransform.mapRect(FloatRect(contentR
ect)); | 242 FloatRect transformedRect = contentSpaceTransform.mapRect(FloatRect(contentR
ect)); |
240 // Take the enclosingIntRect, as we want to include partial pixels in the te
st. | 243 // Take the enclosingIntRect, as we want to include partial pixels in the te
st. |
241 IntRect targetRect = intersection(enclosingIntRect(transformedRect), scissor
Rect); | 244 IntRect targetRect = intersection(enclosingIntRect(transformedRect), scissor
Rect); |
242 return targetRect.isEmpty() || occlusion.contains(targetRect); | 245 return targetRect.isEmpty() || occlusion.contains(targetRect); |
243 } | 246 } |
244 | 247 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 template void CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface>::markOccluded
BehindLayer(const CCLayerImpl*); | 382 template void CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface>::markOccluded
BehindLayer(const CCLayerImpl*); |
380 template bool CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface>::occluded(con
st CCLayerImpl*, const IntRect& contentRect) const; | 383 template bool CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface>::occluded(con
st CCLayerImpl*, const IntRect& contentRect) const; |
381 template IntRect CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface>::unocclude
dContentRect(const CCLayerImpl*, const IntRect& contentRect) const; | 384 template IntRect CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface>::unocclude
dContentRect(const CCLayerImpl*, const IntRect& contentRect) const; |
382 template const Region& CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface>::cur
rentOcclusionInScreenSpace() const; | 385 template const Region& CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface>::cur
rentOcclusionInScreenSpace() const; |
383 template const Region& CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface>::cur
rentOcclusionInTargetSurface() const; | 386 template const Region& CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface>::cur
rentOcclusionInTargetSurface() const; |
384 template IntRect CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface>::layerScis
sorRectInTargetSurface(const CCLayerImpl*) const; | 387 template IntRect CCOcclusionTrackerBase<CCLayerImpl, CCRenderSurface>::layerScis
sorRectInTargetSurface(const CCLayerImpl*) const; |
385 | 388 |
386 | 389 |
387 } // namespace WebCore | 390 } // namespace WebCore |
388 #endif // USE(ACCELERATED_COMPOSITING) | 391 #endif // USE(ACCELERATED_COMPOSITING) |
OLD | NEW |