2013-07-10 21:27:04 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef PROFILER_MARKERS_H
|
|
|
|
#define PROFILER_MARKERS_H
|
|
|
|
|
2014-04-21 13:48:47 -07:00
|
|
|
#include "JSStreamWriter.h"
|
2013-09-25 08:28:34 -07:00
|
|
|
#include "mozilla/TimeStamp.h"
|
2013-07-10 21:27:04 -07:00
|
|
|
#include "nsAutoPtr.h"
|
2014-09-05 12:39:59 -07:00
|
|
|
#include "Units.h" // For ScreenIntPoint
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
class Layer;
|
|
|
|
} // layers
|
|
|
|
} // mozilla
|
2013-07-10 21:27:04 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This is an abstract object that can be implied to supply
|
|
|
|
* data to be attached with a profiler marker. Most data inserted
|
|
|
|
* into a profile is stored in a circular buffer. This buffer
|
|
|
|
* typically wraps around and overwrites most entries. Because
|
|
|
|
* of this, this structure is designed to defer the work of
|
|
|
|
* prepare the payload only when 'preparePayload' is called.
|
|
|
|
*
|
|
|
|
* Note when implementing that this object is typically constructed
|
|
|
|
* on a particular thread but 'preparePayload' and the destructor
|
|
|
|
* is called from the main thread.
|
|
|
|
*/
|
2013-09-25 08:28:34 -07:00
|
|
|
class ProfilerMarkerPayload
|
|
|
|
{
|
2013-07-10 21:27:04 -07:00
|
|
|
public:
|
2013-09-25 08:28:34 -07:00
|
|
|
/**
|
|
|
|
* ProfilerMarkerPayload takes ownership of aStack
|
|
|
|
*/
|
2014-09-02 06:44:54 -07:00
|
|
|
explicit ProfilerMarkerPayload(ProfilerBacktrace* aStack = nullptr);
|
2013-09-25 08:28:34 -07:00
|
|
|
ProfilerMarkerPayload(const mozilla::TimeStamp& aStartTime,
|
|
|
|
const mozilla::TimeStamp& aEndTime,
|
|
|
|
ProfilerBacktrace* aStack = nullptr);
|
2013-07-10 21:27:04 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called from the main thread
|
|
|
|
*/
|
2013-09-25 08:28:34 -07:00
|
|
|
virtual ~ProfilerMarkerPayload();
|
2013-07-10 21:27:04 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called from the main thread
|
|
|
|
*/
|
2014-04-21 13:48:47 -07:00
|
|
|
void StreamPayload(JSStreamWriter& b) {
|
|
|
|
return streamPayload(b);
|
2013-07-10 21:27:04 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2013-09-25 08:28:34 -07:00
|
|
|
/**
|
|
|
|
* Called from the main thread
|
|
|
|
*/
|
2014-04-21 13:48:47 -07:00
|
|
|
void streamCommonProps(const char* aMarkerType, JSStreamWriter& b);
|
2013-09-25 08:28:34 -07:00
|
|
|
|
2013-07-10 21:27:04 -07:00
|
|
|
/**
|
|
|
|
* Called from the main thread
|
|
|
|
*/
|
2014-04-21 13:48:47 -07:00
|
|
|
virtual void
|
|
|
|
streamPayload(JSStreamWriter& b) = 0;
|
2013-09-25 08:28:34 -07:00
|
|
|
|
2014-04-22 11:13:00 -07:00
|
|
|
void SetStack(ProfilerBacktrace* aStack) { mStack = aStack; }
|
|
|
|
|
2013-09-25 08:28:34 -07:00
|
|
|
private:
|
|
|
|
mozilla::TimeStamp mStartTime;
|
|
|
|
mozilla::TimeStamp mEndTime;
|
|
|
|
ProfilerBacktrace* mStack;
|
2013-07-10 21:27:04 -07:00
|
|
|
};
|
|
|
|
|
2013-09-27 09:08:45 -07:00
|
|
|
class ProfilerMarkerTracing : public ProfilerMarkerPayload
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ProfilerMarkerTracing(const char* aCategory, TracingMetadata aMetaData);
|
2014-04-22 11:13:00 -07:00
|
|
|
ProfilerMarkerTracing(const char* aCategory, TracingMetadata aMetaData, ProfilerBacktrace* aCause);
|
2013-09-27 09:08:45 -07:00
|
|
|
|
|
|
|
const char *GetCategory() const { return mCategory; }
|
|
|
|
TracingMetadata GetMetaData() const { return mMetaData; }
|
|
|
|
|
|
|
|
protected:
|
2014-04-21 13:48:47 -07:00
|
|
|
virtual void
|
|
|
|
streamPayload(JSStreamWriter& b) { return streamPayloadImp(b); }
|
2013-09-27 09:08:45 -07:00
|
|
|
|
|
|
|
private:
|
2014-04-21 13:48:47 -07:00
|
|
|
void streamPayloadImp(JSStreamWriter& b);
|
2013-09-27 09:08:45 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
const char *mCategory;
|
|
|
|
TracingMetadata mMetaData;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-07-22 08:29:33 -07:00
|
|
|
#include "gfxASurface.h"
|
2013-09-25 08:28:34 -07:00
|
|
|
class ProfilerMarkerImagePayload : public ProfilerMarkerPayload
|
|
|
|
{
|
2013-07-10 21:27:04 -07:00
|
|
|
public:
|
2014-09-02 06:44:54 -07:00
|
|
|
explicit ProfilerMarkerImagePayload(gfxASurface *aImg);
|
2013-07-10 21:27:04 -07:00
|
|
|
|
|
|
|
protected:
|
2014-04-21 13:48:47 -07:00
|
|
|
virtual void
|
|
|
|
streamPayload(JSStreamWriter& b) { return streamPayloadImp(b); }
|
2013-07-10 21:27:04 -07:00
|
|
|
|
|
|
|
private:
|
2014-04-21 13:48:47 -07:00
|
|
|
void streamPayloadImp(JSStreamWriter& b);
|
2013-09-27 09:08:45 -07:00
|
|
|
|
2013-07-10 21:27:04 -07:00
|
|
|
nsRefPtr<gfxASurface> mImg;
|
|
|
|
};
|
|
|
|
|
2013-09-25 08:28:34 -07:00
|
|
|
class IOMarkerPayload : public ProfilerMarkerPayload
|
|
|
|
{
|
|
|
|
public:
|
2014-02-13 10:32:38 -08:00
|
|
|
IOMarkerPayload(const char* aSource, const char* aFilename, const mozilla::TimeStamp& aStartTime,
|
2013-09-25 08:28:34 -07:00
|
|
|
const mozilla::TimeStamp& aEndTime,
|
|
|
|
ProfilerBacktrace* aStack);
|
2014-02-13 10:32:38 -08:00
|
|
|
~IOMarkerPayload();
|
2013-09-25 08:28:34 -07:00
|
|
|
|
|
|
|
protected:
|
2014-04-21 13:48:47 -07:00
|
|
|
virtual void
|
|
|
|
streamPayload(JSStreamWriter& b) { return streamPayloadImp(b); }
|
2013-09-25 08:28:34 -07:00
|
|
|
|
|
|
|
private:
|
2014-04-21 13:48:47 -07:00
|
|
|
void streamPayloadImp(JSStreamWriter& b);
|
2013-09-27 09:08:45 -07:00
|
|
|
|
2013-09-25 08:28:34 -07:00
|
|
|
const char* mSource;
|
2014-02-13 10:32:38 -08:00
|
|
|
char* mFilename;
|
2013-09-25 08:28:34 -07:00
|
|
|
};
|
|
|
|
|
2014-09-05 12:39:59 -07:00
|
|
|
/**
|
|
|
|
* 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:
|
2014-09-10 19:06:53 -07:00
|
|
|
explicit TouchDataPayload(const mozilla::ScreenIntPoint& aPoint);
|
2014-09-05 12:39:59 -07:00
|
|
|
virtual ~TouchDataPayload() {}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void
|
|
|
|
streamPayload(JSStreamWriter& b) { return streamPayloadImpl(b); }
|
|
|
|
|
|
|
|
private:
|
|
|
|
void streamPayloadImpl(JSStreamWriter& b);
|
|
|
|
mozilla::ScreenIntPoint mPoint;
|
|
|
|
};
|
|
|
|
|
2014-10-01 13:01:59 -07:00
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
};
|
|
|
|
|
2013-07-10 21:27:04 -07:00
|
|
|
#endif // PROFILER_MARKERS_H
|