Backed out changeset 097dc302f5a0 (bug 1279657)

This commit is contained in:
Carsten "Tomcat" Book 2016-06-17 13:33:06 +01:00
parent dd6f87a7f3
commit c0c2282bfb
14 changed files with 62 additions and 67 deletions

View File

@ -587,7 +587,7 @@ CreateGLWithEGL(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
{
const gfx::IntSize dummySize(16, 16);
RefPtr<GLContext> gl = gl::GLContextProviderEGL::CreateOffscreen(dummySize, caps,
flags, out_failureId);
flags, *out_failureId);
if (gl && gl->IsANGLE()) {
gl = nullptr;
}
@ -613,7 +613,7 @@ CreateGLWithANGLE(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
{
const gfx::IntSize dummySize(16, 16);
RefPtr<GLContext> gl = gl::GLContextProviderEGL::CreateOffscreen(dummySize, caps,
flags, out_failureId);
flags, *out_failureId);
if (gl && !gl->IsANGLE()) {
gl = nullptr;
}
@ -652,7 +652,7 @@ CreateGLWithDefault(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
const gfx::IntSize dummySize(16, 16);
RefPtr<GLContext> gl = gl::GLContextProvider::CreateOffscreen(dummySize, caps,
flags, out_failureId);
flags, *out_failureId);
if (gl && gl->IsANGLE()) {
gl = nullptr;

View File

@ -24,7 +24,7 @@ class GLContextEGL : public GLContext
bool isOffscreen,
EGLConfig config,
EGLSurface surface,
nsACString* const out_failureId);
nsACString& aFailureId);
public:
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GLContextEGL, override)
@ -108,7 +108,7 @@ public:
CreateEGLPBufferOffscreenContext(CreateContextFlags flags,
const gfx::IntSize& size,
const SurfaceCaps& minCaps,
nsACString* const out_FailureId);
nsACString& aFailureId);
protected:
friend class GLContextProviderEGL;

View File

