Bug 1226826 - Record velocity at point of displayport request in checkerboard event. r?botond
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -2797,18 +2797,20 @@ int32_t AsyncPanZoomController::GetLastT
RefPtr<GestureEventListener> listener = GetGestureEventListener();
return listener ? listener->GetLastTouchIdentifier() : -1;
}
void AsyncPanZoomController::RequestContentRepaint() {
RequestContentRepaint(mFrameMetrics);
}
-void AsyncPanZoomController::RequestContentRepaint(FrameMetrics& aFrameMetrics) {
- aFrameMetrics.SetDisplayPortMargins(CalculatePendingDisplayPort(aFrameMetrics, GetVelocityVector()));
+void AsyncPanZoomController::RequestContentRepaint(FrameMetrics& aFrameMetrics)
+{
+ ParentLayerPoint velocity = GetVelocityVector();
+ aFrameMetrics.SetDisplayPortMargins(CalculatePendingDisplayPort(aFrameMetrics, velocity));
aFrameMetrics.SetUseDisplayPortMargins(true);
// If we're trying to paint what we already think is painted, discard this
// request since it's a pointless paint.
ScreenMargin marginDelta = (mLastPaintRequestMetrics.GetDisplayPortMargins()
- aFrameMetrics.GetDisplayPortMargins());
if (fabsf(marginDelta.left) < EPSILON &&
fabsf(marginDelta.top) < EPSILON &&
@@ -2822,42 +2824,48 @@ void AsyncPanZoomController::RequestCont
fabsf(aFrameMetrics.GetViewport().width -
mLastPaintRequestMetrics.GetViewport().width) < EPSILON &&
fabsf(aFrameMetrics.GetViewport().height -
mLastPaintRequestMetrics.GetViewport().height) < EPSILON &&
aFrameMetrics.GetScrollGeneration() == mLastPaintRequestMetrics.GetScrollGeneration()) {
return;
}
- DispatchRepaintRequest(aFrameMetrics);
+ DispatchRepaintRequest(aFrameMetrics, velocity);
aFrameMetrics.SetPresShellId(mLastContentPaintMetrics.GetPresShellId());
}
/*static*/ CSSRect
GetDisplayPortRect(const FrameMetrics& aFrameMetrics)
{
// This computation is based on what happens in CalculatePendingDisplayPort. If that
// changes then this might need to change too
CSSRect baseRect(aFrameMetrics.GetScrollOffset(),
aFrameMetrics.CalculateBoundedCompositedSizeInCssPixels());
baseRect.Inflate(aFrameMetrics.GetDisplayPortMargins() / aFrameMetrics.DisplayportPixelsPerCSSPixel());
return baseRect;
}
void
-AsyncPanZoomController::DispatchRepaintRequest(const FrameMetrics& aFrameMetrics) {
+AsyncPanZoomController::DispatchRepaintRequest(const FrameMetrics& aFrameMetrics,
+ const ParentLayerPoint& aVelocity)
+{
RefPtr<GeckoContentController> controller = GetGeckoContentController();
if (!controller) {
return;
}
APZC_LOG_FM(aFrameMetrics, "%p requesting content repaint", this);
if (mCheckerboardEvent) {
+ std::stringstream info;
+ info << " velocity " << aVelocity;
+ std::string str = info.str();
mCheckerboardEvent->UpdateRendertraceProperty(
- CheckerboardEvent::RequestedDisplayPort, GetDisplayPortRect(aFrameMetrics));
+ CheckerboardEvent::RequestedDisplayPort, GetDisplayPortRect(aFrameMetrics),
+ str);
}
if (NS_IsMainThread()) {
controller->RequestContentRepaint(aFrameMetrics);
} else {
NS_DispatchToMainThread(NS_NewRunnableMethodWithArg<FrameMetrics>(
controller, &GeckoContentController::RequestContentRepaint, aFrameMetrics));
}
--- a/gfx/layers/apz/src/AsyncPanZoomController.h
+++ b/gfx/layers/apz/src/AsyncPanZoomController.h
@@ -590,17 +590,18 @@ protected:
* the paint throttler. In particular, the GeckoContentController::RequestContentRepaint
* function will be invoked before this function returns.
*/
void RequestContentRepaint(FrameMetrics& aFrameMetrics);
/**
* Actually send the next pending paint request to gecko.
*/
- void DispatchRepaintRequest(const FrameMetrics& aFrameMetrics);
+ void DispatchRepaintRequest(const FrameMetrics& aFrameMetrics,
+ const ParentLayerPoint& aVelocity);
/**
* Gets the current frame metrics. This is *not* the Gecko copy stored in the
* layers code.
*/
const FrameMetrics& GetFrameMetrics() const;
/**
--- a/gfx/layers/apz/src/CheckerboardEvent.cpp
+++ b/gfx/layers/apz/src/CheckerboardEvent.cpp
@@ -53,30 +53,32 @@ std::string
CheckerboardEvent::GetLog()
{
MonitorAutoLock lock(mRendertraceLock);
return mRendertraceInfo.str();
}
void
CheckerboardEvent::UpdateRendertraceProperty(RendertraceProperty aProperty,
- const CSSRect& aRect)
+ const CSSRect& aRect,
+ const std::string& aExtraInfo)
{
MonitorAutoLock lock(mRendertraceLock);
if (!mCheckerboardingActive) {
- mBufferedProperties[aProperty].Update(aProperty, aRect, lock);
+ mBufferedProperties[aProperty].Update(aProperty, aRect, aExtraInfo, lock);
} else {
- LogInfo(aProperty, TimeStamp::Now(), aRect, lock);
+ LogInfo(aProperty, TimeStamp::Now(), aRect, aExtraInfo, lock);
}
}
void
CheckerboardEvent::LogInfo(RendertraceProperty aProperty,
const TimeStamp& aTimestamp,
const CSSRect& aRect,
+ const std::string& aExtraInfo,
const MonitorAutoLock& aProofOfLock)
{
if (mRendertraceInfo.tellp() >= LOG_LENGTH_LIMIT) {
// The log is already long enough, don't put more things into it. We'll
// append a truncation message when this event ends.
return;
}
// The log is consumed by the page at http://people.mozilla.org/~kgupta/rendertrace.html
@@ -85,17 +87,18 @@ CheckerboardEvent::LogInfo(RendertracePr
// https://github.com/staktrace/rendertrace/blob/master/index.html#L30
mRendertraceInfo << "RENDERTRACE "
<< (aTimestamp - mOriginTime).ToMilliseconds() << " rect "
<< sColors[aProperty] << " "
<< aRect.x << " "
<< aRect.y << " "
<< aRect.width << " "
<< aRect.height << " "
- << "// " << sDescriptions[aProperty] << std::endl;
+ << "// " << sDescriptions[aProperty]
+ << aExtraInfo << std::endl;
}
bool
CheckerboardEvent::RecordFrameInfo(const TimeStamp& aSampleTime,
uint32_t aCssPixelsCheckerboarded)
{
bool eventEnding = false;
if (aCssPixelsCheckerboarded > 0) {
@@ -129,17 +132,17 @@ CheckerboardEvent::StartEvent()
MonitorAutoLock lock(mRendertraceLock);
std::vector<PropertyValue> history;
for (int i = 0; i < MAX_RendertraceProperty; i++) {
mBufferedProperties[i].Flush(history, lock);
}
std::sort(history.begin(), history.end());
for (const PropertyValue& p : history) {
- LogInfo(p.mProperty, p.mTimeStamp, p.mRect, lock);
+ LogInfo(p.mProperty, p.mTimeStamp, p.mRect, p.mExtraInfo, lock);
}
mRendertraceInfo << " -- checkerboarding starts below --" << std::endl;
}
void
CheckerboardEvent::StopEvent()
{
mCheckerboardingActive = false;
@@ -168,19 +171,20 @@ CheckerboardEvent::PropertyValue::operat
CheckerboardEvent::PropertyBuffer::PropertyBuffer()
: mIndex(0)
{
}
void
CheckerboardEvent::PropertyBuffer::Update(RendertraceProperty aProperty,
const CSSRect& aRect,
+ const std::string& aExtraInfo,
const MonitorAutoLock& aProofOfLock)
{
- mValues[mIndex] = { aProperty, TimeStamp::Now(), aRect };
+ mValues[mIndex] = { aProperty, TimeStamp::Now(), aRect, aExtraInfo };
mIndex = (mIndex + 1) % BUFFER_SIZE;
}
void
CheckerboardEvent::PropertyBuffer::Flush(std::vector<PropertyValue>& aOut,
const MonitorAutoLock& aProofOfLock)
{
for (uint32_t i = 0; i < BUFFER_SIZE; i++) {
--- a/gfx/layers/apz/src/CheckerboardEvent.h
+++ b/gfx/layers/apz/src/CheckerboardEvent.h
@@ -55,17 +55,18 @@ public:
*/
std::string GetLog();
/**
* Provide a new value for one of the rects that is tracked for
* checkerboard events.
*/
void UpdateRendertraceProperty(RendertraceProperty aProperty,
- const CSSRect& aRect);
+ const CSSRect& aRect,
+ const std::string& aExtraInfo = std::string());
/**
* Provide the number of CSS pixels that are checkerboarded in a composite
* at the given sample time. The sample times must be non-decreasing, and
* should generally be one vsync apart.
* @return true if the checkerboard event has completed. The caller should
* stop updating this object once this happens.
*/
@@ -84,42 +85,45 @@ private:
/**
* Helper method to log a rendertrace property and its value to the
* rendertrace info buffer (mRendertraceInfo).
*/
void LogInfo(RendertraceProperty aProperty,
const TimeStamp& aTimestamp,
const CSSRect& aRect,
+ const std::string& aExtraInfo,
const MonitorAutoLock& aProofOfLock);
/**
* Helper struct that holds a single rendertrace property value.
*/
struct PropertyValue
{
RendertraceProperty mProperty;
TimeStamp mTimeStamp;
CSSRect mRect;
+ std::string mExtraInfo;
bool operator<(const PropertyValue& aOther) const;
};
/**
* A circular buffer that stores the most recent BUFFER_SIZE values of a
* given property.
*/
class PropertyBuffer
{
public:
PropertyBuffer();
/**
* Add a new value to the buffer, overwriting the oldest one if needed.
*/
void Update(RendertraceProperty aProperty, const CSSRect& aRect,
+ const std::string& aExtraInfo,
const MonitorAutoLock& aProofOfLock);
/**
* Dump the recorded values, oldest to newest, to the given vector, and
* remove them from this buffer.
*/
void Flush(std::vector<PropertyValue>& aOut,
const MonitorAutoLock& aProofOfLock);