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 "cc/occlusion_tracker.h" | 7 #include "cc/occlusion_tracker.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 return Region(); | 128 return Region(); |
129 | 129 |
130 Region transformedRegion; | 130 Region transformedRegion; |
131 | 131 |
132 Vector<WebCore::IntRect> rects = region.rects(); | 132 Vector<WebCore::IntRect> rects = region.rects(); |
133 for (size_t i = 0; i < rects.size(); ++i) { | 133 for (size_t i = 0; i < rects.size(); ++i) { |
134 // We've already checked for clipping in the mapQuad call above, these c
alls should not clip anything further. | 134 // We've already checked for clipping in the mapQuad call above, these c
alls should not clip anything further. |
135 gfx::Rect transformedRect = gfx::ToEnclosedRect(MathUtil::mapClippedRect
(transform, cc::FloatRect(rects[i]))); | 135 gfx::Rect transformedRect = gfx::ToEnclosedRect(MathUtil::mapClippedRect
(transform, cc::FloatRect(rects[i]))); |
136 if (!surface->clipRect().IsEmpty()) | 136 if (!surface->clipRect().IsEmpty()) |
137 transformedRect.Intersect(surface->clipRect()); | 137 transformedRect.Intersect(surface->clipRect()); |
138 transformedRegion.unite(cc::IntRect(transformedRect)); | 138 transformedRegion.Union(transformedRect); |
139 } | 139 } |
140 return transformedRegion; | 140 return transformedRegion; |
141 } | 141 } |
142 | 142 |
143 static inline void reduceOcclusion(const gfx::Rect& affectedArea, const gfx::Rec
t& expandedPixel, Region& occlusion) | 143 static inline void reduceOcclusion(const gfx::Rect& affectedArea, const gfx::Rec
t& expandedPixel, Region& occlusion) |
144 { | 144 { |
145 if (affectedArea.IsEmpty()) | 145 if (affectedArea.IsEmpty()) |
146 return; | 146 return; |
147 | 147 |
148 Region affectedOcclusion = intersect(occlusion, cc::IntRect(affectedArea)); | 148 Region affectedOcclusion = intersect(occlusion, affectedArea); |
149 Vector<WebCore::IntRect> affectedOcclusionRects = affectedOcclusion.rects(); | 149 Vector<WebCore::IntRect> affectedOcclusionRects = affectedOcclusion.rects(); |
150 | 150 |
151 occlusion.subtract(cc::IntRect(affectedArea)); | 151 occlusion.Subtract(affectedArea); |
152 for (size_t j = 0; j < affectedOcclusionRects.size(); ++j) { | 152 for (size_t j = 0; j < affectedOcclusionRects.size(); ++j) { |
153 WebCore::IntRect& occlusionRect = affectedOcclusionRects[j]; | 153 WebCore::IntRect& occlusionRect = affectedOcclusionRects[j]; |
154 | 154 |
155 // Shrink the rect by expanding the non-opaque pixels outside the rect. | 155 // Shrink the rect by expanding the non-opaque pixels outside the rect. |
156 | 156 |
157 // The expandedPixel is the Rect for a single pixel after being | 157 // The expandedPixel is the Rect for a single pixel after being |
158 // expanded by filters on the layer. The original pixel would be | 158 // expanded by filters on the layer. The original pixel would be |
159 // Rect(0, 0, 1, 1), and the expanded pixel is the rect, relative | 159 // Rect(0, 0, 1, 1), and the expanded pixel is the rect, relative |
160 // to this original rect, that the original pixel can influence after | 160 // to this original rect, that the original pixel can influence after |
161 // being filtered. | 161 // being filtered. |
162 // To convert the expandedPixel Rect back to filter outsets: | 162 // To convert the expandedPixel Rect back to filter outsets: |
163 // x = -leftOutset | 163 // x = -leftOutset |
164 // width = leftOutset + rightOutset | 164 // width = leftOutset + rightOutset |
165 // right = x + width = -leftOutset + leftOutset + rightOutset = rightOut
set | 165 // right = x + width = -leftOutset + leftOutset + rightOutset = rightOut
set |
166 | 166 |
167 // The leftOutset of the filters moves pixels on the right side of | 167 // The leftOutset of the filters moves pixels on the right side of |
168 // the occlusionRect into it, shrinking its right edge. | 168 // the occlusionRect into it, shrinking its right edge. |
169 int shrinkLeft = occlusionRect.x() == affectedArea.x() ? 0 : expandedPix
el.right(); | 169 int shrinkLeft = occlusionRect.x() == affectedArea.x() ? 0 : expandedPix
el.right(); |
170 int shrinkTop = occlusionRect.y() == affectedArea.y() ? 0 : expandedPixe
l.bottom(); | 170 int shrinkTop = occlusionRect.y() == affectedArea.y() ? 0 : expandedPixe
l.bottom(); |
171 int shrinkRight = occlusionRect.maxX() == affectedArea.right() ? 0 : -ex
pandedPixel.x(); | 171 int shrinkRight = occlusionRect.maxX() == affectedArea.right() ? 0 : -ex
pandedPixel.x(); |
172 int shrinkBottom = occlusionRect.maxY() == affectedArea.bottom() ? 0 : -
expandedPixel.y(); | 172 int shrinkBottom = occlusionRect.maxY() == affectedArea.bottom() ? 0 : -
expandedPixel.y(); |
173 | 173 |
174 occlusionRect.move(shrinkLeft, shrinkTop); | 174 occlusionRect.move(shrinkLeft, shrinkTop); |
175 occlusionRect.contract(shrinkLeft + shrinkRight, shrinkTop + shrinkBotto
m); | 175 occlusionRect.contract(shrinkLeft + shrinkRight, shrinkTop + shrinkBotto
m); |
176 | 176 |
177 occlusion.unite(occlusionRect); | 177 occlusion.Union(occlusionRect); |
178 } | 178 } |
179 } | 179 } |
180 | 180 |
181 template<typename LayerType> | 181 template<typename LayerType> |
182 static void reduceOcclusionBelowSurface(LayerType* contributingLayer, const gfx:
:Rect& surfaceRect, const WebTransformationMatrix& surfaceTransform, LayerType*
renderTarget, Region& occlusionInTarget, Region& occlusionInScreen) | 182 static void reduceOcclusionBelowSurface(LayerType* contributingLayer, const gfx:
:Rect& surfaceRect, const WebTransformationMatrix& surfaceTransform, LayerType*
renderTarget, Region& occlusionInTarget, Region& occlusionInScreen) |
183 { | 183 { |
184 if (surfaceRect.IsEmpty()) | 184 if (surfaceRect.IsEmpty()) |
185 return; | 185 return; |
186 | 186 |
187 gfx::Rect boundsInTarget = gfx::ToEnclosingRect(MathUtil::mapClippedRect(sur
faceTransform, cc::FloatRect(surfaceRect))); | 187 gfx::Rect boundsInTarget = gfx::ToEnclosingRect(MathUtil::mapClippedRect(sur
faceTransform, gfx::RectF(surfaceRect))); |
188 if (!contributingLayer->renderSurface()->clipRect().IsEmpty()) | 188 if (!contributingLayer->renderSurface()->clipRect().IsEmpty()) |
189 boundsInTarget.Intersect(contributingLayer->renderSurface()->clipRect())
; | 189 boundsInTarget.Intersect(contributingLayer->renderSurface()->clipRect())
; |
190 | 190 |
191 int outsetTop, outsetRight, outsetBottom, outsetLeft; | 191 int outsetTop, outsetRight, outsetBottom, outsetLeft; |
192 contributingLayer->backgroundFilters().getOutsets(outsetTop, outsetRight, ou
tsetBottom, outsetLeft); | 192 contributingLayer->backgroundFilters().getOutsets(outsetTop, outsetRight, ou
tsetBottom, outsetLeft); |
193 | 193 |
194 // The filter can move pixels from outside of the clip, so allow affectedAre
a to expand outside the clip. | 194 // The filter can move pixels from outside of the clip, so allow affectedAre
a to expand outside the clip. |
195 boundsInTarget.Inset(-outsetLeft, -outsetTop, -outsetRight, -outsetBottom); | 195 boundsInTarget.Inset(-outsetLeft, -outsetTop, -outsetRight, -outsetBottom); |
196 | 196 |
197 gfx::Rect boundsInScreen = gfx::ToEnclosingRect(MathUtil::mapClippedRect(ren
derTarget->renderSurface()->screenSpaceTransform(), cc::FloatRect(boundsInTarget
))); | 197 gfx::Rect boundsInScreen = gfx::ToEnclosingRect(MathUtil::mapClippedRect(ren
derTarget->renderSurface()->screenSpaceTransform(), gfx::RectF(boundsInTarget)))
; |
198 | 198 |
199 gfx::Rect filterOutsetsInTarget(-outsetLeft, -outsetTop, outsetLeft + outset
Right, outsetTop + outsetBottom); | 199 gfx::Rect filterOutsetsInTarget(-outsetLeft, -outsetTop, outsetLeft + outset
Right, outsetTop + outsetBottom); |
200 gfx::Rect filterOutsetsInScreen = gfx::ToEnclosingRect(MathUtil::mapClippedR
ect(renderTarget->renderSurface()->screenSpaceTransform(), cc::FloatRect(filterO
utsetsInTarget))); | 200 gfx::Rect filterOutsetsInScreen = gfx::ToEnclosingRect(MathUtil::mapClippedR
ect(renderTarget->renderSurface()->screenSpaceTransform(), gfx::RectF(filterOuts
etsInTarget))); |
201 | 201 |
202 reduceOcclusion(boundsInTarget, filterOutsetsInTarget, occlusionInTarget); | 202 reduceOcclusion(boundsInTarget, filterOutsetsInTarget, occlusionInTarget); |
203 reduceOcclusion(boundsInScreen, filterOutsetsInScreen, occlusionInScreen); | 203 reduceOcclusion(boundsInScreen, filterOutsetsInScreen, occlusionInScreen); |
204 } | 204 } |
205 | 205 |
206 template<typename LayerType, typename RenderSurfaceType> | 206 template<typename LayerType, typename RenderSurfaceType> |
207 void OcclusionTrackerBase<LayerType, RenderSurfaceType>::leaveToRenderTarget(con
st LayerType* newTarget) | 207 void OcclusionTrackerBase<LayerType, RenderSurfaceType>::leaveToRenderTarget(con
st LayerType* newTarget) |
208 { | 208 { |
209 int lastIndex = m_stack.size() - 1; | 209 int lastIndex = m_stack.size() - 1; |
210 bool surfaceWillBeAtTopAfterPop = m_stack.size() > 1 && m_stack[lastIndex -
1].target == newTarget; | 210 bool surfaceWillBeAtTopAfterPop = m_stack.size() > 1 && m_stack[lastIndex -
1].target == newTarget; |
211 | 211 |
212 // We merge the screen occlusion from the current RenderSurfaceImpl subtree
out to its parent target RenderSurfaceImpl. | 212 // We merge the screen occlusion from the current RenderSurfaceImpl subtree
out to its parent target RenderSurfaceImpl. |
213 // The target occlusion can be merged out as well but needs to be transforme
d to the new target. | 213 // The target occlusion can be merged out as well but needs to be transforme
d to the new target. |
214 | 214 |
215 const LayerType* oldTarget = m_stack[lastIndex].target; | 215 const LayerType* oldTarget = m_stack[lastIndex].target; |
216 const RenderSurfaceType* oldSurface = oldTarget->renderSurface(); | 216 const RenderSurfaceType* oldSurface = oldTarget->renderSurface(); |
217 Region oldTargetOcclusionInNewTarget = transformSurfaceOpaqueRegion<RenderSu
rfaceType>(oldSurface, m_stack[lastIndex].occlusionInTarget, oldSurface->drawTra
nsform()); | 217 Region oldTargetOcclusionInNewTarget = transformSurfaceOpaqueRegion<RenderSu
rfaceType>(oldSurface, m_stack[lastIndex].occlusionInTarget, oldSurface->drawTra
nsform()); |
218 if (oldTarget->hasReplica() && !oldTarget->replicaHasMask()) | 218 if (oldTarget->hasReplica() && !oldTarget->replicaHasMask()) |
219 oldTargetOcclusionInNewTarget.unite(transformSurfaceOpaqueRegion<RenderS
urfaceType>(oldSurface, m_stack[lastIndex].occlusionInTarget, oldSurface->replic
aDrawTransform())); | 219 oldTargetOcclusionInNewTarget.Union(transformSurfaceOpaqueRegion<RenderS
urfaceType>(oldSurface, m_stack[lastIndex].occlusionInTarget, oldSurface->replic
aDrawTransform())); |
220 | 220 |
221 gfx::Rect unoccludedSurfaceRect; | 221 gfx::Rect unoccludedSurfaceRect; |
222 gfx::Rect unoccludedReplicaRect; | 222 gfx::Rect unoccludedReplicaRect; |
223 if (oldTarget->backgroundFilters().hasFilterThatMovesPixels()) { | 223 if (oldTarget->backgroundFilters().hasFilterThatMovesPixels()) { |
224 unoccludedSurfaceRect = unoccludedContributingSurfaceContentRect(oldTarg
et, false, oldSurface->contentRect()); | 224 unoccludedSurfaceRect = unoccludedContributingSurfaceContentRect(oldTarg
et, false, oldSurface->contentRect()); |
225 if (oldTarget->hasReplica()) | 225 if (oldTarget->hasReplica()) |
226 unoccludedReplicaRect = unoccludedContributingSurfaceContentRect(old
Target, true, oldSurface->contentRect()); | 226 unoccludedReplicaRect = unoccludedContributingSurfaceContentRect(old
Target, true, oldSurface->contentRect()); |
227 } | 227 } |
228 | 228 |
229 if (surfaceWillBeAtTopAfterPop) { | 229 if (surfaceWillBeAtTopAfterPop) { |
230 // Merge the top of the stack down. | 230 // Merge the top of the stack down. |
231 m_stack[lastIndex - 1].occlusionInScreen.unite(m_stack[lastIndex].occlus
ionInScreen); | 231 m_stack[lastIndex - 1].occlusionInScreen.Union(m_stack[lastIndex].occlus
ionInScreen); |
232 m_stack[lastIndex - 1].occlusionInTarget.unite(oldTargetOcclusionInNewTa
rget); | 232 m_stack[lastIndex - 1].occlusionInTarget.Union(oldTargetOcclusionInNewTa
rget); |
233 m_stack.removeLast(); | 233 m_stack.removeLast(); |
234 } else { | 234 } else { |
235 // Replace the top of the stack with the new pushed surface. Copy the oc
cluded screen region to the top. | 235 // Replace the top of the stack with the new pushed surface. Copy the oc
cluded screen region to the top. |
236 m_stack.last().target = newTarget; | 236 m_stack.last().target = newTarget; |
237 m_stack.last().occlusionInTarget = oldTargetOcclusionInNewTarget; | 237 m_stack.last().occlusionInTarget = oldTargetOcclusionInNewTarget; |
238 } | 238 } |
239 | 239 |
240 if (oldTarget->backgroundFilters().hasFilterThatMovesPixels()) { | 240 if (oldTarget->backgroundFilters().hasFilterThatMovesPixels()) { |
241 reduceOcclusionBelowSurface(oldTarget, unoccludedSurfaceRect, oldSurface
->drawTransform(), newTarget, m_stack.last().occlusionInTarget, m_stack.last().o
cclusionInScreen); | 241 reduceOcclusionBelowSurface(oldTarget, unoccludedSurfaceRect, oldSurface
->drawTransform(), newTarget, m_stack.last().occlusionInTarget, m_stack.last().o
cclusionInScreen); |
242 if (oldTarget->hasReplica()) | 242 if (oldTarget->hasReplica()) |
243 reduceOcclusionBelowSurface(oldTarget, unoccludedReplicaRect, oldSur
face->replicaDrawTransform(), newTarget, m_stack.last().occlusionInTarget, m_sta
ck.last().occlusionInScreen); | 243 reduceOcclusionBelowSurface(oldTarget, unoccludedReplicaRect, oldSur
face->replicaDrawTransform(), newTarget, m_stack.last().occlusionInTarget, m_sta
ck.last().occlusionInScreen); |
244 } | 244 } |
245 } | 245 } |
246 | 246 |
247 // FIXME: Remove usePaintTracking when paint tracking is on for paint culling. | 247 // FIXME: Remove usePaintTracking when paint tracking is on for paint culling. |
248 template<typename LayerType> | 248 template<typename LayerType> |
249 static inline void addOcclusionBehindLayer(Region& region, const LayerType* laye
r, const WebTransformationMatrix& transform, const Region& opaqueContents, const
gfx::Rect& clipRectInTarget, const gfx::Size& minimumTrackingSize, std::vector<
gfx::Rect>* occludingScreenSpaceRects) | 249 static inline void addOcclusionBehindLayer(Region& region, const LayerType* laye
r, const WebTransformationMatrix& transform, const Region& opaqueContents, const
gfx::Rect& clipRectInTarget, const gfx::Size& minimumTrackingSize, std::vector<
gfx::Rect>* occludingScreenSpaceRects) |
250 { | 250 { |
251 DCHECK(layer->visibleContentRect().Contains(cc::IntRect(opaqueContents.bound
s()))); | 251 DCHECK(layer->visibleContentRect().Contains(opaqueContents.bounds())); |
252 | 252 |
253 bool clipped; | 253 bool clipped; |
254 FloatQuad visibleTransformedQuad = MathUtil::mapQuad(transform, FloatQuad(la
yer->visibleContentRect()), clipped); | 254 FloatQuad visibleTransformedQuad = MathUtil::mapQuad(transform, FloatQuad(la
yer->visibleContentRect()), clipped); |
255 // FIXME: Find a rect interior to each transformed quad. | 255 // FIXME: Find a rect interior to each transformed quad. |
256 if (clipped || !visibleTransformedQuad.isRectilinear()) | 256 if (clipped || !visibleTransformedQuad.isRectilinear()) |
257 return; | 257 return; |
258 | 258 |
259 Vector<WebCore::IntRect> contentRects = opaqueContents.rects(); | 259 Vector<WebCore::IntRect> contentRects = opaqueContents.rects(); |
260 for (size_t i = 0; i < contentRects.size(); ++i) { | 260 for (size_t i = 0; i < contentRects.size(); ++i) { |
261 // We've already checked for clipping in the mapQuad call above, these c
alls should not clip anything further. | 261 // We've already checked for clipping in the mapQuad call above, these c
alls should not clip anything further. |
262 gfx::Rect transformedRect = gfx::ToEnclosedRect(MathUtil::mapClippedRect
(transform, cc::FloatRect(contentRects[i]))); | 262 gfx::Rect transformedRect = gfx::ToEnclosedRect(MathUtil::mapClippedRect
(transform, cc::FloatRect(contentRects[i]))); |
263 transformedRect.Intersect(clipRectInTarget); | 263 transformedRect.Intersect(clipRectInTarget); |
264 if (transformedRect.width() >= minimumTrackingSize.width() || transforme
dRect.height() >= minimumTrackingSize.height()) { | 264 if (transformedRect.width() >= minimumTrackingSize.width() || transforme
dRect.height() >= minimumTrackingSize.height()) { |
265 if (occludingScreenSpaceRects) | 265 if (occludingScreenSpaceRects) |
266 occludingScreenSpaceRects->push_back(transformedRect); | 266 occludingScreenSpaceRects->push_back(transformedRect); |
267 region.unite(cc::IntRect(transformedRect)); | 267 region.Union(transformedRect); |
268 } | 268 } |
269 } | 269 } |
270 } | 270 } |
271 | 271 |
272 template<typename LayerType, typename RenderSurfaceType> | 272 template<typename LayerType, typename RenderSurfaceType> |
273 void OcclusionTrackerBase<LayerType, RenderSurfaceType>::markOccludedBehindLayer
(const LayerType* layer) | 273 void OcclusionTrackerBase<LayerType, RenderSurfaceType>::markOccludedBehindLayer
(const LayerType* layer) |
274 { | 274 { |
275 DCHECK(!m_stack.isEmpty()); | 275 DCHECK(!m_stack.isEmpty()); |
276 DCHECK(layer->renderTarget() == m_stack.last().target); | 276 DCHECK(layer->renderTarget() == m_stack.last().target); |
277 if (m_stack.isEmpty()) | 277 if (m_stack.isEmpty()) |
278 return; | 278 return; |
279 | 279 |
280 if (!layerOpacityKnown(layer) || layer->drawOpacity() < 1) | 280 if (!layerOpacityKnown(layer) || layer->drawOpacity() < 1) |
281 return; | 281 return; |
282 | 282 |
283 if (layerIsInUnsorted3dRenderingContext(layer)) | 283 if (layerIsInUnsorted3dRenderingContext(layer)) |
284 return; | 284 return; |
285 | 285 |
286 Region opaqueContents = layer->visibleContentOpaqueRegion(); | 286 Region opaqueContents = layer->visibleContentOpaqueRegion(); |
287 if (opaqueContents.isEmpty()) | 287 if (opaqueContents.IsEmpty()) |
288 return; | 288 return; |
289 | 289 |
290 gfx::Rect clipRectInTarget = layerClipRectInTarget(layer); | 290 gfx::Rect clipRectInTarget = layerClipRectInTarget(layer); |
291 if (layerTransformsToTargetKnown(layer)) | 291 if (layerTransformsToTargetKnown(layer)) |
292 addOcclusionBehindLayer<LayerType>(m_stack.last().occlusionInTarget, lay
er, layer->drawTransform(), opaqueContents, clipRectInTarget, m_minimumTrackingS
ize, 0); | 292 addOcclusionBehindLayer<LayerType>(m_stack.last().occlusionInTarget, lay
er, layer->drawTransform(), opaqueContents, clipRectInTarget, m_minimumTrackingS
ize, 0); |
293 | 293 |
294 // We must clip the occlusion within the layer's clipRectInTarget within scr
een space as well. If the clip rect can't be moved to screen space and | 294 // We must clip the occlusion within the layer's clipRectInTarget within scr
een space as well. If the clip rect can't be moved to screen space and |
295 // remain rectilinear, then we don't add any occlusion in screen space. | 295 // remain rectilinear, then we don't add any occlusion in screen space. |
296 | 296 |
297 if (layerTransformsToScreenKnown(layer)) { | 297 if (layerTransformsToScreenKnown(layer)) { |
298 WebTransformationMatrix targetToScreenTransform = m_stack.last().target-
>renderSurface()->screenSpaceTransform(); | 298 WebTransformationMatrix targetToScreenTransform = m_stack.last().target-
>renderSurface()->screenSpaceTransform(); |
299 bool clipped; | 299 bool clipped; |
300 FloatQuad clipQuadInScreen = MathUtil::mapQuad(targetToScreenTransform,
FloatQuad(FloatRect(clipRectInTarget)), clipped); | 300 FloatQuad clipQuadInScreen = MathUtil::mapQuad(targetToScreenTransform,
FloatQuad(clipRectInTarget), clipped); |
301 // FIXME: Find a rect interior to the transformed clip quad. | 301 // FIXME: Find a rect interior to the transformed clip quad. |
302 if (clipped || !clipQuadInScreen.isRectilinear()) | 302 if (clipped || !clipQuadInScreen.isRectilinear()) |
303 return; | 303 return; |
304 gfx::Rect clipRectInScreen = gfx::IntersectRects(m_rootTargetRect, gfx::
ToEnclosedRect(clipQuadInScreen.boundingBox())); | 304 gfx::Rect clipRectInScreen = gfx::IntersectRects(m_rootTargetRect, gfx::
ToEnclosedRect(clipQuadInScreen.boundingBox())); |
305 addOcclusionBehindLayer<LayerType>(m_stack.last().occlusionInScreen, lay
er, layer->screenSpaceTransform(), opaqueContents, clipRectInScreen, m_minimumTr
ackingSize, m_occludingScreenSpaceRects); | 305 addOcclusionBehindLayer<LayerType>(m_stack.last().occlusionInScreen, lay
er, layer->screenSpaceTransform(), opaqueContents, clipRectInScreen, m_minimumTr
ackingSize, m_occludingScreenSpaceRects); |
306 } | 306 } |
307 } | 307 } |
308 | 308 |
309 static inline bool testContentRectOccluded(const gfx::Rect& contentRect, const W
ebTransformationMatrix& contentSpaceTransform, const gfx::Rect& clipRectInTarget
, const Region& occlusion) | 309 static inline bool testContentRectOccluded(const gfx::Rect& contentRect, const W
ebTransformationMatrix& contentSpaceTransform, const gfx::Rect& clipRectInTarget
, const Region& occlusion) |
310 { | 310 { |
311 gfx::RectF transformedRect = MathUtil::mapClippedRect(contentSpaceTransform,
gfx::RectF(contentRect)); | 311 gfx::RectF transformedRect = MathUtil::mapClippedRect(contentSpaceTransform,
gfx::RectF(contentRect)); |
312 // Take the gfx::ToEnclosingRect, as we want to include partial pixels in th
e test. | 312 // Take the gfx::ToEnclosingRect, as we want to include partial pixels in th
e test. |
313 gfx::Rect targetRect = gfx::IntersectRects(gfx::ToEnclosingRect(transformedR
ect), clipRectInTarget); | 313 gfx::Rect targetRect = gfx::IntersectRects(gfx::ToEnclosingRect(transformedR
ect), clipRectInTarget); |
314 return targetRect.IsEmpty() || occlusion.contains(cc::IntRect(targetRect)); | 314 return targetRect.IsEmpty() || occlusion.Contains(targetRect); |
315 } | 315 } |
316 | 316 |
317 template<typename LayerType, typename RenderSurfaceType> | 317 template<typename LayerType, typename RenderSurfaceType> |
318 bool OcclusionTrackerBase<LayerType, RenderSurfaceType>::occluded(const LayerTyp
e* renderTarget, const gfx::Rect& contentRect, const WebKit::WebTransformationMa
trix& drawTransform, bool implDrawTransformIsUnknown, const gfx::Rect& clippedRe
ctInTarget, bool* hasOcclusionFromOutsideTargetSurface) const | 318 bool OcclusionTrackerBase<LayerType, RenderSurfaceType>::occluded(const LayerTyp
e* renderTarget, const gfx::Rect& contentRect, const WebKit::WebTransformationMa
trix& drawTransform, bool implDrawTransformIsUnknown, const gfx::Rect& clippedRe
ctInTarget, bool* hasOcclusionFromOutsideTargetSurface) const |
319 { | 319 { |
320 if (hasOcclusionFromOutsideTargetSurface) | 320 if (hasOcclusionFromOutsideTargetSurface) |
321 *hasOcclusionFromOutsideTargetSurface = false; | 321 *hasOcclusionFromOutsideTargetSurface = false; |
322 | 322 |
323 DCHECK(!m_stack.isEmpty()); | 323 DCHECK(!m_stack.isEmpty()); |
324 if (m_stack.isEmpty()) | 324 if (m_stack.isEmpty()) |
(...skipping 14 matching lines...) Expand all Loading... |
339 return true; | 339 return true; |
340 } | 340 } |
341 | 341 |
342 return false; | 342 return false; |
343 } | 343 } |
344 | 344 |
345 // Determines what portion of rect, if any, is unoccluded (not occluded by regio
n). If | 345 // Determines what portion of rect, if any, is unoccluded (not occluded by regio
n). If |
346 // the resulting unoccluded region is not rectangular, we return a rect containi
ng it. | 346 // the resulting unoccluded region is not rectangular, we return a rect containi
ng it. |
347 static inline gfx::Rect rectSubtractRegion(const gfx::Rect& rect, const Region&
region) | 347 static inline gfx::Rect rectSubtractRegion(const gfx::Rect& rect, const Region&
region) |
348 { | 348 { |
349 cc::IntRect intRect(rect); | 349 Region rectRegion(rect); |
350 Region rectRegion(intRect); | 350 rectRegion.Subtract(region); |
351 rectRegion.subtract(region); | 351 return rectRegion.bounds(); |
352 return cc::IntRect(rectRegion.bounds()); | |
353 } | 352 } |
354 | 353 |
355 static inline gfx::Rect computeUnoccludedContentRect(const gfx::Rect& contentRec
t, const WebTransformationMatrix& contentSpaceTransform, const gfx::Rect& clipRe
ctInTarget, const Region& occlusion) | 354 static inline gfx::Rect computeUnoccludedContentRect(const gfx::Rect& contentRec
t, const WebTransformationMatrix& contentSpaceTransform, const gfx::Rect& clipRe
ctInTarget, const Region& occlusion) |
356 { | 355 { |
357 if (!contentSpaceTransform.isInvertible()) | 356 if (!contentSpaceTransform.isInvertible()) |
358 return contentRect; | 357 return contentRect; |
359 | 358 |
360 // Take the ToEnclosingRect at each step, as we want to contain any unocclud
ed partial pixels in the resulting Rect. | 359 // Take the ToEnclosingRect at each step, as we want to contain any unocclud
ed partial pixels in the resulting Rect. |
361 gfx::RectF transformedRect = MathUtil::mapClippedRect(contentSpaceTransform,
gfx::RectF(contentRect)); | 360 gfx::RectF transformedRect = MathUtil::mapClippedRect(contentSpaceTransform,
gfx::RectF(contentRect)); |
362 gfx::Rect shrunkRect = rectSubtractRegion(gfx::IntersectRects(gfx::ToEnclosi
ngRect(transformedRect), clipRectInTarget), occlusion); | 361 gfx::Rect shrunkRect = rectSubtractRegion(gfx::IntersectRects(gfx::ToEnclosi
ngRect(transformedRect), clipRectInTarget), occlusion); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 template void OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>::finishedRender
Target(const LayerImpl* finishedTarget); | 477 template void OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>::finishedRender
Target(const LayerImpl* finishedTarget); |
479 template void OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>::leaveToRenderT
arget(const LayerImpl* newTarget); | 478 template void OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>::leaveToRenderT
arget(const LayerImpl* newTarget); |
480 template void OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>::markOccludedBe
hindLayer(const LayerImpl*); | 479 template void OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>::markOccludedBe
hindLayer(const LayerImpl*); |
481 template bool OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>::occluded(const
LayerImpl*, const gfx::Rect& contentRect, const WebKit::WebTransformationMatrix
& drawTransform, bool implDrawTransformIsUnknown, const gfx::Rect& clippedRectIn
Target, bool* hasOcclusionFromOutsideTargetSurface) const; | 480 template bool OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>::occluded(const
LayerImpl*, const gfx::Rect& contentRect, const WebKit::WebTransformationMatrix
& drawTransform, bool implDrawTransformIsUnknown, const gfx::Rect& clippedRectIn
Target, bool* hasOcclusionFromOutsideTargetSurface) const; |
482 template gfx::Rect OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>::unocclude
dContentRect(const LayerImpl*, const gfx::Rect& contentRect, const WebKit::WebTr
ansformationMatrix& drawTransform, bool implDrawTransformIsUnknown, const gfx::R
ect& clippedRectInTarget, bool* hasOcclusionFromOutsideTargetSurface) const; | 481 template gfx::Rect OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>::unocclude
dContentRect(const LayerImpl*, const gfx::Rect& contentRect, const WebKit::WebTr
ansformationMatrix& drawTransform, bool implDrawTransformIsUnknown, const gfx::R
ect& clippedRectInTarget, bool* hasOcclusionFromOutsideTargetSurface) const; |
483 template gfx::Rect OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>::unocclude
dContributingSurfaceContentRect(const LayerImpl*, bool forReplica, const gfx::Re
ct& contentRect, bool* hasOcclusionFromOutsideTargetSurface) const; | 482 template gfx::Rect OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>::unocclude
dContributingSurfaceContentRect(const LayerImpl*, bool forReplica, const gfx::Re
ct& contentRect, bool* hasOcclusionFromOutsideTargetSurface) const; |
484 template gfx::Rect OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>::layerClip
RectInTarget(const LayerImpl*) const; | 483 template gfx::Rect OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>::layerClip
RectInTarget(const LayerImpl*) const; |
485 | 484 |
486 | 485 |
487 } // namespace cc | 486 } // namespace cc |
OLD | NEW |