@ -321,18 +321,17 @@ CreateOffscreenFBOContext(CreateContextFlags flags)
}
already_AddRefed<GLContext>
GLContextProviderCGL::CreateHeadless(CreateContextFlags flags,
nsACString* const out_failureId)
GLContextProviderCGL::CreateHeadless(CreateContextFlags flags, nsACString& aFailureId)
{
RefPtr<GLContextCGL> gl;
gl = CreateOffscreenFBOContext(flags);
if (!gl) {
*out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_CGL_FBO");
aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_CGL_FBO");
return nullptr;
}
if (!gl->Init()) {
*out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_CGL_INIT");
aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_CGL_INIT");
NS_WARNING("Failed during Init.");
return nullptr;
}
@ -344,15 +343,15 @@ already_AddRefed<GLContext>
GLContextProviderCGL::CreateOffscreen(const IntSize& size,
const SurfaceCaps& minCaps,
CreateContextFlags flags,
nsACString* const out_failureId)
nsACString& aFailureId)
{
RefPtr<GLContext> gl = CreateHeadless(flags, out_failureId);
RefPtr<GLContext> gl = CreateHeadless(flags, aFailureId);
if (!gl) {
return nullptr;
}
if (!gl->InitOffscreen(size, minCaps)) {
*out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_CGL_INIT");
aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_CGL_INIT");
return nullptr;
}

View File

@ -460,7 +460,7 @@ GLContextEGL::HoldSurface(gfxASurface* aSurf) {
GLContextEGL::CreateSurfaceForWindow(nsIWidget* aWidget)
{
nsCString discardFailureId;
if (!sEGLLibrary.EnsureInitialized(false, &discardFailureId)) {
if (!sEGLLibrary.EnsureInitialized(false, discardFailureId)) {
MOZ_CRASH("GFX: Failed to load EGL library!\n");
return nullptr;
}
@ -494,10 +494,10 @@ GLContextEGL::CreateGLContext(CreateContextFlags flags,
bool isOffscreen,
EGLConfig config,
EGLSurface surface,
nsACString* const out_failureId)
nsACString& aFailureId)
{
if (sEGLLibrary.fBindAPI(LOCAL_EGL_OPENGL_ES_API) == LOCAL_EGL_FALSE) {
*out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_ES");
aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_ES");
NS_WARNING("Failed to bind API to GLES!");
return nullptr;
}
@ -534,7 +534,7 @@ GLContextEGL::CreateGLContext(CreateContextFlags flags,
contextAttribs.Elements());
}
if (!context) {
*out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_CREATE");
aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_CREATE");
NS_WARNING("Failed to create EGLContext!");
return nullptr;
}
@ -547,7 +547,7 @@ GLContextEGL::CreateGLContext(CreateContextFlags flags,
context);
if (!glContext->Init()) {
*out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_INIT");
aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_INIT");
return nullptr;
}
@ -749,7 +749,7 @@ already_AddRefed<GLContext>
GLContextProviderEGL::CreateWrappingExisting(void* aContext, void* aSurface)
{
nsCString discardFailureId;
if (!sEGLLibrary.EnsureInitialized(false, &discardFailureId)) {
if (!sEGLLibrary.EnsureInitialized(false, discardFailureId)) {
MOZ_CRASH("GFX: Failed to load EGL library 2!\n");
return nullptr;
}
@ -775,7 +775,7 @@ already_AddRefed<GLContext>
GLContextProviderEGL::CreateForWindow(nsIWidget* aWidget, bool aForceAccelerated)
{
nsCString discardFailureId;
if (!sEGLLibrary.EnsureInitialized(false, &discardFailureId)) {
if (!sEGLLibrary.EnsureInitialized(false, discardFailureId)) {
MOZ_CRASH("GFX: Failed to load EGL library 3!\n");
return nullptr;
}
@ -798,7 +798,7 @@ GLContextProviderEGL::CreateForWindow(nsIWidget* aWidget, bool aForceAccelerated
RefPtr<GLContextEGL> glContext =
GLContextEGL::CreateGLContext(CreateContextFlags::NONE, caps,
nullptr, false,
config, surface, &discardFailureId);
config, surface, discardFailureId);
if (!glContext) {
MOZ_CRASH("GFX: Failed to create EGLContext!\n");
@ -841,7 +841,7 @@ void
GLContextProviderEGL::DestroyEGLSurface(EGLSurface surface)
{
nsCString discardFailureId;
if (!sEGLLibrary.EnsureInitialized(false, &discardFailureId)) {
if (!sEGLLibrary.EnsureInitialized(false, discardFailureId)) {
MOZ_CRASH("GFX: Failed to load EGL library 5!\n");
}
@ -953,17 +953,17 @@ ChooseConfig(GLLibraryEGL* egl, CreateContextFlags flags, const SurfaceCaps& min
GLContextEGL::CreateEGLPBufferOffscreenContext(CreateContextFlags flags,
const mozilla::gfx::IntSize& size,
const SurfaceCaps& minCaps,
nsACString* const out_failureId)
nsACString& aFailureId)
{
bool forceEnableHardware = bool(flags & CreateContextFlags::FORCE_ENABLE_HARDWARE);
if (!sEGLLibrary.EnsureInitialized(forceEnableHardware, out_failureId)) {
if (!sEGLLibrary.EnsureInitialized(forceEnableHardware, aFailureId)) {
return nullptr;
}
SurfaceCaps configCaps;
EGLConfig config = ChooseConfig(&sEGLLibrary, flags, minCaps, &configCaps);
if (config == EGL_NO_CONFIG) {
*out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_NO_CONFIG");
aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_NO_CONFIG");
NS_WARNING("Failed to find a compatible config.");
return nullptr;
}
@ -977,13 +977,13 @@ GLContextEGL::CreateEGLPBufferOffscreenContext(CreateContextFlags flags,
LOCAL_EGL_NONE,
pbSize);
if (!surface) {
*out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_POT");
aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_POT");
NS_WARNING("Failed to create PBuffer for context!");
return nullptr;
}
RefPtr<GLContextEGL> gl = GLContextEGL::CreateGLContext(flags, configCaps, nullptr, true,
config, surface, out_failureId);
config, surface, aFailureId);
if (!gl) {
NS_WARNING("Failed to create GLContext from PBuffer");
sEGLLibrary.fDestroySurface(sEGLLibrary.Display(), surface);
@ -994,13 +994,12 @@ GLContextEGL::CreateEGLPBufferOffscreenContext(CreateContextFlags flags,
}
/*static*/ already_AddRefed<GLContext>
GLContextProviderEGL::CreateHeadless(CreateContextFlags flags,
nsACString* const out_failureId)
GLContextProviderEGL::CreateHeadless(CreateContextFlags flags, nsACString& aFailureId)
{
mozilla::gfx::IntSize dummySize = mozilla::gfx::IntSize(16, 16);
SurfaceCaps dummyCaps = SurfaceCaps::Any();
return GLContextEGL::CreateEGLPBufferOffscreenContext(flags, dummySize, dummyCaps,
out_failureId);
aFailureId);
}
// Under EGL, on Android, pbuffers are supported fine, though
@ -1009,11 +1008,11 @@ GLContextProviderEGL::CreateHeadless(CreateContextFlags flags,
GLContextProviderEGL::CreateOffscreen(const mozilla::gfx::IntSize& size,
const SurfaceCaps& minCaps,
CreateContextFlags flags,
nsACString* const out_failureId)
nsACString& aFailureId)
{
bool forceEnableHardware = bool(flags & CreateContextFlags::FORCE_ENABLE_HARDWARE);
if (!sEGLLibrary.EnsureInitialized(forceEnableHardware, out_failureId)) { // Needed for IsANGLE().
*out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_LIB_INIT");
if (!sEGLLibrary.EnsureInitialized(forceEnableHardware, aFailureId)) { // Needed for IsANGLE().
aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_LIB_INIT");
return nullptr;
}
@ -1027,7 +1026,7 @@ GLContextProviderEGL::CreateOffscreen(const mozilla::gfx::IntSize& size,
SurfaceCaps minOffscreenCaps = minCaps;
if (canOffscreenUseHeadless) {
gl = CreateHeadless(flags, out_failureId);
gl = CreateHeadless(flags, aFailureId);
if (!gl) {
return nullptr;
}
@ -1040,7 +1039,7 @@ GLContextProviderEGL::CreateOffscreen(const mozilla::gfx::IntSize& size,
}
gl = GLContextEGL::CreateEGLPBufferOffscreenContext(flags, size, minBackbufferCaps,
out_failureId);
aFailureId);
if (!gl) {
return nullptr;
}
@ -1058,7 +1057,7 @@ GLContextProviderEGL::CreateOffscreen(const mozilla::gfx::IntSize& size,
// Init the offscreen with the updated offscreen caps.
if (!gl->InitOffscreen(size, minOffscreenCaps)) {
*out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_OFFSCREEN");
aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_OFFSCREEN");
return nullptr;
}

View File

@ -1264,8 +1264,7 @@ GLContextGLX::FindFBConfigForWindow(Display* display, int screen, Window window,
}
static already_AddRefed<GLContextGLX>
CreateOffscreenPixmapContext(const IntSize& size, const SurfaceCaps& minCaps,
nsACString* const out_failureId,
CreateOffscreenPixmapContext(const IntSize& size, const SurfaceCaps& minCaps, nsACString& aFailureId,
ContextProfile profile = ContextProfile::OpenGLCompatibility)
{
GLXLibrary* glx = &sGLXLibrary;
@ -1328,18 +1327,18 @@ DONE_CREATING_PIXMAP:
}
/*static*/ already_AddRefed<GLContext>
GLContextProviderGLX::CreateHeadless(CreateContextFlags, nsACString* const out_failureId)
GLContextProviderGLX::CreateHeadless(CreateContextFlags, nsACString& aFailureId)
{
IntSize dummySize = IntSize(16, 16);
SurfaceCaps dummyCaps = SurfaceCaps::Any();
return CreateOffscreenPixmapContext(dummySize, dummyCaps, out_failureId);
return CreateOffscreenPixmapContext(dummySize, dummyCaps, aFailureId);
}
/*static*/ already_AddRefed<GLContext>
GLContextProviderGLX::CreateOffscreen(const IntSize& size,
const SurfaceCaps& minCaps,
CreateContextFlags flags,
nsACString* const out_failureId)
nsACString& aFailureId)
{
SurfaceCaps minBackbufferCaps = minCaps;
if (minCaps.antialias) {
@ -1354,12 +1353,12 @@ GLContextProviderGLX::CreateOffscreen(const IntSize& size,
}
RefPtr<GLContext> gl;
gl = CreateOffscreenPixmapContext(size, minBackbufferCaps, out_failureId, profile);
gl = CreateOffscreenPixmapContext(size, minBackbufferCaps, aFailureId, profile);
if (!gl)
return nullptr;
if (!gl->InitOffscreen(size, minCaps)) {
*out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_GLX_INIT");
aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_GLX_INIT");
return nullptr;
}

View File

@ -68,11 +68,11 @@ public:
CreateOffscreen(const mozilla::gfx::IntSize& size,
const SurfaceCaps& minCaps,
CreateContextFlags flags,
nsACString* const out_failureId);
nsACString& failureId);
// Just create a context. We'll add offscreen stuff ourselves.
static already_AddRefed<GLContext>
CreateHeadless(CreateContextFlags flags, nsACString* const out_failureId);
CreateHeadless(CreateContextFlags flags, nsACString& aFailureId);
/**
* Create wrapping Gecko GLContext for external gl context.

View File

@ -24,9 +24,9 @@ already_AddRefed<GLContext>
GLContextProviderNull::CreateOffscreen(const gfx::IntSize&,
const SurfaceCaps&,
CreateContextFlags,
nsACString* const out_failureId)
nsACString& aFailureId)
{
*out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_NULL");
aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_NULL");
return nullptr;
}

View File

@ -641,7 +641,7 @@ CreateWindowOffscreenContext()
}
/*static*/ already_AddRefed<GLContext>
GLContextProviderWGL::CreateHeadless(CreateContextFlags, nsACString* const out_failureId)
GLContextProviderWGL::CreateHeadless(CreateContextFlags, nsACString& aFailureId)
{
if (!sWGLLib.EnsureInitialized()) {
return nullptr;
@ -677,14 +677,14 @@ GLContextProviderWGL::CreateHeadless(CreateContextFlags, nsACString* const out_f
GLContextProviderWGL::CreateOffscreen(const IntSize& size,
const SurfaceCaps& minCaps,
CreateContextFlags flags,
nsACString* const out_failureId)
nsACString& aFailureId)
{
RefPtr<GLContext> gl = CreateHeadless(flags, out_failureId);
RefPtr<GLContext> gl = CreateHeadless(flags, aFailureId);
if (!gl)
return nullptr;
if (!gl->InitOffscreen(size, minCaps)) {
*out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_WGL_INIT");
aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_WGL_INIT");
return nullptr;
}
@ -702,8 +702,7 @@ GLContextProviderWGL::GetGlobalContext()
MOZ_RELEASE_ASSERT(!gGlobalContext, "GFX: Global GL context already initialized.");
nsCString discardFailureId;
RefPtr<GLContext> temp = CreateHeadless(CreateContextFlags::NONE,
&discardFailureId);
RefPtr<GLContext> temp = CreateHeadless(CreateContextFlags::NONE, discardFailureId);
gGlobalContext = temp;
}

View File

@ -142,8 +142,7 @@ GetAndInitWARPDisplay(GLLibraryEGL& egl, void* displayType)
}
static bool
IsAccelAngleSupported(const nsCOMPtr<nsIGfxInfo>& gfxInfo,
nsACString* const out_failureId)
IsAccelAngleSupported(const nsCOMPtr<nsIGfxInfo>& gfxInfo, nsACString& aFailureId)
{
int32_t angleSupport;
nsCString failureId;
@ -154,7 +153,7 @@ IsAccelAngleSupported(const nsCOMPtr<nsIGfxInfo>& gfxInfo,
Telemetry::Accumulate(Telemetry::CANVAS_WEBGL_ACCL_FAILURE_ID,
failureId);
if (failureId.IsEmpty()) {
*out_failureId = failureId;
aFailureId = failureId;
}
return (angleSupport == nsIGfxInfo::FEATURE_STATUS_OK);
}
@ -207,7 +206,7 @@ GLLibraryEGL::ReadbackEGLImage(EGLImage image, gfx::DataSourceSurface* out_surfa
if (!mReadbackGL) {
nsCString discardFailureId;
mReadbackGL = gl::GLContextProvider::CreateHeadless(gl::CreateContextFlags::NONE,
&discardFailureId);
discardFailureId);
}
ScopedTexture destTex(mReadbackGL);
@ -229,7 +228,7 @@ GLLibraryEGL::ReadbackEGLImage(EGLImage image, gfx::DataSourceSurface* out_surfa
}
bool
GLLibraryEGL::EnsureInitialized(bool forceAccel, nsACString* const out_failureId)
GLLibraryEGL::EnsureInitialized(bool forceAccel, nsACString& aFailureId)
{
if (mInitialized) {
return true;
@ -395,7 +394,7 @@ GLLibraryEGL::EnsureInitialized(bool forceAccel, nsACString* const out_failureId
EGLDisplay chosenDisplay = nullptr;
if (IsExtensionSupported(ANGLE_platform_angle_d3d)) {
bool accelAngleSupport = IsAccelAngleSupported(gfxInfo, out_failureId);
bool accelAngleSupport = IsAccelAngleSupported(gfxInfo, aFailureId);
bool shouldTryAccel = forceAccel || accelAngleSupport;
bool shouldTryWARP = !shouldTryAccel;
@ -416,8 +415,8 @@ GLLibraryEGL::EnsureInitialized(bool forceAccel, nsACString* const out_failureId
// If falling back to WARP did not work and we don't want to try
// using HW accelerated ANGLE, then fail.
if (!shouldTryAccel) {
if (out_failureId->IsEmpty()) {
*out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_WARP_FALLBACK");
if (aFailureId.IsEmpty()) {
aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_WARP_FALLBACK");
}
NS_ERROR("Fallback WARP ANGLE context failed to initialize.");
return false;
@ -431,8 +430,8 @@ GLLibraryEGL::EnsureInitialized(bool forceAccel, nsACString* const out_failureId
}
if (!chosenDisplay) {
if (out_failureId->IsEmpty()) {
*out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_NO_DISPLAY");
if (aFailureId.IsEmpty()) {
aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_NO_DISPLAY");
}
NS_WARNING("Failed to initialize a display.");
return false;

View File

@ -535,7 +535,7 @@ public:
bool ReadbackEGLImage(EGLImage image, gfx::DataSourceSurface* out_surface);
bool EnsureInitialized(bool forceAccel, nsACString* const out_failureId);
bool EnsureInitialized(bool forceAccel, nsACString& aFailureId);
void DumpEGLConfig(EGLConfig cfg);
void DumpEGLConfigs();

View File

@ -53,7 +53,7 @@ GLImage::GetAsSourceSurface()
if (!sSnapshotContext) {
nsCString discardFailureId;
sSnapshotContext = GLContextProvider::CreateHeadless(CreateContextFlags::NONE,
&discardFailureId);
discardFailureId);
if (!sSnapshotContext) {
NS_WARNING("Failed to create snapshot GLContext");
return nullptr;

View File

@ -134,7 +134,7 @@ CompositorOGL::CreateContext()
nsCString discardFailureId;
context = GLContextProvider::CreateOffscreen(mSurfaceSize,
caps, CreateContextFlags::REQUIRE_COMPAT_PROFILE,
&discardFailureId);
discardFailureId);
}
if (!context) {

View File

@ -52,7 +52,7 @@ public:
RefPtr<GLContext> context = GLContextProvider::CreateOffscreen(
IntSize(gCompWidth, gCompHeight), caps,
CreateContextFlags::REQUIRE_COMPAT_PROFILE,
&discardFailureId);
discardFailureId);
return context.forget().take();
}
return nullptr;

View File

@ -1326,7 +1326,7 @@ gfxPlatform::GetSkiaGLGlue()
nsCString discardFailureId;
glContext = GLContextProvider::CreateHeadless(CreateContextFlags::REQUIRE_COMPAT_PROFILE |
CreateContextFlags::ALLOW_OFFLINE_RENDERER,
&discardFailureId);
discardFailureId);
if (!glContext) {
printf_stderr("Failed to create GLContext for SkiaGL!\n");
return nullptr;