From 9edb022892168b83e6bca322462fc2432cceee5e Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Tue, 9 Aug 2011 12:38:27 -0700 Subject: [PATCH] Bug 648484, part D: Allow PuppetWidgets to create D3D10 layer managers (for the time being). r=roc --- layout/ipc/RenderFrameParent.cpp | 27 +++++----------------- widget/src/xpwidgets/Makefile.in | 4 ++++ widget/src/xpwidgets/PuppetWidget.cpp | 33 ++++++++++++++++++++++----- 3 files changed, 37 insertions(+), 27 deletions(-) diff --git a/layout/ipc/RenderFrameParent.cpp b/layout/ipc/RenderFrameParent.cpp index b8b772fc45f1..9ce7b5dad1d3 100644 --- a/layout/ipc/RenderFrameParent.cpp +++ b/layout/ipc/RenderFrameParent.cpp @@ -728,29 +728,14 @@ RenderFrameParent::AllocPLayers(LayerManager::LayersBackend* aBackendType) *aBackendType = LayerManager::LAYERS_NONE; return nsnull; } - LayerManager* lm = GetLayerManager(); - switch (*aBackendType = lm->GetBackendType()) { - case LayerManager::LAYERS_BASIC: { - BasicShadowLayerManager* bslm = static_cast(lm); - return new ShadowLayersParent(bslm); - } - case LayerManager::LAYERS_OPENGL: { - LayerManagerOGL* lmo = static_cast(lm); - return new ShadowLayersParent(lmo); - } -#ifdef MOZ_ENABLE_D3D9_LAYER - case LayerManager::LAYERS_D3D9: { - LayerManagerD3D9* lmd3d9 = static_cast(lm); - return new ShadowLayersParent(lmd3d9); - } -#endif //MOZ_ENABLE_D3D9_LAYER - default: { - NS_WARNING("shadow layers no sprechen D3D backend yet"); - *aBackendType = LayerManager::LAYERS_NONE; - return nsnull; - } + ShadowLayerManager* slm = lm->AsShadowManager(); + if (!slm) { + NS_WARNING("shadow layers no sprechen D3D backend yet"); + return nsnull; } + *aBackendType = lm->GetBackendType(); + return new ShadowLayersParent(slm); } bool diff --git a/widget/src/xpwidgets/Makefile.in b/widget/src/xpwidgets/Makefile.in index 9c763ff9e6d1..38dc02601953 100644 --- a/widget/src/xpwidgets/Makefile.in +++ b/widget/src/xpwidgets/Makefile.in @@ -97,6 +97,10 @@ ifdef MOZ_X11 SHARED_LIBRARY_LIBS += ../shared/x11/$(LIB_PREFIX)widget_shared_x11.$(LIB_SUFFIX) endif +ifdef MOZ_ENABLE_D3D10_LAYER +DEFINES += -DMOZ_ENABLE_D3D10_LAYER +endif + LOCAL_INCLUDES += \ -I$(srcdir)/../$(MOZ_WIDGET_TOOLKIT) \ -I$(srcdir)/../shared \ diff --git a/widget/src/xpwidgets/PuppetWidget.cpp b/widget/src/xpwidgets/PuppetWidget.cpp index 3a77af344e9b..a282e22a2720 100644 --- a/widget/src/xpwidgets/PuppetWidget.cpp +++ b/widget/src/xpwidgets/PuppetWidget.cpp @@ -40,6 +40,9 @@ #include "mozilla/dom/PBrowserChild.h" #include "BasicLayers.h" +#if defined(MOZ_ENABLE_D3D10_LAYER) +# include "LayerManagerD3D10.h" +#endif #include "gfxPlatform.h" #include "PuppetWidget.h" @@ -336,8 +339,21 @@ PuppetWidget::GetLayerManager(PLayersChild* aShadowManager, bool* aAllowRetaining) { if (!mLayerManager) { - mLayerManager = new BasicShadowLayerManager(this); - mLayerManager->AsShadowForwarder()->SetShadowManager(aShadowManager); + // The backend hint is a temporary placeholder until Azure, when + // all content-process layer managers will be BasicLayerManagers. +#if defined(MOZ_ENABLE_D3D10_LAYER) + if (LayerManager::LAYERS_D3D10 == aBackendHint) { + nsRefPtr m = new LayerManagerD3D10(this); + m->AsShadowForwarder()->SetShadowManager(aShadowManager); + if (m->Initialize()) { + mLayerManager = m; + } + } +#endif + if (!mLayerManager) { + mLayerManager = new BasicShadowLayerManager(this); + mLayerManager->AsShadowForwarder()->SetShadowManager(aShadowManager); + } } if (aAllowRetaining) { *aAllowRetaining = true; @@ -542,10 +558,15 @@ PuppetWidget::DispatchPaintEvent() nsCAutoString("PuppetWidget"), nsnull); #endif - nsRefPtr ctx = new gfxContext(mSurface); - AutoLayerManagerSetup setupLayerManager(this, ctx, - BasicLayerManager::BUFFER_NONE); - DispatchEvent(&event, status); + LayerManager* lm = GetLayerManager(); + if (LayerManager::LAYERS_D3D10 == mLayerManager->GetBackendType()) { + DispatchEvent(&event, status); + } else { + nsRefPtr ctx = new gfxContext(mSurface); + AutoLayerManagerSetup setupLayerManager(this, ctx, + BasicLayerManager::BUFFER_NONE); + DispatchEvent(&event, status); + } } nsPaintEvent didPaintEvent(PR_TRUE, NS_DID_PAINT, this);