Bug 779940: Meter layers transactions in addition to composites. r=cjones

This commit is contained in:
Matt Woodrow 2012-08-07 14:41:29 +12:00
Родитель 171fe60ac8
Коммит 8333144733
5 изменённых файлов: 100 добавлений и 4 удалений

Просмотреть файл

@ -322,6 +322,18 @@ CompositorParent::ScheduleTask(CancelableTask* task, int time)
}
}
void
CompositorParent::NotifyShadowTreeTransaction()
{
if (mLayerManager) {
ShadowLayerManager *shadow = mLayerManager->AsShadowManager();
if (shadow) {
shadow->NotifyShadowTreeTransaction();
}
}
ScheduleComposition();
}
void
CompositorParent::ScheduleComposition()
{
@ -887,6 +899,10 @@ CompositorParent::ShadowLayersUpdated(ShadowLayersParent* aLayerTree,
SetShadowProperties(root);
}
ScheduleComposition();
ShadowLayerManager *shadow = mLayerManager->AsShadowManager();
if (shadow) {
shadow->NotifyShadowTreeTransaction();
}
}
PLayersParent*
@ -1194,7 +1210,7 @@ CrossProcessCompositorParent::ShadowLayersUpdated(
}
UpdateIndirectTree(id, shadowRoot, isFirstPaint);
sCurrentCompositor->ScheduleComposition();
sCurrentCompositor->NotifyShadowTreeTransaction();
}
void

Просмотреть файл

@ -86,7 +86,8 @@ public:
void ScheduleResumeOnCompositorThread(int width, int height);
virtual void ScheduleComposition();
void NotifyShadowTreeTransaction();
/**
* Returns a pointer to the compositor corresponding to the given ID.
*/

Просмотреть файл

