Bug 1097699 - Part 1: Remove usage of LayerManagerD3D9. r=jrmuizel

This commit is contained in:
Bas Schouten 2015-01-23 03:41:20 +00:00
parent c9e32517d0
commit 07f200ca26
6 changed files with 2 additions and 142 deletions

View File

@ -101,7 +101,7 @@ LOCAL_INCLUDES += [
DEFINES['MOZ_UNICODE'] = True
for var in ('MOZ_ENABLE_D3D9_LAYER', 'MOZ_ENABLE_D3D10_LAYER'):
for var in ('MOZ_ENABLE_D3D10_LAYER'):
if CONFIG[var]:
DEFINES[var] = True

View File

@ -23,16 +23,6 @@ using namespace mozilla::widget;
nsToolkit* nsToolkit::gToolkit = nullptr;
HINSTANCE nsToolkit::mDllInstance = 0;
static const unsigned long kD3DUsageDelay = 5000;
static void
StartAllowingD3D9(nsITimer *aTimer, void *aClosure)
{
if (XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Desktop) {
nsWindow::StartAllowingD3D9(true);
}
}
MouseTrailer* nsToolkit::gMouseTrailer;
//-------------------------------------------------------------------------
@ -49,14 +39,6 @@ nsToolkit::nsToolkit()
#endif
gMouseTrailer = &mMouseTrailer;
if (XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Desktop) {
mD3D9Timer = do_CreateInstance("@mozilla.org/timer;1");
mD3D9Timer->InitWithFuncCallback(::StartAllowingD3D9,
nullptr,
kD3DUsageDelay,
nsITimer::TYPE_ONE_SHOT);
}
}
@ -86,15 +68,6 @@ nsToolkit::Shutdown()
gToolkit = nullptr;
}
void
nsToolkit::StartAllowingD3D9()
{
if (XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Desktop) {
nsToolkit::GetToolkit()->mD3D9Timer->Cancel();
nsWindow::StartAllowingD3D9(false);
}
}
//-------------------------------------------------------------------------
//
// Return the nsToolkit for the current thread. If a toolkit does not

View File

@ -77,12 +77,10 @@ public:
static void Startup(HMODULE hModule);
static void Shutdown();
static void StartAllowingD3D9();
protected:
static nsToolkit* gToolkit;
nsCOMPtr<nsITimer> mD3D9Timer;
MouseTrailer mMouseTrailer;
};

View File

