Skip to content

Commit

Permalink
Merge pull request mozilla#54 from rainemak/esr_drawwindowunderlay
Browse files Browse the repository at this point in the history
[xulrunner] Add DrawWindowUnderlay and DrawWindowOverlay implementations for embedlite (esr)
  • Loading branch information
tmeshkova committed May 12, 2015
2 parents 5ef99ce + 89afc80 commit 74971d7
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 2 deletions.
7 changes: 7 additions & 0 deletions embedding/embedlite/EmbedLiteView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
8 changes: 8 additions & 0 deletions embedding/embedlite/EmbedLiteView.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ 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() {}

// Will be always called from the compositor thread.
virtual void DrawOverlay(const nsIntRect& aRect) {}
};

class EmbedLiteApp;
Expand Down Expand Up @@ -122,6 +128,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.
Expand Down
1 change: 1 addition & 0 deletions embedding/embedlite/embedhelpers/EmbedLiteViewIface.idl
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 16 additions & 0 deletions embedding/embedlite/embedthread/EmbedLiteCompositorParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,22 @@ EmbedLiteCompositorParent::ResumeRendering()
static_cast<CompositorOGL*>(state->mLayerManager->GetCompositor())->Resume();
}

void mozilla::embedlite::EmbedLiteCompositorParent::DrawWindowUnderlay(LayerManagerComposite *aManager, nsIntRect aRect)
{
EmbedLiteView* view = EmbedLiteApp::GetInstance()->GetViewByID(mId);
if (view) {
view->GetListener()->DrawUnderlay();
}
}

void EmbedLiteCompositorParent::DrawWindowOverlay(LayerManagerComposite *aManager, nsIntRect aRect)
{
EmbedLiteView* view = EmbedLiteApp::GetInstance()->GetViewByID(mId);
if (view) {
view->GetListener()->DrawOverlay(aRect);
}
}

} // namespace embedlite
} // namespace mozilla

8 changes: 8 additions & 0 deletions embedding/embedlite/embedthread/EmbedLiteCompositorParent.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
#include "EmbedLiteViewThreadParent.h"

namespace mozilla {

namespace layers {
class LayerManagerComposite;
}

namespace embedlite {

class EmbedLiteCompositorParent : public mozilla::layers::CompositorParent
Expand All @@ -33,6 +38,9 @@ class EmbedLiteCompositorParent : public mozilla::layers::CompositorParent
virtual void SuspendRendering();
virtual void ResumeRendering();

void DrawWindowUnderlay(mozilla::layers::LayerManagerComposite *aManager, nsIntRect aRect);
void DrawWindowOverlay(mozilla::layers::LayerManagerComposite *aManager, nsIntRect aRect);

protected:
virtual ~EmbedLiteCompositorParent();
virtual PLayerTransactionParent*
Expand Down
15 changes: 15 additions & 0 deletions embedding/embedlite/embedthread/EmbedLitePuppetWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,5 +569,20 @@ EmbedLitePuppetWidget::HasGLContext()
return true;
}

void
EmbedLitePuppetWidget::DrawWindowUnderlay(LayerManagerComposite *aManager, nsIntRect aRect)
{
EmbedLiteCompositorParent* parent =
static_cast<EmbedLiteCompositorParent*>(mCompositorParent.get());
parent->DrawWindowUnderlay(aManager, aRect);
}

void EmbedLitePuppetWidget::DrawWindowOverlay(LayerManagerComposite *aManager, nsIntRect aRect)
{
EmbedLiteCompositorParent* parent =
static_cast<EmbedLiteCompositorParent*>(mCompositorParent.get());
parent->DrawWindowOverlay(aManager, aRect);
}

} // namespace widget
} // namespace mozilla
17 changes: 17 additions & 0 deletions embedding/embedlite/embedthread/EmbedLitePuppetWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,23 @@ 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);


/**
* 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);

Expand Down
9 changes: 9 additions & 0 deletions embedding/embedlite/embedthread/EmbedLiteViewThreadParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
6 changes: 4 additions & 2 deletions gfx/layers/opengl/CompositorOGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 2 additions & 0 deletions gfx/thebes/gfxPrefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 74971d7

Please sign in to comment.