mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 788400 - Part 1: Add a frame counter to OGLLayers. r=jmuizelaar
This commit is contained in:
parent
2b1b0b76b1
commit
3e8d129a99
@ -104,6 +104,8 @@ struct FPSState {
|
||||
|
||||
void DrawFPS(TimeStamp, GLContext*, ShaderProgramOGL*);
|
||||
|
||||
static void DrawFrameCounter(GLContext* context);
|
||||
|
||||
void NotifyShadowTreeTransaction() {
|
||||
mTransactionFps.AddFrame(TimeStamp::Now());
|
||||
}
|
||||
@ -569,6 +571,7 @@ LayerManagerOGL::Initialize(nsRefPtr<GLContext> aContext, bool force)
|
||||
|
||||
if (NS_IsMainThread()) {
|
||||
Preferences::AddBoolVarCache(&sDrawFPS, "layers.acceleration.draw-fps");
|
||||
Preferences::AddBoolVarCache(&sFrameCounter, "layers.acceleration.frame-counter");
|
||||
} else {
|
||||
// We have to dispatch an event to the main thread to read the pref.
|
||||
class ReadDrawFPSPref : public nsRunnable {
|
||||
@ -576,6 +579,7 @@ LayerManagerOGL::Initialize(nsRefPtr<GLContext> aContext, bool force)
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
Preferences::AddBoolVarCache(&sDrawFPS, "layers.acceleration.draw-fps");
|
||||
Preferences::AddBoolVarCache(&sFrameCounter, "layers.acceleration.frame-counter");
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
@ -747,6 +751,28 @@ LayerManagerOGL::RootLayer() const
|
||||
}
|
||||
|
||||
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
|
||||
// draw using the given program. The program already has a necessary
|
||||
@ -948,6 +974,8 @@ LayerManagerOGL::Render()
|
||||
|
||||
if (mFPS) {
|
||||
mFPS->DrawFPS(TimeStamp::Now(), mGLContext, GetProgram(Copy2DProgramType));
|
||||
} else if (sFrameCounter) {
|
||||
DrawFrameCounter(mGLContext);
|
||||
}
|
||||
|
||||
if (mGLContext->IsDoubleBuffered()) {
|
||||
|
@ -442,6 +442,7 @@ private:
|
||||
nsAutoPtr<FPSState> mFPS;
|
||||
|
||||
static bool sDrawFPS;
|
||||
static bool sFrameCounter;
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user