Bug 839808 - Add support for omtc to winrt widget. r=bbondy
authorJim Mathies <jmathies@mozilla.com>
Mon, 04 Mar 2013 12:32:20 -0600
changeset 134100 1473f6edfcad0377b376461adc7a01937a7e9609
parent 134099 eef5f845fb757823b9a8b038d0ddbac4ddc00417
child 134101 9de58c86bebaae69eb626ddcac04e636b311d2c9
push idunknown
push userunknown
push dateunknown
reviewersbbondy
bugs839808
milestone22.0a1
Bug 839808 - Add support for omtc to winrt widget. r=bbondy
browser/app/nsBrowserApp.cpp
browser/metro/profile/metro.js
widget/android/nsWindow.cpp
widget/cocoa/nsChildView.h
widget/cocoa/nsChildView.mm
widget/gonk/nsWindow.cpp
widget/windows/nsWindow.cpp
widget/windows/nsWindow.h
widget/windows/winrt/FrameworkView.cpp
widget/windows/winrt/FrameworkView.h
widget/windows/winrt/FrameworkViewGfx.cpp
widget/windows/winrt/MetroWidget.cpp
widget/windows/winrt/MetroWidget.h
widget/xpwidgets/nsBaseWidget.cpp
widget/xpwidgets/nsBaseWidget.h
--- a/browser/app/nsBrowserApp.cpp
+++ b/browser/app/nsBrowserApp.cpp
@@ -23,16 +23,20 @@
 #include <stdio.h>
 #include <stdarg.h>
 #include <time.h>
 
 #include "nsCOMPtr.h"
 #include "nsIFile.h"
 #include "nsStringGlue.h"
 
+// Easy access to a five second startup delay used to get
+// a debugger attached in the metro environment. 
+// #define DEBUG_delay_start_metro
+
 #ifdef XP_WIN
 // we want a wmain entry point
 #include "nsWindowsWMain.cpp"
 #define snprintf _snprintf
 #define strcasecmp _stricmp
 #endif
 #include "BinaryPath.h"
 
