Bug 748694 - Switch Maemo WebGL to FBO. r=jgilbert,bgirard

This commit is contained in:
Oleg Romashin 2012-04-30 17:03:08 -07:00
Родитель 5932dbcb76
Коммит dfdca5c416
1 изменённых файлов: 8 добавлений и 50 удалений

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

@ -181,7 +181,7 @@ CreateBasicEGLSurfaceForXSurface(gfxASurface* aSurface, EGLConfig* aConfig);
#endif
static EGLConfig
CreateEGLSurfaceForXSurface(gfxASurface* aSurface, EGLConfig* aConfig = nsnull, EGLenum aDepth = 0);
CreateEGLSurfaceForXSurface(gfxASurface* aSurface, EGLConfig* aConfig = nsnull);
#endif
static EGLint gContextAttribs[] = {
@ -744,45 +744,6 @@ GLContextEGL::ResizeOffscreen(const gfxIntSize& aNewSize)
return true;
}
#ifdef MOZ_X11
if (gUseBackingSurface && mThebesSurface) {
if (aNewSize == mThebesSurface->GetSize()) {
return true;
}
EGLNativePixmapType pixmap = 0;
nsRefPtr<gfxXlibSurface> xsurface =
gfxXlibSurface::Create(DefaultScreenOfDisplay(DefaultXDisplay()),
gfxXlibSurface::FindRenderFormat(DefaultXDisplay(),
gfxASurface::ImageFormatRGB24),
aNewSize);
// Make sure that pixmap created and ready for GL rendering
XSync(DefaultXDisplay(), False);
if (xsurface->CairoStatus() != 0) {
return false;
}
pixmap = (EGLNativePixmapType)xsurface->XDrawable();
if (!pixmap) {
return false;
}
EGLSurface surface;
EGLConfig config = 0;
int depth = gfxUtils::ImageFormatToDepth(gfxPlatform::GetPlatform()->GetOffscreenFormat());
surface = CreateEGLSurfaceForXSurface(xsurface, &config, depth);
if (!config) {
return false;
}
if (!ResizeOffscreenFBOs(aNewSize, true))
return false;
mThebesSurface = xsurface;
return true;
}
#endif
#if defined(MOZ_X11) && defined(MOZ_EGL_XRENDER_COMPOSITE)
if (ResizeOffscreenPixmapSurface(aNewSize)) {
if (ResizeOffscreenFBOs(aNewSize, true))
@ -1788,7 +1749,7 @@ TRY_ATTRIBS_AGAIN:
#ifdef MOZ_X11
EGLSurface
CreateEGLSurfaceForXSurface(gfxASurface* aSurface, EGLConfig* aConfig, EGLenum aDepth)
CreateEGLSurfaceForXSurface(gfxASurface* aSurface, EGLConfig* aConfig)
{
gfxXlibSurface* xsurface = static_cast<gfxXlibSurface*>(aSurface);
bool opaque =
@ -1827,7 +1788,7 @@ CreateEGLSurfaceForXSurface(gfxASurface* aSurface, EGLConfig* aConfig, EGLenum a
static EGLint pixmap_config[] = {
LOCAL_EGL_SURFACE_TYPE, LOCAL_EGL_PIXMAP_BIT,
LOCAL_EGL_RENDERABLE_TYPE, LOCAL_EGL_OPENGL_ES2_BIT,
LOCAL_EGL_DEPTH_SIZE, aDepth,
LOCAL_EGL_DEPTH_SIZE, 0,
LOCAL_EGL_BIND_TO_TEXTURE_RGB, LOCAL_EGL_TRUE,
LOCAL_EGL_NONE
};
@ -1835,7 +1796,7 @@ CreateEGLSurfaceForXSurface(gfxASurface* aSurface, EGLConfig* aConfig, EGLenum a
static EGLint pixmap_lock_config[] = {
LOCAL_EGL_SURFACE_TYPE, LOCAL_EGL_PIXMAP_BIT | LOCAL_EGL_LOCK_SURFACE_BIT_KHR,
LOCAL_EGL_RENDERABLE_TYPE, LOCAL_EGL_OPENGL_ES2_BIT,
LOCAL_EGL_DEPTH_SIZE, aDepth,
LOCAL_EGL_DEPTH_SIZE, 0,
LOCAL_EGL_BIND_TO_TEXTURE_RGB, LOCAL_EGL_TRUE,
LOCAL_EGL_NONE
};
@ -1888,7 +1849,7 @@ GLContextEGL::CreateEGLPixmapOffscreenContext(const gfxIntSize& aSize,
gfxXlibSurface::Create(DefaultScreenOfDisplay(DefaultXDisplay()),
gfxXlibSurface::FindRenderFormat(DefaultXDisplay(),
gfxASurface::ImageFormatRGB24),
gUseBackingSurface ? aSize : gfxIntSize(16, 16));
aSize);
// XSync required after gfxXlibSurface::Create, otherwise EGL will fail with BadDrawable error
XSync(DefaultXDisplay(), False);
@ -1907,8 +1868,7 @@ GLContextEGL::CreateEGLPixmapOffscreenContext(const gfxIntSize& aSize,
EGLConfig config = 0;
#ifdef MOZ_X11
int depth = gfxUtils::ImageFormatToDepth(gfxPlatform::GetPlatform()->GetOffscreenFormat());
surface = CreateEGLSurfaceForXSurface(thebesSurface, &config, gUseBackingSurface ? depth : 0);
surface = CreateEGLSurfaceForXSurface(thebesSurface, &config);
#endif
if (!config) {
return nsnull;
@ -1925,8 +1885,6 @@ GLContextEGL::CreateEGLPixmapOffscreenContext(const gfxIntSize& aSize,
glContext->HoldSurface(thebesSurface);
glContext->mCanBindToTexture = true;
return glContext.forget();
}
@ -1974,13 +1932,13 @@ GLContextProviderEGL::CreateOffscreen(const gfxIntSize& aSize,
return glContext.forget();
#elif defined(MOZ_X11)
nsRefPtr<GLContextEGL> glContext =
GLContextEGL::CreateEGLPixmapOffscreenContext(aSize, aFormat, true);
GLContextEGL::CreateEGLPixmapOffscreenContext(gfxIntSize(16, 16), aFormat, true);
if (!glContext) {
return nsnull;
}
if (!(aFlags & GLContext::ContextFlagsGlobal) && !gUseBackingSurface && !glContext->ResizeOffscreenFBOs(glContext->OffscreenActualSize(), true)) {
if (!(aFlags & GLContext::ContextFlagsGlobal) && !glContext->ResizeOffscreenFBO(aSize, true)) {
// we weren't able to create the initial
// offscreen FBO, so this is dead
return nsnull;