Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: cc/occlusion_tracker.cc

Issue 11264056: cc: Use gfx:: Geometry types for positions, bounds, and related things. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: some missed intstuff Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 // FIXME: Find a rect interior to each transformed quad. 126 // FIXME: Find a rect interior to each transformed quad.
127 if (clipped || !transformedBoundsQuad.isRectilinear()) 127 if (clipped || !transformedBoundsQuad.isRectilinear())
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.unite(cc::IntRect(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;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, cc::FloatRect(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(), cc::FloatRect(boundsInTarget )));
198 198
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, 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, Vector<gfx:: Rect>* occludingScreenSpaceRects)
250 { 250 {
251 DCHECK(layer->visibleContentRect().contains(opaqueContents.bounds())); 251 DCHECK(layer->visibleContentRect().Contains(cc::IntRect(opaqueContents.bound s())));
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.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, cc::FloatRect(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(cc::IntRect(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* layer, const gfx::Rect& contentRect, bool* hasOcclusionFromOutsideTargetSurfa ce) const 318 bool OcclusionTrackerBase<LayerType, RenderSurfaceType>::occluded(const LayerTyp e* layer, const gfx::Rect& contentRect, bool* hasOcclusionFromOutsideTargetSurfa ce) const
319 { 319 {
320 if (hasOcclusionFromOutsideTargetSurface) 320 if (hasOcclusionFromOutsideTargetSurface)
321 *hasOcclusionFromOutsideTargetSurface = false; 321 *hasOcclusionFromOutsideTargetSurface = false;
(...skipping 27 matching lines...) Expand all
349 rectRegion.subtract(region); 349 rectRegion.subtract(region);
350 return cc::IntRect(rectRegion.bounds()); 350 return cc::IntRect(rectRegion.bounds());
351 } 351 }
352 352
353 static inline gfx::Rect computeUnoccludedContentRect(const gfx::Rect& contentRec t, const WebTransformationMatrix& contentSpaceTransform, const gfx::Rect& clipRe ctInTarget, const Region& occlusion) 353 static inline gfx::Rect computeUnoccludedContentRect(const gfx::Rect& contentRec t, const WebTransformationMatrix& contentSpaceTransform, const gfx::Rect& clipRe ctInTarget, const Region& occlusion)
354 { 354 {
355 if (!contentSpaceTransform.isInvertible()) 355 if (!contentSpaceTransform.isInvertible())
356 return contentRect; 356 return contentRect;
357 357
358 // Take the ToEnclosingRect at each step, as we want to contain any unocclud ed partial pixels in the resulting Rect. 358 // Take the ToEnclosingRect at each step, as we want to contain any unocclud ed partial pixels in the resulting Rect.
359 FloatRect transformedRect = MathUtil::mapClippedRect(contentSpaceTransform, cc::FloatRect(contentRect)); 359 gfx::RectF transformedRect = MathUtil::mapClippedRect(contentSpaceTransform, gfx::RectF(contentRect));
360 gfx::Rect shrunkRect = rectSubtractRegion(gfx::IntersectRects(gfx::ToEnclosi ngRect(transformedRect), clipRectInTarget), occlusion); 360 gfx::Rect shrunkRect = rectSubtractRegion(gfx::IntersectRects(gfx::ToEnclosi ngRect(transformedRect), clipRectInTarget), occlusion);
361 gfx::Rect unoccludedRect = gfx::ToEnclosingRect(MathUtil::projectClippedRect (contentSpaceTransform.inverse(), cc::FloatRect(shrunkRect))); 361 gfx::Rect unoccludedRect = gfx::ToEnclosingRect(MathUtil::projectClippedRect (contentSpaceTransform.inverse(), gfx::RectF(shrunkRect)));
362 // 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. 362 // 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.
363 return gfx::IntersectRects(unoccludedRect, contentRect); 363 return gfx::IntersectRects(unoccludedRect, contentRect);
364 } 364 }
365 365
366 template<typename LayerType, typename RenderSurfaceType> 366 template<typename LayerType, typename RenderSurfaceType>
367 gfx::Rect OcclusionTrackerBase<LayerType, RenderSurfaceType>::unoccludedContentR ect(const LayerType* layer, const gfx::Rect& contentRect, bool* hasOcclusionFrom OutsideTargetSurface) const 367 gfx::Rect OcclusionTrackerBase<LayerType, RenderSurfaceType>::unoccludedContentR ect(const LayerType* layer, const gfx::Rect& contentRect, bool* hasOcclusionFrom OutsideTargetSurface) const
368 { 368 {
369 DCHECK(!m_stack.isEmpty()); 369 DCHECK(!m_stack.isEmpty());
370 if (m_stack.isEmpty()) 370 if (m_stack.isEmpty())
371 return contentRect; 371 return contentRect;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 template void OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>::finishedRender Target(const LayerImpl* finishedTarget); 474 template void OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>::finishedRender Target(const LayerImpl* finishedTarget);
475 template void OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>::leaveToRenderT arget(const LayerImpl* newTarget); 475 template void OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>::leaveToRenderT arget(const LayerImpl* newTarget);
476 template void OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>::markOccludedBe hindLayer(const LayerImpl*); 476 template void OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>::markOccludedBe hindLayer(const LayerImpl*);
477 template bool OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>::occluded(const LayerImpl*, const gfx::Rect& contentRect, bool* hasOcclusionFromOutsideTargetSu rface) const; 477 template bool OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>::occluded(const LayerImpl*, const gfx::Rect& contentRect, bool* hasOcclusionFromOutsideTargetSu rface) const;
478 template gfx::Rect OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>::unocclude dContentRect(const LayerImpl*, const gfx::Rect& contentRect, bool* hasOcclusionF romOutsideTargetSurface) const; 478 template gfx::Rect OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>::unocclude dContentRect(const LayerImpl*, const gfx::Rect& contentRect, bool* hasOcclusionF romOutsideTargetSurface) const;
479 template gfx::Rect OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>::unocclude dContributingSurfaceContentRect(const LayerImpl*, bool forReplica, const gfx::Re ct& contentRect, bool* hasOcclusionFromOutsideTargetSurface) const; 479 template gfx::Rect OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>::unocclude dContributingSurfaceContentRect(const LayerImpl*, bool forReplica, const gfx::Re ct& contentRect, bool* hasOcclusionFromOutsideTargetSurface) const;
480 template gfx::Rect OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>::layerClip RectInTarget(const LayerImpl*) const; 480 template gfx::Rect OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>::layerClip RectInTarget(const LayerImpl*) const;
481 481
482 482
483 } // namespace cc 483 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698