Bug 733562 - Offscreen FBO must not be created for Global Shared context. r=bjacob

This commit is contained in:
Oleg Romashin 2012-03-20 12:23:14 +01:00
parent c0c565c036
commit 24dca68145
8 changed files with 25 additions and 11 deletions

View File

@ -571,6 +571,11 @@ public:
#endif
}
enum ContextFlags {
ContextFlagsNone = 0x0,
ContextFlagsGlobal = 0x1
};
enum GLContextType {
ContextTypeUnknown,
ContextTypeWGL,

View File

@ -590,7 +590,8 @@ CreateOffscreenFBOContext(const ContextFormat& aFormat,
already_AddRefed<GLContext>
GLContextProviderCGL::CreateOffscreen(const gfxIntSize& aSize,
const ContextFormat& aFormat)
const ContextFormat& aFormat,
const ContextFlags flags)
{
ContextFormat actualFormat(aFormat);

View File

@ -1898,7 +1898,8 @@ GLContextEGL::CreateEGLPixmapOffscreenContext(const gfxIntSize& aSize,
// often without the ability to texture from them directly.
already_AddRefed<GLContext>
GLContextProviderEGL::CreateOffscreen(const gfxIntSize& aSize,
const ContextFormat& aFormat)
const ContextFormat& aFormat,
const ContextFlags aFlags)
{
if (!sEGLLibrary.EnsureInitialized()) {
return nsnull;
@ -1918,7 +1919,7 @@ GLContextProviderEGL::CreateOffscreen(const gfxIntSize& aSize,
return nsnull;
gfxIntSize fboSize = usePBuffers ? glContext->OffscreenActualSize() : aSize;
if (!glContext->ResizeOffscreenFBO(fboSize, !usePBuffers))
if (!(aFlags & ContextFlagsGlobal) && !glContext->ResizeOffscreenFBO(fboSize, !usePBuffers))
return nsnull;
return glContext.forget();
@ -1929,7 +1930,7 @@ GLContextProviderEGL::CreateOffscreen(const gfxIntSize& aSize,
if (!glContext)
return nsnull;
if (!glContext->ResizeOffscreenFBO(glContext->OffscreenActualSize(), true))
if (!(aFlags & ContextFlagsGlobal) && !glContext->ResizeOffscreenFBO(glContext->OffscreenActualSize(), true))
return nsnull;
return glContext.forget();
@ -1941,7 +1942,7 @@ GLContextProviderEGL::CreateOffscreen(const gfxIntSize& aSize,
return nsnull;
}
if (!gUseBackingSurface && !glContext->ResizeOffscreenFBO(glContext->OffscreenActualSize(), true)) {
if (!(aFlags & ContextFlagsGlobal) && !gUseBackingSurface && !glContext->ResizeOffscreenFBO(glContext->OffscreenActualSize(), true)) {
// we weren't able to create the initial
// offscreen FBO, so this is dead
return nsnull;
@ -2000,7 +2001,8 @@ GLContextProviderEGL::GetGlobalContext()
// CreateOffscreen can call us re-entrantly.
nsRefPtr<GLContext> ctx =
GLContextProviderEGL::CreateOffscreen(gfxIntSize(16, 16),
ContextFormat(ContextFormat::BasicRGB24));
ContextFormat(ContextFormat::BasicRGB24),
GLContext::ContextFlagsGlobal);
gGlobalContext = ctx;
if (gGlobalContext)
gGlobalContext->SetIsGlobalSharedContext(true);

View File

@ -1292,7 +1292,8 @@ DONE_CREATING_PIXMAP:
already_AddRefed<GLContext>
GLContextProviderGLX::CreateOffscreen(const gfxIntSize& aSize,
const ContextFormat& aFormat)
const ContextFormat& aFormat,
const ContextFlags)
{
nsRefPtr<GLContextGLX> glContext =
CreateOffscreenPixmapContext(aSize, aFormat, true);

View File

@ -45,6 +45,7 @@
class THEBES_API GL_CONTEXT_PROVIDER_NAME
{
public:
typedef GLContext::ContextFlags ContextFlags;
/**
* Create a context that renders to the surface of the widget that is
* passed in. The context is always created with an RGB pixel format,
@ -90,7 +91,8 @@ public:
*/
static already_AddRefed<GLContext>
CreateOffscreen(const gfxIntSize& aSize,
const ContextFormat& aFormat = ContextFormat::BasicRGBA32Format);
const ContextFormat& aFormat = ContextFormat::BasicRGBA32Format,
const ContextFlags aFlags = GLContext::ContextFlagsNone);
/**
* Try to create a GL context from native surface for arbitrary gfxASurface

View File

@ -46,7 +46,8 @@ GLContextProviderNull::CreateForWindow(nsIWidget*)
already_AddRefed<GLContext>
GLContextProviderNull::CreateOffscreen(const gfxIntSize&,
const ContextFormat&)
const ContextFormat&,
const ContextFlags)
{
return nsnull;
}

View File

@ -259,7 +259,8 @@ GLContextProviderOSMesa::CreateForWindow(nsIWidget *aWidget)
already_AddRefed<GLContext>
GLContextProviderOSMesa::CreateOffscreen(const gfxIntSize& aSize,
const ContextFormat& aFormat)
const ContextFormat& aFormat,
const ContextFlags)
{
if (!sOSMesaLibrary.EnsureInitialized()) {
return nsnull;

View File

@ -751,7 +751,8 @@ CreateWindowOffscreenContext(const ContextFormat& aFormat)
already_AddRefed<GLContext>
GLContextProviderWGL::CreateOffscreen(const gfxIntSize& aSize,
const ContextFormat& aFormat)
const ContextFormat& aFormat,
const ContextFlags)
{
if (!sWGLLibrary.EnsureInitialized()) {
return nsnull;