☠☠ backed out by a525ac9349eb ☠ ☠ | |
author | Matt Woodrow <mwoodrow@mozilla.com> |
Tue, 07 Aug 2012 15:00:42 +1200 | |
changeset 101626 | 9fb78d71f3614a9dc79a6b52c54b15aa5c19b66a |
parent 101625 | 28f8ce199bede458b958aec583d72aab5a78bd05 |
child 101627 | 60d2911bf59ec1d35a22961c7b7e0915078e79f8 |
push id | 13089 |
push user | mwoodrow@mozilla.com |
push date | Tue, 07 Aug 2012 03:02:36 +0000 |
treeherder | mozilla-inbound@9fb78d71f361 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | cjones |
bugs | 779940 |
milestone | 17.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/gfx/layers/ipc/CompositorParent.cpp +++ b/gfx/layers/ipc/CompositorParent.cpp @@ -316,16 +316,26 @@ CompositorParent::ScheduleTask(Cancelabl if (time == 0) { MessageLoop::current()->PostTask(FROM_HERE, task); } else { MessageLoop::current()->PostDelayedTask(FROM_HERE, task, time); } } void +CompositorParent::NotifyShadowTreeTransaction() +{ + ShadowLayerManager *shadow = mLayerManager->AsShadowManager(); + if (shadow) { + shadow->NotifyShadowTreeTransaction(); + } + ScheduleComposition(); +} + +void CompositorParent::ScheduleComposition() { if (mCurrentCompositeTask) { return; } bool initialComposition = mLastCompose.IsNull(); TimeDuration delta; @@ -881,16 +891,20 @@ CompositorParent::ShadowLayersUpdated(Sh mIsFirstPaint = mIsFirstPaint || isFirstPaint; mLayersUpdated = true; Layer* root = aLayerTree->GetRoot(); mLayerManager->SetRoot(root); if (root) { SetShadowProperties(root); } ScheduleComposition(); + ShadowLayerManager *shadow = mLayerManager->AsShadowManager(); + if (shadow) { + shadow->NotifyShadowTreeTransaction(); + } } PLayersParent* CompositorParent::AllocPLayers(const LayersBackend& aBackendHint, const uint64_t& aId, LayersBackend* aBackend, int32_t* aMaxTextureSize) { @@ -1188,17 +1202,17 @@ CrossProcessCompositorParent::ShadowLaye uint64_t id = aLayerTree->GetId(); MOZ_ASSERT(id != 0); Layer* shadowRoot = aLayerTree->GetRoot(); if (shadowRoot) { SetShadowProperties(shadowRoot); } UpdateIndirectTree(id, shadowRoot, isFirstPaint); - sCurrentCompositor->ScheduleComposition(); + sCurrentCompositor->NotifyShadowTreeTransaction(); } void CrossProcessCompositorParent::DeferredDestroy() { mSelfRef = NULL; // |this| was just destroyed, hands off }
--- a/gfx/layers/ipc/CompositorParent.h +++ b/gfx/layers/ipc/CompositorParent.h @@ -81,16 +81,17 @@ public: void AsyncRender(); // Can be called from any thread void ScheduleRenderOnCompositorThread(); void SchedulePauseOnCompositorThread(); void ScheduleResumeOnCompositorThread(int width, int height); virtual void ScheduleComposition(); + void NotifyShadowTreeTransaction(); /** * Returns a pointer to the compositor corresponding to the given ID. */ static CompositorParent* GetCompositor(PRUint64 id); /** * Returns the compositor thread's message loop.
--- a/gfx/layers/ipc/ShadowLayers.h +++ b/gfx/layers/ipc/ShadowLayers.h @@ -406,16 +406,18 @@ public: virtual already_AddRefed<ShadowImageLayer> CreateShadowImageLayer() = 0; /** CONSTRUCTION PHASE ONLY */ virtual already_AddRefed<ShadowColorLayer> CreateShadowColorLayer() = 0; /** CONSTRUCTION PHASE ONLY */ virtual already_AddRefed<ShadowCanvasLayer> CreateShadowCanvasLayer() = 0; /** 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 * TextureImage is returned. Otherwise null is returned. */ static already_AddRefed<TextureImage> OpenDescriptorForDirectTexturing(GLContext* aContext, const SurfaceDescriptor& aDescriptor,
--- a/gfx/layers/opengl/LayerManagerOGL.cpp +++ b/gfx/layers/opengl/LayerManagerOGL.cpp @@ -501,31 +501,44 @@ LayerManagerOGL::RootLayer() const return nullptr; } return static_cast<LayerOGL*>(mRoot->ImplData()); } 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 LayerManagerOGL::FPSState::DrawFPS(GLContext* context, ShaderProgramOGL* copyprog) { fcount++; int rate = 30; if (fcount >= rate) { TimeStamp now = TimeStamp::Now(); TimeDuration duration = now - last; last = now; 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); static GLuint texture; if (!initialized) { // Bind the number of textures we need, in this case one. context->fGenTextures(1, &texture); @@ -570,23 +583,44 @@ LayerManagerOGL::FPSState::DrawFPS(GLCon { -1.0f + 22.f / viewport[2], 1.0f - 42.f / viewport[3] }, { -1.0f + 22.f / viewport[2], 1.0f }, { -1.0f + 44.f / viewport[2], 1.0f - 42.f / viewport[3] }, { -1.0f + 44.f / viewport[2], 1.0f }, { -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[] = { (v100 * 4.f) / 64, 7.f / 8, (v100 * 4.f) / 64, 0.0f, (v100 * 4.f + 4) / 64, 7.f / 8, (v100 * 4.f + 4) / 64, 0.0f, @@ -595,16 +629,33 @@ LayerManagerOGL::FPSState::DrawFPS(GLCon (v10 * 4.f + 4) / 64, 7.f / 8, (v10 * 4.f + 4) / 64, 0.0f, (v1 * 4.f) / 64, 7.f / 8, (v1 * 4.f) / 64, 0.0f, (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); context->fBlendFunc(LOCAL_GL_ONE, LOCAL_GL_SRC_COLOR); context->fActiveTexture(LOCAL_GL_TEXTURE0); context->fBindTexture(LOCAL_GL_TEXTURE_2D, texture); @@ -632,16 +683,28 @@ LayerManagerOGL::FPSState::DrawFPS(GLCon 0, vertices); context->fVertexAttribPointer(tcattr, 2, LOCAL_GL_FLOAT, LOCAL_GL_FALSE, 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 // draw using the given program. The program already has a necessary // offset and scale, so the geometry that needs to be drawn is a unit // square from 0,0 to 1,1. // // |aTexSize| is the actual size of the texture, as it can be larger @@ -710,16 +773,22 @@ LayerManagerOGL::BindAndDrawQuadWithText mGLContext->fDisableVertexAttribArray(vertAttribIndex); } mGLContext->fDisableVertexAttribArray(texCoordAttribIndex); } } void +LayerManagerOGL::NotifyShadowTreeTransaction() +{ + mFPS.NotifyShadowTreeTransaction(); +} + +void LayerManagerOGL::Render() { SAMPLE_LABEL("LayerManagerOGL", "Render"); if (mDestroyed) { NS_WARNING("Call on destroyed layer manager"); return; }
--- a/gfx/layers/opengl/LayerManagerOGL.h +++ b/gfx/layers/opengl/LayerManagerOGL.h @@ -98,16 +98,17 @@ public: void BeginTransaction(); void BeginTransactionWithTarget(gfxContext* aTarget); void EndConstruction(); virtual bool EndEmptyTransaction(); + virtual void NotifyShadowTreeTransaction(); virtual void EndTransaction(DrawThebesLayerCallback aCallback, void* aCallbackData, EndTransactionFlags aFlags = END_DEFAULT); virtual void SetRoot(Layer* aLayer) { mRoot = aLayer; } virtual bool CanUseCanvasLayerForSize(const gfxIntSize &aSize) { @@ -437,25 +438,32 @@ private: struct FPSState { GLuint texture; int fps; bool initialized; 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; }; /** * General information and tree management for OGL layers. */