cc: 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. TBR=jamesr BUG=119126 Relanding: https://codereview.chromium.org/11293143/ Review URL: https://codereview.chromium.org/11312129 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166521 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
@ -668,7 +668,7 @@ bool LayerTreeHost::paintLayerContents(const LayerList& renderSurfaceLayerList,
|
||||
typedef LayerIterator<Layer, LayerList, RenderSurface, LayerIteratorActions::FrontToBack> LayerIteratorType;
|
||||
|
||||
bool needMoreUpdates = false;
|
||||
bool recordMetricsForFrame = true; // FIXME: In the future, disable this when about:tracing is off.
|
||||
bool recordMetricsForFrame = base::debug::TraceLog::GetInstance() && base::debug::TraceLog::GetInstance()->IsEnabled();
|
||||
OcclusionTracker occlusionTracker(m_rootLayer->renderSurface()->contentRect(), recordMetricsForFrame);
|
||||
occlusionTracker.setMinimumTrackingSize(m_settings.minimumOcclusionTrackingSize);
|
||||
|
||||
|
@ -381,7 +381,7 @@ bool LayerTreeHostImpl::calculateRenderPasses(FrameData& frame)
|
||||
renderSurfaceLayer->renderSurface()->appendRenderPasses(frame);
|
||||
}
|
||||
|
||||
bool recordMetricsForFrame = true; // FIXME: In the future, disable this when about:tracing is off.
|
||||
bool recordMetricsForFrame = base::debug::TraceLog::GetInstance() && base::debug::TraceLog::GetInstance()->IsEnabled();
|
||||
OcclusionTrackerImpl occlusionTracker(m_rootLayerImpl->renderSurface()->contentRect(), recordMetricsForFrame);
|
||||
occlusionTracker.setMinimumTrackingSize(m_settings.minimumOcclusionTrackingSize);
|
||||
|
||||
|
@ -33,32 +33,6 @@ 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)
|
||||
@ -78,8 +52,10 @@ void OverdrawMetrics::didUpload(const WebTransformationMatrix& transformToTarget
|
||||
if (!m_recordMetricsForFrame)
|
||||
return;
|
||||
|
||||
float uploadArea = areaOfMappedQuad(transformToTarget, gfx::QuadF(uploadRect));
|
||||
float uploadOpaqueArea = areaOfMappedQuad(transformToTarget, gfx::QuadF(gfx::IntersectRects(opaqueRect, uploadRect)));
|
||||
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();
|
||||
|
||||
m_pixelsUploadedOpaque += uploadOpaqueArea;
|
||||
m_pixelsUploadedTranslucent += uploadArea - uploadOpaqueArea;
|
||||
@ -106,8 +82,8 @@ void OverdrawMetrics::didCullForDrawing(const WebTransformationMatrix& transform
|
||||
if (!m_recordMetricsForFrame)
|
||||
return;
|
||||
|
||||
float beforeCullArea = areaOfMappedQuad(transformToTarget, gfx::QuadF(beforeCullRect));
|
||||
float afterCullArea = areaOfMappedQuad(transformToTarget, gfx::QuadF(afterCullRect));
|
||||
float beforeCullArea = static_cast<float>(beforeCullRect.width()) * beforeCullRect.height();
|
||||
float afterCullArea = static_cast<float>(afterCullRect.width()) * afterCullRect.height();
|
||||
|
||||
m_pixelsCulledForDrawing += beforeCullArea - afterCullArea;
|
||||
}
|
||||
@ -117,8 +93,10 @@ void OverdrawMetrics::didDraw(const WebTransformationMatrix& transformToTarget,
|
||||
if (!m_recordMetricsForFrame)
|
||||
return;
|
||||
|
||||
float afterCullArea = areaOfMappedQuad(transformToTarget, gfx::QuadF(afterCullRect));
|
||||
float afterCullOpaqueArea = areaOfMappedQuad(transformToTarget, gfx::QuadF(gfx::IntersectRects(opaqueRect, afterCullRect)));
|
||||
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();
|
||||
|
||||
m_pixelsDrawnOpaque += afterCullOpaqueArea;
|
||||
m_pixelsDrawnTranslucent += afterCullArea - afterCullOpaqueArea;
|
||||
|
@ -224,7 +224,7 @@ TEST(QuadCullerTest, verifyCullCenterTileNonIntegralSize1)
|
||||
appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker);
|
||||
EXPECT_EQ(quadList.size(), 2u);
|
||||
|
||||
EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 20363, 1);
|
||||
EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 20000, 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(), 19643, 1);
|
||||
EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnOpaque(), 20000, 1);
|
||||
EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsDrawnTranslucent(), 0, 1);
|
||||
EXPECT_NEAR(occlusionTracker.overdrawMetrics().pixelsCulledForDrawing(), 0, 1);
|
||||
}
|
||||
|
Reference in New Issue
Block a user