Bug 703484 - Part 1: Allow OMTC to be used with basic layers. r=bgirard

--HG--
extra : rebase_source : a96747d6ea09d7112649fa46d2d6a84ababaeaab
This commit is contained in:
Marco Castelluccio 2012-05-15 15:56:56 -04:00
parent 7e3b302b27
commit 8c545c33a9
3 changed files with 32 additions and 15 deletions

View File

@ -494,7 +494,6 @@ CompositorParent::AllocPLayers(const LayersBackend& aBackendType, int* aMaxTextu
*aMaxTextureSize = layerManager->GetMaxTextureSize();
return new ShadowLayersParent(slm, this);
} else if (aBackendType == LayerManager::LAYERS_BASIC) {
// This require Cairo to be thread-safe
nsRefPtr<LayerManager> layerManager = new BasicShadowLayerManager(mWidget);
mWidget = NULL;
mLayerManager = layerManager;

View File

@ -3194,9 +3194,21 @@ nsWindow::GetLayerManager(PLayersChild* aShadowManager,
}
// Fall back to software if we couldn't use any hardware backends.
if (!mLayerManager) {
// Try to use an async compositor first, if possible
bool useCompositor =
Preferences::GetBool("layers.offmainthreadcomposition.enabled", false);
if (useCompositor) {
// e10s uses the parameter to pass in the shadow manager from the TabChild
// so we don't expect to see it there since this doesn't support e10s.
NS_ASSERTION(aShadowManager == nsnull, "Async Compositor not supported with e10s");
CreateCompositor();
}
if (!mLayerManager)
mLayerManager = CreateBasicLayerManager();
}
}
NS_ASSERTION(mLayerManager, "Couldn't provide a valid layer manager.");

View File

@ -876,8 +876,12 @@ void nsBaseWidget::CreateCompositor()
AsyncChannel::Side childSide = mozilla::ipc::AsyncChannel::Child;
mCompositorChild->Open(parentChannel, childMessageLoop, childSide);
PRInt32 maxTextureSize;
PLayersChild* shadowManager =
mCompositorChild->SendPLayersConstructor(LayerManager::LAYERS_OPENGL, &maxTextureSize);
PLayersChild* shadowManager;
if (mUseAcceleratedRendering) {
shadowManager = mCompositorChild->SendPLayersConstructor(LayerManager::LAYERS_OPENGL, &maxTextureSize);
} else {
shadowManager = mCompositorChild->SendPLayersConstructor(LayerManager::LAYERS_BASIC, &maxTextureSize);
}
if (shadowManager) {
ShadowLayerForwarder* lf = lm->AsShadowForwarder();
@ -887,7 +891,10 @@ void nsBaseWidget::CreateCompositor()
return;
}
lf->SetShadowManager(shadowManager);
if (mUseAcceleratedRendering)
lf->SetParentBackendType(LayerManager::LAYERS_OPENGL);
else
lf->SetParentBackendType(LayerManager::LAYERS_BASIC);
lf->SetMaxTextureSize(maxTextureSize);
mLayerManager = lm;
@ -913,8 +920,6 @@ LayerManager* nsBaseWidget::GetLayerManager(PLayersChild* aShadowManager,
mUseAcceleratedRendering = GetShouldAccelerate();
if (mUseAcceleratedRendering) {
// Try to use an async compositor first, if possible
if (UseOffMainThreadCompositing()) {
// e10s uses the parameter to pass in the shadow manager from the TabChild
@ -923,6 +928,7 @@ LayerManager* nsBaseWidget::GetLayerManager(PLayersChild* aShadowManager,
CreateCompositor();
}
if (mUseAcceleratedRendering) {
if (!mLayerManager) {
nsRefPtr<LayerManagerOGL> layerManager = new LayerManagerOGL(this);
/**