Backed out changeset 783d0fe2770b (bug 1124394) for test bustage on a CLOSED TREE

This commit is contained in:
Wes Kocher 2015-01-26 18:57:36 -08:00
parent 6e4bdea85d
commit da3c6c9afd
27 changed files with 305 additions and 386 deletions

View File

@ -505,7 +505,7 @@ IsFeatureInBlacklist(const nsCOMPtr<nsIGfxInfo>& gfxInfo, int32_t feature)
static already_AddRefed<GLContext>
CreateHeadlessNativeGL(bool forceEnabled, const nsCOMPtr<nsIGfxInfo>& gfxInfo,
bool requireCompatProfile, WebGLContext* webgl)
WebGLContext* webgl)
{
if (!forceEnabled &&
IsFeatureInBlacklist(gfxInfo, nsIGfxInfo::FEATURE_WEBGL_OPENGL))
@ -515,7 +515,7 @@ CreateHeadlessNativeGL(bool forceEnabled, const nsCOMPtr<nsIGfxInfo>& gfxInfo,
return nullptr;
}
nsRefPtr<GLContext> gl = gl::GLContextProvider::CreateHeadless(requireCompatProfile);
nsRefPtr<GLContext> gl = gl::GLContextProvider::CreateHeadless();
if (!gl) {
webgl->GenerateWarning("Error during native OpenGL init.");
return nullptr;
@ -530,7 +530,7 @@ CreateHeadlessNativeGL(bool forceEnabled, const nsCOMPtr<nsIGfxInfo>& gfxInfo,
// Eventually, we want to be able to pick ANGLE-EGL or native EGL.
static already_AddRefed<GLContext>
CreateHeadlessANGLE(bool forceEnabled, const nsCOMPtr<nsIGfxInfo>& gfxInfo,
bool requireCompatProfile, WebGLContext* webgl)
WebGLContext* webgl)
{
nsRefPtr<GLContext> gl;
@ -543,7 +543,7 @@ CreateHeadlessANGLE(bool forceEnabled, const nsCOMPtr<nsIGfxInfo>& gfxInfo,
return nullptr;
}
gl = gl::GLContextProviderEGL::CreateHeadless(requireCompatProfile);
gl = gl::GLContextProviderEGL::CreateHeadless();
if (!gl) {
webgl->GenerateWarning("Error during ANGLE OpenGL init.");
return nullptr;
@ -555,13 +555,13 @@ CreateHeadlessANGLE(bool forceEnabled, const nsCOMPtr<nsIGfxInfo>& gfxInfo,
}
static already_AddRefed<GLContext>
CreateHeadlessEGL(bool forceEnabled, bool requireCompatProfile,
CreateHeadlessEGL(bool forceEnabled, const nsCOMPtr<nsIGfxInfo>& gfxInfo,
WebGLContext* webgl)
{
nsRefPtr<GLContext> gl;
#ifdef ANDROID
gl = gl::GLContextProviderEGL::CreateHeadless(requireCompatProfile);
gl = gl::GLContextProviderEGL::CreateHeadless();
if (!gl) {
webgl->GenerateWarning("Error during EGL OpenGL init.");
return nullptr;
@ -583,22 +583,16 @@ CreateHeadlessGL(bool forceEnabled, const nsCOMPtr<nsIGfxInfo>& gfxInfo,
if (PR_GetEnv("MOZ_WEBGL_FORCE_OPENGL"))
disableANGLE = true;
bool requireCompatProfile = webgl->IsWebGL2() ? false : true;
nsRefPtr<GLContext> gl;
if (preferEGL)
gl = CreateHeadlessEGL(forceEnabled, requireCompatProfile, webgl);
gl = CreateHeadlessEGL(forceEnabled, gfxInfo, webgl);
if (!gl && !disableANGLE) {
gl = CreateHeadlessANGLE(forceEnabled, gfxInfo, requireCompatProfile,
webgl);
}
if (!gl && !disableANGLE)
gl = CreateHeadlessANGLE(forceEnabled, gfxInfo, webgl);
if (!gl) {
gl = CreateHeadlessNativeGL(forceEnabled, gfxInfo,
requireCompatProfile, webgl);
}
if (!gl)
gl = CreateHeadlessNativeGL(forceEnabled, gfxInfo, webgl);
return gl.forget();
}

View File

@ -1209,10 +1209,9 @@ protected:
// -------------------------------------------------------------------------
// WebGL 2 specifics (implemented in WebGL2Context.cpp)
public:
virtual bool IsWebGL2() const = 0;
protected:
bool InitWebGL2();
// -------------------------------------------------------------------------

View File

@ -2107,6 +2107,7 @@ WebGLContext::ReadPixels(GLint x, GLint y, GLsizei width,
// if we're reading alpha, we may need to do fixup. Note that we don't allow
// GL_ALPHA to readpixels currently, but we had the code written for it already.
const bool formatHasAlpha = format == LOCAL_GL_ALPHA ||
format == LOCAL_GL_RGBA;
if (!formatHasAlpha)

View File

@ -1117,12 +1117,11 @@ WebGLContext::AssertCachedState()
AssertUintParamCorrect(gl, LOCAL_GL_STENCIL_CLEAR_VALUE, mStencilClearValue);
GLint stencilBits = 0;
if (GetStencilBits(&stencilBits)) {
const GLuint stencilRefMask = (1 << stencilBits) - 1;
gl->fGetIntegerv(LOCAL_GL_STENCIL_BITS, &stencilBits);
const GLuint stencilRefMask = (1 << stencilBits) - 1;
AssertMaskedUintParamCorrect(gl, LOCAL_GL_STENCIL_REF, stencilRefMask, mStencilRefFront);
AssertMaskedUintParamCorrect(gl, LOCAL_GL_STENCIL_BACK_REF, stencilRefMask, mStencilRefBack);
}
AssertMaskedUintParamCorrect(gl, LOCAL_GL_STENCIL_REF, stencilRefMask, mStencilRefFront);
AssertMaskedUintParamCorrect(gl, LOCAL_GL_STENCIL_BACK_REF, stencilRefMask, mStencilRefBack);
AssertUintParamCorrect(gl, LOCAL_GL_STENCIL_VALUE_MASK, mStencilValueMaskFront);
AssertUintParamCorrect(gl, LOCAL_GL_STENCIL_BACK_VALUE_MASK, mStencilValueMaskBack);

View File

@ -1779,8 +1779,8 @@ WebGLContext::InitAndValidateGL()
MakeContextCurrent();
// For OpenGL compat. profiles, we always keep vertex attrib 0 array enabled.
if (gl->IsCompatibilityProfile())
// on desktop OpenGL, we always keep vertex attrib 0 array enabled
if (!gl->IsGLES())
gl->fEnableVertexAttribArray(0);
if (MinCapabilityMode())
@ -1889,7 +1889,7 @@ WebGLContext::InitAndValidateGL()
// Always 1 for GLES2
mMaxFramebufferColorAttachments = 1;
if (gl->IsCompatibilityProfile()) {
if (!gl->IsGLES()) {
// gl_PointSize is always available in ES2 GLSL, but has to be
// specifically enabled on desktop GLSL.
gl->fEnable(LOCAL_GL_VERTEX_PROGRAM_POINT_SIZE);

View File

@ -173,7 +173,7 @@ protected:
return true;
}
mGLContext = GLContextProvider::CreateHeadless(false);
mGLContext = GLContextProvider::CreateHeadless();
return mGLContext;
}

View File

@ -91,8 +91,9 @@ static nsRefPtr<GLContext> sPluginContext = nullptr;
static bool EnsureGLContext()
{
if (!sPluginContext) {
bool requireCompatProfile = true;
sPluginContext = GLContextProvider::CreateHeadless(requireCompatProfile);
gfxIntSize dummySize(16, 16);
sPluginContext = GLContextProvider::CreateOffscreen(dummySize,
SurfaceCaps::Any());
}
return sPluginContext != nullptr;

View File

@ -8,7 +8,6 @@
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <vector>
#include "GLContext.h"
#include "GLBlitHelper.h"
@ -157,7 +156,8 @@ static const char *sExtensionNames[] = {
"GL_OES_texture_half_float",
"GL_OES_texture_half_float_linear",
"GL_OES_texture_npot",
"GL_OES_vertex_array_object"
"GL_OES_vertex_array_object",
nullptr
};
static bool
@ -317,8 +317,6 @@ GLContext::~GLContext() {
ReportOutstandingNames();
}
#endif
DeleteAndClearIterable(mDriverExtensionList);
}
/*static*/ void
@ -503,8 +501,6 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
mInitialized = LoadSymbols(&symbols[0], trygl, prefix);
MakeCurrent();
if (mInitialized) {
MOZ_ASSERT(mProfile != ContextProfile::Unknown);
uint32_t version = 0;
ParseGLVersion(this, &version);
@ -660,15 +656,6 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
}
}
if (IsFeatureProvidedByCoreSymbols(GLFeature::get_string_indexed)) {
SymLoadStruct moreSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fGetStringi, { "GetStringi", nullptr } },
END_SYMBOLS
};
MOZ_ALWAYS_TRUE(LoadSymbols(moreSymbols, trygl, prefix));
}
InitExtensions();
InitFeatures();
@ -683,6 +670,12 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
MarkUnsupported(GLFeature::standard_derivatives);
}
if (Vendor() == GLVendor::Imagination &&
Renderer() == GLRenderer::SGX540) {
// Bug 980048
MarkExtensionUnsupported(OES_EGL_sync);
}
if (Renderer() == GLRenderer::MicrosoftBasicRenderDriver) {
// Bug 978966: on Microsoft's "Basic Render Driver" (software renderer)
// multisampling hardcodes blending with the default blendfunc, which breaks WebGL.
@ -1475,13 +1468,10 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
// We're ready for final setup.
fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, 0);
// TODO: Remove SurfaceCaps::any.
if (mCaps.any) {
mCaps.any = false;
mCaps.color = true;
mCaps.alpha = false;
}
if (mCaps.any)
DetermineCaps();
UpdatePixelFormat();
UpdateGLFormats(mCaps);
mTexGarbageBin = new TextureGarbageBin(this);
@ -1603,101 +1593,61 @@ GLContext::DebugCallback(GLenum source,
void
GLContext::InitExtensions()
{
MOZ_ASSERT(IsCurrent());
MakeCurrent();
const char* extensions = (const char*)fGetString(LOCAL_GL_EXTENSIONS);
if (!extensions)
return;
if (IsFeatureProvidedByCoreSymbols(GLFeature::get_string_indexed)) {
GLuint count = 0;
GetUIntegerv(LOCAL_GL_NUM_EXTENSIONS, &count);
for (GLuint i = 0; i < count; i++) {
// This is UTF-8.
const char* rawExt = (const char*)fGetStringi(LOCAL_GL_EXTENSIONS,
i);
nsACString* ext = new nsDependentCString(rawExt);
mDriverExtensionList.push_back(ext);
}
} else {
MOZ_ALWAYS_TRUE(!fGetError());
const char* rawExts = (const char*)fGetString(LOCAL_GL_EXTENSIONS);
MOZ_ALWAYS_TRUE(!fGetError());
InitializeExtensionsBitSet(mAvailableExtensions, extensions,
sExtensionNames);
if (rawExts) {
nsDependentCString exts(rawExts);
SplitByChar(exts, ' ', &mDriverExtensionList);
}
if (WorkAroundDriverBugs() &&
Vendor() == GLVendor::Qualcomm) {
// Some Adreno drivers do not report GL_OES_EGL_sync, but they really do support it.
MarkExtensionSupported(OES_EGL_sync);
}
const bool shouldDumpExts = ShouldDumpExts();
if (shouldDumpExts) {
printf_stderr("%i GL driver extensions:\n",
(uint32_t)mDriverExtensionList.size());
if (WorkAroundDriverBugs() &&
Renderer() == GLRenderer::AndroidEmulator) {
// the Android emulator, which we use to run B2G reftests on,
// doesn't expose the OES_rgb8_rgba8 extension, but it seems to
// support it (tautologically, as it only runs on desktop GL).
MarkExtensionSupported(OES_rgb8_rgba8);
}
MarkBitfieldByStrings(mDriverExtensionList, shouldDumpExts, sExtensionNames,
mAvailableExtensions);
if (WorkAroundDriverBugs()) {
if (Vendor() == GLVendor::Qualcomm) {
// Some Adreno drivers do not report GL_OES_EGL_sync, but they really do support it.
MarkExtensionSupported(OES_EGL_sync);
}
if (Vendor() == GLVendor::Imagination &&
Renderer() == GLRenderer::SGX540)
{
// Bug 980048
MarkExtensionUnsupported(OES_EGL_sync);
}
if (Renderer() == GLRenderer::AndroidEmulator) {
// the Android emulator, which we use to run B2G reftests on,
// doesn't expose the OES_rgb8_rgba8 extension, but it seems to
// support it (tautologically, as it only runs on desktop GL).
MarkExtensionSupported(OES_rgb8_rgba8);
}
if (Vendor() == GLVendor::VMware &&
Renderer() == GLRenderer::GalliumLlvmpipe)
{
// The llvmpipe driver that is used on linux try servers appears to have
// buggy support for s3tc/dxt1 compressed textures.
// See Bug 975824.
MarkExtensionUnsupported(EXT_texture_compression_s3tc);
MarkExtensionUnsupported(EXT_texture_compression_dxt1);
MarkExtensionUnsupported(ANGLE_texture_compression_dxt3);
MarkExtensionUnsupported(ANGLE_texture_compression_dxt5);
}
if (WorkAroundDriverBugs() &&
Vendor() == GLVendor::VMware &&
Renderer() == GLRenderer::GalliumLlvmpipe)
{
// The llvmpipe driver that is used on linux try servers appears to have
// buggy support for s3tc/dxt1 compressed textures.
// See Bug 975824.
MarkExtensionUnsupported(EXT_texture_compression_s3tc);
MarkExtensionUnsupported(EXT_texture_compression_dxt1);
MarkExtensionUnsupported(ANGLE_texture_compression_dxt3);
MarkExtensionUnsupported(ANGLE_texture_compression_dxt5);
}
#ifdef XP_MACOSX
// Bug 1009642: On OSX Mavericks (10.9), the driver for Intel HD
// 3000 appears to be buggy WRT updating sub-images of S3TC
// textures with glCompressedTexSubImage2D. Works on Intel HD 4000
// and Intel HD 5000/Iris that I tested.
if (nsCocoaFeatures::OSXVersionMajor() == 10 &&
nsCocoaFeatures::OSXVersionMinor() == 9 &&
Renderer() == GLRenderer::IntelHD3000)
{
MarkExtensionUnsupported(EXT_texture_compression_s3tc);
}
// Bug 1009642: On OSX Mavericks (10.9), the driver for Intel HD
// 3000 appears to be buggy WRT updating sub-images of S3TC
// textures with glCompressedTexSubImage2D. Works on Intel HD 4000
// and Intel HD 5000/Iris that I tested.
if (WorkAroundDriverBugs() &&
nsCocoaFeatures::OSXVersionMajor() == 10 &&
nsCocoaFeatures::OSXVersionMinor() == 9 &&
Renderer() == GLRenderer::IntelHD3000)
{
MarkExtensionUnsupported(EXT_texture_compression_s3tc);
}
#endif
}
if (shouldDumpExts) {
printf_stderr("\nActivated extensions:\n");
for (size_t i = 0; i < mAvailableExtensions.size(); i++) {
if (!mAvailableExtensions[i])
continue;
const char* ext = sExtensionNames[i];
printf_stderr("[%i] %s\n", (uint32_t)i, ext);
}
}
}
void
GLContext::PlatformStartup()
{
RegisterStrongMemoryReporter(new GfxTexturesReporter());
RegisterStrongMemoryReporter(new GfxTexturesReporter());
}
// Common code for checking for both GL extensions and GLX extensions.
@ -1738,6 +1688,66 @@ GLContext::ListHasExtension(const GLubyte *extensions, const char *extension)
return false;
}
void
GLContext::DetermineCaps()
{
PixelBufferFormat format = QueryPixelFormat();
SurfaceCaps caps;
caps.color = !!format.red && !!format.green && !!format.blue;
caps.bpp16 = caps.color && format.ColorBits() == 16;
caps.alpha = !!format.alpha;
caps.depth = !!format.depth;
caps.stencil = !!format.stencil;
caps.antialias = format.samples > 1;
caps.preserve = true;
mCaps = caps;
}
PixelBufferFormat
GLContext::QueryPixelFormat()
{
PixelBufferFormat format;
ScopedBindFramebuffer autoFB(this, 0);
fGetIntegerv(LOCAL_GL_RED_BITS , &format.red );
fGetIntegerv(LOCAL_GL_GREEN_BITS, &format.green);
fGetIntegerv(LOCAL_GL_BLUE_BITS , &format.blue );
fGetIntegerv(LOCAL_GL_ALPHA_BITS, &format.alpha);
fGetIntegerv(LOCAL_GL_DEPTH_BITS, &format.depth);
fGetIntegerv(LOCAL_GL_STENCIL_BITS, &format.stencil);
fGetIntegerv(LOCAL_GL_SAMPLES, &format.samples);
return format;
}
void
GLContext::UpdatePixelFormat()
{
PixelBufferFormat format = QueryPixelFormat();
#ifdef MOZ_GL_DEBUG
const SurfaceCaps& caps = Caps();
MOZ_ASSERT(!caps.any, "Did you forget to DetermineCaps()?");
MOZ_ASSERT(caps.color == !!format.red);
MOZ_ASSERT(caps.color == !!format.green);
MOZ_ASSERT(caps.color == !!format.blue);
// These we either must have if they're requested, or
// we can have if they're not.
MOZ_ASSERT(caps.alpha == !!format.alpha || !caps.alpha);
MOZ_ASSERT(caps.depth == !!format.depth || !caps.depth);
MOZ_ASSERT(caps.stencil == !!format.stencil || !caps.stencil);
MOZ_ASSERT(caps.antialias == (format.samples > 1));
#endif
mPixelFormat = new PixelBufferFormat(format);
}
GLFormats
GLContext::ChooseGLFormats(const SurfaceCaps& caps) const
{
@ -2407,12 +2417,6 @@ GLContext::FlushIfHeavyGLCallsSinceLastFlush()
fFlush();
}
/*static*/ bool
GLContext::ShouldDumpExts()
{
return PR_GetEnv("MOZ_GL_DUMP_EXTS");
}
bool
DoesStringMatch(const char* aString, const char *aWantedString)
{
@ -2444,27 +2448,5 @@ GLContext::ShouldSpew()
return spew;
}
void
SplitByChar(const nsACString& str, const char delim,
std::vector<nsACString*>* out)
{
uint32_t start = 0;
while (true) {
int32_t end = str.FindChar(' ', start);
if (end == -1)
break;
uint32_t len = (uint32_t)end - start;
nsACString* substr = new nsDependentCSubstring(str, start, len);
out->push_back(substr);
start = end + 1;
continue;
}
nsACString* substr = new nsDependentCSubstring(str, start);
out->push_back(substr);
}
} /* namespace gl */
} /* namespace mozilla */

View File

@ -104,7 +104,6 @@ enum class GLFeature {
get_integer_indexed,
get_integer64_indexed,
get_query_object_iv,
get_string_indexed,
gpu_shader4,
instanced_arrays,
instanced_non_arrays,
@ -309,6 +308,7 @@ public:
virtual bool IsCurrent() = 0;
protected:
bool mInitialized;
bool mIsOffscreen;
bool mIsGlobalSharedContext;
@ -325,12 +325,9 @@ protected:
GLVendor mVendor;
GLRenderer mRenderer;
void SetProfileVersion(ContextProfile profile, uint32_t version) {
MOZ_ASSERT(!mInitialized, "SetProfileVersion can only be called before"
" initialization!");
MOZ_ASSERT(profile != ContextProfile::Unknown &&
profile != ContextProfile::OpenGL,
"Invalid `profile` for SetProfileVersion");
inline void SetProfileVersion(ContextProfile profile, unsigned int version) {
MOZ_ASSERT(!mInitialized, "SetProfileVersion can only be called before initialization!");
MOZ_ASSERT(profile != ContextProfile::Unknown && profile != ContextProfile::OpenGL, "Invalid `profile` for SetProfileVersion");
MOZ_ASSERT(version >= 100, "Invalid `version` for SetProfileVersion");
mVersion = version;
@ -460,7 +457,6 @@ public:
return mAvailableExtensions[aKnownExtension];
}
protected:
void MarkExtensionUnsupported(GLExtensions aKnownExtension) {
mAvailableExtensions[aKnownExtension] = 0;
}
@ -469,6 +465,42 @@ protected:
mAvailableExtensions[aKnownExtension] = 1;
}
public:
template<size_t N>
static void InitializeExtensionsBitSet(std::bitset<N>& extensionsBitset,
const char* extStr,
const char** extList)
{
char* exts = ::strdup(extStr);
if (ShouldSpew())
printf_stderr("Extensions: %s\n", exts);
char* cur = exts;
bool done = false;
while (!done) {
char* space = strchr(cur, ' ');
if (space) {
*space = '\0';
} else {
done = true;
}
for (int i = 0; extList[i]; ++i) {
if (PL_strcasecmp(cur, extList[i]) == 0) {
if (ShouldSpew())
printf_stderr("Found extension %s\n", cur);
extensionsBitset[i] = true;
}
}
cur = space + 1;
}
free(exts);
}
protected:
std::bitset<Extensions_Max> mAvailableExtensions;
// -----------------------------------------------------------------------------
@ -3148,17 +3180,6 @@ public:
AFTER_GL_CALL;
}
// -----------------------------------------------------------------------------
// get_string_indexed
const GLubyte* fGetStringi(GLenum name, GLuint index) {
BEFORE_GL_CALL;
ASSERT_SYMBOL_PRESENT(fGetStringi);
const GLubyte* ret = mSymbols.fGetStringi(name, index);
AFTER_GL_CALL;
return ret;
}
// -----------------------------------------------------------------------------
// Constructor
protected:
@ -3427,9 +3448,11 @@ public:
fViewport(0, 0, size.width, size.height);
mCaps = mScreen->mCaps;
MOZ_ASSERT(!mCaps.any);
if (mCaps.any)
DetermineCaps();
UpdateGLFormats(mCaps);
UpdatePixelFormat();
return true;
}
@ -3452,8 +3475,10 @@ public:
protected:
SurfaceCaps mCaps;
nsAutoPtr<GLFormats> mGLFormats;
nsAutoPtr<PixelBufferFormat> mPixelFormat;
public:
void DetermineCaps();
const SurfaceCaps& Caps() const {
return mCaps;
}
@ -3469,6 +3494,14 @@ public:
return *mGLFormats;
}
PixelBufferFormat QueryPixelFormat();
void UpdatePixelFormat();
const PixelBufferFormat& GetPixelFormat() const {
MOZ_ASSERT(mPixelFormat);
return *mPixelFormat;
}
bool IsFramebufferComplete(GLuint fb, GLenum* status = nullptr);
// Does not check completeness.
@ -3545,8 +3578,6 @@ protected:
void InitExtensions();
std::vector<nsACString*> mDriverExtensionList;
GLint mViewportRect[4];
GLint mScissorRect[4];
@ -3665,55 +3696,10 @@ protected:
public:
void FlushIfHeavyGLCallsSinceLastFlush();
static bool ShouldSpew();
static bool ShouldDumpExts();
};
bool DoesStringMatch(const char* aString, const char *aWantedString);
void SplitByChar(const nsACString& str, const char delim,
std::vector<nsACString*>* out);
template<size_t N>
bool
MarkBitfieldByString(const nsACString& str, const char* (&markStrList)[N],
std::bitset<N>& markList)
{
for (size_t i = 0; i < N; i++) {
if (str.Equals(markStrList[i])) {
markList[i] = 1;
return true;
}
}
return false;
}
template<size_t N>
void
MarkBitfieldByStrings(const std::vector<nsACString*> strList,
bool dumpStrings, const char* (&markStrList)[N],
std::bitset<N>& markList)
{
for (auto itr = strList.begin(); itr != strList.end(); ++itr) {
const nsACString& str = **itr;
const bool wasMarked = MarkBitfieldByString(str, markStrList,
markList);
if (dumpStrings) {
nsCString nullTermed(str);
printf_stderr(" %s%s\n", nullTermed.BeginReading(),
wasMarked ? "(*)" : "");
}
}
}
template<typename C>
void
DeleteAndClearIterable(C& cont)
{
for(auto itr = cont.begin(); itr != cont.end(); ++itr) {
delete *itr;
}
cont.clear();
}
} /* namespace gl */
} /* namespace mozilla */

