Bug 1073545 - Add Vsync Markers to SPS Profiler. r=benwa

This commit is contained in:
Mason Chang 2014-10-01 13:01:59 -07:00
parent a670476201
commit 98d9d46202
5 changed files with 79 additions and 2 deletions

View File

@ -60,6 +60,9 @@
#include "mozilla/Hal.h"
#include "mozilla/HalTypes.h"
#include "mozilla/StaticPtr.h"
#ifdef MOZ_ENABLE_PROFILER_SPS
#include "ProfilerMarkers.h"
#endif
namespace mozilla {
namespace layers {
@ -1117,6 +1120,25 @@ CompositorParent::ComputeRenderIntegrity()
return 1.0f;
}
static void
InsertVsyncProfilerMarker(TimeStamp aVsyncTimestamp)
{
#ifdef MOZ_ENABLE_PROFILER_SPS
MOZ_ASSERT(CompositorParent::IsInCompositorThread());
MOZ_ASSERT(profiler_is_active());
VsyncPayload* payload = new VsyncPayload(aVsyncTimestamp);
PROFILER_MARKER_PAYLOAD("VsyncTimestamp", payload);
#endif
}
/*static */ void
CompositorParent::PostInsertVsyncProfilerMarker(TimeStamp aVsyncTimestamp)
{
if (profiler_is_active()) {
CompositorLoop()->PostTask(FROM_HERE,
NewRunnableFunction(InsertVsyncProfilerMarker, aVsyncTimestamp));
}
}
/**
* This class handles layer updates pushed directly from child

View File

@ -261,6 +261,11 @@ public:
*/
static LayerTreeState* GetIndirectShadowTree(uint64_t aId);
/**
* Used by the profiler to denote when a vsync occured
*/
static void PostInsertVsyncProfilerMarker(mozilla::TimeStamp aVsyncTimestamp);
float ComputeRenderIntegrity();
/**

View File

@ -169,3 +169,18 @@ TouchDataPayload::streamPayloadImpl(JSStreamWriter& b)
b.NameValue("y", mPoint.y);
b.EndObject();
}
VsyncPayload::VsyncPayload(mozilla::TimeStamp aVsyncTimestamp)
: ProfilerMarkerPayload(aVsyncTimestamp, aVsyncTimestamp, nullptr)
, mVsyncTimestamp(aVsyncTimestamp)
{
}
void
VsyncPayload::streamPayloadImpl(JSStreamWriter& b)
{
b.BeginObject();
b.NameValue("vsync", profiler_time(mVsyncTimestamp));
b.NameValue("category", "VsyncTimestamp");
b.EndObject();
}

View File

@ -168,4 +168,22 @@ private:
mozilla::ScreenIntPoint mPoint;
};
/**
* Tracks when a vsync occurs according to the HardwareComposer.
*/
class VsyncPayload : public ProfilerMarkerPayload
{
public:
explicit VsyncPayload(mozilla::TimeStamp aVsyncTimestamp);
virtual ~VsyncPayload() {}
protected:
virtual void
streamPayload(JSStreamWriter& b) { return streamPayloadImpl(b); }
private:
void streamPayloadImpl(JSStreamWriter& b);
mozilla::TimeStamp mVsyncTimestamp;
};
#endif // PROFILER_MARKERS_H

View File

@ -31,6 +31,11 @@
#include "gfx2DGlue.h"
#include "GeckoTouchDispatcher.h"
#ifdef MOZ_ENABLE_PROFILER_SPS
#include "GeckoProfiler.h"
#include "ProfilerMarkers.h"
#endif
#if ANDROID_VERSION >= 17
#include "libdisplay/FramebufferSurface.h"
#include "gfxPrefs.h"
@ -70,6 +75,8 @@ using namespace mozilla::layers;
namespace mozilla {
#if ANDROID_VERSION >= 17
nsecs_t sAndroidInitTime = 0;
mozilla::TimeStamp sMozInitTime;
static void
HookInvalidate(const struct hwc_procs* aProcs)
{
@ -154,6 +161,8 @@ HwcComposer2D::Init(hwc_display_t dpy, hwc_surface_t sur, gl::GLContext* aGLCont
}
if (RegisterHwcEventCallback()) {
sAndroidInitTime = systemTime(SYSTEM_TIME_MONOTONIC);
sMozInitTime = TimeStamp::Now();
EnableVsync(true);
}
#else
@ -229,9 +238,17 @@ HwcComposer2D::RunVsyncEventControl(bool aEnable)
}
void
HwcComposer2D::Vsync(int aDisplay, int64_t aTimestamp)
HwcComposer2D::Vsync(int aDisplay, nsecs_t aVsyncTimestamp)
{
GeckoTouchDispatcher::NotifyVsync(aTimestamp);
#ifdef MOZ_ENABLE_PROFILER_SPS
if (profiler_is_active()) {
nsecs_t timeSinceInit = aVsyncTimestamp - sAndroidInitTime;
TimeStamp vsyncTime = sMozInitTime + TimeDuration::FromMicroseconds(timeSinceInit / 1000);
CompositorParent::PostInsertVsyncProfilerMarker(vsyncTime);
}
#endif
GeckoTouchDispatcher::NotifyVsync(aVsyncTimestamp);
}
// Called on the "invalidator" thread (run from HAL).