@@ -462,16 +466,19 @@ InitXPCOMGlue(const char *argv0, nsIFile
                              xreDirectory);
 #endif
 
   return rv;
 }
 
 int main(int argc, char* argv[])
 {
+#ifdef DEBUG_delay_start_metro
+  Sleep(5000);
+#endif
   PRTime start = _PR_Now();
 
 #ifdef XP_MACOSX
   TriggerQuirks();
 #endif
 
   int gotCounters;
 #if defined(XP_UNIX)
--- a/browser/metro/profile/metro.js
+++ b/browser/metro/profile/metro.js
@@ -16,16 +16,19 @@ pref("app.reportCrashes", true);
 
 // Debug prefs, see input.js
 pref("metro.debug.treatmouseastouch", false);
 pref("metro.debug.colorizeInputOverlay", false);
 pref("metro.debug.selection.displayRanges", false);
 pref("metro.debug.selection.dumpRanges", false);
 pref("metro.debug.selection.dumpEvents", false);
 
+// Enable off main thread compositing
+pref("layers.offmainthreadcomposition.enabled", false);
+
 // Form helper options: 0 = disabled, 1 = enabled, 2 = dynamic depending on screen size
 pref("formhelper.mode", 0);
 // Auto zoom to form elements when they take focus 
 pref("formhelper.autozoom", true);
 // Auto zoom to the caret
 pref("formhelper.autozoom.caret", false);
 
 // form autocomplete service
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -685,17 +685,17 @@ nsWindow::GetLayerManager(PLayersChild*,
     if (aAllowRetaining) {
         *aAllowRetaining = true;
     }
     if (mLayerManager) {
         return mLayerManager;
     }
     // for OMTC allow use of the single layer manager/compositor
     // shared across all windows
-    if (UseOffMainThreadCompositing()) {
+    if (ShouldUseOffMainThreadCompositing()) {
         return sLayerManager;
     }
     return nullptr;
 }
 
 void
 nsWindow::CreateLayerManager()
 {
@@ -706,17 +706,17 @@ nsWindow::CreateLayerManager()
     nsWindow *topLevelWindow = FindTopLevel();
     if (!topLevelWindow || topLevelWindow->mWindowType == eWindowType_invisible) {
         // don't create a layer manager for an invisible top-level window
         return;
     }
 
     mUseLayersAcceleration = ComputeShouldAccelerate(mUseLayersAcceleration);
 
-    if (UseOffMainThreadCompositing()) {
+    if (ShouldUseOffMainThreadCompositing()) {
         if (sLayerManager) {
             return;
         }
         CreateCompositor();
         if (mLayerManager) {
             // for OMTC create a single layer manager and compositor that will be
             // used for all windows.
             SetCompositor(mLayerManager, mCompositorParent, mCompositorChild);
--- a/widget/cocoa/nsChildView.h
+++ b/widget/cocoa/nsChildView.h
@@ -423,17 +423,17 @@ public:
   virtual nsIntPoint      WidgetToScreenOffset();
   virtual bool            ShowsResizeIndicator(nsIntRect* aResizerRect);
 
   static  bool            ConvertStatus(nsEventStatus aStatus)
                           { return aStatus == nsEventStatus_eConsumeNoDefault; }
   NS_IMETHOD              DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus);
 
   virtual bool            ComputeShouldAccelerate(bool aDefault);
-  virtual bool            UseOffMainThreadCompositing();
+  virtual bool            ShouldUseOffMainThreadCompositing();
 
   NS_IMETHOD        SetCursor(nsCursor aCursor);
   NS_IMETHOD        SetCursor(imgIContainer* aCursor, uint32_t aHotspotX, uint32_t aHotspotY);
 
   NS_IMETHOD        CaptureRollupEvents(nsIRollupListener * aListener, bool aDoCapture);
   NS_IMETHOD        SetTitle(const nsAString& title);
 
   NS_IMETHOD        GetAttention(int32_t aCycleCount);
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -1398,21 +1398,21 @@ nsChildView::ComputeShouldAccelerate(boo
   if (!mView || ![[mView window] isOpaque] ||
       [[mView window] isKindOfClass:[PopupWindow class]])
     return false;
 
   return nsBaseWidget::ComputeShouldAccelerate(aDefault);
 }
 
 bool
-nsChildView::UseOffMainThreadCompositing()
+nsChildView::ShouldUseOffMainThreadCompositing()
 {
   // OMTC doesn't work with Basic Layers on OS X right now. Once it works, we'll
   // still want to disable it for certain kinds of windows (e.g. popups).
-  return nsBaseWidget::UseOffMainThreadCompositing() &&
+  return nsBaseWidget::ShouldUseOffMainThreadCompositing() &&
          ComputeShouldAccelerate(mUseLayersAcceleration);
 }
 
 inline uint16_t COLOR8TOCOLOR16(uint8_t color8)
 {
   // return (color8 == 0xFF ? 0xFFFF : (color8 << 8));
   return (color8 << 8) | color8;  /* (color8 * 257) == (color8 * 0x0101) */
 }
--- a/widget/gonk/nsWindow.cpp
+++ b/widget/gonk/nsWindow.cpp
@@ -185,17 +185,17 @@ nsWindow::nsWindow()
 
         // This is a hack to force initialization of the compositor
         // resources, if we're going to use omtc.
         //
         // NB: GetPlatform() will create the gfxPlatform, which wants
         // to know the color depth, which asks our native window.
         // This has to happen after other init has finished.
         gfxPlatform::GetPlatform();
-        sUsingOMTC = UseOffMainThreadCompositing();
+        sUsingOMTC = ShouldUseOffMainThreadCompositing();
         sUsingHwc = Preferences::GetBool("layers.composer2d.enabled", false);
 
         if (sUsingOMTC) {
           sOMTCSurface = new gfxImageSurface(gfxIntSize(1, 1),
                                              gfxASurface::ImageFormatRGB24);
         }
     }
 }
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -3206,17 +3206,17 @@ GetLayerManagerPrefs(LayerManagerPrefs* 
   nsCOMPtr<nsIXULRuntime> xr = do_GetService("@mozilla.org/xre/runtime;1");
   if (xr)
     xr->GetInSafeMode(&safeMode);
   aManagerPrefs->mDisableAcceleration =
     aManagerPrefs->mDisableAcceleration || safeMode;
 }
 
 bool
-nsWindow::UseOffMainThreadCompositing()
+nsWindow::ShouldUseOffMainThreadCompositing()
 {
   // OMTC doesn't work on Windows right now.
   return false;
 }
 
 LayerManager*
 nsWindow::GetLayerManager(PLayersChild* aShadowManager,
                           LayersBackend aBackendHint,
@@ -3313,17 +3313,17 @@ nsWindow::GetLayerManager(PLayersChild* 
           NS_WARNING("OpenGL accelerated layers are not supported on this system.");
         }
       }
     }
 
     // Fall back to software if we couldn't use any hardware backends.
     if (!mLayerManager) {
       // Try to use an async compositor first, if possible
-      if (UseOffMainThreadCompositing()) {
+      if (ShouldUseOffMainThreadCompositing()) {
         // 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 == nullptr, "Async Compositor not supported with e10s");
         CreateCompositor();
       }
 
       if (!mLayerManager)
         mLayerManager = CreateBasicLayerManager();
--- a/widget/windows/nsWindow.h
+++ b/widget/windows/nsWindow.h
@@ -274,17 +274,17 @@ public:
   // Open file picker tracking
   void                    PickerOpen();
   void                    PickerClosed();
 
   bool                    const DestroyCalled() { return mDestroyCalled; }
 
   static void             SetupKeyModifiersSequence(nsTArray<KeyPair>* aArray, uint32_t aModifiers);
 
-  virtual bool            UseOffMainThreadCompositing();
+  virtual bool            ShouldUseOffMainThreadCompositing();
 protected:
 
   // A magic number to identify the FAKETRACKPOINTSCROLLABLE window created
   // when the trackpoint hack is enabled.
   enum { eFakeTrackPointScrollableID = 0x46545053 };
 
   /**
    * Callbacks
--- a/widget/windows/winrt/FrameworkView.cpp
+++ b/widget/windows/winrt/FrameworkView.cpp
@@ -109,17 +109,17 @@ FrameworkView::Run()
   if (mDeferredActivationEventArgs) {
     RunStartupArgs(mDeferredActivationEventArgs.Get());
     mDeferredActivationEventArgs = nullptr;
   }
 
   // Activate the window
   mWindow->Activate();
 
-  UpdateSizeAndPosition();
+  UpdateWidgetSizeAndPosition();
 
   MetroUtils::GetViewState(mViewState);
 
   // Get the metro event dispatcher
   HRESULT hr = mWindow->get_Dispatcher(&mDispatcher);
   AssertRetHRESULT(hr, hr);
 
   // Needs mDispatcher
@@ -243,41 +243,37 @@ FrameworkView::UpdateLogicalDPI()
   FLOAT value;
   AssertHRESULT(dispProps->get_LogicalDpi(&value));
   SetDpi(value);
 }
 
 void
 FrameworkView::GetBounds(nsIntRect &aRect)
 {
+  // May be called by compositor thread
   if (mShuttingDown) {
     return;
   }
-  NS_ASSERTION(mWindow, "SetWindow must be called before GetBounds!");
-  Rect msrect;
-  mWindow->get_Bounds(&msrect);
-  nsIntRect mozrect(0, 0, (uint32_t)ceil(msrect.Width),
-                    (uint32_t)ceil(msrect.Height));
+  nsIntRect mozrect(0, 0, (uint32_t)ceil(mWindowBounds.Width),
+                    (uint32_t)ceil(mWindowBounds.Height));
   aRect = mozrect;
 }
 
 void
-FrameworkView::UpdateSizeAndPosition()
+FrameworkView::UpdateWidgetSizeAndPosition()
 {
   if (mShuttingDown)
     return;
 
-  NS_ASSERTION(mWindow, "SetWindow must be called before UpdateSizeAndPosition!");
-  NS_ASSERTION(mWidget, "SetWidget must be called before UpdateSizeAndPosition!");
+  NS_ASSERTION(mWindow, "SetWindow must be called before UpdateWidgetSizeAndPosition!");
+  NS_ASSERTION(mWidget, "SetWidget must be called before UpdateWidgetSizeAndPosition!");
 
-  Rect rect;
-  mWindow->get_Bounds(&rect);
   mWidget->Move(0, 0);
-  mWidget->Resize(0, 0, (uint32_t)ceil(rect.Width),
-                  (uint32_t)ceil(rect.Height), true);
+  mWidget->Resize(0, 0, (uint32_t)ceil(mWindowBounds.Width),
+                  (uint32_t)ceil(mWindowBounds.Height), true);
   mWidget->SizeModeChanged();
 }
 
 bool
 FrameworkView::IsEnabled() const
 {
   return mWinActiveState;
 }
@@ -290,56 +286,44 @@ FrameworkView::IsVisible() const
   // or activation.
   return mWinVisible;
 }
 
 void FrameworkView::SetDpi(float aDpi)
 {
   if (aDpi != mDPI) {
       mDPI = aDpi;
-      // Often a DPI change implies a window size change. In some cases Windows will issues
-      // both a size changed event and a DPI changed event. In this case, the resulting bounds 
-      // will not change, and the window resize code will only be executed once.
-      UpdateForWindowSizeChange();
+      // Often a DPI change implies a window size change.
+      NS_ASSERTION(mWindow, "SetWindow must be called before SetDpi!");
+      mWindow->get_Bounds(&mWindowBounds);
   }
 }
 
 void
 FrameworkView::SetWidget(MetroWidget* aWidget)
 {
   NS_ASSERTION(!mWidget, "Attempting to set a widget for a view that already has a widget!");
   NS_ASSERTION(aWidget, "Attempting to set a null widget for a view!");
   LogFunction();
   mWidget = aWidget;
   mWidget->FindMetroWindow();
 }
 
-// This routine is called in the event handler for the view SizeChanged event.
-void
-FrameworkView::UpdateForWindowSizeChange()
-{
-  if (mShuttingDown) {
-    return;
-  }
-  NS_ASSERTION(mWindow, "SetWindow must be called before UpdateForWindowSizeChange!");
-  mWindow->get_Bounds(&mWindowBounds);
-}
-
 ////////////////////////////////////////////////////
 // Event handlers
 
 void
 FrameworkView::SendActivationEvent() 
 {
   if (mShuttingDown) {
     return;
   }
   NS_ASSERTION(mWindow, "SetWindow must be called before SendActivationEvent!");
   mWidget->Activated(mWinActiveState);
-  UpdateSizeAndPosition();
+  UpdateWidgetSizeAndPosition();
   EnsureAutomationProviderCreated();
 }
 
 HRESULT
 FrameworkView::OnWindowVisibilityChanged(ICoreWindow* aWindow,
                                          IVisibilityChangedEventArgs* aArgs)
 {
   // If we're visible, or we can't determine if we're visible, just store
@@ -431,18 +415,25 @@ FrameworkView::FireViewStateObservers()
   };
   MetroUtils::FireObserver("metro_viewstate_changed", name.get());
 }
 
 HRESULT
 FrameworkView::OnWindowSizeChanged(ICoreWindow* aSender, IWindowSizeChangedEventArgs* aArgs)
 {
   LogFunction();
-  UpdateForWindowSizeChange();
-  UpdateSizeAndPosition();
+
+  if (mShuttingDown) {
+    return S_OK;
+  }
+
+  NS_ASSERTION(mWindow, "SetWindow must be called before OnWindowSizeChanged!");
+  mWindow->get_Bounds(&mWindowBounds);
+
+  UpdateWidgetSizeAndPosition();
   FireViewStateObservers();
   return S_OK;
 }
 
 HRESULT
 FrameworkView::OnWindowActivated(ICoreWindow* aSender, IWindowActivatedEventArgs* aArgs)
 {
   LogFunction();
--- a/widget/windows/winrt/FrameworkView.h
+++ b/widget/windows/winrt/FrameworkView.h
@@ -132,17 +132,17 @@ protected:
   HRESULT OnSettingsCommandsRequested(ISettingsPane* aPane, ISettingsPaneCommandsRequestedEventArgs* aArgs);
   HRESULT OnPlayToSourceRequested(IPlayToManager* aPane, IPlayToSourceRequestedEventArgs* aArgs);
   HRESULT OnSettingsCommandInvoked(IUICommand* aCommand);
   HRESULT OnPrintTaskRequested(IPrintManager* aMgr, IPrintTaskRequestedEventArgs* aArgs);
   HRESULT OnPrintTaskSourceRequested(IPrintTaskSourceRequestedArgs* aArgs);
 
 protected:
   void SetDpi(float aDpi);
-  void UpdateSizeAndPosition();
+  void UpdateWidgetSizeAndPosition();
   void PerformURILoad(Microsoft::WRL::ComPtr<ABI::Windows::Foundation::IUriRuntimeClass>& aURI);
   void PerformSearch(Microsoft::WRL::Wrappers::HString& aQuery);
   void PerformURILoadOrSearch(Microsoft::WRL::Wrappers::HString& aString);
   bool EnsureAutomationProviderCreated();
   void SearchActivated(Microsoft::WRL::ComPtr<ISearchActivatedEventArgs>& aArgs);
   void FileActivated(Microsoft::WRL::ComPtr<IFileActivatedEventArgs>& aArgs);
   void LaunchActivated(Microsoft::WRL::ComPtr<ILaunchActivatedEventArgs>& aArgs);
   void RunStartupArgs(IActivatedEventArgs* aArgs);
--- a/widget/windows/winrt/FrameworkViewGfx.cpp
+++ b/widget/windows/winrt/FrameworkViewGfx.cpp
@@ -62,15 +62,14 @@ FrameworkView::Render(const nsIntRegion&
 
   if (mWidget->GetTransparencyMode() != eTransparencyOpaque) {
     NS_WARNING("transparency modes other than eTransparencyOpaque unsupported, can't draw.");
     return false;
   }
 
   AutoRestore<bool> painting(mPainting);
   mPainting = true;
-  UpdateForWindowSizeChange();
   gfxWindowsPlatform::GetPlatform()->UpdateRenderMode();
   mWidget->Paint(aInvalidRegion);
   return true;
 }
 
 } } }
--- a/widget/windows/winrt/MetroWidget.cpp
+++ b/widget/windows/winrt/MetroWidget.cpp
@@ -14,16 +14,18 @@
 #include "nsToolkitCompsCID.h"
 #include "nsIAppStartup.h"
 #include "../resource.h"
 #include "nsIWidgetListener.h"
 #include "nsPrintfCString.h"
 #include "nsWindowDefs.h"
 #include "FrameworkView.h"
 #include "nsTextStore.h"
+#include "Layers.h"
+#include "BasicLayers.h"
 
 using namespace Microsoft::WRL;
 using namespace Microsoft::WRL::Wrappers;
 
 using namespace mozilla;
 using namespace mozilla::widget;
 using namespace mozilla::layers;
 using namespace mozilla::widget::winrt;
@@ -124,16 +126,17 @@ namespace {
 }
 
 NS_IMPL_ISUPPORTS_INHERITED0(MetroWidget, nsBaseWidget)
 
 MetroWidget::MetroWidget() :
   mTransparencyMode(eTransparencyOpaque),
   mWnd(NULL),
   mMetroWndProc(NULL),
+  mTempBasicLayerInUse(false),
   nsWindowBase()
 {
   // Global initialization
   if (!gInstanceCount) {
     UserActivity();
     nsTextStore::Initialize();
   } // !gInstanceCount
   gInstanceCount++;
@@ -747,37 +750,108 @@ MetroWidget::RemoveSubclass()
       NS_ASSERTION(mMetroWndProc, "Should have old proc here.");
       SetWindowLongPtr(mWnd, GWLP_WNDPROC,
         reinterpret_cast<LONG_PTR>(mMetroWndProc));
       mMetroWndProc = NULL;
   }
   RemovePropW(mWnd, kMetroSubclassThisProp);
 }
 
+bool
+MetroWidget::ShouldUseOffMainThreadCompositing()
+{
+  // Either we're not initialized yet, or this is the toolkit widget
+  if (!mView) {
+    return false;
+  }
+  // toolkit or test widgets can't use omtc, they don't have ICoreWindow.
+  return (CompositorParent::CompositorLoop() && mWindowType == eWindowType_toplevel);
+}
+
+bool
+MetroWidget::ShouldUseMainThreadD3D10Manager()
+{
+  // Either we're not initialized yet, or this is the toolkit widget
+  if (!mView) {
+    return false;
+  }
+  return (!CompositorParent::CompositorLoop() && mWindowType == eWindowType_toplevel);
+}
+
+bool
+MetroWidget::ShouldUseBasicManager()
+{
+  // toolkit or test widgets fall back on empty shadow layers
+  return (mWindowType != eWindowType_toplevel);
+}
+
 LayerManager*
 MetroWidget::GetLayerManager(PLayersChild* aShadowManager,
                              LayersBackend aBackendHint,
                              LayerManagerPersistence aPersistence,
                              bool* aAllowRetaining)
 {
-  if (!mView) {
-    Log(L"Attempting to initialize layermanager for a window that has no view!");
-    return nsBaseWidget::GetLayerManager(aShadowManager, aBackendHint, aPersistence, aAllowRetaining);
+  bool retaining = true;
+
+  // If we initialized earlier than the view, recreate the layer manager now
+  if (mLayerManager &&
+      mTempBasicLayerInUse &&
+      ShouldUseOffMainThreadCompositing()) {
+    mLayerManager = nullptr;
+    mTempBasicLayerInUse = false;
+    retaining = false;
+  }
+
+  // If the backend device has changed, create a new manager (pulled from nswindow)
+  if (mLayerManager) {
+    if (mLayerManager->GetBackendType() == LAYERS_D3D10) {
+      LayerManagerD3D10 *layerManagerD3D10 =
+        static_cast<LayerManagerD3D10*>(mLayerManager.get());
+      if (layerManagerD3D10->device() !=
+          gfxWindowsPlatform::GetPlatform()->GetD3D10Device()) {
+        MOZ_ASSERT(!mLayerManager->IsInTransaction());
+
+        mLayerManager->Destroy();
+        mLayerManager = nullptr;
+        retaining = false;
+      }
+    }
+  }
+
+  // Create a layer manager: try to use an async compositor first, if enabled.
+  // Otherwise fall back on the main thread d3d manager.
+  if (!mLayerManager) {
+    if (ShouldUseOffMainThreadCompositing()) {
+      NS_ASSERTION(aShadowManager == nullptr, "Async Compositor not supported with e10s");
+      CreateCompositor();
+    } else if (ShouldUseMainThreadD3D10Manager()) {
+      nsRefPtr<mozilla::layers::LayerManagerD3D10> layerManager =
+        new mozilla::layers::LayerManagerD3D10(this);
+      if (layerManager->Initialize(true)) {
+        mLayerManager = layerManager;
+      }
+    } else if (ShouldUseBasicManager()) {
+      mLayerManager = CreateBasicLayerManager();
+    }
+
+    // Either we're not ready to initialize yet due to a missing view pointer,
+    // or something has gone wrong.
+    if (!mLayerManager) {
+      if (!mView) {
+        NS_WARNING("Using temporary basic layer manager.");
+        mLayerManager = new BasicShadowLayerManager(this);
+        mTempBasicLayerInUse = true;
+      } else {
+        NS_RUNTIMEABORT("Couldn't create layer manager");
+      }
+    }
   }
 
   if (aAllowRetaining) {
-    *aAllowRetaining = true;
-  }
-
-  if (!mLayerManager) {
-    nsRefPtr<mozilla::layers::LayerManagerD3D10> layerManager =
-      new mozilla::layers::LayerManagerD3D10(this);
-    if (layerManager->Initialize(true)) {
-      mLayerManager = layerManager;
-    }
+    *aAllowRetaining = retaining;
   }
 
   return mLayerManager;
 }
 
 NS_IMETHODIMP
 MetroWidget::Invalidate(bool aEraseBackground,
                         bool aUpdateNCArea,
--- a/widget/windows/winrt/MetroWidget.h
+++ b/widget/windows/winrt/MetroWidget.h
@@ -16,16 +16,17 @@
 #include "nsTArray.h"
 #include "nsWindowDbg.h"
 #include "WindowHook.h"
 #include "TaskbarWindowPreview.h"
 #include "nsIdleService.h"
 #ifdef ACCESSIBILITY
 #include "mozilla/a11y/Accessible.h"
 #endif
+#include "mozilla/layers/CompositorParent.h"
 
 #include "mozwrlbase.h"
 
 #include <windows.system.h>
 #include <windows.ui.core.h>
 #include <Windows.ApplicationModel.core.h>
 #include <Windows.ApplicationModel.h>
 #include <Windows.Applicationmodel.Activation.h>
@@ -107,16 +108,20 @@ public:
                                                     double aDeltaY,
                                                     double aDeltaZ,
                                                     uint32_t aModifierFlags,
                                                     uint32_t aAdditionalFlags);
   virtual bool  HasPendingInputEvent();
   float         GetDPI();
   virtual bool  IsVisible() const;
   virtual bool  IsEnabled() const;
+  // ShouldUseOffMainThreadCompositing is defined in base widget
+  virtual bool  ShouldUseOffMainThreadCompositing();
+  bool          ShouldUseMainThreadD3D10Manager();
+  bool          ShouldUseBasicManager();
   virtual LayerManager* GetLayerManager(PLayersChild* aShadowManager = nullptr,
                                         LayersBackend aBackendHint = mozilla::layers::LAYERS_NONE,
                                         LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT,
                                         bool* aAllowRetaining = nullptr);
 
   // IME related interfaces
   NS_IMETHOD_(void) SetInputContext(const InputContext& aContext,
                                     const InputContextAction& aAction);
@@ -192,9 +197,10 @@ protected:
   WindowHook mWindowHook;
   Microsoft::WRL::ComPtr<FrameworkView> mView;
   nsTransparencyMode mTransparencyMode;
   nsIntRegion mInvalidatedRegion;
   nsCOMPtr<nsIdleService> mIdleService;
   HWND mWnd;
   WNDPROC mMetroWndProc;
   nsIWidget::InputContext mInputContext;
+  bool mTempBasicLayerInUse;
 };
--- a/widget/xpwidgets/nsBaseWidget.cpp
+++ b/widget/xpwidgets/nsBaseWidget.cpp
@@ -896,34 +896,34 @@ void nsBaseWidget::CreateCompositor()
   } else {
     // We don't currently want to support not having a LayersChild
     NS_RUNTIMEABORT("failed to construct LayersChild");
     delete lm;
     mCompositorChild = nullptr;
   }
 }
 
-bool nsBaseWidget::UseOffMainThreadCompositing()
+bool nsBaseWidget::ShouldUseOffMainThreadCompositing()
 {
   bool isSmallPopup = ((mWindowType == eWindowType_popup) &&
                       (mPopupType != ePopupTypePanel));
   return CompositorParent::CompositorLoop() && !isSmallPopup;
 }
 
 LayerManager* nsBaseWidget::GetLayerManager(PLayersChild* aShadowManager,
                                             LayersBackend aBackendHint,
                                             LayerManagerPersistence aPersistence,
                                             bool* aAllowRetaining)
 {
   if (!mLayerManager) {
 
     mUseLayersAcceleration = ComputeShouldAccelerate(mUseLayersAcceleration);
 
     // Try to use an async compositor first, if possible
-    if (UseOffMainThreadCompositing()) {
+    if (ShouldUseOffMainThreadCompositing()) {
       // 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 == nullptr, "Async Compositor not supported with e10s");
       CreateCompositor();
     }
 
     if (mUseLayersAcceleration) {
       if (!mLayerManager) {
--- a/widget/xpwidgets/nsBaseWidget.h
+++ b/widget/xpwidgets/nsBaseWidget.h
@@ -229,17 +229,17 @@ public:
   private:
     nsBaseWidget* mWidget;
     bool mPreviousTemporarilyUseBasicLayerManager;
   };
   friend class AutoUseBasicLayerManager;
 
   nsWindowType            GetWindowType() { return mWindowType; }
 
-  virtual bool            UseOffMainThreadCompositing();
+  virtual bool            ShouldUseOffMainThreadCompositing();
 
   static nsIRollupListener* GetActiveRollupListener();
 
 protected:
 
   virtual void            ResolveIconName(const nsAString &aIconName,
                                           const nsAString &aIconSuffix,
                                           nsIFile **aResult);