View File

@ -28,8 +28,10 @@ class GLContextCGL : public GLContext
public:
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GLContextCGL, MOZ_OVERRIDE)
GLContextCGL(const SurfaceCaps& caps, NSOpenGLContext* context,
bool isOffscreen, ContextProfile profile);
GLContextCGL(const SurfaceCaps& caps,
GLContext *shareContext,
NSOpenGLContext *context,
bool isOffscreen = false);
~GLContextCGL();

View File

@ -274,16 +274,6 @@ static const FeatureInfo sFeatureInfoArr[] = {
* ARB_occlusion_query (added by OpenGL 2.0).
*/
},
{
"get_string_indexed",
GLVersion::GL3,
GLESVersion::ES3,
GLContext::Extension_None,
{
GLContext::Extensions_End
}
// glGetStringi
},
{
"gpu_shader4",
GLVersion::GL3,

View File

@ -21,14 +21,16 @@ namespace gl {
using namespace mozilla::gfx;
static bool gUseDoubleBufferedWindows = true;
class CGLLibrary
{
public:
CGLLibrary()
: mInitialized(false)
, mUseDoubleBufferedWindows(true)
, mOGLLibrary(nullptr)
{}
: mInitialized(false),
mOGLLibrary(nullptr),
mPixelFormat(nullptr)
{ }
bool EnsureInitialized()
{
@ -44,33 +46,48 @@ public:
}
const char* db = PR_GetEnv("MOZ_CGL_DB");
if (db) {
mUseDoubleBufferedWindows = *db != '0';
}
gUseDoubleBufferedWindows = (!db || *db != '0');
mInitialized = true;
return true;
}
bool UseDoubleBufferedWindows() const {
MOZ_ASSERT(mInitialized);
return mUseDoubleBufferedWindows;
}
NSOpenGLPixelFormat *PixelFormat()
{
if (mPixelFormat == nullptr) {
NSOpenGLPixelFormatAttribute attribs[] = {
NSOpenGLPFAAccelerated,
NSOpenGLPFAAllowOfflineRenderers,
NSOpenGLPFADoubleBuffer,
0
};
if (!gUseDoubleBufferedWindows) {
attribs[2] = 0;
}
mPixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs];
}
return mPixelFormat;
}
private:
bool mInitialized;
bool mUseDoubleBufferedWindows;
PRLibrary *mOGLLibrary;
NSOpenGLPixelFormat *mPixelFormat;
};
CGLLibrary sCGLLibrary;
GLContextCGL::GLContextCGL(const SurfaceCaps& caps, NSOpenGLContext* context,
bool isOffscreen, ContextProfile profile)
: GLContext(caps, nullptr, isOffscreen)
, mContext(context)
GLContextCGL::GLContextCGL(
const SurfaceCaps& caps,
GLContext *shareContext,
NSOpenGLContext *context,
bool isOffscreen)
: GLContext(caps, shareContext, isOffscreen),
mContext(context)
{
SetProfileVersion(profile, 210);
SetProfileVersion(ContextProfile::OpenGLCompatibility, 210);
}
GLContextCGL::~GLContextCGL()
@ -145,7 +162,7 @@ GLContextCGL::SetupLookupFunction()
bool
GLContextCGL::IsDoubleBuffered() const
{
return sCGLLibrary.UseDoubleBufferedWindows();
return gUseDoubleBufferedWindows;
}
bool
@ -165,66 +182,26 @@ GLContextCGL::SwapBuffers()
}
static GLContextCGL *
GetGlobalContextCGL()
{
return static_cast<GLContextCGL*>(GLContextProviderCGL::GetGlobalContext());
}
already_AddRefed<GLContext>
GLContextProviderCGL::CreateWrappingExisting(void*, void*)
{
return nullptr;
}
static const NSOpenGLPixelFormatAttribute kAttribs_singleBuffered[] = {
NSOpenGLPFAAccelerated,
NSOpenGLPFAAllowOfflineRenderers,
0
};
static const NSOpenGLPixelFormatAttribute kAttribs_doubleBuffered[] = {
NSOpenGLPFAAccelerated,
NSOpenGLPFAAllowOfflineRenderers,
NSOpenGLPFADoubleBuffer,
0
};
static const NSOpenGLPixelFormatAttribute kAttribs_offscreen[] = {
NSOpenGLPFAPixelBuffer,
0
};
static const NSOpenGLPixelFormatAttribute kAttribs_offscreen_coreProfile[] = {
NSOpenGLPFAAccelerated,
NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core,
0
};
static NSOpenGLContext*
CreateWithFormat(const NSOpenGLPixelFormatAttribute* attribs)
{
NSOpenGLPixelFormat* format = [[NSOpenGLPixelFormat alloc]
initWithAttributes:attribs];
if (!format)
return nullptr;
NSOpenGLContext* context = [[NSOpenGLContext alloc] initWithFormat:format
shareContext:nullptr];
[format release];
return context;
}
already_AddRefed<GLContext>
GLContextProviderCGL::CreateForWindow(nsIWidget *aWidget)
{
if (!sCGLLibrary.EnsureInitialized()) {
return nullptr;
}
GLContextCGL *shareContext = GetGlobalContextCGL();
const NSOpenGLPixelFormatAttribute* attribs;
if (sCGLLibrary.UseDoubleBufferedWindows()) {
attribs = kAttribs_doubleBuffered;
} else {
attribs = kAttribs_singleBuffered;
}
NSOpenGLContext* context = CreateWithFormat(attribs);
NSOpenGLContext *context = [[NSOpenGLContext alloc]
initWithFormat:sCGLLibrary.PixelFormat()
shareContext:(shareContext ? shareContext->mContext : NULL)];
if (!context) {
return nullptr;
}
@ -234,13 +211,10 @@ GLContextProviderCGL::CreateForWindow(nsIWidget *aWidget)
[context setValues:&opaque forParameter:NSOpenGLCPSurfaceOpacity];
SurfaceCaps caps = SurfaceCaps::ForRGBA();
ContextProfile profile = ContextProfile::OpenGLCompatibility;
nsRefPtr<GLContextCGL> glContext = new GLContextCGL(caps, context, false,
profile);
nsRefPtr<GLContextCGL> glContext = new GLContextCGL(caps,
shareContext,
context);
if (!glContext->Init()) {
glContext = nullptr;
[context release];
return nullptr;
}
@ -248,54 +222,49 @@ GLContextProviderCGL::CreateForWindow(nsIWidget *aWidget)
}
static already_AddRefed<GLContextCGL>
CreateOffscreenFBOContext(bool requireCompatProfile)
CreateOffscreenFBOContext(bool aShare = true)
{
if (!sCGLLibrary.EnsureInitialized()) {
return nullptr;
}
ContextProfile profile;
NSOpenGLContext* context = nullptr;
GLContextCGL *shareContext = aShare ? GetGlobalContextCGL() : nullptr;
if (aShare && !shareContext) {
// if there is no share context, then we can't use FBOs.
return nullptr;
}
if (!requireCompatProfile) {
profile = ContextProfile::OpenGLCore;
context = CreateWithFormat(kAttribs_offscreen_coreProfile);
}
if (!context) {
profile = ContextProfile::OpenGLCompatibility;
context = CreateWithFormat(kAttribs_offscreen);
}
NSOpenGLContext *context = [[NSOpenGLContext alloc]
initWithFormat:sCGLLibrary.PixelFormat()
shareContext:shareContext ? shareContext->GetNSOpenGLContext() : NULL];
if (!context) {
return nullptr;
}
SurfaceCaps dummyCaps = SurfaceCaps::Any();
nsRefPtr<GLContextCGL> glContext = new GLContextCGL(dummyCaps, context,
true, profile);
nsRefPtr<GLContextCGL> glContext = new GLContextCGL(dummyCaps, shareContext, context, true);
return glContext.forget();
}
already_AddRefed<GLContext>
GLContextProviderCGL::CreateHeadless(bool requireCompatProfile)
GLContextProviderCGL::CreateHeadless()
{
nsRefPtr<GLContextCGL> gl;
gl = CreateOffscreenFBOContext(requireCompatProfile);
if (!gl)
nsRefPtr<GLContextCGL> glContext = CreateOffscreenFBOContext();
if (!glContext)
return nullptr;
if (!gl->Init())
if (!glContext->Init())
return nullptr;
return gl.forget();
return glContext.forget();
}
already_AddRefed<GLContext>
GLContextProviderCGL::CreateOffscreen(const gfxIntSize& size,
const SurfaceCaps& caps,
bool requireCompatProfile)
const SurfaceCaps& caps)
{
nsRefPtr<GLContext> glContext = CreateHeadless(requireCompatProfile);
nsRefPtr<GLContext> glContext = CreateHeadless();
if (!glContext->InitOffscreen(ToIntSize(size), caps))
return nullptr;
@ -330,7 +299,7 @@ GLContextProviderCGL::GetGlobalContext()
void
GLContextProviderCGL::Shutdown()
{
gGlobalContext = nullptr;
gGlobalContext = nullptr;
}
} /* namespace gl */

