зеркало из https://github.com/mozilla/gecko-dev.git
Add support for pausing/resuming composition from Java.
This commit is contained in:
Родитель
a57b590b7d
Коммит
375d4d84d8
|
@ -52,7 +52,7 @@ namespace mozilla {
|
|||
namespace layers {
|
||||
|
||||
CompositorParent::CompositorParent(nsIWidget* aWidget)
|
||||
: mStopped(false), mWidget(aWidget)
|
||||
: mPaused(false), mWidget(aWidget)
|
||||
{
|
||||
MOZ_COUNT_CTOR(CompositorParent);
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ CompositorParent::Destroy()
|
|||
bool
|
||||
CompositorParent::RecvStop()
|
||||
{
|
||||
mStopped = true;
|
||||
mPaused = true;
|
||||
Destroy();
|
||||
return true;
|
||||
}
|
||||
|
@ -88,6 +88,42 @@ CompositorParent::ScheduleRenderOnCompositorThread(::base::Thread &aCompositorTh
|
|||
aCompositorThread.message_loop()->PostTask(FROM_HERE, renderTask);
|
||||
}
|
||||
|
||||
void
|
||||
CompositorParent::PauseComposition()
|
||||
{
|
||||
mPaused = true;
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
// TODO: Tell GLContextEGL we're paused, so it should release surface.
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
CompositorParent::ResumeComposition()
|
||||
{
|
||||
mPaused = false;
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
// TODO: Tell GLContextEGL we've resumed, so it should obtain new surface.
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
CompositorParent::SchedulePauseOnCompositorThread(::base::Thread &aCompositorThread)
|
||||
{
|
||||
CancelableTask *pauseTask = NewRunnableMethod(this,
|
||||
&CompositorParent::PauseComposition);
|
||||
aCompositorThread.message_loop()->PostTask(FROM_HERE, pauseTask);
|
||||
}
|
||||
|
||||
void
|
||||
CompositorParent::ScheduleResumeOnCompositorThread(::base::Thread &aCompositorThread)
|
||||
{
|
||||
CancelableTask *resumeTask = NewRunnableMethod(this,
|
||||
&CompositorParent::ResumeComposition);
|
||||
aCompositorThread.message_loop()->PostTask(FROM_HERE, resumeTask);
|
||||
}
|
||||
|
||||
void
|
||||
CompositorParent::ScheduleComposition()
|
||||
{
|
||||
|
@ -118,7 +154,7 @@ CompositorParent::SetTransformation(float aScale, nsIntPoint aScrollOffset)
|
|||
void
|
||||
CompositorParent::Composite()
|
||||
{
|
||||
if (mStopped || !mLayerManager) {
|
||||
if (mPaused || !mLayerManager) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -218,7 +254,7 @@ CompositorParent::TransformShadowTree(Layer* aLayer, const ViewTransform& aTrans
|
|||
void
|
||||
CompositorParent::AsyncRender()
|
||||
{
|
||||
if (mStopped || !mLayerManager) {
|
||||
if (mPaused || !mLayerManager) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -92,6 +92,11 @@ public:
|
|||
void AsyncRender();
|
||||
void ScheduleRenderOnCompositorThread(::base::Thread &aCompositorThread);
|
||||
|
||||
void PauseComposition();
|
||||
void ResumeComposition();
|
||||
void SchedulePauseOnCompositorThread(::base::Thread &aCompositorThread);
|
||||
void ScheduleResumeOnCompositorThread(::base::Thread &aCompositorThread);
|
||||
|
||||
protected:
|
||||
virtual PLayersParent* AllocPLayers(const LayersBackend &backendType);
|
||||
virtual bool DeallocPLayers(PLayersParent* aLayers);
|
||||
|
@ -123,7 +128,7 @@ private:
|
|||
#endif
|
||||
|
||||
nsRefPtr<LayerManager> mLayerManager;
|
||||
bool mStopped;
|
||||
bool mPaused;
|
||||
nsIWidget* mWidget;
|
||||
float mXScale;
|
||||
float mYScale;
|
||||
|
|
|
@ -171,6 +171,8 @@ public class GeckoAppShell
|
|||
public static native void freeDirectBuffer(ByteBuffer buf);
|
||||
public static native void bindWidgetTexture();
|
||||
public static native void scheduleComposite();
|
||||
public static native void schedulePauseComposition();
|
||||
public static native void scheduleResumeComposition();
|
||||
|
||||
// A looper thread, accessed by GeckoAppShell.getHandler
|
||||
private static class LooperThread extends Thread {
|
||||
|
|
|
@ -192,6 +192,8 @@ public class FlexibleGLSurfaceView extends SurfaceView implements SurfaceHolder.
|
|||
|
||||
public interface Listener {
|
||||
void renderRequested();
|
||||
void compositionPauseRequested();
|
||||
void compositionResumeRequested();
|
||||
}
|
||||
|
||||
public static class FlexibleGLSurfaceViewException extends RuntimeException {
|
||||
|
|
|
@ -193,5 +193,15 @@ public class GeckoGLLayerClient extends GeckoLayerClient
|
|||
Log.e(LOGTAG, "### Render requested, scheduling composite");
|
||||
GeckoAppShell.scheduleComposite();
|
||||
}
|
||||
|
||||
public void compositionPauseRequested() {
|
||||
Log.e(LOGTAG, "### Scheduling PauseComposition");
|
||||
GeckoAppShell.schedulePauseComposition();
|
||||
}
|
||||
|
||||
public void compositionResumeRequested() {
|
||||
Log.e(LOGTAG, "### Scheduling ResumeComposition");
|
||||
GeckoAppShell.scheduleResumeComposition();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1869,6 +1869,22 @@ AndroidBridge::ScheduleComposite()
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
AndroidBridge::SchedulePauseComposition()
|
||||
{
|
||||
if (mCompositorParent) {
|
||||
mCompositorParent->SchedulePauseOnCompositorThread(*mCompositorThread);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AndroidBridge::ScheduleResumeComposition()
|
||||
{
|
||||
if (mCompositorParent) {
|
||||
mCompositorParent->ScheduleResumeOnCompositorThread(*mCompositorThread);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AndroidBridge::SetViewTransformGetter(AndroidViewTransformGetter& aViewTransformGetter)
|
||||
{
|
||||
|
|
|
@ -403,6 +403,8 @@ public:
|
|||
void SetCompositorParent(mozilla::layers::CompositorParent* aCompositorParent,
|
||||
base::Thread* aCompositorThread);
|
||||
void ScheduleComposite();
|
||||
void SchedulePauseComposition();
|
||||
void ScheduleResumeComposition();
|
||||
void SetViewTransformGetter(AndroidViewTransformGetter& aViewTransformGetter);
|
||||
void GetViewTransform(nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY);
|
||||
|
||||
|
|
|
@ -107,6 +107,8 @@ extern "C" {
|
|||
#ifdef MOZ_JAVA_COMPOSITOR
|
||||
NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_bindWidgetTexture(JNIEnv* jenv, jclass);
|
||||
NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_scheduleComposite(JNIEnv* jenv, jclass);
|
||||
NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_schedulePauseComposition(JNIEnv* jenv, jclass);
|
||||
NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_scheduleResumeComposition(JNIEnv* jenv, jclass);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
@ -861,4 +863,18 @@ Java_org_mozilla_gecko_GeckoAppShell_scheduleComposite(JNIEnv*, jclass)
|
|||
AndroidBridge::Bridge()->ScheduleComposite();
|
||||
}
|
||||
|
||||
NS_EXPORT void JNICALL
|
||||
Java_org_mozilla_gecko_GeckoAppShell_schedulePauseComposition(JNIEnv*, jclass)
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_ERROR, "Gecko", "### schedulePauseComposition()");
|
||||
AndroidBridge::Bridge()->SchedulePauseComposition();
|
||||
}
|
||||
|
||||
NS_EXPORT void JNICALL
|
||||
Java_org_mozilla_gecko_GeckoAppShell_scheduleResumeComposition(JNIEnv*, jclass)
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_ERROR, "Gecko", "### scheduleResumeComposition()");
|
||||
AndroidBridge::Bridge()->ScheduleResumeComposition();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Загрузка…
Ссылка в новой задаче