@ -411,6 +411,8 @@ public:
/** CONSTRUCTION PHASE ONLY */
virtual already_AddRefed<ShadowRefLayer> CreateShadowRefLayer() { return nullptr; }
virtual void NotifyShadowTreeTransaction() {}
/**
* Try to open |aDescriptor| for direct texturing. If the
* underlying surface supports direct texturing, a non-null

Просмотреть файл

@ -514,6 +514,12 @@ LayerManagerOGL::RootLayer() const
bool LayerManagerOGL::sDrawFPS = false;
void
LayerManagerOGL::FPSState::NotifyShadowTreeTransaction()
{
contentFCount++;
}
/* This function tries to stick to portable C89 as much as possible
* so that it can be easily copied into other applications */
void
@ -529,6 +535,13 @@ LayerManagerOGL::FPSState::DrawFPS(GLContext* context, ShaderProgramOGL* copypro
fps = rate / duration.ToSeconds() + .5;
fcount = 0;
}
if (contentFCount >= rate) {
TimeStamp now = TimeStamp::Now();
TimeDuration duration = now - contentLast;
contentLast = now;
contentFps = contentFCount / duration.ToSeconds() + .5;
contentFCount = 0;
}
GLint viewport[4];
context->fGetIntegerv(LOCAL_GL_VIEWPORT, viewport);
@ -583,13 +596,34 @@ LayerManagerOGL::FPSState::DrawFPS(GLContext* context, ShaderProgramOGL* copypro
{ -1.0f + 44.f / viewport[2], 1.0f - 42.f / viewport[3] },
{ -1.0f + 44.f / viewport[2], 1.0f },
{ -1.0f + 66.f / viewport[2], 1.0f - 42.f / viewport[3] },
{ -1.0f + 66.f / viewport[2], 1.0f }
{ -1.0f + 66.f / viewport[2], 1.0f },
};
const Vertex2D vertices2[] = {
{ -1.0f + 80.f / viewport[2], 1.0f - 42.f / viewport[3] },
{ -1.0f + 80.f / viewport[2], 1.0f },
{ -1.0f + 102.f / viewport[2], 1.0f - 42.f / viewport[3] },
{ -1.0f + 102.f / viewport[2], 1.0f },
{ -1.0f + 102.f / viewport[2], 1.0f - 42.f / viewport[3] },
{ -1.0f + 102.f / viewport[2], 1.0f },
{ -1.0f + 124.f / viewport[2], 1.0f - 42.f / viewport[3] },
{ -1.0f + 124.f / viewport[2], 1.0f },
{ -1.0f + 124.f / viewport[2], 1.0f - 42.f / viewport[3] },
{ -1.0f + 124.f / viewport[2], 1.0f },
{ -1.0f + 146.f / viewport[2], 1.0f - 42.f / viewport[3] },
{ -1.0f + 146.f / viewport[2], 1.0f },
};
int v1 = fps % 10;
int v10 = (fps % 100) / 10;
int v100 = (fps % 1000) / 100;
int content1 = contentFps % 10;
int content10 = (contentFps % 100) / 10;
int content100 = (contentFps % 1000) / 100;
// Feel free to comment these texture coordinates out and use one
// of the ones below instead, or play around with your own values.
const GLfloat texCoords[] = {
@ -608,6 +642,23 @@ LayerManagerOGL::FPSState::DrawFPS(GLContext* context, ShaderProgramOGL* copypro
(v1 * 4.f + 4) / 64, 7.f / 8,
(v1 * 4.f + 4) / 64, 0.0f,
};
const GLfloat texCoords2[] = {
(content100 * 4.f) / 64, 7.f / 8,
(content100 * 4.f) / 64, 0.0f,
(content100 * 4.f + 4) / 64, 7.f / 8,
(content100 * 4.f + 4) / 64, 0.0f,
(content10 * 4.f) / 64, 7.f / 8,
(content10 * 4.f) / 64, 0.0f,
(content10 * 4.f + 4) / 64, 7.f / 8,
(content10 * 4.f + 4) / 64, 0.0f,
(content1 * 4.f) / 64, 7.f / 8,
(content1 * 4.f) / 64, 0.0f,
(content1 * 4.f + 4) / 64, 7.f / 8,
(content1 * 4.f + 4) / 64, 0.0f,
};
// Turn necessary features on
context->fEnable(LOCAL_GL_BLEND);
@ -645,6 +696,18 @@ LayerManagerOGL::FPSState::DrawFPS(GLContext* context, ShaderProgramOGL* copypro
0, texCoords);
context->fDrawArrays(LOCAL_GL_TRIANGLE_STRIP, 0, 12);
context->fVertexAttribPointer(vcattr,
2, LOCAL_GL_FLOAT,
LOCAL_GL_FALSE,
0, vertices2);
context->fVertexAttribPointer(tcattr,
2, LOCAL_GL_FLOAT,
LOCAL_GL_FALSE,
0, texCoords2);
context->fDrawArrays(LOCAL_GL_TRIANGLE_STRIP, 0, 12);
}
// |aTexCoordRect| is the rectangle from the texture that we want to
@ -722,6 +785,12 @@ LayerManagerOGL::BindAndDrawQuadWithTextureRect(ShaderProgramOGL *aProg,
}
}
void
LayerManagerOGL::NotifyShadowTreeTransaction()
{
mFPS.NotifyShadowTreeTransaction();
}
void
LayerManagerOGL::Render()
{

Просмотреть файл

@ -103,6 +103,7 @@ public:
void EndConstruction();
virtual bool EndEmptyTransaction(EndTransactionFlags aFlags = END_DEFAULT);
virtual void NotifyShadowTreeTransaction();
virtual void EndTransaction(DrawThebesLayerCallback aCallback,
void* aCallbackData,
EndTransactionFlags aFlags = END_DEFAULT);
@ -446,15 +447,22 @@ private:
int fcount;
TimeStamp last;
int contentFps;
int contentFCount;
TimeStamp contentLast;
FPSState()
: texture(0)
, fps(0)
, initialized(false)
, fcount(0)
, contentFps(0)
, contentFCount(0)
{
last = TimeStamp::Now();
contentLast = last = TimeStamp::Now();
}
void DrawFPS(GLContext*, ShaderProgramOGL*);
void NotifyShadowTreeTransaction();
} mFPS;
static bool sDrawFPS;