Bug 1049258 - Make it easier to collect frame uniformity results. r=benwa

This commit is contained in:
Mason Chang 2014-09-05 12:39:59 -07:00
parent 119040e108
commit db9dd016ea
5 changed files with 100 additions and 11 deletions

View File

@ -35,6 +35,8 @@
#include "nsTArray.h" // for nsAutoTArray
#include "TextRenderer.h" // for TextRenderer
#include <vector>
#include "GeckoProfiler.h" // for GeckoProfiler
#include "ProfilerMarkers.h" // for ProfilerMarkers
#define CULLING_LOG(...)
// #define CULLING_LOG(...) printf_stderr("CULLING: " __VA_ARGS__)
@ -115,7 +117,9 @@ static void DrawLayerInfo(const RenderTargetIntRect& aClipRect,
static void PrintUniformityInfo(Layer* aLayer)
{
static TimeStamp t0 = TimeStamp::Now();
if (!profiler_is_active()) {
return;
}
// Don't want to print a log for smaller layers
if (aLayer->GetEffectiveVisibleRegion().GetBounds().width < 300 ||
@ -127,10 +131,10 @@ static void PrintUniformityInfo(Layer* aLayer)
if (!transform.Is2D()) {
return;
}
Point translation = transform.As2D().GetTranslation();
printf_stderr("UniformityInfo Layer_Move %llu %p %s\n",
(unsigned long long)(TimeStamp::Now() - t0).ToMilliseconds(), aLayer,
ToString(translation).c_str());
LayerTranslationPayload* payload = new LayerTranslationPayload(aLayer, translation);
PROFILER_MARKER_PAYLOAD("LayerTranslation", payload);
}
/* all of the per-layer prepared data we need to maintain */

View File

@ -8,6 +8,8 @@
#include "ProfilerMarkers.h"
#include "gfxASurface.h"
#include "SyncProfile.h"
#include "Layers.h"
#include "prprf.h"
ProfilerMarkerPayload::ProfilerMarkerPayload(ProfilerBacktrace* aStack)
: mStack(aStack)
@ -124,9 +126,46 @@ IOMarkerPayload::streamPayloadImp(JSStreamWriter& b)
b.EndObject();
}
void
ProfilerJSEventMarker(const char *event)
{
PROFILER_MARKER(event);
}
LayerTranslationPayload::LayerTranslationPayload(mozilla::layers::Layer* aLayer,
mozilla::gfx::Point aPoint)
: ProfilerMarkerPayload(mozilla::TimeStamp::Now(), mozilla::TimeStamp::Now(), nullptr)
, mLayer(aLayer)
, mPoint(aPoint)
{
}
void
LayerTranslationPayload::streamPayloadImpl(JSStreamWriter& b)
{
const size_t bufferSize = 32;
char buffer[bufferSize];
PR_snprintf(buffer, bufferSize, "%p", mLayer);
b.BeginObject();
b.NameValue("layer", buffer);
b.NameValue("x", mPoint.x);
b.NameValue("y", mPoint.y);
b.NameValue("category", "LayerTranslation");
b.EndObject();
}
TouchDataPayload::TouchDataPayload(const mozilla::ScreenIntPoint& aPoint)
: ProfilerMarkerPayload(mozilla::TimeStamp::Now(), mozilla::TimeStamp::Now(), nullptr)
{
mPoint = aPoint;
}
void
TouchDataPayload::streamPayloadImpl(JSStreamWriter& b)
{
b.BeginObject();
b.NameValue("x", mPoint.x);
b.NameValue("y", mPoint.y);
b.EndObject();
}

View File

@ -9,6 +9,13 @@
#include "JSStreamWriter.h"
#include "mozilla/TimeStamp.h"
#include "nsAutoPtr.h"
#include "Units.h" // For ScreenIntPoint
namespace mozilla {
namespace layers {
class Layer;
} // layers
} // mozilla
/**
* This is an abstract object that can be implied to supply
@ -122,4 +129,43 @@ private:
char* mFilename;
};
/**
* Contains the translation applied to a 2d layer so we can
* track the layer position at each frame.
*/
class LayerTranslationPayload : public ProfilerMarkerPayload
{
public:
LayerTranslationPayload(mozilla::layers::Layer* aLayer,
mozilla::gfx::Point aPoint);
protected:
virtual void
streamPayload(JSStreamWriter& b) { return streamPayloadImpl(b); }
private:
void streamPayloadImpl(JSStreamWriter& b);
mozilla::layers::Layer* mLayer;
mozilla::gfx::Point mPoint;
};
/**
* Tracks when touch events are processed by gecko, not when
* the touch actually occured in gonk/android.
*/
class TouchDataPayload : public ProfilerMarkerPayload
{
public:
TouchDataPayload(const mozilla::ScreenIntPoint& aPoint);
virtual ~TouchDataPayload() {}
protected:
virtual void
streamPayload(JSStreamWriter& b) { return streamPayloadImpl(b); }
private:
void streamPayloadImpl(JSStreamWriter& b);
mozilla::ScreenIntPoint mPoint;
};
#endif // PROFILER_MARKERS_H

View File

@ -15,6 +15,7 @@ if CONFIG['MOZ_ENABLE_PROFILER_SPS']:
EXPORTS += [
'GeckoProfilerFunc.h',
'GeckoProfilerImpl.h',
'JSStreamWriter.h',
'ProfilerMarkers.h',
'PseudoStack.h',
'shared-libraries.h',

View File

@ -19,6 +19,7 @@
#include "GeckoProfiler.h"
#include "GeckoTouchDispatcher.h"
#include "InputData.h"
#include "ProfilerMarkers.h"
#include "base/basictypes.h"
#include "gfxPrefs.h"
#include "libui/Input.h"
@ -379,7 +380,7 @@ GeckoTouchDispatcher::DispatchTouchEvent(MultiTouchInput& aMultiTouch)
WidgetTouchEvent event = aMultiTouch.ToWidgetTouchEvent(nullptr);
nsEventStatus status = nsWindow::DispatchInputEvent(event, &captured);
if (mEnabledUniformityInfo) {
if (mEnabledUniformityInfo && profiler_is_active()) {
const char* touchAction = "Invalid";
switch (aMultiTouch.mType) {
case MultiTouchInput::MULTITOUCH_START:
@ -394,11 +395,9 @@ GeckoTouchDispatcher::DispatchTouchEvent(MultiTouchInput& aMultiTouch)
break;
}
const SingleTouchData& firstTouch = aMultiTouch.mTouches[0];
const ScreenIntPoint& touchPoint = firstTouch.mScreenPoint;
LOG("UniformityInfo %s %llu %d %d", touchAction, systemTime(SYSTEM_TIME_MONOTONIC),
touchPoint.x, touchPoint.y);
const ScreenIntPoint& touchPoint = aMultiTouch.mTouches[0].mScreenPoint;
TouchDataPayload* payload = new TouchDataPayload(touchPoint);
PROFILER_MARKER_PAYLOAD(touchAction, payload);
}
if (!captured && (aMultiTouch.mTouches.Length() == 1)) {