зеркало из https://github.com/mozilla/gecko-dev.git
Bug 788400 - Part 1: Add a frame counter to OGLLayers. r=jmuizelaar
This commit is contained in:
Родитель
6667c8fbd7
Коммит
d2c9c87488
|
@ -104,6 +104,8 @@ struct FPSState {
|
||||||
|
|
||||||
void DrawFPS(TimeStamp, GLContext*, ShaderProgramOGL*);
|
void DrawFPS(TimeStamp, GLContext*, ShaderProgramOGL*);
|
||||||
|
|
||||||
|
static void DrawFrameCounter(GLContext* context);
|
||||||
|
|
||||||
void NotifyShadowTreeTransaction() {
|
void NotifyShadowTreeTransaction() {
|
||||||
mTransactionFps.AddFrame(TimeStamp::Now());
|
mTransactionFps.AddFrame(TimeStamp::Now());
|
||||||
}
|
}
|
||||||
|
@ -569,6 +571,7 @@ LayerManagerOGL::Initialize(nsRefPtr<GLContext> aContext, bool force)
|
||||||
|
|
||||||
if (NS_IsMainThread()) {
|
if (NS_IsMainThread()) {
|
||||||
Preferences::AddBoolVarCache(&sDrawFPS, "layers.acceleration.draw-fps");
|
Preferences::AddBoolVarCache(&sDrawFPS, "layers.acceleration.draw-fps");
|
||||||
|
Preferences::AddBoolVarCache(&sFrameCounter, "layers.acceleration.frame-counter");
|
||||||
} else {
|
} else {
|
||||||
// We have to dispatch an event to the main thread to read the pref.
|
// We have to dispatch an event to the main thread to read the pref.
|
||||||
class ReadDrawFPSPref : public nsRunnable {
|
class ReadDrawFPSPref : public nsRunnable {
|
||||||
|
@ -576,6 +579,7 @@ LayerManagerOGL::Initialize(nsRefPtr<GLContext> aContext, bool force)
|
||||||
NS_IMETHOD Run()
|
NS_IMETHOD Run()
|
||||||
{
|
{
|
||||||
Preferences::AddBoolVarCache(&sDrawFPS, "layers.acceleration.draw-fps");
|
Preferences::AddBoolVarCache(&sDrawFPS, "layers.acceleration.draw-fps");
|
||||||
|
Preferences::AddBoolVarCache(&sFrameCounter, "layers.acceleration.frame-counter");
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -747,6 +751,28 @@ LayerManagerOGL::RootLayer() const
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LayerManagerOGL::sDrawFPS = false;
|
bool LayerManagerOGL::sDrawFPS = false;
|
||||||
|
bool LayerManagerOGL::sFrameCounter = false;
|
||||||
|
|
||||||
|
static uint16_t sFrameCount = 0;
|
||||||
|
void
|
||||||
|
FPSState::DrawFrameCounter(GLContext* context)
|
||||||
|
{
|
||||||
|
|
||||||
|
// We intentionally overflow at 2^16.
|
||||||
|
uint16_t frameNumber = sFrameCount++;
|
||||||
|
for (size_t i = 0; i < 16; i++) {
|
||||||
|
context->fScissor(3*i, 0, 3, 3);
|
||||||
|
|
||||||
|
// We should do this using a single draw call
|
||||||
|
// instead of 16 glClear()
|
||||||
|
if ((frameNumber >> i) & 0x1) {
|
||||||
|
context->fClearColor(0.0, 0.0, 0.0, 0.0);
|
||||||
|
} else {
|
||||||
|
context->fClearColor(1.0, 1.0, 1.0, 0.0);
|
||||||
|
}
|
||||||
|
context->fClear(LOCAL_GL_COLOR_BUFFER_BIT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// |aTexCoordRect| is the rectangle from the texture that we want to
|
// |aTexCoordRect| is the rectangle from the texture that we want to
|
||||||
// draw using the given program. The program already has a necessary
|
// draw using the given program. The program already has a necessary
|
||||||
|
@ -948,6 +974,8 @@ LayerManagerOGL::Render()
|
||||||
|
|
||||||
if (mFPS) {
|
if (mFPS) {
|
||||||
mFPS->DrawFPS(TimeStamp::Now(), mGLContext, GetProgram(Copy2DProgramType));
|
mFPS->DrawFPS(TimeStamp::Now(), mGLContext, GetProgram(Copy2DProgramType));
|
||||||
|
} else if (sFrameCounter) {
|
||||||
|
DrawFrameCounter(mGLContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mGLContext->IsDoubleBuffered()) {
|
if (mGLContext->IsDoubleBuffered()) {
|
||||||
|
|
|
@ -442,6 +442,7 @@ private:
|
||||||
nsAutoPtr<FPSState> mFPS;
|
nsAutoPtr<FPSState> mFPS;
|
||||||
|
|
||||||
static bool sDrawFPS;
|
static bool sDrawFPS;
|
||||||
|
static bool sFrameCounter;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Загрузка…
Ссылка в новой задаче