diff --git a/gfx/layers/ipc/CompositorParent.cpp b/gfx/layers/ipc/CompositorParent.cpp index 799b1f18355a..a953e00f71e6 100644 --- a/gfx/layers/ipc/CompositorParent.cpp +++ b/gfx/layers/ipc/CompositorParent.cpp @@ -42,6 +42,7 @@ #include "ShadowLayersParent.h" #include "LayerManagerOGL.h" #include "nsIWidget.h" +#include "nsGkAtoms.h" #if defined(MOZ_WIDGET_ANDROID) #include "AndroidBridge.h" @@ -192,6 +193,12 @@ CompositorParent::Composite() #endif layer->AsShadowLayer()->SetShadowTransform(worldTransform); + // Hang the transform of the root layer off the layer manager. + gfx3DMatrix transform = layer->GetTransform(); + transform *= worldTransform; + TransformLayerUserData* transformUserData = new TransformLayerUserData(transform); + mLayerManager->SetUserData(nsGkAtoms::transform, transformUserData); + mLayerManager->EndEmptyTransaction(); mLastCompose = mozilla::TimeStamp::Now(); } @@ -206,7 +213,7 @@ CompositorParent::GetPrimaryScrollableLayer() nsTArray queue; queue.AppendElement(root); - for (int i = 0; i < queue.Length(); i++) { + for (unsigned i = 0; i < queue.Length(); i++) { ContainerLayer* containerLayer = queue[i]->AsContainerLayer(); if (!containerLayer) { continue; diff --git a/gfx/layers/ipc/CompositorParent.h b/gfx/layers/ipc/CompositorParent.h index 25f03f1ccc48..8fd60a744ce4 100644 --- a/gfx/layers/ipc/CompositorParent.h +++ b/gfx/layers/ipc/CompositorParent.h @@ -140,6 +140,14 @@ private: DISALLOW_EVIL_CONSTRUCTORS(CompositorParent); }; +class TransformLayerUserData : public LayerUserData { +public: + gfx3DMatrix matrix; + + TransformLayerUserData(gfx3DMatrix& aMatrix) : matrix(aMatrix) {} + virtual ~TransformLayerUserData() {} +}; + } // layers } // mozilla diff --git a/gfx/layers/opengl/LayerManagerOGL.cpp b/gfx/layers/opengl/LayerManagerOGL.cpp index 15381cbc1f7b..11ceed1f49ac 100644 --- a/gfx/layers/opengl/LayerManagerOGL.cpp +++ b/gfx/layers/opengl/LayerManagerOGL.cpp @@ -785,10 +785,14 @@ LayerManagerOGL::Render() mGLContext->fClearColor(1.0, 1.0, 1.0, 0.0); mGLContext->fClear(LOCAL_GL_COLOR_BUFFER_BIT | LOCAL_GL_DEPTH_BUFFER_BIT); + // Allow widget to render a custom background. + mWidget->DrawWindowUnderlay(this, rect); + // Render our layers. RootLayer()->RenderLayer(mGLContext->IsDoubleBuffered() ? 0 : mBackBufferFBO, nsIntPoint(0, 0)); + // Allow widget to render a custom foreground too. mWidget->DrawWindowOverlay(this, rect); if (mTarget) { @@ -801,8 +805,6 @@ LayerManagerOGL::Render() mFPS.DrawFPS(mGLContext, GetCopy2DProgram()); } - PerformPostRenderHook(); - if (mGLContext->IsDoubleBuffered()) { mGLContext->SwapBuffers(); LayerManager::PostPresent(); @@ -894,22 +896,6 @@ LayerManagerOGL::Render() mGLContext->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, 0); } -void -LayerManagerOGL::PerformPreRenderHook() -{ -#ifdef MOZ_WIDGET_ANDROID - // TODO: AndroidBridge::PerformPreRenderHook(); -#endif -} - -void -LayerManagerOGL::PerformPostRenderHook() -{ -#ifdef MOZ_WIDGET_ANDROID - // TODO: AndroidBridge::PerformPostRenderHook(); -#endif -} - void LayerManagerOGL::SetWorldTransform(const gfxMatrix& aMatrix) { diff --git a/gfx/layers/opengl/LayerManagerOGL.h b/gfx/layers/opengl/LayerManagerOGL.h index 00635fc7e316..094b4fd6faac 100644 --- a/gfx/layers/opengl/LayerManagerOGL.h +++ b/gfx/layers/opengl/LayerManagerOGL.h @@ -387,9 +387,6 @@ public: * to a window of the given dimensions. */ void SetupPipeline(int aWidth, int aHeight, WorldTransforPolicy aTransformPolicy); - - void PerformPreRenderHook(); - void PerformPostRenderHook(); /** * Setup World transform matrix. diff --git a/widget/android/nsWindow.cpp b/widget/android/nsWindow.cpp index 8b0ed5240a49..fd8a8bc5415b 100644 --- a/widget/android/nsWindow.cpp +++ b/widget/android/nsWindow.cpp @@ -2385,3 +2385,15 @@ nsWindow::GetIMEUpdatePreference() return nsIMEUpdatePreference(true, true); } +#ifdef MOZ_JAVA_COMPOSITOR +void +nsWindow::DrawWindowUnderlay(LayerManager* aManager, nsIntRect aRect) { + __android_log_print(ANDROID_LOG_ERROR, "Gecko", "### TODO: Render custom background"); +} + +void +nsWindow::DrawWindowOverlay(LayerManager* aManager, nsIntRect aRect) { + __android_log_print(ANDROID_LOG_ERROR, "Gecko", "### TODO: Render custom foreground"); +} +#endif + diff --git a/widget/android/nsWindow.h b/widget/android/nsWindow.h index cb2fe2879630..74344b65bce3 100644 --- a/widget/android/nsWindow.h +++ b/widget/android/nsWindow.h @@ -179,6 +179,9 @@ public: #ifdef MOZ_JAVA_COMPOSITOR static void BindToTexture(); static bool HasDirectTexture(); + + virtual void DrawWindowUnderlay(LayerManager* aManager, nsIntRect aRect); + virtual void DrawWindowOverlay(LayerManager* aManager, nsIntRect aRect); #endif protected: diff --git a/widget/nsIWidget.h b/widget/nsIWidget.h index eb5e28795816..394a81ac1f8d 100644 --- a/widget/nsIWidget.h +++ b/widget/nsIWidget.h @@ -1071,6 +1071,14 @@ class nsIWidget : public nsISupports { LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT, bool* aAllowRetaining = nsnull) = 0; + /** + * Called before the LayerManager draws the layer tree. + * + * @param aManager The drawing LayerManager. + * @param aWidgetRect The current widget rect that is being drawn. + */ + virtual void DrawWindowUnderlay(LayerManager* aManager, nsIntRect aRect) = 0; + /** * Called after the LayerManager draws the layer tree * diff --git a/widget/xpwidgets/nsBaseWidget.h b/widget/xpwidgets/nsBaseWidget.h index 4f9647134d7b..8455e0cebb38 100644 --- a/widget/xpwidgets/nsBaseWidget.h +++ b/widget/xpwidgets/nsBaseWidget.h @@ -132,6 +132,7 @@ public: bool* aAllowRetaining = nsnull); virtual void CreateCompositor(); + virtual void DrawWindowUnderlay(LayerManager* aManager, nsIntRect aRect) {} virtual void DrawWindowOverlay(LayerManager* aManager, nsIntRect aRect) {} virtual void UpdateThemeGeometries(const nsTArray& aThemeGeometries) {} virtual gfxASurface* GetThebesSurface();