diff options
author | scottmg@google.com <scottmg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-07 18:40:14 +0000 |
---|---|---|
committer | scottmg@google.com <scottmg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-07 18:40:14 +0000 |
commit | 2d4dbdb0bd2445350fe2f62cb1ebcc7f608bfe66 (patch) | |
tree | b3a37e8f140004e53f8ceeadd98da23e3ef722ff /cc | |
parent | c32a69cce152ec89c3f186593890ec2397439a7a (diff) | |
download | chromium_src-2d4dbdb0bd2445350fe2f62cb1ebcc7f608bfe66.zip chromium_src-2d4dbdb0bd2445350fe2f62cb1ebcc7f608bfe66.tar.gz chromium_src-2d4dbdb0bd2445350fe2f62cb1ebcc7f608bfe66.tar.bz2 |
Revert 166464 - Turn overdraw metrics on only when about:tracing is recording.
Now that we're in chromium, we can tell if about:tracing is enabled ot not!
Turn on overdraw metrics, and their expensive computations, only when
about:tracing is turned on.
When we do turn them on, we don't want the performance characteristics of
the system to suddenly change, or the tracing is not very meaningful! So, we
track the number of pixels read, instead of written, for overdraw (which
should mostly be the same with the new rasterScale feature). This
computation is very cheap compared to the old one.
R=jamesr
BUG=119126
Review URL: https://codereview.chromium.org/11293143
TBR=danakj@chromium.org
Review URL: https://codereview.chromium.org/11364132
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166477 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/layer_tree_host.cc | 2 | ||||
-rw-r--r-- | cc/layer_tree_host_impl.cc | 2 | ||||
-rw-r--r-- | cc/overdraw_metrics.cc | 42 | ||||
-rw-r--r-- | cc/quad_culler_unittest.cc | 4 |
4 files changed, 36 insertions, 14 deletions
diff --git a/cc/layer_tree_host.cc b/cc/layer_tree_host.cc index 418a450..07d2591 100644 --- a/cc/layer_tree_host.cc +++ b/cc/layer_tree_host.cc @@ -668,7 +668,7 @@ bool LayerTreeHost::paintLayerContents(const LayerList& renderSurfaceLayerList, typedef LayerIterator<Layer, LayerList, RenderSurface, LayerIteratorActions::FrontToBack> LayerIteratorType; bool needMoreUpdates = false; - bool recordMetricsForFrame = base::debug::TraceLog::GetInstance()->IsEnabled(); + bool recordMetricsForFrame = true; // FIXME: In the future, disable this when about:tracing is off. OcclusionTracker occlusionTracker(m_rootLayer->renderSurface()->contentRect(), recordMetricsForFrame); occlusionTracker.setMinimumTrackingSize(m_settings.minimumOcclusionTrackingSize); diff --git a/cc/layer_tree_host_impl.cc b/cc/layer_tree_host_impl.cc index b095040..2f5ee5c 100644 --- a/cc/layer_tree_host_impl.cc +++ b/cc/layer_tree_host_impl.cc @@ -381,7 +381,7 @@ bool LayerTreeHostImpl::calculateRenderPasses(FrameData& frame) renderSurfaceLayer->renderSurface()->appendRenderPasses(frame); } - bool recordMetricsForFrame = base::debug::TraceLog::GetInstance()->IsEnabled(); + bool recordMetricsForFrame = true; // FIXME: In the future, disable this when about:tracing is off. OcclusionTrackerImpl occlusionTracker(m_rootLayerImpl->renderSurface()->contentRect(), recordMetricsForFrame); occlusionTracker.setMinimumTrackingSize(m_settings.minimumOcclusionTrackingSize); diff --git a/cc/overdraw_metrics.cc b/cc/overdraw_metrics.cc index 1f8aed8..be8e7f8 100644 --- a/cc/overdraw_metrics.cc +++ b/cc/overdraw_metrics.cc @@ -33,6 +33,32 @@ OverdrawMetrics::OverdrawMetrics(bool recordMetricsForFrame) { } +static inline float wedgeProduct(const gfx::PointF& p1, const gfx::PointF& p2) +{ + return p1.x() * p2.y() - p1.y() * p2.x(); +} + +// Calculates area of an arbitrary convex polygon with up to 8 points. +static inline float polygonArea(const gfx::PointF points[8], int numPoints) +{ + if (numPoints < 3) + return 0; + + float area = 0; + for (int i = 0; i < numPoints; ++i) + area += wedgeProduct(points[i], points[(i+1)%numPoints]); + return fabs(0.5f * area); +} + +// Takes a given quad, maps it by the given transformation, and gives the area of the resulting polygon. +static inline float areaOfMappedQuad(const WebTransformationMatrix& transform, const gfx::QuadF& quad) +{ + gfx::PointF clippedQuad[8]; + int numVerticesInClippedQuad = 0; + MathUtil::mapClippedQuad(transform, quad, clippedQuad, numVerticesInClippedQuad); + return polygonArea(clippedQuad, numVerticesInClippedQuad); +} + void OverdrawMetrics::didPaint(const gfx::Rect& paintedRect) { if (!m_recordMetricsForFrame) @@ -52,10 +78,8 @@ void OverdrawMetrics::didUpload(const WebTransformationMatrix& transformToTarget if (!m_recordMetricsForFrame) return; - gfx::Rect uploadOpaqueRect = gfx::IntersectRects(opaqueRect, uploadRect); - - float uploadArea = static_cast<float>(uploadRect.width()) * uploadRect.height(); - float uploadOpaqueArea = static_cast<float>(uploadOpaqueRect.width()) * uploadOpaqueRect.height(); + float uploadArea = areaOfMappedQuad(transformToTarget, gfx::QuadF(uploadRect)); + float uploadOpaqueArea = areaOfMappedQuad(transformToTarget, gfx::QuadF(gfx::IntersectRects(opaqueRect, uploadRect))); m_pixelsUploadedOpaque += uploadOpaqueArea; m_pixelsUploadedTranslucent += uploadArea - uploadOpaqueArea; @@ -82,8 +106,8 @@ void OverdrawMetrics::didCullForDrawing(const WebTransformationMatrix& transform if (!m_recordMetricsForFrame) return; - float beforeCullArea = static_cast<float>(beforeCullRect.width()) * beforeCullRect.height(); - float afterCullArea = static_cast<float>(afterCullRect.width()) * afterCullRect.height(); + float beforeCullArea = areaOfMappedQuad(transformToTarget, gfx::QuadF(beforeCullRect)); + float afterCullArea = areaOfMappedQuad(transformToTarget, gfx::QuadF(afterCullRect)); m_pixelsCulledForDrawing += beforeCullArea - afterCullArea; } @@ -93,10 +117,8 @@ void OverdrawMetrics::didDraw(const WebTransformationMatrix& transformToTarget, if (!m_recordMetricsForFrame) return; - gfx::Rect afterCullOpaqueRect = gfx::IntersectRects(opaqueRect, afterCullRect); - - float afterCullArea = static_cast<float>(afterCullRect.width()) * afterCullRect.height(); - float afterCullOpaqueArea = static_cast<float>(afterCullOpaqueRect.width()) * afterCullOpaqueRect.height(); + float afterCullArea = areaOfMappedQuad(transformToTarget, gfx::QuadF(afterCullRect)); + float afterCullOpaqueArea = areaOfMappedQuad(transformToTarget, gfx::QuadF(gfx::IntersectRects(opaqueRect, afterCullRect))); m_pixelsDrawnOpaque += afterCullOpaqueArea; m_pixelsDrawnTranslucent += afterCullArea - afterCullOpaqueArea; diff --git a/cc/quad_culler_unittest.cc b/cc/quad_culler_unittest.cc index 433d489..c60aec6 100644 --- a/cc/quad_culler_unittest.cc +++ b/cc/quad_culler_unittest.cc @@ -224,7 +224,7 @@ TEST(QuadCullerTest, verifyCullCenterTileNonIntegralSize1) appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker); EXPECT_EQ(quadList.size(), 2u); - EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 20000, 1); + EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 20363, 1); EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 0, 1); EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 0, 1); } @@ -252,7 +252,7 @@ TEST(QuadCullerTest, verifyCullCenterTileNonIntegralSize2) appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker); EXPECT_EQ(quadList.size(), 2u); - EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 20000, 1); + EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 19643, 1); EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 0, 1); EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 0, 1); } |