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;
|
||||
}
|
||||
|
||||
mUseAcceleratedRendering = GetShouldAccelerate();
|
||||
mUseLayersAcceleration = ComputeShouldAccelerate(mUseLayersAcceleration);
|
||||
|
||||
bool useCompositor = UseOffMainThreadCompositing();
|
||||
|
||||
@ -703,7 +703,7 @@ nsWindow::GetLayerManager(PLayersChild*, LayersBackend, LayerManagerPersistence,
|
||||
sFailedToCreateGLContext = true;
|
||||
}
|
||||
|
||||
if (!mUseAcceleratedRendering ||
|
||||
if (!mUseLayersAcceleration ||
|
||||
sFailedToCreateGLContext)
|
||||
{
|
||||
printf_stderr(" -- creating basic, not accelerated\n");
|
||||
|
@ -413,7 +413,7 @@ public:
|
||||
{ return aStatus == nsEventStatus_eConsumeNoDefault; }
|
||||
NS_IMETHOD DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus);
|
||||
|
||||
virtual bool GetShouldAccelerate();
|
||||
virtual bool ComputeShouldAccelerate(bool aDefault);
|
||||
virtual bool UseOffMainThreadCompositing();
|
||||
|
||||
NS_IMETHOD SetCursor(nsCursor aCursor);
|
||||
|
@ -1312,14 +1312,14 @@ NS_IMETHODIMP nsChildView::Invalidate(const nsIntRect &aRect)
|
||||
}
|
||||
|
||||
bool
|
||||
nsChildView::GetShouldAccelerate()
|
||||
nsChildView::ComputeShouldAccelerate(bool aDefault)
|
||||
{
|
||||
// Don't use OpenGL for transparent windows or for popup windows.
|
||||
if (!mView || ![[mView window] isOpaque] ||
|
||||
[[mView window] isKindOfClass:[PopupWindow class]])
|
||||
return false;
|
||||
|
||||
return nsBaseWidget::GetShouldAccelerate();
|
||||
return nsBaseWidget::ComputeShouldAccelerate(aDefault);
|
||||
}
|
||||
|
||||
bool
|
||||
@ -1327,7 +1327,8 @@ nsChildView::UseOffMainThreadCompositing()
|
||||
{
|
||||
// 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() && GetShouldAccelerate();
|
||||
return nsBaseWidget::UseOffMainThreadCompositing() &&
|
||||
ComputeShouldAccelerate(mUseLayersAcceleration);
|
||||
}
|
||||
|
||||
inline uint16_t COLOR8TOCOLOR16(uint8_t color8)
|
||||
|
@ -576,9 +576,9 @@ nsWindow::GetLayerManager(PLayersChild* aShadowManager,
|
||||
return mLayerManager;
|
||||
}
|
||||
|
||||
// Set mUseAcceleratedRendering here to make it consistent with
|
||||
// Set mUseLayersAcceleration here to make it consistent with
|
||||
// nsBaseWidget::GetLayerManager
|
||||
mUseAcceleratedRendering = GetShouldAccelerate();
|
||||
mUseLayersAcceleration = ComputeShouldAccelerate(mUseLayersAcceleration);
|
||||
nsWindow *topWindow = sTopWindows[0];
|
||||
|
||||
if (!topWindow) {
|
||||
@ -592,7 +592,7 @@ nsWindow::GetLayerManager(PLayersChild* aShadowManager,
|
||||
return mLayerManager;
|
||||
}
|
||||
|
||||
if (mUseAcceleratedRendering) {
|
||||
if (mUseLayersAcceleration) {
|
||||
DebugOnly<nsIntRect> fbBounds = gScreenBounds;
|
||||
if (!sGLContext) {
|
||||
sGLContext = GLContextProvider::CreateForWindow(this);
|
||||
@ -623,7 +623,7 @@ nsWindow::GetLayerManager(PLayersChild* aShadowManager,
|
||||
}
|
||||
|
||||
mLayerManager = new BasicShadowLayerManager(this);
|
||||
mUseAcceleratedRendering = false;
|
||||
mUseLayersAcceleration = false;
|
||||
|
||||
return mLayerManager;
|
||||
}
|
||||
|
@ -1497,9 +1497,9 @@ class nsIWidget : public nsISupports {
|
||||
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.
|
||||
|
@ -2667,7 +2667,7 @@ nsWindow::createQWidget(MozQWidget *parent,
|
||||
}
|
||||
|
||||
#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
|
||||
if (!HasGLContext()) {
|
||||
MozQGraphicsView *qview = qobject_cast<MozQGraphicsView*>(newView);
|
||||
|
@ -3259,11 +3259,11 @@ nsWindow::GetLayerManager(PLayersChild* aShadowManager,
|
||||
prefs.mDisableAcceleration ||
|
||||
windowRect.right - windowRect.left > MAX_ACCELERATED_DIMENSION ||
|
||||
windowRect.bottom - windowRect.top > MAX_ACCELERATED_DIMENSION)
|
||||
mUseAcceleratedRendering = false;
|
||||
mUseLayersAcceleration = false;
|
||||
else if (prefs.mAccelerateByDefault)
|
||||
mUseAcceleratedRendering = true;
|
||||
mUseLayersAcceleration = true;
|
||||
|
||||
if (mUseAcceleratedRendering) {
|
||||
if (mUseLayersAcceleration) {
|
||||
if (aPersistence == LAYER_MANAGER_PERSISTENT && !sAllowD3D9) {
|
||||
MOZ_ASSERT(!mLayerManager || !mLayerManager->IsInTransaction());
|
||||
|
||||
|
@ -93,7 +93,7 @@ nsBaseWidget::nsBaseWidget()
|
||||
, mCursor(eCursor_standard)
|
||||
, mWindowType(eWindowType_child)
|
||||
, mBorderStyle(eBorderStyle_none)
|
||||
, mUseAcceleratedRendering(false)
|
||||
, mUseLayersAcceleration(false)
|
||||
, mForceLayersAcceleration(false)
|
||||
, mTemporarilyUseBasicLayerManager(false)
|
||||
, mUseAttachedEvents(false)
|
||||
@ -770,7 +770,7 @@ nsBaseWidget::AutoUseBasicLayerManager::~AutoUseBasicLayerManager()
|
||||
}
|
||||
|
||||
bool
|
||||
nsBaseWidget::GetShouldAccelerate()
|
||||
nsBaseWidget::ComputeShouldAccelerate(bool aDefault)
|
||||
{
|
||||
#if defined(XP_WIN) || defined(ANDROID) || (MOZ_PLATFORM_MAEMO > 5) || \
|
||||
defined(MOZ_GL_PROVIDER) || defined(XP_MACOSX)
|
||||
@ -835,7 +835,7 @@ nsBaseWidget::GetShouldAccelerate()
|
||||
return true;
|
||||
|
||||
/* use the window acceleration flag */
|
||||
return mUseAcceleratedRendering;
|
||||
return aDefault;
|
||||
}
|
||||
|
||||
void nsBaseWidget::CreateCompositor()
|
||||
@ -857,7 +857,7 @@ void nsBaseWidget::CreateCompositor()
|
||||
int32_t maxTextureSize;
|
||||
PLayersChild* shadowManager;
|
||||
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;
|
||||
shadowManager = mCompositorChild->SendPLayersConstructor(
|
||||
backendHint, 0, &parentBackend, &maxTextureSize);
|
||||
@ -896,7 +896,7 @@ LayerManager* nsBaseWidget::GetLayerManager(PLayersChild* aShadowManager,
|
||||
{
|
||||
if (!mLayerManager) {
|
||||
|
||||
mUseAcceleratedRendering = GetShouldAccelerate();
|
||||
mUseLayersAcceleration = ComputeShouldAccelerate(mUseLayersAcceleration);
|
||||
|
||||
// Try to use an async compositor first, if possible
|
||||
if (UseOffMainThreadCompositing()) {
|
||||
@ -906,7 +906,7 @@ LayerManager* nsBaseWidget::GetLayerManager(PLayersChild* aShadowManager,
|
||||
CreateCompositor();
|
||||
}
|
||||
|
||||
if (mUseAcceleratedRendering) {
|
||||
if (mUseLayersAcceleration) {
|
||||
if (!mLayerManager) {
|
||||
nsRefPtr<LayerManagerOGL> layerManager = new LayerManagerOGL(this);
|
||||
/**
|
||||
@ -1146,12 +1146,21 @@ nsBaseWidget::ShowsResizeIndicator(nsIntRect* aResizerRect)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseWidget::SetAcceleratedRendering(bool aEnabled)
|
||||
nsBaseWidget::SetLayersAcceleration(bool aEnabled)
|
||||
{
|
||||
if (mUseAcceleratedRendering == aEnabled) {
|
||||
if (mUseLayersAcceleration == aEnabled) {
|
||||
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) {
|
||||
mLayerManager->Destroy();
|
||||
}
|
||||
@ -1159,12 +1168,6 @@ nsBaseWidget::SetAcceleratedRendering(bool aEnabled)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
nsBaseWidget::GetAcceleratedRendering()
|
||||
{
|
||||
return mUseAcceleratedRendering;
|
||||
}
|
||||
|
||||
NS_METHOD nsBaseWidget::RegisterTouchWindow()
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
@ -139,9 +139,9 @@ public:
|
||||
virtual nsresult ForceUpdateNativeMenuAt(const nsAString& indexString) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD ResetInputState() { return NS_OK; }
|
||||
NS_IMETHOD CancelIMEComposition() { return NS_OK; }
|
||||
NS_IMETHOD SetAcceleratedRendering(bool aEnabled);
|
||||
virtual bool GetAcceleratedRendering();
|
||||
virtual bool GetShouldAccelerate();
|
||||
NS_IMETHOD SetLayersAcceleration(bool aEnabled);
|
||||
virtual bool GetLayersAcceleration() { return mUseLayersAcceleration; }
|
||||
virtual bool ComputeShouldAccelerate(bool aDefault);
|
||||
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 OnIMETextChange(uint32_t aStart, uint32_t aOldEnd, uint32_t aNewEnd) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
@ -338,7 +338,7 @@ protected:
|
||||
nsCursor mCursor;
|
||||
nsWindowType mWindowType;
|
||||
nsBorderStyle mBorderStyle;
|
||||
bool mUseAcceleratedRendering;
|
||||
bool mUseLayersAcceleration;
|
||||
bool mForceLayersAcceleration;
|
||||
bool mTemporarilyUseBasicLayerManager;
|
||||
bool mUseAttachedEvents;
|
||||
|
@ -1395,7 +1395,7 @@ void nsXULWindow::SyncAttributesToWidget()
|
||||
bool isAccelerated;
|
||||
rv = windowElement->HasAttribute(NS_LITERAL_STRING("accelerated"), &isAccelerated);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mWindow->SetAcceleratedRendering(isAccelerated);
|
||||
mWindow->SetLayersAcceleration(isAccelerated);
|
||||
}
|
||||
|
||||
// "windowtype" attribute
|
||||
|
Loading…
Reference in New Issue
Block a user