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

Side by Side Diff: cc/occlusion_tracker.cc

Issue 11364044: cc: Replace WebCore::FloatQuad with gfx::QuadF. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reeebase. 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
« no previous file with comments | « cc/occlusion_tracker.h ('k') | cc/overdraw_metrics.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 #include "FloatRect.h"
11 #include "cc/layer.h" 12 #include "cc/layer.h"
12 #include "cc/layer_impl.h" 13 #include "cc/layer_impl.h"
13 #include "cc/math_util.h" 14 #include "cc/math_util.h"
14 #include "cc/overdraw_metrics.h" 15 #include "cc/overdraw_metrics.h"
16 #include "ui/gfx/quad_f.h"
15 #include "ui/gfx/rect_conversions.h" 17 #include "ui/gfx/rect_conversions.h"
16 18
17 using namespace std; 19 using namespace std;
18 using WebKit::WebTransformationMatrix; 20 using WebKit::WebTransformationMatrix;
19 21
20 namespace cc { 22 namespace cc {
21 23
22 template<typename LayerType, typename RenderSurfaceType> 24 template<typename LayerType, typename RenderSurfaceType>
23 OcclusionTrackerBase<LayerType, RenderSurfaceType>::OcclusionTrackerBase(gfx::Re ct rootTargetRect, bool recordMetricsForFrame) 25 OcclusionTrackerBase<LayerType, RenderSurfaceType>::OcclusionTrackerBase(gfx::Re ct rootTargetRect, bool recordMetricsForFrame)
24 : m_rootTargetRect(rootTargetRect) 26 : m_rootTargetRect(rootTargetRect)
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 } 117 }
116 } 118 }
117 119
118 template<typename RenderSurfaceType> 120 template<typename RenderSurfaceType>
119 static inline Region transformSurfaceOpaqueRegion(const RenderSurfaceType* surfa ce, const Region& region, const WebTransformationMatrix& transform) 121 static inline Region transformSurfaceOpaqueRegion(const RenderSurfaceType* surfa ce, const Region& region, const WebTransformationMatrix& transform)
120 { 122 {
121 // Verify that rects within the |surface| will remain rects in its target su rface after applying |transform|. If this is true, then 123 // Verify that rects within the |surface| will remain rects in its target su rface after applying |transform|. If this is true, then
122 // apply |transform| to each rect within |region| in order to transform the entire Region. 124 // apply |transform| to each rect within |region| in order to transform the entire Region.
123 125
124 bool clipped; 126 bool clipped;
125 FloatQuad transformedBoundsQuad = MathUtil::mapQuad(transform, FloatQuad(reg ion.bounds()), clipped); 127 gfx::QuadF transformedBoundsQuad = MathUtil::mapQuad(transform, gfx::QuadF(r egion.bounds()), clipped);
126 // FIXME: Find a rect interior to each transformed quad. 128 // FIXME: Find a rect interior to each transformed quad.
127 if (clipped || !transformedBoundsQuad.isRectilinear()) 129 if (clipped || !transformedBoundsQuad.IsRectilinear())
128 return Region(); 130 return Region();
129 131
130 Region transformedRegion; 132 Region transformedRegion;
131 133
132 Vector<WebCore::IntRect> rects = region.rects(); 134 Vector<WebCore::IntRect> rects = region.rects();
133 for (size_t i = 0; i < rects.size(); ++i) { 135 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. 136 // 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]))); 137 gfx::Rect transformedRect = gfx::ToEnclosedRect(MathUtil::mapClippedRect (transform, cc::FloatRect(rects[i])));
136 if (!surface->clipRect().IsEmpty()) 138 if (!surface->clipRect().IsEmpty())
137 transformedRect.Intersect(surface->clipRect()); 139 transformedRect.Intersect(surface->clipRect());
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 } 246 }
245 } 247 }
246 248
247 // FIXME: Remove usePaintTracking when paint tracking is on for paint culling. 249 // FIXME: Remove usePaintTracking when paint tracking is on for paint culling.
248 template<typename LayerType> 250 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) 251 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 { 252 {
251 DCHECK(layer->visibleContentRect().Contains(opaqueContents.bounds())); 253 DCHECK(layer->visibleContentRect().Contains(opaqueContents.bounds()));
252 254
253 bool clipped; 255 bool clipped;
254 FloatQuad visibleTransformedQuad = MathUtil::mapQuad(transform, FloatQuad(la yer->visibleContentRect()), clipped); 256 gfx::QuadF visibleTransformedQuad = MathUtil::mapQuad(transform, gfx::QuadF( layer->visibleContentRect()), clipped);
255 // FIXME: Find a rect interior to each transformed quad. 257 // FIXME: Find a rect interior to each transformed quad.
256 if (clipped || !visibleTransformedQuad.isRectilinear()) 258 if (clipped || !visibleTransformedQuad.IsRectilinear())
257 return; 259 return;
258 260
259 Vector<WebCore::IntRect> contentRects = opaqueContents.rects(); 261 Vector<WebCore::IntRect> contentRects = opaqueContents.rects();
260 for (size_t i = 0; i < contentRects.size(); ++i) { 262 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. 263 // 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]))); 264 gfx::Rect transformedRect = gfx::ToEnclosedRect(MathUtil::mapClippedRect (transform, cc::FloatRect(contentRects[i])));
263 transformedRect.Intersect(clipRectInTarget); 265 transformedRect.Intersect(clipRectInTarget);
264 if (transformedRect.width() >= minimumTrackingSize.width() || transforme dRect.height() >= minimumTrackingSize.height()) { 266 if (transformedRect.width() >= minimumTrackingSize.width() || transforme dRect.height() >= minimumTrackingSize.height()) {
265 if (occludingScreenSpaceRects) 267 if (occludingScreenSpaceRects)
266 occludingScreenSpaceRects->push_back(transformedRect); 268 occludingScreenSpaceRects->push_back(transformedRect);
(...skipping 23 matching lines...) Expand all
290 gfx::Rect clipRectInTarget = layerClipRectInTarget(layer); 292 gfx::Rect clipRectInTarget = layerClipRectInTarget(layer);
291 if (layerTransformsToTargetKnown(layer)) 293 if (layerTransformsToTargetKnown(layer))
292 addOcclusionBehindLayer<LayerType>(m_stack.last().occlusionInTarget, lay er, layer->drawTransform(), opaqueContents, clipRectInTarget, m_minimumTrackingS ize, 0); 294 addOcclusionBehindLayer<LayerType>(m_stack.last().occlusionInTarget, lay er, layer->drawTransform(), opaqueContents, clipRectInTarget, m_minimumTrackingS ize, 0);
293 295
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 296 // 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. 297 // remain rectilinear, then we don't add any occlusion in screen space.
296 298
297 if (layerTransformsToScreenKnown(layer)) { 299 if (layerTransformsToScreenKnown(layer)) {
298 WebTransformationMatrix targetToScreenTransform = m_stack.last().target- >renderSurface()->screenSpaceTransform(); 300 WebTransformationMatrix targetToScreenTransform = m_stack.last().target- >renderSurface()->screenSpaceTransform();
299 bool clipped; 301 bool clipped;
300 FloatQuad clipQuadInScreen = MathUtil::mapQuad(targetToScreenTransform, FloatQuad(clipRectInTarget), clipped); 302 gfx::QuadF clipQuadInScreen = MathUtil::mapQuad(targetToScreenTransform, gfx::QuadF(clipRectInTarget), clipped);
301 // FIXME: Find a rect interior to the transformed clip quad. 303 // FIXME: Find a rect interior to the transformed clip quad.
302 if (clipped || !clipQuadInScreen.isRectilinear()) 304 if (clipped || !clipQuadInScreen.IsRectilinear())
303 return; 305 return;
304 gfx::Rect clipRectInScreen = gfx::IntersectRects(m_rootTargetRect, gfx:: ToEnclosedRect(clipQuadInScreen.boundingBox())); 306 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); 307 addOcclusionBehindLayer<LayerType>(m_stack.last().occlusionInScreen, lay er, layer->screenSpaceTransform(), opaqueContents, clipRectInScreen, m_minimumTr ackingSize, m_occludingScreenSpaceRects);
306 } 308 }
307 } 309 }
308 310
309 static inline bool testContentRectOccluded(const gfx::Rect& contentRect, const W ebTransformationMatrix& contentSpaceTransform, const gfx::Rect& clipRectInTarget , const Region& occlusion) 311 static inline bool testContentRectOccluded(const gfx::Rect& contentRect, const W ebTransformationMatrix& contentSpaceTransform, const gfx::Rect& clipRectInTarget , const Region& occlusion)
310 { 312 {
311 gfx::RectF transformedRect = MathUtil::mapClippedRect(contentSpaceTransform, gfx::RectF(contentRect)); 313 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. 314 // 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); 315 gfx::Rect targetRect = gfx::IntersectRects(gfx::ToEnclosingRect(transformedR ect), clipRectInTarget);
314 return targetRect.IsEmpty() || occlusion.Contains(targetRect); 316 return targetRect.IsEmpty() || occlusion.Contains(targetRect);
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 template void OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>::finishedRender Target(const LayerImpl* finishedTarget); 479 template void OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>::finishedRender Target(const LayerImpl* finishedTarget);
478 template void OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>::leaveToRenderT arget(const LayerImpl* newTarget); 480 template void OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>::leaveToRenderT arget(const LayerImpl* newTarget);
479 template void OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>::markOccludedBe hindLayer(const LayerImpl*); 481 template void OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>::markOccludedBe hindLayer(const LayerImpl*);
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 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;
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 dContentRect(const LayerImpl*, const gfx::Rect& contentRect, const WebKit::WebTr ansformationMatrix& drawTransform, bool implDrawTransformIsUnknown, const gfx::R ect& clippedRectInTarget, 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>::unocclude dContributingSurfaceContentRect(const LayerImpl*, bool forReplica, const gfx::Re ct& contentRect, bool* hasOcclusionFromOutsideTargetSurface) const;
483 template gfx::Rect OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>::layerClip RectInTarget(const LayerImpl*) const; 485 template gfx::Rect OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>::layerClip RectInTarget(const LayerImpl*) const;
484 486
485 487
486 } // namespace cc 488 } // namespace cc
OLDNEW
« no previous file with comments | « cc/occlusion_tracker.h ('k') | cc/overdraw_metrics.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698