From a255d5cca60f6192a3a779025708da156fbbd274 Mon Sep 17 00:00:00 2001 From: Raine Makelainen Date: Fri, 24 Apr 2015 15:39:57 +0300 Subject: [PATCH 1/3] [xulrunner] Add DrawWindowUnderlay implementation for embedlite JB#28056 --- embedding/embedlite/EmbedLiteView.h | 3 +++ .../embedlite/embedthread/EmbedLiteCompositorParent.cpp | 8 ++++++++ .../embedlite/embedthread/EmbedLiteCompositorParent.h | 7 +++++++ embedding/embedlite/embedthread/EmbedLitePuppetWidget.cpp | 8 ++++++++ embedding/embedlite/embedthread/EmbedLitePuppetWidget.h | 8 ++++++++ gfx/layers/opengl/CompositorOGL.cpp | 6 ++++-- gfx/thebes/gfxPrefs.h | 2 ++ 7 files changed, 40 insertions(+), 2 deletions(-) diff --git a/embedding/embedlite/EmbedLiteView.h b/embedding/embedlite/EmbedLiteView.h index f4886f0c0583f..214ba152dff40 100644 --- a/embedding/embedlite/EmbedLiteView.h +++ b/embedding/embedlite/EmbedLiteView.h @@ -71,6 +71,9 @@ class EmbedLiteViewListener const gfxSize& aScrollableSize) { return false; } // Some GL Context implementations require Platform GL context to be active and valid virtual bool RequestCurrentGLContext() { return false; } + + // Will be always called from the compositor thread. + virtual void DrawUnderlay() {} }; class EmbedLiteApp; diff --git a/embedding/embedlite/embedthread/EmbedLiteCompositorParent.cpp b/embedding/embedlite/embedthread/EmbedLiteCompositorParent.cpp index 1a439e7e4af51..3c1cf2f6af973 100644 --- a/embedding/embedlite/embedthread/EmbedLiteCompositorParent.cpp +++ b/embedding/embedlite/embedthread/EmbedLiteCompositorParent.cpp @@ -288,6 +288,14 @@ EmbedLiteCompositorParent::ResumeRendering() static_cast(state->mLayerManager->GetCompositor())->Resume(); } +void mozilla::embedlite::EmbedLiteCompositorParent::DrawWindowUnderlay(LayerManagerComposite *aManager, nsIntRect aRect) +{ + EmbedLiteView* view = EmbedLiteApp::GetInstance()->GetViewByID(mId); + if (view) { + view->GetListener()->DrawUnderlay(); + } +} + } // namespace embedlite } // namespace mozilla diff --git a/embedding/embedlite/embedthread/EmbedLiteCompositorParent.h b/embedding/embedlite/embedthread/EmbedLiteCompositorParent.h index 441121e6fa357..4660196d3f4c2 100644 --- a/embedding/embedlite/embedthread/EmbedLiteCompositorParent.h +++ b/embedding/embedlite/embedthread/EmbedLiteCompositorParent.h @@ -14,6 +14,11 @@ #include "EmbedLiteViewThreadParent.h" namespace mozilla { + +namespace layers { +class LayerManagerComposite; +} + namespace embedlite { class EmbedLiteCompositorParent : public mozilla::layers::CompositorParent @@ -33,6 +38,8 @@ class EmbedLiteCompositorParent : public mozilla::layers::CompositorParent virtual void SuspendRendering(); virtual void ResumeRendering(); + void DrawWindowUnderlay(mozilla::layers::LayerManagerComposite *aManager, nsIntRect aRect); + protected: virtual ~EmbedLiteCompositorParent(); virtual PLayerTransactionParent* diff --git a/embedding/embedlite/embedthread/EmbedLitePuppetWidget.cpp b/embedding/embedlite/embedthread/EmbedLitePuppetWidget.cpp index e48fab82f690b..110c208c7b27c 100644 --- a/embedding/embedlite/embedthread/EmbedLitePuppetWidget.cpp +++ b/embedding/embedlite/embedthread/EmbedLitePuppetWidget.cpp @@ -569,5 +569,13 @@ EmbedLitePuppetWidget::HasGLContext() return true; } +void +EmbedLitePuppetWidget::DrawWindowUnderlay(LayerManagerComposite *aManager, nsIntRect aRect) +{ + EmbedLiteCompositorParent* parent = + static_cast(mCompositorParent.get()); + parent->DrawWindowUnderlay(aManager, aRect); +} + } // namespace widget } // namespace mozilla diff --git a/embedding/embedlite/embedthread/EmbedLitePuppetWidget.h b/embedding/embedlite/embedthread/EmbedLitePuppetWidget.h index 61bc2286324a4..d9ccb82c7e96d 100644 --- a/embedding/embedlite/embedthread/EmbedLitePuppetWidget.h +++ b/embedding/embedlite/embedthread/EmbedLitePuppetWidget.h @@ -150,6 +150,14 @@ class EmbedLitePuppetWidget : public nsBaseWidget, virtual nsIntRect GetNaturalBounds(); virtual bool HasGLContext(); + /** + * Called before the LayerManager draws the layer tree. + * + * Always called from the compositing thread. Puppet Widget passes the call + * forward to the EmbedLiteCompositorParent. + */ + virtual void DrawWindowUnderlay(LayerManagerComposite* aManager, nsIntRect aRect); + NS_IMETHOD SetParent(nsIWidget* aNewParent); virtual nsIWidget *GetParent(void); diff --git a/gfx/layers/opengl/CompositorOGL.cpp b/gfx/layers/opengl/CompositorOGL.cpp index 0b85a2d096de6..c12d38105cbc2 100644 --- a/gfx/layers/opengl/CompositorOGL.cpp +++ b/gfx/layers/opengl/CompositorOGL.cpp @@ -723,8 +723,10 @@ CompositorOGL::BeginFrame(const nsIntRegion& aInvalidRegion, // DrawWindowUnderlay. Make sure the bits used here match up with those used // in mobile/android/base/gfx/LayerRenderer.java #ifndef MOZ_ANDROID_OMTC - mGLContext->fClearColor(0.0, 0.0, 0.0, 0.0); - mGLContext->fClear(LOCAL_GL_COLOR_BUFFER_BIT | LOCAL_GL_DEPTH_BUFFER_BIT); + if (gfxPrefs::ClearCompoisitorContext()) { + mGLContext->fClearColor(0.0, 0.0, 0.0, 0.0); + mGLContext->fClear(LOCAL_GL_COLOR_BUFFER_BIT | LOCAL_GL_DEPTH_BUFFER_BIT); + } #endif } diff --git a/gfx/thebes/gfxPrefs.h b/gfx/thebes/gfxPrefs.h index 96ddfaf7d7c7c..af0175b9695b1 100644 --- a/gfx/thebes/gfxPrefs.h +++ b/gfx/thebes/gfxPrefs.h @@ -137,6 +137,8 @@ class gfxPrefs MOZ_FINAL DECL_GFX_PREF(Once, "gfx.canvas.skiagl.cache-size", CanvasSkiaGLCacheSize, int32_t, 96); DECL_GFX_PREF(Once, "gfx.canvas.skiagl.cache-items", CanvasSkiaGLCacheItems, int32_t, 256); + DECL_GFX_PREF(Once, "gfx.compositor.clear-context", ClearCompoisitorContext, bool, true); + DECL_GFX_PREF(Live, "gfx.color_management.enablev4", CMSEnableV4, bool, false); DECL_GFX_PREF(Live, "gfx.color_management.mode", CMSMode, int32_t,-1); // The zero default here should match QCMS_INTENT_DEFAULT from qcms.h From 715390dcff9fa49f982037751b871aa60b003e5d Mon Sep 17 00:00:00 2001 From: Raine Makelainen Date: Mon, 11 May 2015 08:54:08 +0300 Subject: [PATCH 2/3] [embedlite] Add ScheduleUpdate method for EmbedLiteView --- embedding/embedlite/EmbedLiteView.cpp | 7 +++++++ embedding/embedlite/EmbedLiteView.h | 2 ++ embedding/embedlite/embedhelpers/EmbedLiteViewIface.idl | 1 + .../embedlite/embedthread/EmbedLiteViewThreadParent.cpp | 9 +++++++++ 4 files changed, 19 insertions(+) diff --git a/embedding/embedlite/EmbedLiteView.cpp b/embedding/embedlite/EmbedLiteView.cpp index 7471501abb744..5367416f7364c 100644 --- a/embedding/embedlite/EmbedLiteView.cpp +++ b/embedding/embedlite/EmbedLiteView.cpp @@ -288,6 +288,13 @@ EmbedLiteView::SetGLViewPortSize(int width, int height) mViewImpl->SetGLViewPortSize(width, height); } +void +EmbedLiteView::ScheduleUpdate() +{ + NS_ENSURE_TRUE(mViewImpl, ); + mViewImpl->ScheduleUpdate(); +} + void EmbedLiteView::SuspendRendering() { diff --git a/embedding/embedlite/EmbedLiteView.h b/embedding/embedlite/EmbedLiteView.h index 214ba152dff40..68ee0574964b1 100644 --- a/embedding/embedlite/EmbedLiteView.h +++ b/embedding/embedlite/EmbedLiteView.h @@ -125,6 +125,8 @@ class EmbedLiteView // Setup renderable GL/EGL window surface size virtual void SetGLViewPortSize(int width, int height); + virtual void ScheduleUpdate(); + // Scripting Interface, allow to extend embedding API by creating // child js scripts and messaging interface. // and do communication between UI and Content child via json messages. diff --git a/embedding/embedlite/embedhelpers/EmbedLiteViewIface.idl b/embedding/embedlite/embedhelpers/EmbedLiteViewIface.idl index 86f140c992827..4a52eb2937215 100644 --- a/embedding/embedlite/embedhelpers/EmbedLiteViewIface.idl +++ b/embedding/embedlite/embedhelpers/EmbedLiteViewIface.idl @@ -30,6 +30,7 @@ interface EmbedLiteViewIface void RenderToImage(in buffer aData, in int32_t aWidth, in int32_t aHeigth, in int32_t aStride, in int32_t aDepth); void SetViewSize(in int32_t aWidth, in int32_t aHeight); void SetGLViewPortSize(in int32_t aWidth, in int32_t aHeight); + void ScheduleUpdate(); void ReceiveInputEvent([const] in InputData aEvent); void TextEvent(in string aComposite, in string aPreEdit); void SendKeyPress(in int32_t aDomKeyCode, in int32_t aModifiers, in int32_t aCharCode); diff --git a/embedding/embedlite/embedthread/EmbedLiteViewThreadParent.cpp b/embedding/embedlite/embedthread/EmbedLiteViewThreadParent.cpp index b160c7b814ae1..faf4dfbb9c4b0 100644 --- a/embedding/embedlite/embedthread/EmbedLiteViewThreadParent.cpp +++ b/embedding/embedlite/embedthread/EmbedLiteViewThreadParent.cpp @@ -399,6 +399,15 @@ EmbedLiteViewThreadParent::SetGLViewPortSize(int width, int height) return NS_OK; } +NS_IMETHODIMP +EmbedLiteViewThreadParent::ScheduleUpdate() +{ + if (mCompositor) { + mCompositor->ScheduleRenderOnCompositorThread(); + } + return NS_OK; +} + NS_IMETHODIMP EmbedLiteViewThreadParent::ResumeRendering() { From 89afc80252e8e5259c6e9768ac55c9093bf587ab Mon Sep 17 00:00:00 2001 From: Raine Makelainen Date: Mon, 11 May 2015 08:57:35 +0300 Subject: [PATCH 3/3] [embedlite] Add DrawWindowOverlay implementation for embedlite JB#27803 --- embedding/embedlite/EmbedLiteView.h | 3 +++ .../embedlite/embedthread/EmbedLiteCompositorParent.cpp | 8 ++++++++ .../embedlite/embedthread/EmbedLiteCompositorParent.h | 1 + .../embedlite/embedthread/EmbedLitePuppetWidget.cpp | 7 +++++++ embedding/embedlite/embedthread/EmbedLitePuppetWidget.h | 9 +++++++++ 5 files changed, 28 insertions(+) diff --git a/embedding/embedlite/EmbedLiteView.h b/embedding/embedlite/EmbedLiteView.h index 68ee0574964b1..90f1f6322f91f 100644 --- a/embedding/embedlite/EmbedLiteView.h +++ b/embedding/embedlite/EmbedLiteView.h @@ -74,6 +74,9 @@ class EmbedLiteViewListener // Will be always called from the compositor thread. virtual void DrawUnderlay() {} + + // Will be always called from the compositor thread. + virtual void DrawOverlay(const nsIntRect& aRect) {} }; class EmbedLiteApp; diff --git a/embedding/embedlite/embedthread/EmbedLiteCompositorParent.cpp b/embedding/embedlite/embedthread/EmbedLiteCompositorParent.cpp index 3c1cf2f6af973..30974cb702410 100644 --- a/embedding/embedlite/embedthread/EmbedLiteCompositorParent.cpp +++ b/embedding/embedlite/embedthread/EmbedLiteCompositorParent.cpp @@ -296,6 +296,14 @@ void mozilla::embedlite::EmbedLiteCompositorParent::DrawWindowUnderlay(LayerMana } } +void EmbedLiteCompositorParent::DrawWindowOverlay(LayerManagerComposite *aManager, nsIntRect aRect) +{ + EmbedLiteView* view = EmbedLiteApp::GetInstance()->GetViewByID(mId); + if (view) { + view->GetListener()->DrawOverlay(aRect); + } +} + } // namespace embedlite } // namespace mozilla diff --git a/embedding/embedlite/embedthread/EmbedLiteCompositorParent.h b/embedding/embedlite/embedthread/EmbedLiteCompositorParent.h index 4660196d3f4c2..74a894f1bea31 100644 --- a/embedding/embedlite/embedthread/EmbedLiteCompositorParent.h +++ b/embedding/embedlite/embedthread/EmbedLiteCompositorParent.h @@ -39,6 +39,7 @@ class EmbedLiteCompositorParent : public mozilla::layers::CompositorParent virtual void ResumeRendering(); void DrawWindowUnderlay(mozilla::layers::LayerManagerComposite *aManager, nsIntRect aRect); + void DrawWindowOverlay(mozilla::layers::LayerManagerComposite *aManager, nsIntRect aRect); protected: virtual ~EmbedLiteCompositorParent(); diff --git a/embedding/embedlite/embedthread/EmbedLitePuppetWidget.cpp b/embedding/embedlite/embedthread/EmbedLitePuppetWidget.cpp index 110c208c7b27c..9d06ae4afd2b7 100644 --- a/embedding/embedlite/embedthread/EmbedLitePuppetWidget.cpp +++ b/embedding/embedlite/embedthread/EmbedLitePuppetWidget.cpp @@ -577,5 +577,12 @@ EmbedLitePuppetWidget::DrawWindowUnderlay(LayerManagerComposite *aManager, nsInt parent->DrawWindowUnderlay(aManager, aRect); } +void EmbedLitePuppetWidget::DrawWindowOverlay(LayerManagerComposite *aManager, nsIntRect aRect) +{ + EmbedLiteCompositorParent* parent = + static_cast(mCompositorParent.get()); + parent->DrawWindowOverlay(aManager, aRect); +} + } // namespace widget } // namespace mozilla diff --git a/embedding/embedlite/embedthread/EmbedLitePuppetWidget.h b/embedding/embedlite/embedthread/EmbedLitePuppetWidget.h index d9ccb82c7e96d..8a4cb3dbc63c1 100644 --- a/embedding/embedlite/embedthread/EmbedLitePuppetWidget.h +++ b/embedding/embedlite/embedthread/EmbedLitePuppetWidget.h @@ -158,6 +158,15 @@ class EmbedLitePuppetWidget : public nsBaseWidget, */ virtual void DrawWindowUnderlay(LayerManagerComposite* aManager, nsIntRect aRect); + + /** + * Called after the LayerManager draws the layer tree + * + * Always called from the compositing thread. Puppet Widget passes the call + * forward to the EmbedLiteCompositorParent. + */ + virtual void DrawWindowOverlay(LayerManagerComposite* aManager, nsIntRect aRect); + NS_IMETHOD SetParent(nsIWidget* aNewParent); virtual nsIWidget *GetParent(void);