View File

@ -878,7 +878,7 @@ GLContextEGL::CreateEGLPixmapOffscreenContext(const gfxIntSize& size)
}
already_AddRefed<GLContext>
GLContextProviderEGL::CreateHeadless(bool)
GLContextProviderEGL::CreateHeadless()
{
if (!sEGLLibrary.EnsureInitialized()) {
return nullptr;
@ -897,10 +897,9 @@ GLContextProviderEGL::CreateHeadless(bool)
// often without the ability to texture from them directly.
already_AddRefed<GLContext>
GLContextProviderEGL::CreateOffscreen(const gfxIntSize& size,
const SurfaceCaps& caps,
bool requireCompatProfile)
const SurfaceCaps& caps)
{
nsRefPtr<GLContext> glContext = CreateHeadless(requireCompatProfile);
nsRefPtr<GLContext> glContext = CreateHeadless();
if (!glContext)
return nullptr;

View File

@ -1213,7 +1213,7 @@ DONE_CREATING_PIXMAP:
}
already_AddRefed<GLContext>
GLContextProviderGLX::CreateHeadless(bool)
GLContextProviderGLX::CreateHeadless()
{
gfxIntSize dummySize = gfxIntSize(16, 16);
nsRefPtr<GLContext> glContext = CreateOffscreenPixmapContext(dummySize);
@ -1225,10 +1225,9 @@ GLContextProviderGLX::CreateHeadless(bool)
already_AddRefed<GLContext>
GLContextProviderGLX::CreateOffscreen(const gfxIntSize& size,
const SurfaceCaps& caps,
bool requireCompatProfile)
const SurfaceCaps& caps)
{
nsRefPtr<GLContext> glContext = CreateHeadless(requireCompatProfile);
nsRefPtr<GLContext> glContext = CreateHeadless();
if (!glContext)
return nullptr;

View File

@ -58,12 +58,11 @@ public:
*/
static already_AddRefed<GLContext>
CreateOffscreen(const gfxIntSize& size,
const SurfaceCaps& caps,
bool requireCompatProfile);
const SurfaceCaps& caps);
// Just create a context. We'll add offscreen stuff ourselves.
static already_AddRefed<GLContext>
CreateHeadless(bool requireCompatProfile);
CreateHeadless();
/**
* Create wrapping Gecko GLContext for external gl context.

View File

@ -22,14 +22,13 @@ GLContextProviderNull::CreateWrappingExisting(void*, void*)
already_AddRefed<GLContext>
GLContextProviderNull::CreateOffscreen(const gfxIntSize&,
const SurfaceCaps&,
bool)
const SurfaceCaps&)
{
return nullptr;
}
already_AddRefed<GLContext>
GLContextProviderNull::CreateHeadless(bool)
GLContextProviderNull::CreateHeadless()
{
return nullptr;
}

View File

@ -607,7 +607,7 @@ CreateWindowOffscreenContext()
}
already_AddRefed<GLContext>
GLContextProviderWGL::CreateHeadless(bool)
GLContextProviderWGL::CreateHeadless()
{
if (!sWGLLib.EnsureInitialized()) {
return nullptr;
@ -641,10 +641,9 @@ GLContextProviderWGL::CreateHeadless(bool)
already_AddRefed<GLContext>
GLContextProviderWGL::CreateOffscreen(const gfxIntSize& size,
const SurfaceCaps& caps,
bool requireCompatProfile)
const SurfaceCaps& caps)
{
nsRefPtr<GLContext> glContext = CreateHeadless(requireCompatProfile);
nsRefPtr<GLContext> glContext = CreateHeadless();
if (!glContext)
return nullptr;

View File

@ -666,10 +666,6 @@ struct GLContextSymbols
GLsizei width, GLsizei height, GLsizei depth,
GLenum format, GLsizei imageSize, const GLvoid* data);
PFNGLCOMPRESSEDTEXSUBIMAGE3D fCompressedTexSubImage3D;
// get_string_indexed
typedef const GLubyte* (GLAPIENTRY * pfnGLGetStringiT)(GLenum name, GLuint index);
pfnGLGetStringiT fGetStringi;
};
}

View File

@ -12,3 +12,8 @@ GLFormats::GLFormats()
{
std::memset(this, 0, sizeof(GLFormats));
}
PixelBufferFormat::PixelBufferFormat()
{
std::memset(this, 0, sizeof(PixelBufferFormat));
}

View File

@ -43,6 +43,19 @@ struct GLFormats
GLsizei samples;
};
struct PixelBufferFormat
{
// Constructs a zeroed object:
PixelBufferFormat();
int red, green, blue;
int alpha;
int depth, stencil;
int samples;
int ColorBits() const { return red + green + blue; }
};
} /* namespace gl */
} /* namespace mozilla */

