Bug 927954 - Adding rendertrace logging to the APZ code. r=botond

To use this logging, enable the #define at the top of
AsyncPanZoomController.cpp, run through the scenario you wish
to trace and collect the logs, and then paste them into the
textarea on the page at github.com/staktrace/rendertrace/.
This commit is contained in:
Kartikaya Gupta 2013-11-12 19:03:27 -05:00
parent 0c39b384db
commit 0790196f1e

View File

@ -52,6 +52,8 @@
#include "nsThreadUtils.h" // for NS_IsMainThread
#include "nsTraceRefcnt.h" // for MOZ_COUNT_CTOR, etc
// #define APZC_ENABLE_RENDERTRACE
#define APZC_LOG(...)
// #define APZC_LOG(...) printf_stderr("APZC: " __VA_ARGS__)
#define APZC_LOG_FM(fm, prefix, ...) \
@ -210,6 +212,16 @@ static bool IsCloseToVertical(float aAngle, float aThreshold)
return (fabs(aAngle - (M_PI / 2)) < aThreshold);
}
static inline void LogRendertraceRect(const char* aDesc, const char* aColor, const CSSRect& aRect)
{
#ifdef APZC_ENABLE_RENDERTRACE
static const TimeStamp sRenderStart = TimeStamp::Now();
TimeDuration delta = TimeStamp::Now() - sRenderStart;
printf_stderr("%s RENDERTRACE %f rect %s %f %f %f %f\n",
aDesc, delta.ToMilliseconds(), aColor,
aRect.x, aRect.y, aRect.width, aRect.height);
#endif
}
static TimeStamp sFrameTime;
@ -1143,6 +1155,8 @@ void AsyncPanZoomController::RequestContentRepaint() {
if (controller) {
APZC_LOG_FM(mFrameMetrics, "%p requesting content repaint", this);
LogRendertraceRect("requested displayport", "yellow", newDisplayPort);
mPaintThrottler.PostTask(
FROM_HERE,
NewRunnableMethod(controller.get(),
@ -1223,6 +1237,10 @@ bool AsyncPanZoomController::SampleContentTransformForFrame(const TimeStamp& aSa
aScrollOffset = mFrameMetrics.mScrollOffset * mFrameMetrics.mZoom;
*aNewTransform = GetCurrentAsyncTransform();
LogRendertraceRect("viewport", "red",
CSSRect(mFrameMetrics.mScrollOffset,
ScreenSize(mFrameMetrics.mCompositionBounds.Size()) / mFrameMetrics.mZoom));
mCurrentAsyncScrollOffset = mFrameMetrics.mScrollOffset;
}
@ -1290,6 +1308,10 @@ void AsyncPanZoomController::NotifyLayersUpdated(const FrameMetrics& aLayerMetri
mFrameMetrics.mMayHaveTouchListeners = aLayerMetrics.mMayHaveTouchListeners;
APZC_LOG_FM(aLayerMetrics, "%p got a NotifyLayersUpdated with aIsFirstPaint=%d", this, aIsFirstPaint);
LogRendertraceRect("page", "brown", aLayerMetrics.mScrollableRect);
LogRendertraceRect("painted displayport", "green",
aLayerMetrics.mDisplayPort + aLayerMetrics.mScrollOffset);
mPaintThrottler.TaskComplete(GetFrameTime());
bool needContentRepaint = false;
if (aLayerMetrics.mCompositionBounds.width == mFrameMetrics.mCompositionBounds.width &&