@ -133,10 +133,6 @@
#include "mozilla/WindowsVersion.h"
#include "nsThemeConstants.h"
#ifdef MOZ_ENABLE_D3D9_LAYER
#include "LayerManagerD3D9.h"
#endif
#ifdef MOZ_ENABLE_D3D10_LAYER
#include "LayerManagerD3D10.h"
#endif
@ -256,9 +252,6 @@ int nsWindow::sTrimOnMinimize = 2;
// Default value for general window class (used when the pref is the empty string).
const char* nsWindow::sDefaultMainWindowClass = kClassNameGeneral;
// If we're using D3D9, this will not be allowed during initial 5 seconds.
bool nsWindow::sAllowD3D9 = false;
TriStateBool nsWindow::sHasBogusPopupsDropShadowOnMultiMonitor = TRI_UNKNOWN;
// Used in OOPP plugin focus processing.
@ -3349,10 +3342,7 @@ nsWindow::GetLayerManager(PLayerTransactionChild* aShadowManager,
CreateCompositor();
}
if (!mLayerManager ||
(!sAllowD3D9 && aPersistence == LAYER_MANAGER_PERSISTENT &&
mLayerManager->GetBackendType() == LayersBackend::LAYERS_BASIC &&
!ShouldUseOffMainThreadCompositing())) {
if (!mLayerManager) {
// If D3D9 is not currently allowed but the permanent manager is required,
// -and- we're currently using basic layers, run through this check.
LayerManagerPrefs prefs;
@ -3370,14 +3360,6 @@ nsWindow::GetLayerManager(PLayerTransactionChild* aShadowManager,
mUseLayersAcceleration = true;
if (mUseLayersAcceleration) {
if (aPersistence == LAYER_MANAGER_PERSISTENT && !sAllowD3D9) {
MOZ_ASSERT(!mLayerManager || !mLayerManager->IsInTransaction());
// This will clear out our existing layer manager if we have one since
// if we hit this with a LayerManager we're always using BasicLayers.
nsToolkit::StartAllowingD3D9();
}
#ifdef MOZ_ENABLE_D3D10_LAYER
if (!prefs.mPreferD3D9 && !prefs.mPreferOpenGL) {
nsRefPtr<LayerManagerD3D10> layerManager =
@ -3386,15 +3368,6 @@ nsWindow::GetLayerManager(PLayerTransactionChild* aShadowManager,
mLayerManager = layerManager;
}
}
#endif
#ifdef MOZ_ENABLE_D3D9_LAYER
if (!prefs.mPreferOpenGL && !mLayerManager && sAllowD3D9) {
nsRefPtr<LayerManagerD3D9> layerManager =
new LayerManagerD3D9(this);
if (layerManager->Initialize(prefs.mForceAcceleration)) {
mLayerManager = layerManager;
}
}
#endif
}
@ -6672,56 +6645,6 @@ bool nsWindow::AutoErase(HDC dc)
return false;
}
void
nsWindow::AllowD3D9Callback(nsWindow *aWindow)
{
if (aWindow->mLayerManager && !aWindow->ShouldUseOffMainThreadCompositing()) {
aWindow->mLayerManager->Destroy();
aWindow->mLayerManager = nullptr;
}
}
void
nsWindow::AllowD3D9WithReinitializeCallback(nsWindow *aWindow)
{
if (aWindow->mLayerManager && !aWindow->ShouldUseOffMainThreadCompositing()) {
aWindow->mLayerManager->Destroy();
aWindow->mLayerManager = nullptr;
(void) aWindow->GetLayerManager();
}
}
void
nsWindow::StartAllowingD3D9(bool aReinitialize)
{
sAllowD3D9 = true;
LayerManagerPrefs prefs;
GetLayerManagerPrefs(&prefs);
if (prefs.mDisableAcceleration) {
// The guarantee here is, if there's *any* chance that after we
// throw out our layer managers we'd create at least one new,
// accelerated one, we *will* throw out all the current layer
// managers. We early-return here because currently, if
// |disableAcceleration|, we will always use basic managers and
// it's a waste to recreate them. If we're using OMTC we don't want to
// recreate out layer manager and its compositor either. This is even
// more wasteful.
//
// NB: the above implies that it's eminently possible for us to
// skip this early return but still recreate basic managers.
// That's OK. It's *not* OK to take this early return when we
// *might* have created an accelerated manager.
return;
}
if (aReinitialize) {
EnumAllWindows(AllowD3D9WithReinitializeCallback);
} else {
EnumAllWindows(AllowD3D9Callback);
}
}
bool
nsWindow::ShouldUseOffMainThreadCompositing()
{

View File

@ -238,16 +238,6 @@ public:
*/
virtual bool AutoErase(HDC dc);
/**
* Start allowing Direct3D9 to be used by widgets when GetLayerManager is
* called.
*
* @param aReinitialize Call GetLayerManager on widgets to ensure D3D9 is
* initialized, this is usually called when this function
* is triggered by timeout and not user/web interaction.
*/
static void StartAllowingD3D9(bool aReinitialize);
/**
* AssociateDefaultIMC() associates or disassociates the default IMC for
* the window.
@ -314,8 +304,6 @@ protected:
static BOOL CALLBACK ClearResourcesCallback(HWND aChild, LPARAM aParam);
static BOOL CALLBACK EnumAllChildWindProc(HWND aWnd, LPARAM aParam);
static BOOL CALLBACK EnumAllThreadWindowProc(HWND aWnd, LPARAM aParam);
static void AllowD3D9Callback(nsWindow *aWindow);
static void AllowD3D9WithReinitializeCallback(nsWindow *aWindow);
/**
* Window utilities
@ -498,7 +486,6 @@ protected:
static bool sIsInMouseCapture;
static int sTrimOnMinimize;
static const char* sDefaultMainWindowClass;
static bool sAllowD3D9;
// Always use the helper method to read this property. See bug 603793.
static TriStateBool sHasBogusPopupsDropShadowOnMultiMonitor;

View File

@ -44,9 +44,6 @@ using mozilla::plugins::PluginInstanceParent;
#include "nsDebug.h"
#include "nsIXULRuntime.h"
#ifdef MOZ_ENABLE_D3D9_LAYER
#include "LayerManagerD3D9.h"
#endif
#ifdef MOZ_ENABLE_D3D10_LAYER
#include "LayerManagerD3D10.h"
#endif
@ -521,24 +518,6 @@ bool nsWindow::OnPaint(HDC aDC, uint32_t aNestingLevel)
}
}
break;
#ifdef MOZ_ENABLE_D3D9_LAYER
case LayersBackend::LAYERS_D3D9:
{
nsRefPtr<LayerManagerD3D9> layerManagerD3D9 =
static_cast<mozilla::layers::LayerManagerD3D9*>(GetLayerManager());
layerManagerD3D9->SetClippingRegion(region);
result = listener->PaintWindow(this, region);
if (layerManagerD3D9->DeviceWasRemoved()) {
mLayerManager->Destroy();
mLayerManager = nullptr;
// When our device was removed, we should have gfxWindowsPlatform
// check if its render mode is up to date!
gfxWindowsPlatform::GetPlatform()->UpdateRenderMode();
Invalidate();
}
}
break;
#endif
#ifdef MOZ_ENABLE_D3D10_LAYER
case LayersBackend::LAYERS_D3D10:
{