View File

@ -35,7 +35,8 @@ static const char *sEGLExtensionNames[] = {
"EGL_EXT_create_context_robustness",
"EGL_KHR_image",
"EGL_KHR_fence_sync",
"EGL_ANDROID_native_fence_sync"
"EGL_ANDROID_native_fence_sync",
nullptr
};
#if defined(ANDROID)
@ -420,23 +421,15 @@ GLLibraryEGL::EnsureInitialized()
void
GLLibraryEGL::InitExtensions()
{
const char* rawExts = (const char*)fQueryString(mEGLDisplay,
LOCAL_EGL_EXTENSIONS);
if (rawExts) {
nsDependentCString exts(rawExts);
SplitByChar(exts, ' ', &mDriverExtensionList);
} else {
const char *extensions = (const char*)fQueryString(mEGLDisplay, LOCAL_EGL_EXTENSIONS);
if (!extensions) {
NS_WARNING("Failed to load EGL extension list!");
return;
}
const bool shouldDumpExts = GLContext::ShouldDumpExts();
if (shouldDumpExts) {
printf_stderr("%i EGL driver extensions:\n",
(uint32_t)mDriverExtensionList.size());
}
MarkBitfieldByStrings(mDriverExtensionList, shouldDumpExts,
sEGLExtensionNames, mAvailableExtensions);
GLContext::InitializeExtensionsBitSet(mAvailableExtensions, extensions,
sEGLExtensionNames);
}
void

View File

@ -15,7 +15,6 @@
#include "GeckoProfiler.h"
#include <bitset>
#include <vector>
#if defined(XP_WIN)
@ -143,7 +142,6 @@ public:
}
protected:
std::vector<nsACString*> mDriverExtensionList;
std::bitset<Extensions_Max> mAvailableExtensions;
public:

