mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Bug 903893. Backend fallback for OMTC. r=mattwoodrow
This commit is contained in:
parent
99a8e9e1c5
commit
d54a23dd47
@ -2288,9 +2288,11 @@ TabChild::InitRenderingState()
|
||||
NS_WARNING("failed to get CompositorChild instance");
|
||||
return false;
|
||||
}
|
||||
nsTArray<LayersBackend> backends;
|
||||
backends.AppendElement(mTextureFactoryIdentifier.mParentBackend);
|
||||
bool success;
|
||||
shadowManager =
|
||||
compositorChild->SendPLayerTransactionConstructor(mTextureFactoryIdentifier.mParentBackend,
|
||||
compositorChild->SendPLayerTransactionConstructor(backends,
|
||||
id, &mTextureFactoryIdentifier, &success);
|
||||
if (!success) {
|
||||
NS_WARNING("failed to properly allocate layer transaction");
|
||||
|
@ -39,7 +39,6 @@ typedef gfxASurface::gfxContentType gfxContentType;
|
||||
typedef gfxASurface::gfxImageFormat PixelFormat;
|
||||
typedef gfxASurface::gfxSurfaceType gfxSurfaceType;
|
||||
typedef gfxPattern::GraphicsFilter GraphicsFilterType;
|
||||
typedef layers::LayersBackend LayersBackend;
|
||||
typedef layers::ImageLayer::ScaleMode ScaleMode;
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -71,7 +71,7 @@ CompositorChild::Get()
|
||||
}
|
||||
|
||||
PLayerTransactionChild*
|
||||
CompositorChild::AllocPLayerTransactionChild(const LayersBackend& aBackendHint,
|
||||
CompositorChild::AllocPLayerTransactionChild(const nsTArray<LayersBackend>& aBackendHints,
|
||||
const uint64_t& aId,
|
||||
TextureFactoryIdentifier*,
|
||||
bool*)
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
static bool ChildProcessHasCompositor() { return sCompositor != nullptr; }
|
||||
protected:
|
||||
virtual PLayerTransactionChild*
|
||||
AllocPLayerTransactionChild(const LayersBackend& aBackendHint,
|
||||
AllocPLayerTransactionChild(const nsTArray<LayersBackend>& aBackendHints,
|
||||
const uint64_t& aId,
|
||||
TextureFactoryIdentifier* aTextureFactoryIdentifier,
|
||||
bool* aSuccess) MOZ_OVERRIDE;
|
||||
|
@ -598,8 +598,47 @@ CompositorParent::ShadowLayersUpdated(LayerTransactionParent* aLayerTree,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CompositorParent::InitializeLayerManager(const nsTArray<LayersBackend>& aBackendHints)
|
||||
{
|
||||
NS_ASSERTION(!mLayerManager, "Already initialised mLayerManager");
|
||||
|
||||
for (size_t i = 0; i < aBackendHints.Length(); ++i) {
|
||||
RefPtr<LayerManagerComposite> layerManager;
|
||||
if (aBackendHints[i] == LAYERS_OPENGL) {
|
||||
layerManager =
|
||||
new LayerManagerComposite(new CompositorOGL(mWidget,
|
||||
mEGLSurfaceSize.width,
|
||||
mEGLSurfaceSize.height,
|
||||
mUseExternalSurfaceSize));
|
||||
} else if (aBackendHints[i] == LAYERS_BASIC) {
|
||||
layerManager =
|
||||
new LayerManagerComposite(new BasicCompositor(mWidget));
|
||||
#ifdef XP_WIN
|
||||
} else if (aBackendHints[i] == LAYERS_D3D11) {
|
||||
layerManager =
|
||||
new LayerManagerComposite(new CompositorD3D11(mWidget));
|
||||
} else if (aBackendHints[i] == LAYERS_D3D9) {
|
||||
layerManager =
|
||||
new LayerManagerComposite(new CompositorD3D9(mWidget));
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!layerManager) {
|
||||
continue;
|
||||
}
|
||||
|
||||
layerManager->SetCompositorID(mCompositorID);
|
||||
|
||||
if (layerManager->Initialize()) {
|
||||
mLayerManager = layerManager;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PLayerTransactionParent*
|
||||
CompositorParent::AllocPLayerTransactionParent(const LayersBackend& aBackendHint,
|
||||
CompositorParent::AllocPLayerTransactionParent(const nsTArray<LayersBackend>& aBackendHints,
|
||||
const uint64_t& aId,
|
||||
TextureFactoryIdentifier* aTextureFactoryIdentifier,
|
||||
bool *aSuccess)
|
||||
@ -610,35 +649,11 @@ CompositorParent::AllocPLayerTransactionParent(const LayersBackend& aBackendHint
|
||||
// nullptr before returning from this method, to avoid accessing it elsewhere.
|
||||
nsIntRect rect;
|
||||
mWidget->GetClientBounds(rect);
|
||||
|
||||
if (aBackendHint == mozilla::layers::LAYERS_OPENGL) {
|
||||
mLayerManager =
|
||||
new LayerManagerComposite(new CompositorOGL(mWidget,
|
||||
mEGLSurfaceSize.width,
|
||||
mEGLSurfaceSize.height,
|
||||
mUseExternalSurfaceSize));
|
||||
} else if (aBackendHint == mozilla::layers::LAYERS_BASIC) {
|
||||
mLayerManager =
|
||||
new LayerManagerComposite(new BasicCompositor(mWidget));
|
||||
#ifdef XP_WIN
|
||||
} else if (aBackendHint == mozilla::layers::LAYERS_D3D11) {
|
||||
mLayerManager =
|
||||
new LayerManagerComposite(new CompositorD3D11(mWidget));
|
||||
} else if (aBackendHint == mozilla::layers::LAYERS_D3D9) {
|
||||
mLayerManager =
|
||||
new LayerManagerComposite(new CompositorD3D9(mWidget));
|
||||
#endif
|
||||
} else {
|
||||
NS_WARNING("Unsupported backend selected for Async Compositor");
|
||||
*aSuccess = false;
|
||||
return new LayerTransactionParent(nullptr, this, 0);
|
||||
}
|
||||
|
||||
InitializeLayerManager(aBackendHints);
|
||||
mWidget = nullptr;
|
||||
mLayerManager->SetCompositorID(mCompositorID);
|
||||
|
||||
if (!mLayerManager->Initialize()) {
|
||||
NS_WARNING("Failed to init Compositor");
|
||||
if (!mLayerManager) {
|
||||
NS_WARNING("Failed to initialise Compositor");
|
||||
*aSuccess = false;
|
||||
return new LayerTransactionParent(nullptr, this, 0);
|
||||
}
|
||||
@ -834,7 +849,7 @@ public:
|
||||
virtual bool RecvFlushRendering() MOZ_OVERRIDE { return true; }
|
||||
|
||||
virtual PLayerTransactionParent*
|
||||
AllocPLayerTransactionParent(const LayersBackend& aBackendType,
|
||||
AllocPLayerTransactionParent(const nsTArray<LayersBackend>& aBackendHints,
|
||||
const uint64_t& aId,
|
||||
TextureFactoryIdentifier* aTextureFactoryIdentifier,
|
||||
bool *aSuccess) MOZ_OVERRIDE;
|
||||
@ -916,7 +931,7 @@ CrossProcessCompositorParent::ActorDestroy(ActorDestroyReason aWhy)
|
||||
}
|
||||
|
||||
PLayerTransactionParent*
|
||||
CrossProcessCompositorParent::AllocPLayerTransactionParent(const LayersBackend& aBackendType,
|
||||
CrossProcessCompositorParent::AllocPLayerTransactionParent(const nsTArray<LayersBackend>&,
|
||||
const uint64_t& aId,
|
||||
TextureFactoryIdentifier* aTextureFactoryIdentifier,
|
||||
bool *aSuccess)
|
||||
|
@ -206,7 +206,7 @@ public:
|
||||
static bool IsInCompositorThread();
|
||||
protected:
|
||||
virtual PLayerTransactionParent*
|
||||
AllocPLayerTransactionParent(const LayersBackend& aBackendHint,
|
||||
AllocPLayerTransactionParent(const nsTArray<LayersBackend>& aBackendHints,
|
||||
const uint64_t& aId,
|
||||
TextureFactoryIdentifier* aTextureFactoryIdentifier,
|
||||
bool* aSuccess);
|
||||
@ -218,6 +218,7 @@ protected:
|
||||
void SetEGLSurfaceSize(int width, int height);
|
||||
|
||||
private:
|
||||
void InitializeLayerManager(const nsTArray<LayersBackend>& aBackendHints);
|
||||
void PauseComposition();
|
||||
void ResumeComposition();
|
||||
void ResumeCompositionAndResize(int width, int height);
|
||||
|
@ -60,7 +60,10 @@ parent:
|
||||
// block until they are completed.
|
||||
sync FlushRendering();
|
||||
|
||||
sync PLayerTransaction(LayersBackend layersBackendHint, uint64_t id)
|
||||
// layersBackendHints is an ordered list of preffered backends where
|
||||
// layersBackendHints[0] is the best backend. If any hints are LAYERS_NONE
|
||||
// that hint is ignored.
|
||||
sync PLayerTransaction(LayersBackend[] layersBackendHints, uint64_t id)
|
||||
returns (TextureFactoryIdentifier textureFactoryIdentifier, bool success);
|
||||
};
|
||||
|
||||
|
@ -6558,18 +6558,19 @@ nsWindow::StartAllowingD3D9(bool aReinitialize)
|
||||
}
|
||||
}
|
||||
|
||||
mozilla::layers::LayersBackend
|
||||
nsWindow::GetPreferredCompositorBackend()
|
||||
void
|
||||
nsWindow::GetPreferredCompositorBackends(nsTArray<LayersBackend>& aHints)
|
||||
{
|
||||
LayerManagerPrefs prefs;
|
||||
GetLayerManagerPrefs(&prefs);
|
||||
if (prefs.mDisableAcceleration) {
|
||||
return mozilla::layers::LAYERS_BASIC;
|
||||
|
||||
if (!prefs.mDisableAcceleration) {
|
||||
if (!prefs.mPreferD3D9) {
|
||||
aHints.AppendElement(LAYERS_D3D11);
|
||||
}
|
||||
aHints.AppendElement(LAYERS_D3D9);
|
||||
}
|
||||
if (prefs.mPreferD3D9) {
|
||||
return mozilla::layers::LAYERS_D3D9;
|
||||
}
|
||||
return mozilla::layers::LAYERS_D3D11;
|
||||
aHints.AppendElement(LAYERS_BASIC);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -275,7 +275,7 @@ public:
|
||||
|
||||
bool const DestroyCalled() { return mDestroyCalled; }
|
||||
|
||||
virtual mozilla::layers::LayersBackend GetPreferredCompositorBackend();
|
||||
virtual void GetPreferredCompositorBackends(nsTArray<mozilla::layers::LayersBackend>& aHints);
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -140,7 +140,7 @@ public:
|
||||
LayersBackend aBackendHint = mozilla::layers::LAYERS_NONE,
|
||||
LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT,
|
||||
bool* aAllowRetaining = nullptr);
|
||||
virtual mozilla::layers::LayersBackend GetPreferredCompositorBackend() { return mozilla::layers::LAYERS_D3D11; }
|
||||
virtual void GetPreferredCompositorBackends(nsTArray<mozilla::layers::LayersBackend>& aHints) { aHints.AppendElement(mozilla::layers::LAYERS_D3D11); }
|
||||
|
||||
// IME related interfaces
|
||||
NS_IMETHOD_(void) SetInputContext(const InputContext& aContext,
|
||||
|
@ -914,14 +914,27 @@ void nsBaseWidget::CreateCompositor()
|
||||
CreateCompositor(rect.width, rect.height);
|
||||
}
|
||||
|
||||
mozilla::layers::LayersBackend
|
||||
nsBaseWidget::GetPreferredCompositorBackend()
|
||||
void
|
||||
nsBaseWidget::GetPreferredCompositorBackends(nsTArray<LayersBackend>& aHints)
|
||||
{
|
||||
if (mUseLayersAcceleration) {
|
||||
return mozilla::layers::LAYERS_OPENGL;
|
||||
aHints.AppendElement(LAYERS_OPENGL);
|
||||
}
|
||||
|
||||
return mozilla::layers::LAYERS_BASIC;
|
||||
aHints.AppendElement(LAYERS_BASIC);
|
||||
}
|
||||
|
||||
static void
|
||||
CheckForBasicBackends(nsTArray<LayersBackend>& aHints)
|
||||
{
|
||||
for (size_t i = 0; i < aHints.Length(); ++i) {
|
||||
if (aHints[i] == LAYERS_BASIC &&
|
||||
!Preferences::GetBool("layers.offmainthreadcomposition.force-basic", false) &&
|
||||
!Preferences::GetBool("browser.tabs.remote", false)) {
|
||||
// basic compositor is not stable enough for regular use
|
||||
aHints[i] = LAYERS_NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void nsBaseWidget::CreateCompositor(int aWidth, int aHeight)
|
||||
@ -945,19 +958,15 @@ void nsBaseWidget::CreateCompositor(int aWidth, int aHeight)
|
||||
|
||||
TextureFactoryIdentifier textureFactoryIdentifier;
|
||||
PLayerTransactionChild* shadowManager;
|
||||
mozilla::layers::LayersBackend backendHint = GetPreferredCompositorBackend();
|
||||
nsTArray<LayersBackend> backendHints;
|
||||
GetPreferredCompositorBackends(backendHints);
|
||||
|
||||
if (backendHint == LAYERS_BASIC &&
|
||||
!Preferences::GetBool("layers.offmainthreadcomposition.force-basic", false) &&
|
||||
!Preferences::GetBool("browser.tabs.remote", false)) {
|
||||
// basic compositor is not stable enough for regular use
|
||||
backendHint = LAYERS_NONE;
|
||||
}
|
||||
CheckForBasicBackends(backendHints);
|
||||
|
||||
bool success = false;
|
||||
if (backendHint) {
|
||||
if (!backendHints.IsEmpty()) {
|
||||
shadowManager = mCompositorChild->SendPLayerTransactionConstructor(
|
||||
backendHint, 0, &textureFactoryIdentifier, &success);
|
||||
backendHints, 0, &textureFactoryIdentifier, &success);
|
||||
}
|
||||
|
||||
if (success) {
|
||||
|
@ -361,7 +361,7 @@ protected:
|
||||
|
||||
virtual CompositorChild* GetRemoteRenderer() MOZ_OVERRIDE;
|
||||
|
||||
virtual mozilla::layers::LayersBackend GetPreferredCompositorBackend();
|
||||
virtual void GetPreferredCompositorBackends(nsTArray<mozilla::layers::LayersBackend>& aHints);
|
||||
|
||||
/**
|
||||
* Notify the widget that this window is being used with OMTC.
|
||||
|
Loading…
Reference in New Issue
Block a user