Bug 648484, part D: Allow PuppetWidgets to create D3D10 layer managers (for the time being). r=roc
authorChris Jones <jones.chris.g@gmail.com>
Wed, 13 Jul 2011 22:43:43 -0700
changeset 72814 e3c251c789f3e68c7c17d92f622873a3cb9de48f
parent 72813 ecbf6db5d91204d225bf2a8e227cce404bc1f2c2
child 72815 a0ea3fd86f200e0c621b568d71f91ed4dc8acf5f
push id20772
push usereakhgari@mozilla.com
push dateThu, 14 Jul 2011 16:20:50 +0000
treeherdermozilla-central@89b5fccb0514 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs648484
milestone8.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 648484, part D: Allow PuppetWidgets to create D3D10 layer managers (for the time being). r=roc
layout/ipc/RenderFrameParent.cpp
widget/src/xpwidgets/Makefile.in
widget/src/xpwidgets/PuppetWidget.cpp
--- a/layout/ipc/RenderFrameParent.cpp
+++ b/layout/ipc/RenderFrameParent.cpp
@@ -716,39 +716,24 @@ RenderFrameParent::ActorDestroy(ActorDes
 
 PLayersParent*
 RenderFrameParent::AllocPLayers(LayerManager::LayersBackend* aBackendType)
 {
   if (!mFrameLoader) {
     *aBackendType = LayerManager::LAYERS_NONE;
     return nsnull;
   }
-
   LayerManager* lm = GetLayerManager();
-  switch (*aBackendType = lm->GetBackendType()) {
-  case LayerManager::LAYERS_BASIC: {
-    BasicShadowLayerManager* bslm = static_cast<BasicShadowLayerManager*>(lm);
-    return new ShadowLayersParent(bslm);
-  }
-  case LayerManager::LAYERS_OPENGL: {
-    LayerManagerOGL* lmo = static_cast<LayerManagerOGL*>(lm);
-    return new ShadowLayersParent(lmo);
+  ShadowLayerManager* slm = lm->AsShadowManager();
+  if (!slm) {
+     NS_WARNING("shadow layers no sprechen D3D backend yet");
+     return nsnull;
   }
-#ifdef MOZ_ENABLE_D3D9_LAYER
-  case LayerManager::LAYERS_D3D9: {
-    LayerManagerD3D9* lmd3d9 = static_cast<LayerManagerD3D9*>(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;
-  }
-  }
+  *aBackendType = lm->GetBackendType();
+  return new ShadowLayersParent(slm);
 }
 
 bool
 RenderFrameParent::DeallocPLayers(PLayersParent* aLayers)
 {
   delete aLayers;
   return true;
 }
--- a/widget/src/xpwidgets/Makefile.in
+++ b/widget/src/xpwidgets/Makefile.in
@@ -92,16 +92,20 @@ ifneq (,$(filter qt gtk2 windows cocoa,$
 CPPSRCS += nsNativeTheme.cpp
 endif
 
 SHARED_LIBRARY_LIBS = ../shared/$(LIB_PREFIX)widget_shared.$(LIB_SUFFIX)
 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 \
 		-I$(topsrcdir)/layout/forms \
 		-I$(topsrcdir)/layout/generic \
 		-I$(topsrcdir)/layout/xul/base/src \
 		-I$(srcdir) \
 		$(NULL)
--- a/widget/src/xpwidgets/PuppetWidget.cpp
+++ b/widget/src/xpwidgets/PuppetWidget.cpp
@@ -35,16 +35,19 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "mozilla/dom/PBrowserChild.h"
 #include "BasicLayers.h"
+#if defined(MOZ_ENABLE_D3D10_LAYER)
+# include "LayerManagerD3D10.h"
+#endif
 
 #include "gfxPlatform.h"
 #include "PuppetWidget.h"
 
 using namespace mozilla::layers;
 using namespace mozilla::widget;
 using namespace mozilla::dom;
 
@@ -331,18 +334,31 @@ PuppetWidget::DispatchEvent(nsGUIEvent* 
 
 LayerManager*
 PuppetWidget::GetLayerManager(PLayersChild* aShadowManager,
                               LayersBackend aBackendHint,
                               LayerManagerPersistence aPersistence,
                               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<LayerManagerD3D10> 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;
   }
   return mLayerManager;
 }
 
 gfxASurface*
@@ -537,20 +553,25 @@ PuppetWidget::DispatchPaintEvent()
 
   nsEventStatus status;
   {
 #ifdef DEBUG
     debug_DumpPaintEvent(stderr, this, &event,
                          nsCAutoString("PuppetWidget"), nsnull);
 #endif
 
-    nsRefPtr<gfxContext> 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<gfxContext> ctx = new gfxContext(mSurface);
+      AutoLayerManagerSetup setupLayerManager(this, ctx,
+                                              BasicLayerManager::BUFFER_NONE);
+      DispatchEvent(&event, status);  
+    }
   }
 
   nsPaintEvent didPaintEvent(PR_TRUE, NS_DID_PAINT, this);
   DispatchEvent(&didPaintEvent, status);
 
   return NS_OK;
 }