Bug 1227706 - Get rid of compositor singletons in nsWindow; r=snorp

Now that we properly support individual compositors for nsWindows, we
should get rid of the static singletons that held the compositor
objects.
This commit is contained in:
Jim Chen 2015-12-23 22:03:34 -05:00
Родитель 827f34efc0
Коммит 7e8d79c4ee
2 изменённых файлов: 21 добавлений и 64 удалений

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

@ -766,11 +766,6 @@ nsWindow::~nsWindow()
{
gTopLevelWindows.RemoveElement(this);
ALOG("nsWindow %p destructor", (void*)this);
if (mLayerManager == sLayerManager) {
// If this window was the one that created the global OMTC layer manager
// and compositor, then we should null those out.
SetCompositor(nullptr, nullptr, nullptr);
}
if (gGeckoViewWindow == this) {
gGeckoViewWindow = nullptr;
@ -1288,11 +1283,6 @@ nsWindow::GetLayerManager(PLayerTransactionChild*, LayersBackend, LayerManagerPe
if (mLayerManager) {
return mLayerManager;
}
// for OMTC allow use of the single layer manager/compositor
// shared across all windows
if (ShouldUseOffMainThreadCompositing()) {
return sLayerManager;
}
return nullptr;
}
@ -1310,15 +1300,8 @@ nsWindow::CreateLayerManager(int aCompositorWidth, int aCompositorHeight)
}
if (ShouldUseOffMainThreadCompositing()) {
if (sLayerManager) {
return;
}
CreateCompositor(aCompositorWidth, aCompositorHeight);
if (mLayerManager) {
// for OMTC create a single layer manager and compositor that will be
// used for all windows.
SetCompositor(mLayerManager, mCompositorParent, mCompositorChild);
sCompositorPaused = false;
return;
}
@ -2965,50 +2948,38 @@ nsWindow::DrawWindowOverlay(LayerManagerComposite* aManager,
// off-main-thread compositor fields and functions
StaticRefPtr<mozilla::layers::APZCTreeManager> nsWindow::sApzcTreeManager;
StaticRefPtr<mozilla::layers::LayerManager> nsWindow::sLayerManager;
StaticRefPtr<mozilla::layers::CompositorParent> nsWindow::sCompositorParent;
StaticRefPtr<mozilla::layers::CompositorChild> nsWindow::sCompositorChild;
bool nsWindow::sCompositorPaused = true;
void
nsWindow::SetCompositor(mozilla::layers::LayerManager* aLayerManager,
mozilla::layers::CompositorParent* aCompositorParent,
mozilla::layers::CompositorChild* aCompositorChild)
{
sLayerManager = aLayerManager;
sCompositorParent = aCompositorParent;
sCompositorChild = aCompositorChild;
}
void
nsWindow::InvalidateAndScheduleComposite()
{
if (sCompositorParent) {
sCompositorParent->InvalidateOnCompositorThread();
sCompositorParent->ScheduleRenderOnCompositorThread();
if (gGeckoViewWindow && gGeckoViewWindow->mGLControllerSupport) {
gGeckoViewWindow->mGLControllerSupport->
SyncInvalidateAndScheduleComposite();
}
}
bool
nsWindow::IsCompositionPaused()
{
return sCompositorPaused;
if (gGeckoViewWindow && gGeckoViewWindow->mGLControllerSupport) {
return gGeckoViewWindow->mGLControllerSupport->CompositorPaused();
}
return false;
}
void
nsWindow::SchedulePauseComposition()
{
if (sCompositorParent) {
sCompositorParent->SchedulePauseOnCompositorThread();
sCompositorPaused = true;
if (gGeckoViewWindow && gGeckoViewWindow->mGLControllerSupport) {
return gGeckoViewWindow->mGLControllerSupport->SyncPauseCompositor();
}
}
void
nsWindow::ScheduleResumeComposition()
{
if (sCompositorParent && sCompositorParent->ScheduleResumeOnCompositorThread()) {
sCompositorPaused = false;
if (gGeckoViewWindow && gGeckoViewWindow->mGLControllerSupport) {
return gGeckoViewWindow->mGLControllerSupport->SyncResumeCompositor();
}
}
@ -3020,19 +2991,11 @@ nsWindow::ScheduleResumeComposition(int width, int height)
}
}
void
nsWindow::ForceIsFirstPaint()
{
if (sCompositorParent) {
sCompositorParent->ForceIsFirstPaint();
}
}
float
nsWindow::ComputeRenderIntegrity()
{
if (sCompositorParent) {
return sCompositorParent->ComputeRenderIntegrity();
if (gGeckoViewWindow && gGeckoViewWindow->mCompositorParent) {
return gGeckoViewWindow->mCompositorParent->ComputeRenderIntegrity();
}
return 1.f;
@ -3057,10 +3020,12 @@ nsWindow::WidgetPaintsBackground()
bool
nsWindow::NeedsPaint()
{
if (sCompositorPaused || FindTopLevel() != nsWindow::TopWindow() || !GetLayerManager(nullptr)) {
return false;
}
return nsIWidget::NeedsPaint();
if (!mGLControllerSupport || mGLControllerSupport->CompositorPaused() ||
// FindTopLevel() != nsWindow::TopWindow() ||
!GetLayerManager(nullptr)) {
return false;
}
return nsIWidget::NeedsPaint();
}
CompositorParent*
@ -3100,8 +3065,8 @@ nsWindow::CreateRootContentController()
uint64_t
nsWindow::RootLayerTreeId()
{
MOZ_ASSERT(sCompositorParent);
return sCompositorParent->RootLayerTreeId();
MOZ_ASSERT(gGeckoViewWindow && gGeckoViewWindow->mCompositorParent);
return gGeckoViewWindow->mCompositorParent->RootLayerTreeId();
}
uint32_t

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

@ -163,15 +163,11 @@ public:
virtual mozilla::layers::CompositorParent* NewCompositorParent(int aSurfaceWidth, int aSurfaceHeight) override;
static void SetCompositor(mozilla::layers::LayerManager* aLayerManager,
mozilla::layers::CompositorParent* aCompositorParent,
mozilla::layers::CompositorChild* aCompositorChild);
static bool IsCompositionPaused();
static void InvalidateAndScheduleComposite();
static void SchedulePauseComposition();
static void ScheduleResumeComposition();
static void ScheduleResumeComposition(int width, int height);
static void ForceIsFirstPaint();
static float ComputeRenderIntegrity();
static mozilla::layers::APZCTreeManager* GetAPZCTreeManager();
/* RootLayerTreeId() can only be called when GetAPZCTreeManager() returns non-null */
@ -229,10 +225,6 @@ private:
mozilla::widget::LayerRenderer::Frame::GlobalRef mLayerRendererFrame;
static mozilla::StaticRefPtr<mozilla::layers::APZCTreeManager> sApzcTreeManager;
static mozilla::StaticRefPtr<mozilla::layers::LayerManager> sLayerManager;
static mozilla::StaticRefPtr<mozilla::layers::CompositorParent> sCompositorParent;
static mozilla::StaticRefPtr<mozilla::layers::CompositorChild> sCompositorChild;
static bool sCompositorPaused;
};
#endif /* NSWINDOW_H_ */