From cf74a0c719cf50103a1f89c1e1bf4df6673098c6 Mon Sep 17 00:00:00 2001 From: Ryan VanderMeulen Date: Wed, 5 Aug 2015 10:24:55 -0400 Subject: [PATCH] Backed out changeset 6ee70eb03b02 (bug 1183788) for Android crashes. --- gfx/gl/AndroidSurfaceTexture.cpp | 20 +++++++++++++++++++- gfx/gl/AndroidSurfaceTexture.h | 4 +++- gfx/thebes/gfxPlatform.cpp | 13 ------------- gfx/thebes/gfxPlatform.h | 23 +++++++---------------- 4 files changed, 29 insertions(+), 31 deletions(-) diff --git a/gfx/gl/AndroidSurfaceTexture.cpp b/gfx/gl/AndroidSurfaceTexture.cpp index 74b659262938..c02ec4fb0ff8 100644 --- a/gfx/gl/AndroidSurfaceTexture.cpp +++ b/gfx/gl/AndroidSurfaceTexture.cpp @@ -18,7 +18,6 @@ #include "SurfaceTexture.h" #include "GLContext.h" #include "mozilla/Preferences.h" -#include "gfxPlatform.h" using namespace mozilla; using namespace mozilla::jni; @@ -100,6 +99,8 @@ AndroidSurfaceTexture::Attach(GLContext* aContext, PRIntervalTime aTimeout) mAttachedContext->MakeCurrent(); aContext->fGenTextures(1, &mTexture); + UpdateCanDetach(); + return mSurfaceTexture->AttachToGLContext(mTexture); } @@ -125,9 +126,25 @@ AndroidSurfaceTexture::Detach() return NS_OK; } +void +AndroidSurfaceTexture::UpdateCanDetach() +{ + // The API for attach/detach only exists on 16+, and PowerVR has some sort of + // fencing issue. Additionally, attach/detach seems to be busted on at least some + // Mali adapters (400MP2 for sure, bug 1131793) + bool canDetach = Preferences::GetBool("gfx.SurfaceTexture.detach.enabled", true); + + mCanDetach = AndroidBridge::Bridge()->GetAPIVersion() >= 16 && + (!mAttachedContext || mAttachedContext->Vendor() != GLVendor::Imagination) && + (!mAttachedContext || mAttachedContext->Vendor() != GLVendor::ARM /* Mali */) && + canDetach; +} + bool AndroidSurfaceTexture::Init(GLContext* aContext, GLuint aTexture) { + UpdateCanDetach(); + if (!aTexture && !CanDetach()) { // We have no texture and cannot initialize detached, bail out return false; @@ -165,6 +182,7 @@ AndroidSurfaceTexture::AndroidSurfaceTexture() , mSurface() , mMonitor("AndroidSurfaceTexture::mContextMonitor") , mAttachedContext(nullptr) + , mCanDetach(false) { } diff --git a/gfx/gl/AndroidSurfaceTexture.h b/gfx/gl/AndroidSurfaceTexture.h index 2dc7a7aba3c2..3099a6e259fe 100644 --- a/gfx/gl/AndroidSurfaceTexture.h +++ b/gfx/gl/AndroidSurfaceTexture.h @@ -63,7 +63,7 @@ public: // Ability to detach is based on API version (16+), and we also block PowerVR since it has some type // of fencing problem. Bug 1100126. - bool CanDetach() { return gfxPlatform::GetPlatform()->CanDetachSurfaceTexture(); } + bool CanDetach() { return mCanDetach; } GLContext* GetAttachedContext() { return mAttachedContext; } @@ -95,6 +95,7 @@ private: ~AndroidSurfaceTexture(); bool Init(GLContext* aContext, GLuint aTexture); + void UpdateCanDetach(); GLuint mTexture; widget::sdk::SurfaceTexture::GlobalRef mSurfaceTexture; @@ -102,6 +103,7 @@ private: Monitor mMonitor; GLContext* mAttachedContext; + bool mCanDetach; RefPtr mNativeWindow; int mID; diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index a50a3c5369bd..f746df0d83af 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -83,7 +83,6 @@ #ifdef MOZ_WIDGET_ANDROID #include "TexturePoolOGL.h" -#include "AndroidBridge.h" #endif #ifdef MOZ_WIDGET_GONK @@ -580,18 +579,6 @@ gfxPlatform::Init() if (XRE_IsParentProcess() && gfxPrefs::HardwareVsyncEnabled()) { gPlatform->mVsyncSource = gPlatform->CreateHardwareVsyncSource(); } - - // The API for attach/detach only exists on 16+, and PowerVR has some sort of - // fencing issue. Additionally, attach/detach seems to be busted on at least some - // Mali adapters (400MP2 for sure, bug 1131793) -#ifdef MOZ_WIDGET_ANDROID - nsString vendorID; - gfxInfo->GetAdapterVendorID(vendorID); - gPlatform->mCanDetachSurfaceTexture = AndroidBridge::Bridge()->GetAPIVersion() >= 16 && - !vendorID.EqualsLiteral("Imagination") && - !vendorID.EqualsLiteral("ARM") && - Preferences::GetBool("gfx.SurfaceTexture.detach.enabled", true); -#endif } static bool sLayersIPCIsUp = false; diff --git a/gfx/thebes/gfxPlatform.h b/gfx/thebes/gfxPlatform.h index 905878191363..7f835a516a5b 100644 --- a/gfx/thebes/gfxPlatform.h +++ b/gfx/thebes/gfxPlatform.h @@ -41,7 +41,6 @@ class SRGBOverrideObserver; namespace mozilla { namespace gl { class SkiaGLGlue; -class GLContext; } // namespace gl namespace gfx { class DrawTarget; @@ -229,7 +228,7 @@ public: CreateOffscreenCanvasDrawTarget(const mozilla::gfx::IntSize& aSize, mozilla::gfx::SurfaceFormat aFormat); virtual already_AddRefed - CreateDrawTargetForData(unsigned char* aData, const mozilla::gfx::IntSize& aSize, + CreateDrawTargetForData(unsigned char* aData, const mozilla::gfx::IntSize& aSize, int32_t aStride, mozilla::gfx::SurfaceFormat aFormat); /** @@ -343,8 +342,8 @@ public: *CreateFontGroup(const mozilla::FontFamilyList& aFontFamilyList, const gfxFontStyle *aStyle, gfxUserFontSet *aUserFontSet) = 0; - - + + /** * Look up a local platform font using the full font face name. * (Needed to support @font-face src local().) @@ -435,7 +434,7 @@ public: // in some situations, need to make decisions about ambiguous characters, may need to look at multiple pref langs void GetLangPrefs(eFontPrefLang aPrefLangs[], uint32_t &aLen, eFontPrefLang aCharLang, eFontPrefLang aPageLang); - + /** * Iterate over pref fonts given a list of lang groups. For a single lang * group, multiple pref fonts are possible. If error occurs, returns false, @@ -458,13 +457,13 @@ public: // convert a enum constant to lang group string (i.e. eFontPrefLang_ChineseTW ==> "zh-TW") static const char* GetPrefLangName(eFontPrefLang aLang); - + // map a Unicode range (based on char code) to a font language for Preferences static eFontPrefLang GetFontPrefLangFor(uint8_t aUnicodeRange); // returns true if a pref lang is CJK static bool IsLangCJK(eFontPrefLang aLang); - + // helper method to add a pref lang to an array, if not already in array static void AppendPrefLang(eFontPrefLang aPrefLangs[], uint32_t& aLen, eFontPrefLang aAddLang); @@ -653,12 +652,6 @@ public: // devices. Currently this is only used on Windows. virtual void GetDeviceInitData(mozilla::gfx::DeviceInitData* aOut); - /** - * Used to test whether surface texture detach is enabled. Ability to detach - * is based on API Version and device GPU as well as a preference. - */ - bool CanDetachSurfaceTexture() { return mCanDetachSurfaceTexture; } - protected: gfxPlatform(); virtual ~gfxPlatform(); @@ -736,7 +729,7 @@ protected: int8_t mBidiNumeralOption; - // whether to always search font cmaps globally + // whether to always search font cmaps globally // when doing system font fallback int8_t mFallbackUsesCmaps; @@ -794,8 +787,6 @@ private: // Backend that we are compositing with. NONE, if no compositor has been // created yet. mozilla::layers::LayersBackend mCompositorBackend; - - bool mCanDetachSurfaceTexture; }; #endif /* GFX_PLATFORM_H */