From b7f22960455b044bb0d357bd49525cf126eb4aa9 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Wed, 13 Jul 2011 22:43:43 -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 0c990ae54c5..40afac51ccd 100644 --- a/layout/ipc/RenderFrameParent.cpp +++ b/layout/ipc/RenderFrameParent.cpp @@ -721,29 +721,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 9c763ff9e6d..38dc0260195 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 3a77af344e9..a282e22a272 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);