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 87bf06bd8e
commit b9712ecc03
5 changed files with 99 additions and 11 deletions

View File

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

View File

@@ -8,6 +8,7 @@
#include "ProfilerMarkers.h" #include "ProfilerMarkers.h"
#include "gfxASurface.h" #include "gfxASurface.h"
#include "SyncProfile.h" #include "SyncProfile.h"
#include "Layers.h"
ProfilerMarkerPayload::ProfilerMarkerPayload(ProfilerBacktrace* aStack) ProfilerMarkerPayload::ProfilerMarkerPayload(ProfilerBacktrace* aStack)
: mStack(aStack) : mStack(aStack)
@@ -124,9 +125,46 @@ IOMarkerPayload::streamPayloadImp(JSStreamWriter& b)
b.EndObject(); b.EndObject();
} }
void void
ProfilerJSEventMarker(const char *event) ProfilerJSEventMarker(const char *event)
{ {
PROFILER_MARKER(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];
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 "JSStreamWriter.h"
#include "mozilla/TimeStamp.h" #include "mozilla/TimeStamp.h"
#include "nsAutoPtr.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 * This is an abstract object that can be implied to supply
@@ -122,4 +129,43 @@ private:
char* mFilename; 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 #endif // PROFILER_MARKERS_H

View File

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

View File

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