View File

@ -39,7 +39,7 @@ GLImage::GetAsSourceSurface()
MOZ_ASSERT(NS_IsMainThread(), "Should be on the main thread");
if (!sSnapshotContext) {
sSnapshotContext = GLContextProvider::CreateHeadless(false);
sSnapshotContext = GLContextProvider::CreateHeadless();
if (!sSnapshotContext) {
NS_WARNING("Failed to create snapshot GLContext");
return nullptr;

View File

@ -124,11 +124,8 @@ CompositorOGL::CreateContext()
SurfaceCaps caps = SurfaceCaps::ForRGB();
caps.preserve = false;
caps.bpp16 = gfxPlatform::GetPlatform()->GetOffscreenFormat() == gfxImageFormat::RGB16_565;
bool requireCompatProfile = true;
context = GLContextProvider::CreateOffscreen(gfxIntSize(mSurfaceSize.width,
mSurfaceSize.height),
caps, requireCompatProfile);
mSurfaceSize.height), caps);
}
if (!context)

View File

@ -45,7 +45,7 @@ public:
caps.preserve = false;
caps.bpp16 = false;
nsRefPtr<GLContext> context = GLContextProvider::CreateOffscreen(
gfxIntSize(gCompWidth, gCompHeight), caps, true);
gfxIntSize(gCompWidth, gCompHeight), caps);
return context.forget().take();
}
return nullptr;

View File

@ -1099,9 +1099,8 @@ gfxPlatform::GetSkiaGLGlue()
* FIXME: This should be stored in TLS or something, since there needs to be one for each thread using it. As it
* stands, this only works on the main thread.
*/
bool requireCompatProfile = true;
nsRefPtr<mozilla::gl::GLContext> glContext;
glContext = mozilla::gl::GLContextProvider::CreateHeadless(requireCompatProfile);
mozilla::gl::SurfaceCaps caps = mozilla::gl::SurfaceCaps::ForRGBA();
nsRefPtr<mozilla::gl::GLContext> glContext = mozilla::gl::GLContextProvider::CreateOffscreen(gfxIntSize(16, 16), caps);
if (!glContext) {
printf_stderr("Failed to create GLContext for SkiaGL!\n");
return nullptr;

View File

@ -72,8 +72,8 @@ public:
}
nsRefPtr<gl::GLContext> gl;
bool requireCompatProfile = true;
gl = gl::GLContextProvider::CreateHeadless(requireCompatProfile);
gl = gl::GLContextProvider::CreateOffscreen(gfxIntSize(16, 16),
gl::SurfaceCaps::ForRGB());
if (!gl) {
// Setting mReady to true here means that we won't retry. Everything will