Bug 860613 - Create an android-specific subclass of CompositorParent to be able to pick the target layer for APZC. r=BenWa

This commit is contained in:
Kartikaya Gupta 2013-04-17 17:39:13 -04:00
Родитель df9cf426fc
Коммит ff617de66b
4 изменённых файлов: 66 добавлений и 6 удалений

Просмотреть файл

@ -62,8 +62,10 @@ NS_IMPL_ISUPPORTS_INHERITED0(nsWindow, nsBaseWidget)
static gfxIntSize gAndroidBounds = gfxIntSize(0, 0);
static gfxIntSize gAndroidScreenBounds;
#include "mozilla/layers/AsyncPanZoomController.h"
#include "mozilla/layers/CompositorChild.h"
#include "mozilla/layers/CompositorParent.h"
#include "mozilla/layers/ShadowLayersParent.h"
#include "mozilla/Mutex.h"
#include "nsThreadUtils.h"
@ -2241,6 +2243,7 @@ nsRefPtr<mozilla::layers::LayerManager> nsWindow::sLayerManager = 0;
nsRefPtr<mozilla::layers::CompositorParent> nsWindow::sCompositorParent = 0;
nsRefPtr<mozilla::layers::CompositorChild> nsWindow::sCompositorChild = 0;
bool nsWindow::sCompositorPaused = true;
nsRefPtr<mozilla::layers::AsyncPanZoomController> nsWindow::sApzc = 0;
void
nsWindow::SetCompositor(mozilla::layers::LayerManager* aLayerManager,
@ -2315,4 +2318,53 @@ nsWindow::NeedsPaint()
return nsIWidget::NeedsPaint();
}
class AndroidCompositorParent : public mozilla::layers::CompositorParent {
public:
AndroidCompositorParent(nsIWidget* aWidget, bool aRenderToEGLSurface,
int aSurfaceWidth, int aSurfaceHeight)
: CompositorParent(aWidget, aRenderToEGLSurface, aSurfaceHeight, aSurfaceHeight)
{
if (nsWindow::GetPanZoomController()) {
nsWindow::GetPanZoomController()->SetCompositorParent(this);
}
}
virtual void ShadowLayersUpdated(mozilla::layers::ShadowLayersParent* aLayerTree,
const mozilla::layers::TargetConfig& aTargetConfig,
bool isFirstPaint) MOZ_OVERRIDE
{
CompositorParent::ShadowLayersUpdated(aLayerTree, aTargetConfig, isFirstPaint);
mozilla::layers::Layer* targetLayer = GetLayerManager()->GetPrimaryScrollableLayer();
mozilla::layers::AsyncPanZoomController* controller = nsWindow::GetPanZoomController();
if (targetLayer && targetLayer->AsContainerLayer() && controller) {
targetLayer->SetAsyncPanZoomController(controller);
controller->NotifyLayersUpdated(targetLayer->AsContainerLayer()->GetFrameMetrics(), isFirstPaint);
}
}
};
mozilla::layers::CompositorParent*
nsWindow::NewCompositorParent(int aSurfaceWidth, int aSurfaceHeight)
{
return new AndroidCompositorParent(this, true, aSurfaceWidth, aSurfaceHeight);
}
void
nsWindow::SetPanZoomController(mozilla::layers::AsyncPanZoomController* apzc)
{
if (sApzc) {
sApzc->SetCompositorParent(nullptr);
sApzc = nullptr;
}
if (apzc) {
sApzc = apzc;
sApzc->SetCompositorParent(sCompositorParent);
}
}
mozilla::layers::AsyncPanZoomController*
nsWindow::GetPanZoomController()
{
return sApzc;
}

Просмотреть файл

@ -24,6 +24,7 @@ namespace mozilla {
class CompositorParent;
class CompositorChild;
class LayerManager;
class AsyncPanZoomController;
}
}
@ -145,6 +146,8 @@ public:
virtual void DrawWindowUnderlay(LayerManager* aManager, nsIntRect aRect);
virtual void DrawWindowOverlay(LayerManager* aManager, nsIntRect aRect);
virtual mozilla::layers::CompositorParent* NewCompositorParent(int aSurfaceWidth, int aSurfaceHeight) MOZ_OVERRIDE;
static void SetCompositor(mozilla::layers::LayerManager* aLayerManager,
mozilla::layers::CompositorParent* aCompositorParent,
mozilla::layers::CompositorChild* aCompositorChild);
@ -152,6 +155,8 @@ public:
static void ScheduleResumeComposition(int width, int height);
static void ForceIsFirstPaint();
static float ComputeRenderIntegrity();
static void SetPanZoomController(mozilla::layers::AsyncPanZoomController* apzc);
static mozilla::layers::AsyncPanZoomController* GetPanZoomController();
virtual bool WidgetPaintsBackground();
@ -230,6 +235,7 @@ private:
static nsRefPtr<mozilla::layers::CompositorParent> sCompositorParent;
static nsRefPtr<mozilla::layers::CompositorChild> sCompositorChild;
static bool sCompositorPaused;
static nsRefPtr<mozilla::layers::AsyncPanZoomController> sApzc;
};
#endif /* NSWINDOW_H_ */

Просмотреть файл

@ -872,6 +872,12 @@ nsBaseWidget::ComputeShouldAccelerate(bool aDefault)
return aDefault;
}
CompositorParent* nsBaseWidget::NewCompositorParent(int aSurfaceWidth,
int aSurfaceHeight)
{
return new CompositorParent(this, false, aSurfaceWidth, aSurfaceHeight);
}
void nsBaseWidget::CreateCompositor()
{
nsIntRect rect;
@ -881,12 +887,7 @@ void nsBaseWidget::CreateCompositor()
void nsBaseWidget::CreateCompositor(int aWidth, int aHeight)
{
bool renderToEGLSurface = false;
#ifdef MOZ_ANDROID_OMTC
renderToEGLSurface = true;
#endif
mCompositorParent =
new CompositorParent(this, renderToEGLSurface, aWidth, aHeight);
mCompositorParent = NewCompositorParent(aWidth, aHeight);
AsyncChannel *parentChannel = mCompositorParent->GetIPCChannel();
LayerManager* lm = CreateBasicLayerManager();
MessageLoop *childMessageLoop = CompositorParent::CompositorLoop();

Просмотреть файл

@ -110,6 +110,7 @@ public:
LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT,
bool* aAllowRetaining = nullptr);
virtual CompositorParent* NewCompositorParent(int aSurfaceWidth, int aSurfaceHeight);
virtual void CreateCompositor();
virtual void CreateCompositor(int aWidth, int aHeight);
virtual void DrawWindowUnderlay(LayerManager* aManager, nsIntRect aRect) {}