mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 806428 - Fix crash in omtc-linux caused by nsBaseWidget::SetLayersAcceleration, and rename xxxAcceleratedRendering into xxxLayersAcceleration for concistency. r=BenWa
This commit is contained in:
parent
554226fcdd
commit
51dd83878a
@ -688,7 +688,7 @@ nsWindow::GetLayerManager(PLayersChild*, LayersBackend, LayerManagerPersistence,
|
|||||||
return mLayerManager;
|
return mLayerManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
mUseAcceleratedRendering = GetShouldAccelerate();
|
mUseLayersAcceleration = ComputeShouldAccelerate(mUseLayersAcceleration);
|
||||||
|
|
||||||
bool useCompositor = UseOffMainThreadCompositing();
|
bool useCompositor = UseOffMainThreadCompositing();
|
||||||
|
|
||||||
@ -703,7 +703,7 @@ nsWindow::GetLayerManager(PLayersChild*, LayersBackend, LayerManagerPersistence,
|
|||||||
sFailedToCreateGLContext = true;
|
sFailedToCreateGLContext = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mUseAcceleratedRendering ||
|
if (!mUseLayersAcceleration ||
|
||||||
sFailedToCreateGLContext)
|
sFailedToCreateGLContext)
|
||||||
{
|
{
|
||||||
printf_stderr(" -- creating basic, not accelerated\n");
|
printf_stderr(" -- creating basic, not accelerated\n");
|
||||||
|
@ -413,7 +413,7 @@ public:
|
|||||||
{ return aStatus == nsEventStatus_eConsumeNoDefault; }
|
{ return aStatus == nsEventStatus_eConsumeNoDefault; }
|
||||||
NS_IMETHOD DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus);
|
NS_IMETHOD DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus);
|
||||||
|
|
||||||
virtual bool GetShouldAccelerate();
|
virtual bool ComputeShouldAccelerate(bool aDefault);
|
||||||
virtual bool UseOffMainThreadCompositing();
|
virtual bool UseOffMainThreadCompositing();
|
||||||
|
|
||||||
NS_IMETHOD SetCursor(nsCursor aCursor);
|
NS_IMETHOD SetCursor(nsCursor aCursor);
|
||||||
|
@ -1312,14 +1312,14 @@ NS_IMETHODIMP nsChildView::Invalidate(const nsIntRect &aRect)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
nsChildView::GetShouldAccelerate()
|
nsChildView::ComputeShouldAccelerate(bool aDefault)
|
||||||
{
|
{
|
||||||
// Don't use OpenGL for transparent windows or for popup windows.
|
// Don't use OpenGL for transparent windows or for popup windows.
|
||||||
if (!mView || ![[mView window] isOpaque] ||
|
if (!mView || ![[mView window] isOpaque] ||
|
||||||
[[mView window] isKindOfClass:[PopupWindow class]])
|
[[mView window] isKindOfClass:[PopupWindow class]])
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return nsBaseWidget::GetShouldAccelerate();
|
return nsBaseWidget::ComputeShouldAccelerate(aDefault);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@ -1327,7 +1327,8 @@ nsChildView::UseOffMainThreadCompositing()
|
|||||||
{
|
{
|
||||||
// OMTC doesn't work with Basic Layers on OS X right now. Once it works, we'll
|
// 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).
|
// still want to disable it for certain kinds of windows (e.g. popups).
|
||||||
return nsBaseWidget::UseOffMainThreadCompositing() && GetShouldAccelerate();
|
return nsBaseWidget::UseOffMainThreadCompositing() &&
|
||||||
|
ComputeShouldAccelerate(mUseLayersAcceleration);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline uint16_t COLOR8TOCOLOR16(uint8_t color8)
|
inline uint16_t COLOR8TOCOLOR16(uint8_t color8)
|
||||||
|
@ -576,9 +576,9 @@ nsWindow::GetLayerManager(PLayersChild* aShadowManager,
|
|||||||
return mLayerManager;
|
return mLayerManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set mUseAcceleratedRendering here to make it consistent with
|
// Set mUseLayersAcceleration here to make it consistent with
|
||||||
// nsBaseWidget::GetLayerManager
|
// nsBaseWidget::GetLayerManager
|
||||||
mUseAcceleratedRendering = GetShouldAccelerate();
|
mUseLayersAcceleration = ComputeShouldAccelerate(mUseLayersAcceleration);
|
||||||
nsWindow *topWindow = sTopWindows[0];
|
nsWindow *topWindow = sTopWindows[0];
|
||||||
|
|
||||||
if (!topWindow) {
|
if (!topWindow) {
|
||||||
@ -592,7 +592,7 @@ nsWindow::GetLayerManager(PLayersChild* aShadowManager,
|
|||||||
return mLayerManager;
|
return mLayerManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mUseAcceleratedRendering) {
|
if (mUseLayersAcceleration) {
|
||||||
DebugOnly<nsIntRect> fbBounds = gScreenBounds;
|
DebugOnly<nsIntRect> fbBounds = gScreenBounds;
|
||||||
if (!sGLContext) {
|
if (!sGLContext) {
|
||||||
sGLContext = GLContextProvider::CreateForWindow(this);
|
sGLContext = GLContextProvider::CreateForWindow(this);
|
||||||
@ -623,7 +623,7 @@ nsWindow::GetLayerManager(PLayersChild* aShadowManager,
|
|||||||
}
|
}
|
||||||
|
|
||||||
mLayerManager = new BasicShadowLayerManager(this);
|
mLayerManager = new BasicShadowLayerManager(this);
|
||||||
mUseAcceleratedRendering = false;
|
mUseLayersAcceleration = false;
|
||||||
|
|
||||||
return mLayerManager;
|
return mLayerManager;
|
||||||
}
|
}
|
||||||
|
@ -1497,9 +1497,9 @@ class nsIWidget : public nsISupports {
|
|||||||
NS_IMETHOD_(InputContext) GetInputContext() = 0;
|
NS_IMETHOD_(InputContext) GetInputContext() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set accelerated rendering to 'True' or 'False'
|
* Set layers acceleration to 'True' or 'False'
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD SetAcceleratedRendering(bool aEnabled) = 0;
|
NS_IMETHOD SetLayersAcceleration(bool aEnabled) = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get toggled key states.
|
* Get toggled key states.
|
||||||
|
@ -2667,7 +2667,7 @@ nsWindow::createQWidget(MozQWidget *parent,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(MOZ_PLATFORM_MAEMO) || defined(MOZ_GL_PROVIDER)
|
#if defined(MOZ_PLATFORM_MAEMO) || defined(MOZ_GL_PROVIDER)
|
||||||
if (GetShouldAccelerate()) {
|
if (ComputeShouldAccelerate(mUseLayersAcceleration)) {
|
||||||
// Only create new OGL widget if it is not yet installed
|
// Only create new OGL widget if it is not yet installed
|
||||||
if (!HasGLContext()) {
|
if (!HasGLContext()) {
|
||||||
MozQGraphicsView *qview = qobject_cast<MozQGraphicsView*>(newView);
|
MozQGraphicsView *qview = qobject_cast<MozQGraphicsView*>(newView);
|
||||||
|
@ -3259,11 +3259,11 @@ nsWindow::GetLayerManager(PLayersChild* aShadowManager,
|
|||||||
prefs.mDisableAcceleration ||
|
prefs.mDisableAcceleration ||
|
||||||
windowRect.right - windowRect.left > MAX_ACCELERATED_DIMENSION ||
|
windowRect.right - windowRect.left > MAX_ACCELERATED_DIMENSION ||
|
||||||
windowRect.bottom - windowRect.top > MAX_ACCELERATED_DIMENSION)
|
windowRect.bottom - windowRect.top > MAX_ACCELERATED_DIMENSION)
|
||||||
mUseAcceleratedRendering = false;
|
mUseLayersAcceleration = false;
|
||||||
else if (prefs.mAccelerateByDefault)
|
else if (prefs.mAccelerateByDefault)
|
||||||
mUseAcceleratedRendering = true;
|
mUseLayersAcceleration = true;
|
||||||
|
|
||||||
if (mUseAcceleratedRendering) {
|
if (mUseLayersAcceleration) {
|
||||||
if (aPersistence == LAYER_MANAGER_PERSISTENT && !sAllowD3D9) {
|
if (aPersistence == LAYER_MANAGER_PERSISTENT && !sAllowD3D9) {
|
||||||
MOZ_ASSERT(!mLayerManager || !mLayerManager->IsInTransaction());
|
MOZ_ASSERT(!mLayerManager || !mLayerManager->IsInTransaction());
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ nsBaseWidget::nsBaseWidget()
|
|||||||
, mCursor(eCursor_standard)
|
, mCursor(eCursor_standard)
|
||||||
, mWindowType(eWindowType_child)
|
, mWindowType(eWindowType_child)
|
||||||
, mBorderStyle(eBorderStyle_none)
|
, mBorderStyle(eBorderStyle_none)
|
||||||
, mUseAcceleratedRendering(false)
|
, mUseLayersAcceleration(false)
|
||||||
, mForceLayersAcceleration(false)
|
, mForceLayersAcceleration(false)
|
||||||
, mTemporarilyUseBasicLayerManager(false)
|
, mTemporarilyUseBasicLayerManager(false)
|
||||||
, mUseAttachedEvents(false)
|
, mUseAttachedEvents(false)
|
||||||
@ -770,7 +770,7 @@ nsBaseWidget::AutoUseBasicLayerManager::~AutoUseBasicLayerManager()
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
nsBaseWidget::GetShouldAccelerate()
|
nsBaseWidget::ComputeShouldAccelerate(bool aDefault)
|
||||||
{
|
{
|
||||||
#if defined(XP_WIN) || defined(ANDROID) || (MOZ_PLATFORM_MAEMO > 5) || \
|
#if defined(XP_WIN) || defined(ANDROID) || (MOZ_PLATFORM_MAEMO > 5) || \
|
||||||
defined(MOZ_GL_PROVIDER) || defined(XP_MACOSX)
|
defined(MOZ_GL_PROVIDER) || defined(XP_MACOSX)
|
||||||
@ -835,7 +835,7 @@ nsBaseWidget::GetShouldAccelerate()
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
/* use the window acceleration flag */
|
/* use the window acceleration flag */
|
||||||
return mUseAcceleratedRendering;
|
return aDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsBaseWidget::CreateCompositor()
|
void nsBaseWidget::CreateCompositor()
|
||||||
@ -857,7 +857,7 @@ void nsBaseWidget::CreateCompositor()
|
|||||||
int32_t maxTextureSize;
|
int32_t maxTextureSize;
|
||||||
PLayersChild* shadowManager;
|
PLayersChild* shadowManager;
|
||||||
mozilla::layers::LayersBackend backendHint =
|
mozilla::layers::LayersBackend backendHint =
|
||||||
mUseAcceleratedRendering ? mozilla::layers::LAYERS_OPENGL : mozilla::layers::LAYERS_BASIC;
|
mUseLayersAcceleration ? mozilla::layers::LAYERS_OPENGL : mozilla::layers::LAYERS_BASIC;
|
||||||
mozilla::layers::LayersBackend parentBackend;
|
mozilla::layers::LayersBackend parentBackend;
|
||||||
shadowManager = mCompositorChild->SendPLayersConstructor(
|
shadowManager = mCompositorChild->SendPLayersConstructor(
|
||||||
backendHint, 0, &parentBackend, &maxTextureSize);
|
backendHint, 0, &parentBackend, &maxTextureSize);
|
||||||
@ -896,7 +896,7 @@ LayerManager* nsBaseWidget::GetLayerManager(PLayersChild* aShadowManager,
|
|||||||
{
|
{
|
||||||
if (!mLayerManager) {
|
if (!mLayerManager) {
|
||||||
|
|
||||||
mUseAcceleratedRendering = GetShouldAccelerate();
|
mUseLayersAcceleration = ComputeShouldAccelerate(mUseLayersAcceleration);
|
||||||
|
|
||||||
// Try to use an async compositor first, if possible
|
// Try to use an async compositor first, if possible
|
||||||
if (UseOffMainThreadCompositing()) {
|
if (UseOffMainThreadCompositing()) {
|
||||||
@ -906,7 +906,7 @@ LayerManager* nsBaseWidget::GetLayerManager(PLayersChild* aShadowManager,
|
|||||||
CreateCompositor();
|
CreateCompositor();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mUseAcceleratedRendering) {
|
if (mUseLayersAcceleration) {
|
||||||
if (!mLayerManager) {
|
if (!mLayerManager) {
|
||||||
nsRefPtr<LayerManagerOGL> layerManager = new LayerManagerOGL(this);
|
nsRefPtr<LayerManagerOGL> layerManager = new LayerManagerOGL(this);
|
||||||
/**
|
/**
|
||||||
@ -1146,12 +1146,21 @@ nsBaseWidget::ShowsResizeIndicator(nsIntRect* aResizerRect)
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsBaseWidget::SetAcceleratedRendering(bool aEnabled)
|
nsBaseWidget::SetLayersAcceleration(bool aEnabled)
|
||||||
{
|
{
|
||||||
if (mUseAcceleratedRendering == aEnabled) {
|
if (mUseLayersAcceleration == aEnabled) {
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
mUseAcceleratedRendering = aEnabled;
|
|
||||||
|
bool usedAcceleration = mUseLayersAcceleration;
|
||||||
|
|
||||||
|
mUseLayersAcceleration = ComputeShouldAccelerate(aEnabled);
|
||||||
|
// ComputeShouldAccelerate may have set mUseLayersAcceleration to a value
|
||||||
|
// different from aEnabled.
|
||||||
|
if (usedAcceleration == mUseLayersAcceleration) {
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
if (mLayerManager) {
|
if (mLayerManager) {
|
||||||
mLayerManager->Destroy();
|
mLayerManager->Destroy();
|
||||||
}
|
}
|
||||||
@ -1159,12 +1168,6 @@ nsBaseWidget::SetAcceleratedRendering(bool aEnabled)
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
nsBaseWidget::GetAcceleratedRendering()
|
|
||||||
{
|
|
||||||
return mUseAcceleratedRendering;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_METHOD nsBaseWidget::RegisterTouchWindow()
|
NS_METHOD nsBaseWidget::RegisterTouchWindow()
|
||||||
{
|
{
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
return NS_ERROR_NOT_IMPLEMENTED;
|
||||||
|
@ -139,9 +139,9 @@ public:
|
|||||||
virtual nsresult ForceUpdateNativeMenuAt(const nsAString& indexString) { return NS_ERROR_NOT_IMPLEMENTED; }
|
virtual nsresult ForceUpdateNativeMenuAt(const nsAString& indexString) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||||
NS_IMETHOD ResetInputState() { return NS_OK; }
|
NS_IMETHOD ResetInputState() { return NS_OK; }
|
||||||
NS_IMETHOD CancelIMEComposition() { return NS_OK; }
|
NS_IMETHOD CancelIMEComposition() { return NS_OK; }
|
||||||
NS_IMETHOD SetAcceleratedRendering(bool aEnabled);
|
NS_IMETHOD SetLayersAcceleration(bool aEnabled);
|
||||||
virtual bool GetAcceleratedRendering();
|
virtual bool GetLayersAcceleration() { return mUseLayersAcceleration; }
|
||||||
virtual bool GetShouldAccelerate();
|
virtual bool ComputeShouldAccelerate(bool aDefault);
|
||||||
NS_IMETHOD GetToggledKeyState(uint32_t aKeyCode, bool* aLEDState) { return NS_ERROR_NOT_IMPLEMENTED; }
|
NS_IMETHOD GetToggledKeyState(uint32_t aKeyCode, bool* aLEDState) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||||
NS_IMETHOD OnIMEFocusChange(bool aFocus) { return NS_ERROR_NOT_IMPLEMENTED; }
|
NS_IMETHOD OnIMEFocusChange(bool aFocus) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||||
NS_IMETHOD OnIMETextChange(uint32_t aStart, uint32_t aOldEnd, uint32_t aNewEnd) { return NS_ERROR_NOT_IMPLEMENTED; }
|
NS_IMETHOD OnIMETextChange(uint32_t aStart, uint32_t aOldEnd, uint32_t aNewEnd) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||||
@ -338,7 +338,7 @@ protected:
|
|||||||
nsCursor mCursor;
|
nsCursor mCursor;
|
||||||
nsWindowType mWindowType;
|
nsWindowType mWindowType;
|
||||||
nsBorderStyle mBorderStyle;
|
nsBorderStyle mBorderStyle;
|
||||||
bool mUseAcceleratedRendering;
|
bool mUseLayersAcceleration;
|
||||||
bool mForceLayersAcceleration;
|
bool mForceLayersAcceleration;
|
||||||
bool mTemporarilyUseBasicLayerManager;
|
bool mTemporarilyUseBasicLayerManager;
|
||||||
bool mUseAttachedEvents;
|
bool mUseAttachedEvents;
|
||||||
|
@ -1395,7 +1395,7 @@ void nsXULWindow::SyncAttributesToWidget()
|
|||||||
bool isAccelerated;
|
bool isAccelerated;
|
||||||
rv = windowElement->HasAttribute(NS_LITERAL_STRING("accelerated"), &isAccelerated);
|
rv = windowElement->HasAttribute(NS_LITERAL_STRING("accelerated"), &isAccelerated);
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
mWindow->SetAcceleratedRendering(isAccelerated);
|
mWindow->SetLayersAcceleration(isAccelerated);
|
||||||
}
|
}
|
||||||
|
|
||||||
// "windowtype" attribute
|
// "windowtype" attribute
|
||||||
|
Loading…
Reference in New Issue
Block a user