Skip to content

Commit

Permalink
Expose an API for throttling nsRefreshDriver. Contributes to JB#30183
Browse files Browse the repository at this point in the history
In sailfish-browser we're interested in being able to limit view CPU
usage while still keeping it active. Browser live covers are prime user
of such feature. This patch makes it possible to enable layout engine's
refresh driver throttling without fully deactivating the view. When
refresh driver throttling is enabled the engine will update/repaint the
content less often. The frequeency can be tweaked through
layout.throttled_frame_rate pref (defaults to 1).
  • Loading branch information
tworaz committed Jun 25, 2015
1 parent 5602689 commit dd4a8d0
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
8 changes: 8 additions & 0 deletions embedding/embedlite/EmbedLiteView.cpp
Expand Up @@ -94,6 +94,14 @@ EmbedLiteView::SetIsFocused(bool aIsFocused)
unused << mViewParent->SendSetIsFocused(aIsFocused);
}

void
EmbedLiteView::SetThrottlePainting(bool aThrottle)
{
LOGT();
NS_ENSURE_TRUE(mViewParent, );
unused << mViewParent->SendSetThrottlePainting(aThrottle);
}

void
EmbedLiteView::SuspendTimeouts()
{
Expand Down
1 change: 1 addition & 0 deletions embedding/embedlite/EmbedLiteView.h
Expand Up @@ -90,6 +90,7 @@ class EmbedLiteView
virtual void LoadURL(const char* aUrl);
virtual void SetIsActive(bool);
virtual void SetIsFocused(bool);
virtual void SetThrottlePainting(bool);
virtual void SuspendTimeouts();
virtual void ResumeTimeouts();
virtual void GoBack();
Expand Down
1 change: 1 addition & 0 deletions embedding/embedlite/PEmbedLiteView.ipdl
Expand Up @@ -40,6 +40,7 @@ child:
SetGLViewSize(gfxSize aSize);
SetIsActive(bool aIsActive);
SetIsFocused(bool aIsFocused);
SetThrottlePainting(bool aThrottle);
SuspendTimeouts();
ResumeTimeouts();
AsyncScrollDOMEvent(gfxRect contentRect, gfxSize scrollSize);
Expand Down
10 changes: 9 additions & 1 deletion embedding/embedlite/embedshared/EmbedLiteViewBaseChild.cpp
Expand Up @@ -20,7 +20,7 @@
#include "nsIFocusManager.h"
#include "nsFocusManager.h"
#include "nsIWebBrowserChrome.h"

#include "nsRefreshDriver.h"
#include "nsIDOMWindowUtils.h"
#include "nsPIDOMWindow.h"
#include "nsIDocument.h"
Expand Down Expand Up @@ -511,6 +511,14 @@ EmbedLiteViewBaseChild::RecvSetIsFocused(const bool& aIsFocused)
return true;
}

bool
EmbedLiteViewBaseChild::RecvSetThrottlePainting(const bool& aThrottle)
{
LOGT("aThrottle:%d", aThrottle);
mHelper->GetPresContext()->RefreshDriver()->SetThrottled(aThrottle);
return true;
}

bool
EmbedLiteViewBaseChild::RecvSuspendTimeouts()
{
Expand Down
1 change: 1 addition & 0 deletions embedding/embedlite/embedshared/EmbedLiteViewBaseChild.h
Expand Up @@ -118,6 +118,7 @@ class EmbedLiteViewBaseChild : public PEmbedLiteViewChild,

virtual bool RecvSetIsActive(const bool&) override;
virtual bool RecvSetIsFocused(const bool&) override;
virtual bool RecvSetThrottlePainting(const bool&) override;
virtual bool RecvSuspendTimeouts() override;
virtual bool RecvResumeTimeouts() override;
virtual bool RecvLoadFrameScript(const nsString&) override;
Expand Down

0 comments on commit dd4a8d0

Please sign in to comment.