Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[embedlite] Expose nsIBaseWidget::PreRender in EmbedLite public API.
Per function documentation:
  Called before rendering using OMTC. Returns false when the widget
  is not ready to be rendered (for example while the window is closed).

  Always called from the compositing thread, which may be the main-thread
  if OMTC is not enabled.

With this function we should be able to prevent gecko from
drawing contents for the active view in certain situations.
Current usecase is to prevent painting when device screen is
turned off.
  • Loading branch information
tworaz committed Sep 29, 2015
1 parent d2a5951 commit 2c28162
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions embedding/embedlite/EmbedLiteWindow.h
Expand Up @@ -42,6 +42,9 @@ class EmbedLiteWindowListener
// Will be always called from the compositor thread.
virtual void DrawOverlay(const nsIntRect& aRect) {}

// Will be always called from the compositor thread.
virtual bool PreRender() { return true; }

// Request GL implementation specific surface and context objects from the
// platform. This can be EGLSurface / EGLContext in case of EGL, or
// GLXContext / GLXDrawable in case of GLX.
Expand Down
11 changes: 11 additions & 0 deletions embedding/embedlite/embedshared/EmbedLitePuppetWidget.cpp
Expand Up @@ -751,6 +751,17 @@ EmbedLitePuppetWidget::DrawWindowOverlay(LayerManagerComposite *aManager, nsIntR
}
}

bool
EmbedLitePuppetWidget::PreRender(LayerManagerComposite *aManager)
{
MOZ_ASSERT(mWindow);
EmbedLiteWindow* window = EmbedLiteApp::GetInstance()->GetWindowByID(mWindow->GetUniqueID());
if (window) {
return window->GetListener()->PreRender();
}
return true;
}

void
EmbedLitePuppetWidget::AddObserver(EmbedLitePuppetWidgetObserver* obs)
{
Expand Down
2 changes: 2 additions & 0 deletions embedding/embedlite/embedshared/EmbedLitePuppetWidget.h
Expand Up @@ -168,6 +168,8 @@ class EmbedLitePuppetWidget : public nsBaseWidget
*/
virtual void DrawWindowOverlay(LayerManagerComposite* aManager, nsIntRect aRect) override;

virtual bool PreRender(LayerManagerComposite* aManager) override;

NS_IMETHOD SetParent(nsIWidget* aNewParent) override;
virtual nsIWidget* GetParent(void) override;

Expand Down

0 comments on commit 2c28162

Please sign in to comment.