Fixes for support for multisampled Mac/CGL GLContexts

This commit is contained in:
Jeff Gilbert 2011-10-19 15:09:57 -04:00
Родитель ef36f1acc5
Коммит 80c22fa28a
1 изменённых файлов: 15 добавлений и 9 удалений

Просмотреть файл

@ -278,6 +278,10 @@ GLContextCGL::ResizeOffscreen(const gfxIntSize& aNewSize)
return false;
}
if (!ResizeOffscreenFBO(aNewSize, false)) {
return false;
}
[mPBuffer release];
mPBuffer = pb;
@ -293,7 +297,7 @@ GLContextCGL::ResizeOffscreen(const gfxIntSize& aNewSize)
return true;
}
return ResizeOffscreenFBO(aNewSize);
return ResizeOffscreenFBO(aNewSize, true);
}
class TextureImageCGL : public BasicTextureImage
@ -532,8 +536,7 @@ CreateOffscreenPBufferContext(const gfxIntSize& aSize,
}
static already_AddRefed<GLContextCGL>
CreateOffscreenFBOContext(const gfxIntSize& aSize,
const ContextFormat& aFormat,
CreateOffscreenFBOContext(const ContextFormat& aFormat,
bool aShare = true)
{
if (!sCGLLibrary.EnsureInitialized()) {
@ -561,15 +564,19 @@ already_AddRefed<GLContext>
GLContextProviderCGL::CreateOffscreen(const gfxIntSize& aSize,
const ContextFormat& aFormat)
{
ContextFormat actualFormat(aFormat);
actualFormat.samples = 0;
nsRefPtr<GLContextCGL> glContext;
NS_ENSURE_TRUE(Preferences::GetRootBranch(), nsnull);
const bool preferFBOs = Preferences::GetBool("cgl.prefer-fbo", false);
if (!preferFBOs)
{
glContext = CreateOffscreenPBufferContext(aSize, aFormat);
glContext = CreateOffscreenPBufferContext(aSize, actualFormat);
if (glContext &&
glContext->Init())
glContext->Init() &&
glContext->ResizeOffscreenFBO(aSize, false))
{
glContext->mOffscreenSize = aSize;
glContext->mOffscreenActualSize = aSize;
@ -581,10 +588,10 @@ GLContextProviderCGL::CreateOffscreen(const gfxIntSize& aSize,
}
// try a FBO as second choice
glContext = CreateOffscreenFBOContext(aSize, aFormat);
glContext = CreateOffscreenFBOContext(actualFormat);
if (glContext &&
glContext->Init() &&
glContext->ResizeOffscreenFBO(aSize))
glContext->ResizeOffscreenFBO(aSize, true))
{
return glContext.forget();
}
@ -613,8 +620,7 @@ GLContextProviderCGL::GetGlobalContext()
// than 16x16 in size; also 16x16 is POT so that we can do
// a FBO with it on older video cards. A FBO context for
// sharing is preferred since it has no associated target.
gGlobalContext = CreateOffscreenFBOContext(gfxIntSize(16, 16),
ContextFormat(ContextFormat::BasicRGB24),
gGlobalContext = CreateOffscreenFBOContext(ContextFormat(ContextFormat::BasicRGB24),
false);
if (!gGlobalContext || !static_cast<GLContextCGL*>(gGlobalContext.get())->Init()) {
NS_WARNING("Couldn't init gGlobalContext.");