Back out Jeff's patches because they lack a Bug number and/or a r= field. Sorry, should have checked that. Re-landing.
This commit is contained in:
@@ -527,14 +527,14 @@ WebGLContext::SetDimensions(PRInt32 width, PRInt32 height)
|
|||||||
height = 1;
|
height = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we already have a gl context, then we just need to resize it
|
// If we already have a gl context, then we just need to resize
|
||||||
if (gl) {
|
// FB0.
|
||||||
gl->ResizeOffscreen(gfxIntSize(width, height)); // Doesn't matter if it succeeds (soft-fail)
|
if (gl &&
|
||||||
// It's unlikely that we'll get a proper-sized context if we recreate if we didn't on resize
|
gl->ResizeOffscreen(gfxIntSize(width, height)))
|
||||||
|
{
|
||||||
// everything's good, we're done here
|
// everything's good, we're done here
|
||||||
mWidth = gl->OffscreenActualSize().width;
|
mWidth = width;
|
||||||
mHeight = gl->OffscreenActualSize().height;
|
mHeight = height;
|
||||||
mResetLayer = true;
|
mResetLayer = true;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
@@ -601,11 +601,6 @@ WebGLContext::SetDimensions(PRInt32 width, PRInt32 height)
|
|||||||
format.minAlpha = 0;
|
format.minAlpha = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mOptions.antialias) {
|
|
||||||
PRUint32 msaaLevel = Preferences::GetUint("webgl.msaa-level", 2);
|
|
||||||
format.samples = msaaLevel*msaaLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PR_GetEnv("MOZ_WEBGL_PREFER_EGL")) {
|
if (PR_GetEnv("MOZ_WEBGL_PREFER_EGL")) {
|
||||||
preferEGL = true;
|
preferEGL = true;
|
||||||
}
|
}
|
||||||
@@ -903,7 +898,7 @@ WebGLContext::GetContextAttributes(jsval *aResult)
|
|||||||
NULL, NULL, JSPROP_ENUMERATE) ||
|
NULL, NULL, JSPROP_ENUMERATE) ||
|
||||||
!JS_DefineProperty(cx, obj, "stencil", cf.stencil > 0 ? JSVAL_TRUE : JSVAL_FALSE,
|
!JS_DefineProperty(cx, obj, "stencil", cf.stencil > 0 ? JSVAL_TRUE : JSVAL_FALSE,
|
||||||
NULL, NULL, JSPROP_ENUMERATE) ||
|
NULL, NULL, JSPROP_ENUMERATE) ||
|
||||||
!JS_DefineProperty(cx, obj, "antialias", cf.samples > 0 ? JSVAL_TRUE : JSVAL_FALSE,
|
!JS_DefineProperty(cx, obj, "antialias", JSVAL_FALSE,
|
||||||
NULL, NULL, JSPROP_ENUMERATE) ||
|
NULL, NULL, JSPROP_ENUMERATE) ||
|
||||||
!JS_DefineProperty(cx, obj, "premultipliedAlpha",
|
!JS_DefineProperty(cx, obj, "premultipliedAlpha",
|
||||||
mOptions.premultipliedAlpha ? JSVAL_TRUE : JSVAL_FALSE,
|
mOptions.premultipliedAlpha ? JSVAL_TRUE : JSVAL_FALSE,
|
||||||
|
|||||||
@@ -310,7 +310,7 @@ struct WebGLContextOptions {
|
|||||||
// these are defaults
|
// these are defaults
|
||||||
WebGLContextOptions()
|
WebGLContextOptions()
|
||||||
: alpha(true), depth(true), stencil(false),
|
: alpha(true), depth(true), stencil(false),
|
||||||
premultipliedAlpha(true), antialias(true),
|
premultipliedAlpha(true), antialias(false),
|
||||||
preserveDrawingBuffer(false)
|
preserveDrawingBuffer(false)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
conformance/canvas/drawingbuffer-static-canvas-test.html
|
||||||
|
conformance/canvas/drawingbuffer-test.html
|
||||||
conformance/context/premultiplyalpha-test.html
|
conformance/context/premultiplyalpha-test.html
|
||||||
conformance/glsl/misc/glsl-long-variable-names.html
|
conformance/glsl/misc/glsl-long-variable-names.html
|
||||||
conformance/glsl/misc/shader-with-256-character-identifier.frag.html
|
conformance/glsl/misc/shader-with-256-character-identifier.frag.html
|
||||||
@@ -6,6 +8,7 @@ conformance/misc/uninitialized-test.html
|
|||||||
conformance/programs/gl-get-active-attribute.html
|
conformance/programs/gl-get-active-attribute.html
|
||||||
conformance/reading/read-pixels-test.html
|
conformance/reading/read-pixels-test.html
|
||||||
conformance/renderbuffers/framebuffer-object-attachment.html
|
conformance/renderbuffers/framebuffer-object-attachment.html
|
||||||
|
conformance/renderbuffers/renderbuffer-initialization.html
|
||||||
conformance/textures/texture-mips.html
|
conformance/textures/texture-mips.html
|
||||||
conformance/uniforms/gl-uniform-bool.html
|
conformance/uniforms/gl-uniform-bool.html
|
||||||
conformance/more/functions/copyTexImage2D.html
|
conformance/more/functions/copyTexImage2D.html
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
conformance/canvas/buffer-preserve-test.html
|
conformance/canvas/buffer-preserve-test.html
|
||||||
|
conformance/canvas/drawingbuffer-static-canvas-test.html
|
||||||
|
conformance/canvas/drawingbuffer-test.html
|
||||||
conformance/context/context-attributes-alpha-depth-stencil-antialias.html
|
conformance/context/context-attributes-alpha-depth-stencil-antialias.html
|
||||||
conformance/context/premultiplyalpha-test.html
|
conformance/context/premultiplyalpha-test.html
|
||||||
conformance/glsl/misc/glsl-function-nodes.html
|
conformance/glsl/misc/glsl-function-nodes.html
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
conformance/canvas/buffer-preserve-test.html
|
conformance/canvas/buffer-preserve-test.html
|
||||||
|
conformance/canvas/drawingbuffer-static-canvas-test.html
|
||||||
|
conformance/canvas/drawingbuffer-test.html
|
||||||
conformance/context/premultiplyalpha-test.html
|
conformance/context/premultiplyalpha-test.html
|
||||||
conformance/glsl/functions/glsl-function-atan.html
|
conformance/glsl/functions/glsl-function-atan.html
|
||||||
conformance/glsl/functions/glsl-function-atan-xy.html
|
conformance/glsl/functions/glsl-function-atan-xy.html
|
||||||
|
|||||||
@@ -1111,7 +1111,7 @@ BasicCanvasLayer::UpdateSurface(gfxASurface* aDestSurface)
|
|||||||
mGLContext->MakeCurrent();
|
mGLContext->MakeCurrent();
|
||||||
|
|
||||||
#if defined (MOZ_X11) && defined (MOZ_EGL_XRENDER_COMPOSITE)
|
#if defined (MOZ_X11) && defined (MOZ_EGL_XRENDER_COMPOSITE)
|
||||||
mGLContext->Finish();
|
mGLContext->fFinish();
|
||||||
gfxASurface* offscreenSurface = mGLContext->GetOffscreenPixmapSurface();
|
gfxASurface* offscreenSurface = mGLContext->GetOffscreenPixmapSurface();
|
||||||
|
|
||||||
// XRender can only blend premuliplied alpha, so only allow xrender
|
// XRender can only blend premuliplied alpha, so only allow xrender
|
||||||
|
|||||||
@@ -172,10 +172,6 @@ CanvasLayerOGL::UpdateSurface()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (mCanvasGLContext) {
|
|
||||||
mCanvasGLContext->MakeCurrent();
|
|
||||||
mCanvasGLContext->fFinish();
|
|
||||||
}
|
|
||||||
mOGLManager->MakeCurrent();
|
mOGLManager->MakeCurrent();
|
||||||
|
|
||||||
if (mCanvasGLContext &&
|
if (mCanvasGLContext &&
|
||||||
|
|||||||
@@ -377,33 +377,6 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
|
|||||||
(mSymbols.fMapBuffer && mSymbols.fUnmapBuffer),
|
(mSymbols.fMapBuffer && mSymbols.fUnmapBuffer),
|
||||||
"ARB_pixel_buffer_object supported without glMapBuffer/UnmapBuffer being available!");
|
"ARB_pixel_buffer_object supported without glMapBuffer/UnmapBuffer being available!");
|
||||||
|
|
||||||
// Check for aux symbols based on extensions
|
|
||||||
if (IsExtensionSupported(GLContext::ANGLE_framebuffer_blit) ||
|
|
||||||
IsExtensionSupported(GLContext::EXT_framebuffer_blit)) {
|
|
||||||
SymLoadStruct auxSymbols[] = {
|
|
||||||
{ (PRFuncPtr*) &mSymbols.fBlitFramebuffer, { "BlitFramebuffer", "BlitFramebufferEXT", "BlitFramebufferANGLE", NULL } },
|
|
||||||
{ NULL, { NULL } },
|
|
||||||
};
|
|
||||||
if (!LoadSymbols(&auxSymbols[0], trygl, prefix)) {
|
|
||||||
NS_RUNTIMEABORT("GL supports framebuffer_blit without supplying glBlitFramebuffer");
|
|
||||||
mInitialized = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsExtensionSupported(GLContext::ANGLE_framebuffer_multisample) ||
|
|
||||||
IsExtensionSupported(GLContext::EXT_framebuffer_multisample)) {
|
|
||||||
SymLoadStruct auxSymbols[] = {
|
|
||||||
{ (PRFuncPtr*) &mSymbols.fRenderbufferStorageMultisample, { "RenderbufferStorageMultisample", "RenderbufferStorageMultisampleEXT", "RenderbufferStorageMultisampleANGLE", NULL } },
|
|
||||||
{ NULL, { NULL } },
|
|
||||||
};
|
|
||||||
if (!LoadSymbols(&auxSymbols[0], trygl, prefix)) {
|
|
||||||
NS_RUNTIMEABORT("GL supports framebuffer_multisample without supplying glRenderbufferStorageMultisample");
|
|
||||||
mInitialized = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mInitialized) {
|
|
||||||
GLint v[4];
|
GLint v[4];
|
||||||
|
|
||||||
fGetIntegerv(LOCAL_GL_SCISSOR_BOX, v);
|
fGetIntegerv(LOCAL_GL_SCISSOR_BOX, v);
|
||||||
@@ -465,11 +438,6 @@ static const char *sExtensionNames[] = {
|
|||||||
"GL_ARB_texture_float",
|
"GL_ARB_texture_float",
|
||||||
"GL_EXT_unpack_subimage",
|
"GL_EXT_unpack_subimage",
|
||||||
"GL_OES_standard_derivatives",
|
"GL_OES_standard_derivatives",
|
||||||
"GL_EXT_framebuffer_blit",
|
|
||||||
"GL_ANGLE_framebuffer_blit",
|
|
||||||
"GL_EXT_framebuffer_multisample",
|
|
||||||
"GL_ANGLE_framebuffer_multisample",
|
|
||||||
"GL_OES_rgb8_rgba8",
|
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1018,155 +986,107 @@ PRUint32 TiledTextureImage::GetTileCount()
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
GLContext::ResizeOffscreenFBO(const gfxIntSize& aSize, const bool aUseReadFBO, const bool aDisableAA)
|
GLContext::ResizeOffscreenFBO(const gfxIntSize& aSize)
|
||||||
{
|
{
|
||||||
if (!IsOffscreenSizeAllowed(aSize))
|
if (!IsOffscreenSizeAllowed(aSize))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
MakeCurrent();
|
MakeCurrent();
|
||||||
|
|
||||||
const bool alpha = mCreationFormat.alpha > 0;
|
bool alpha = mCreationFormat.alpha > 0;
|
||||||
const int depth = mCreationFormat.depth;
|
int depth = mCreationFormat.depth;
|
||||||
const int stencil = mCreationFormat.stencil;
|
int stencil = mCreationFormat.stencil;
|
||||||
int samples = mCreationFormat.samples;
|
|
||||||
|
|
||||||
const bool useDrawMSFBO = (samples > 0) && SupportsFramebufferMultisample();
|
bool firstTime = (mOffscreenFBO == 0);
|
||||||
|
|
||||||
if (!useDrawMSFBO && !aUseReadFBO)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (!useDrawMSFBO || aDisableAA)
|
|
||||||
samples = 0;
|
|
||||||
|
|
||||||
const bool firstTime = (mOffscreenDrawFBO == 0 && mOffscreenReadFBO == 0);
|
|
||||||
|
|
||||||
GLuint curBoundFramebufferDraw = 0;
|
|
||||||
GLuint curBoundFramebufferRead = 0;
|
|
||||||
GLuint curBoundRenderbuffer = 0;
|
|
||||||
GLuint curBoundTexture = 0;
|
GLuint curBoundTexture = 0;
|
||||||
|
GLuint curBoundRenderbuffer = 0;
|
||||||
|
GLuint curBoundFramebuffer = 0;
|
||||||
|
|
||||||
GLint viewport[4];
|
GLint viewport[4];
|
||||||
|
|
||||||
const bool useDepthStencil =
|
bool useDepthStencil =
|
||||||
!mIsGLES2 || IsExtensionSupported(OES_packed_depth_stencil);
|
!mIsGLES2 || IsExtensionSupported(OES_packed_depth_stencil);
|
||||||
|
|
||||||
// save a few things for later restoring
|
// save a few things for later restoring
|
||||||
curBoundFramebufferDraw = GetBoundDrawFBO();
|
|
||||||
curBoundFramebufferRead = GetBoundReadFBO();
|
|
||||||
fGetIntegerv(LOCAL_GL_RENDERBUFFER_BINDING, (GLint*) &curBoundRenderbuffer);
|
|
||||||
fGetIntegerv(LOCAL_GL_TEXTURE_BINDING_2D, (GLint*) &curBoundTexture);
|
fGetIntegerv(LOCAL_GL_TEXTURE_BINDING_2D, (GLint*) &curBoundTexture);
|
||||||
|
fGetIntegerv(LOCAL_GL_FRAMEBUFFER_BINDING, (GLint*) &curBoundFramebuffer);
|
||||||
|
fGetIntegerv(LOCAL_GL_RENDERBUFFER_BINDING, (GLint*) &curBoundRenderbuffer);
|
||||||
fGetIntegerv(LOCAL_GL_VIEWPORT, viewport);
|
fGetIntegerv(LOCAL_GL_VIEWPORT, viewport);
|
||||||
|
|
||||||
// the context format of what we're defining
|
// the context format of what we're defining;
|
||||||
// This becomes mActualFormat on success
|
// for some reason, UpdateActualFormat isn't working with a bound FBO.
|
||||||
ContextFormat cf(mCreationFormat);
|
ContextFormat cf;
|
||||||
|
|
||||||
// Create everything we need for the resize, so if it fails, we haven't broken anything
|
// If this is the first time we're going through this, we need
|
||||||
// If successful, these new resized objects will replace their associated member vars in GLContext
|
// to create the objects we'll use. Otherwise, just bind them.
|
||||||
GLuint newOffscreenDrawFBO = 0;
|
if (firstTime) {
|
||||||
GLuint newOffscreenReadFBO = 0;
|
fGenTextures(1, &mOffscreenTexture);
|
||||||
GLuint newOffscreenTexture = 0;
|
fBindTexture(LOCAL_GL_TEXTURE_2D, mOffscreenTexture);
|
||||||
GLuint newOffscreenColorRB = 0;
|
|
||||||
GLuint newOffscreenDepthRB = 0;
|
|
||||||
GLuint newOffscreenStencilRB = 0;
|
|
||||||
|
|
||||||
// Create the buffers and texture
|
|
||||||
if (aUseReadFBO) {
|
|
||||||
fGenFramebuffers(1, &newOffscreenReadFBO);
|
|
||||||
fGenTextures(1, &newOffscreenTexture);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (useDrawMSFBO) {
|
|
||||||
fGenFramebuffers(1, &newOffscreenDrawFBO);
|
|
||||||
fGenRenderbuffers(1, &newOffscreenColorRB);
|
|
||||||
} else {
|
|
||||||
newOffscreenDrawFBO = newOffscreenReadFBO;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (depth && stencil && useDepthStencil) {
|
|
||||||
fGenRenderbuffers(1, &newOffscreenDepthRB);
|
|
||||||
} else {
|
|
||||||
if (depth) {
|
|
||||||
fGenRenderbuffers(1, &newOffscreenDepthRB);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stencil) {
|
|
||||||
fGenRenderbuffers(1, &newOffscreenStencilRB);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Allocate texture
|
|
||||||
if (aUseReadFBO) {
|
|
||||||
fBindTexture(LOCAL_GL_TEXTURE_2D, newOffscreenTexture);
|
|
||||||
fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MIN_FILTER, LOCAL_GL_LINEAR);
|
fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MIN_FILTER, LOCAL_GL_LINEAR);
|
||||||
fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MAG_FILTER, LOCAL_GL_LINEAR);
|
fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MAG_FILTER, LOCAL_GL_LINEAR);
|
||||||
|
|
||||||
if (alpha) {
|
fGenFramebuffers(1, &mOffscreenFBO);
|
||||||
fTexImage2D(LOCAL_GL_TEXTURE_2D,
|
fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, mOffscreenFBO);
|
||||||
0,
|
|
||||||
LOCAL_GL_RGBA,
|
|
||||||
aSize.width, aSize.height,
|
|
||||||
0,
|
|
||||||
LOCAL_GL_RGBA,
|
|
||||||
LOCAL_GL_UNSIGNED_BYTE,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
cf.red = cf.green = cf.blue = cf.alpha = 8;
|
if (depth && stencil && useDepthStencil) {
|
||||||
|
fGenRenderbuffers(1, &mOffscreenDepthRB);
|
||||||
} else {
|
} else {
|
||||||
fTexImage2D(LOCAL_GL_TEXTURE_2D,
|
if (depth) {
|
||||||
0,
|
fGenRenderbuffers(1, &mOffscreenDepthRB);
|
||||||
LOCAL_GL_RGB,
|
}
|
||||||
aSize.width, aSize.height,
|
|
||||||
0,
|
|
||||||
LOCAL_GL_RGB,
|
|
||||||
#ifdef XP_WIN
|
|
||||||
LOCAL_GL_UNSIGNED_BYTE,
|
|
||||||
#else
|
|
||||||
mIsGLES2 ? LOCAL_GL_UNSIGNED_SHORT_5_6_5
|
|
||||||
: LOCAL_GL_UNSIGNED_BYTE,
|
|
||||||
#endif
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
#ifdef XP_WIN
|
if (stencil) {
|
||||||
cf.red = cf.green = cf.blue = 8;
|
fGenRenderbuffers(1, &mOffscreenStencilRB);
|
||||||
#else
|
}
|
||||||
cf.red = 5;
|
|
||||||
cf.green = 6;
|
|
||||||
cf.blue = 5;
|
|
||||||
#endif
|
|
||||||
cf.alpha = 0;
|
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
cf.samples = samples;
|
fBindTexture(LOCAL_GL_TEXTURE_2D, mOffscreenTexture);
|
||||||
|
fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, mOffscreenFBO);
|
||||||
// Allocate color buffer
|
}
|
||||||
if (useDrawMSFBO) {
|
|
||||||
GLenum colorFormat;
|
// resize the FBO components
|
||||||
if (!mIsGLES2 || IsExtensionSupported(OES_rgb8_rgba8))
|
if (alpha) {
|
||||||
colorFormat = alpha ? LOCAL_GL_RGBA8 : LOCAL_GL_RGB8;
|
fTexImage2D(LOCAL_GL_TEXTURE_2D,
|
||||||
else
|
0,
|
||||||
colorFormat = alpha ? LOCAL_GL_RGBA4 : LOCAL_GL_RGB565;
|
LOCAL_GL_RGBA,
|
||||||
|
aSize.width, aSize.height,
|
||||||
fBindRenderbuffer(LOCAL_GL_RENDERBUFFER, newOffscreenColorRB);
|
0,
|
||||||
fRenderbufferStorageMultisample(LOCAL_GL_RENDERBUFFER,
|
LOCAL_GL_RGBA,
|
||||||
samples,
|
LOCAL_GL_UNSIGNED_BYTE,
|
||||||
colorFormat,
|
NULL);
|
||||||
aSize.width, aSize.height);
|
|
||||||
|
cf.red = cf.green = cf.blue = cf.alpha = 8;
|
||||||
|
} else {
|
||||||
|
fTexImage2D(LOCAL_GL_TEXTURE_2D,
|
||||||
|
0,
|
||||||
|
LOCAL_GL_RGB,
|
||||||
|
aSize.width, aSize.height,
|
||||||
|
0,
|
||||||
|
LOCAL_GL_RGB,
|
||||||
|
#ifdef XP_WIN
|
||||||
|
LOCAL_GL_UNSIGNED_BYTE,
|
||||||
|
#else
|
||||||
|
mIsGLES2 ? LOCAL_GL_UNSIGNED_SHORT_5_6_5
|
||||||
|
: LOCAL_GL_UNSIGNED_BYTE,
|
||||||
|
#endif
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
#ifdef XP_WIN
|
||||||
|
cf.red = cf.green = cf.blue = 8;
|
||||||
|
#else
|
||||||
|
cf.red = 5;
|
||||||
|
cf.green = 6;
|
||||||
|
cf.blue = 5;
|
||||||
|
#endif
|
||||||
|
cf.alpha = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate depth and stencil buffers
|
|
||||||
if (depth && stencil && useDepthStencil) {
|
if (depth && stencil && useDepthStencil) {
|
||||||
fBindRenderbuffer(LOCAL_GL_RENDERBUFFER, newOffscreenDepthRB);
|
fBindRenderbuffer(LOCAL_GL_RENDERBUFFER, mOffscreenDepthRB);
|
||||||
if (useDrawMSFBO) {
|
fRenderbufferStorage(LOCAL_GL_RENDERBUFFER,
|
||||||
fRenderbufferStorageMultisample(LOCAL_GL_RENDERBUFFER,
|
LOCAL_GL_DEPTH24_STENCIL8,
|
||||||
samples,
|
aSize.width, aSize.height);
|
||||||
LOCAL_GL_DEPTH24_STENCIL8,
|
|
||||||
aSize.width, aSize.height);
|
|
||||||
} else {
|
|
||||||
fRenderbufferStorage(LOCAL_GL_RENDERBUFFER,
|
|
||||||
LOCAL_GL_DEPTH24_STENCIL8,
|
|
||||||
aSize.width, aSize.height);
|
|
||||||
}
|
|
||||||
cf.depth = 24;
|
cf.depth = 24;
|
||||||
cf.stencil = 8;
|
cf.stencil = 8;
|
||||||
} else {
|
} else {
|
||||||
@@ -1188,167 +1108,77 @@ GLContext::ResizeOffscreenFBO(const gfxIntSize& aSize, const bool aUseReadFBO, c
|
|||||||
cf.depth = 24;
|
cf.depth = 24;
|
||||||
}
|
}
|
||||||
|
|
||||||
fBindRenderbuffer(LOCAL_GL_RENDERBUFFER, newOffscreenDepthRB);
|
fBindRenderbuffer(LOCAL_GL_RENDERBUFFER, mOffscreenDepthRB);
|
||||||
if (useDrawMSFBO) {
|
fRenderbufferStorage(LOCAL_GL_RENDERBUFFER, depthType,
|
||||||
fRenderbufferStorageMultisample(LOCAL_GL_RENDERBUFFER,
|
aSize.width, aSize.height);
|
||||||
samples,
|
|
||||||
depthType,
|
|
||||||
aSize.width, aSize.height);
|
|
||||||
} else {
|
|
||||||
fRenderbufferStorage(LOCAL_GL_RENDERBUFFER,
|
|
||||||
depthType,
|
|
||||||
aSize.width, aSize.height);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stencil) {
|
if (stencil) {
|
||||||
fBindRenderbuffer(LOCAL_GL_RENDERBUFFER, newOffscreenStencilRB);
|
fBindRenderbuffer(LOCAL_GL_RENDERBUFFER, mOffscreenStencilRB);
|
||||||
if (useDrawMSFBO) {
|
fRenderbufferStorage(LOCAL_GL_RENDERBUFFER,
|
||||||
fRenderbufferStorageMultisample(LOCAL_GL_RENDERBUFFER,
|
LOCAL_GL_STENCIL_INDEX8,
|
||||||
samples,
|
aSize.width, aSize.height);
|
||||||
LOCAL_GL_STENCIL_INDEX8,
|
|
||||||
aSize.width, aSize.height);
|
|
||||||
} else {
|
|
||||||
fRenderbufferStorage(LOCAL_GL_RENDERBUFFER,
|
|
||||||
LOCAL_GL_STENCIL_INDEX8,
|
|
||||||
aSize.width, aSize.height);
|
|
||||||
}
|
|
||||||
cf.stencil = 8;
|
cf.stencil = 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now assemble the FBO
|
// Now assemble the FBO, if we're creating one
|
||||||
fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, newOffscreenDrawFBO); // If we're not using a separate draw FBO, this will be the read FBO
|
// for the first time.
|
||||||
if (useDrawMSFBO) {
|
if (firstTime) {
|
||||||
fFramebufferRenderbuffer(LOCAL_GL_FRAMEBUFFER,
|
|
||||||
LOCAL_GL_COLOR_ATTACHMENT0,
|
|
||||||
LOCAL_GL_RENDERBUFFER,
|
|
||||||
newOffscreenColorRB);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (depth && stencil && useDepthStencil) {
|
|
||||||
fFramebufferRenderbuffer(LOCAL_GL_FRAMEBUFFER,
|
|
||||||
LOCAL_GL_DEPTH_ATTACHMENT,
|
|
||||||
LOCAL_GL_RENDERBUFFER,
|
|
||||||
newOffscreenDepthRB);
|
|
||||||
fFramebufferRenderbuffer(LOCAL_GL_FRAMEBUFFER,
|
|
||||||
LOCAL_GL_STENCIL_ATTACHMENT,
|
|
||||||
LOCAL_GL_RENDERBUFFER,
|
|
||||||
newOffscreenDepthRB);
|
|
||||||
} else {
|
|
||||||
if (depth) {
|
|
||||||
fFramebufferRenderbuffer(LOCAL_GL_FRAMEBUFFER,
|
|
||||||
LOCAL_GL_DEPTH_ATTACHMENT,
|
|
||||||
LOCAL_GL_RENDERBUFFER,
|
|
||||||
newOffscreenDepthRB);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stencil) {
|
|
||||||
fFramebufferRenderbuffer(LOCAL_GL_FRAMEBUFFER,
|
|
||||||
LOCAL_GL_STENCIL_ATTACHMENT,
|
|
||||||
LOCAL_GL_RENDERBUFFER,
|
|
||||||
newOffscreenStencilRB);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (aUseReadFBO) {
|
|
||||||
fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, newOffscreenReadFBO);
|
|
||||||
fFramebufferTexture2D(LOCAL_GL_FRAMEBUFFER,
|
fFramebufferTexture2D(LOCAL_GL_FRAMEBUFFER,
|
||||||
LOCAL_GL_COLOR_ATTACHMENT0,
|
LOCAL_GL_COLOR_ATTACHMENT0,
|
||||||
LOCAL_GL_TEXTURE_2D,
|
LOCAL_GL_TEXTURE_2D,
|
||||||
newOffscreenTexture,
|
mOffscreenTexture,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
|
if (depth && stencil && useDepthStencil) {
|
||||||
|
fFramebufferRenderbuffer(LOCAL_GL_FRAMEBUFFER,
|
||||||
|
LOCAL_GL_DEPTH_ATTACHMENT,
|
||||||
|
LOCAL_GL_RENDERBUFFER,
|
||||||
|
mOffscreenDepthRB);
|
||||||
|
fFramebufferRenderbuffer(LOCAL_GL_FRAMEBUFFER,
|
||||||
|
LOCAL_GL_STENCIL_ATTACHMENT,
|
||||||
|
LOCAL_GL_RENDERBUFFER,
|
||||||
|
mOffscreenDepthRB);
|
||||||
|
} else {
|
||||||
|
if (depth) {
|
||||||
|
fFramebufferRenderbuffer(LOCAL_GL_FRAMEBUFFER,
|
||||||
|
LOCAL_GL_DEPTH_ATTACHMENT,
|
||||||
|
LOCAL_GL_RENDERBUFFER,
|
||||||
|
mOffscreenDepthRB);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stencil) {
|
||||||
|
fFramebufferRenderbuffer(LOCAL_GL_FRAMEBUFFER,
|
||||||
|
LOCAL_GL_STENCIL_ATTACHMENT,
|
||||||
|
LOCAL_GL_RENDERBUFFER,
|
||||||
|
mOffscreenStencilRB);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We should be all resized. Check for framebuffer completeness.
|
// We should be all resized. Check for framebuffer completeness.
|
||||||
GLenum status;
|
GLenum status = fCheckFramebufferStatus(LOCAL_GL_FRAMEBUFFER);
|
||||||
bool framebuffersComplete = true;
|
|
||||||
|
|
||||||
fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, newOffscreenDrawFBO);
|
|
||||||
status = fCheckFramebufferStatus(LOCAL_GL_FRAMEBUFFER);
|
|
||||||
if (status != LOCAL_GL_FRAMEBUFFER_COMPLETE) {
|
if (status != LOCAL_GL_FRAMEBUFFER_COMPLETE) {
|
||||||
NS_WARNING("DrawFBO: Incomplete");
|
NS_WARNING("Error resizing offscreen framebuffer -- framebuffer not complete");
|
||||||
#ifdef DEBUG
|
|
||||||
printf_stderr("Framebuffer status: %X\n", status);
|
|
||||||
#endif
|
|
||||||
framebuffersComplete = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, newOffscreenReadFBO);
|
|
||||||
status = fCheckFramebufferStatus(LOCAL_GL_FRAMEBUFFER);
|
|
||||||
if (status != LOCAL_GL_FRAMEBUFFER_COMPLETE) {
|
|
||||||
NS_WARNING("ReadFBO: Incomplete");
|
|
||||||
#ifdef DEBUG
|
|
||||||
printf_stderr("Framebuffer status: %X\n", status);
|
|
||||||
#endif
|
|
||||||
framebuffersComplete = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!framebuffersComplete) {
|
|
||||||
NS_WARNING("Error resizing offscreen framebuffer -- framebuffer(s) not complete");
|
|
||||||
|
|
||||||
// Clean up the mess
|
|
||||||
fDeleteFramebuffers(1, &newOffscreenDrawFBO);
|
|
||||||
fDeleteFramebuffers(1, &newOffscreenReadFBO);
|
|
||||||
fDeleteTextures(1, &newOffscreenTexture);
|
|
||||||
fDeleteRenderbuffers(1, &newOffscreenColorRB);
|
|
||||||
fDeleteRenderbuffers(1, &newOffscreenDepthRB);
|
|
||||||
fDeleteRenderbuffers(1, &newOffscreenStencilRB);
|
|
||||||
|
|
||||||
BindReadFBO(curBoundFramebufferRead);
|
|
||||||
BindDrawFBO(curBoundFramebufferDraw);
|
|
||||||
fBindTexture(LOCAL_GL_TEXTURE_2D, curBoundTexture);
|
|
||||||
fBindRenderbuffer(LOCAL_GL_RENDERBUFFER, curBoundRenderbuffer);
|
|
||||||
fViewport(viewport[0], viewport[1], viewport[2], viewport[3]);
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Success, so delete the old and busted
|
|
||||||
fDeleteFramebuffers(1, &mOffscreenDrawFBO);
|
|
||||||
fDeleteFramebuffers(1, &mOffscreenReadFBO);
|
|
||||||
fDeleteTextures(1, &mOffscreenTexture);
|
|
||||||
fDeleteRenderbuffers(1, &mOffscreenColorRB);
|
|
||||||
fDeleteRenderbuffers(1, &mOffscreenDepthRB);
|
|
||||||
fDeleteRenderbuffers(1, &mOffscreenStencilRB);
|
|
||||||
|
|
||||||
// Update currently bound references if we're changing what they were point to
|
|
||||||
// This way we don't rebind to old buffers when we're done here
|
|
||||||
if (curBoundFramebufferDraw == mOffscreenDrawFBO)
|
|
||||||
curBoundFramebufferDraw = newOffscreenDrawFBO;
|
|
||||||
if (curBoundFramebufferRead == mOffscreenReadFBO)
|
|
||||||
curBoundFramebufferRead = newOffscreenReadFBO;
|
|
||||||
if (curBoundTexture == mOffscreenTexture)
|
|
||||||
curBoundTexture = newOffscreenTexture;
|
|
||||||
if (curBoundRenderbuffer == mOffscreenColorRB)
|
|
||||||
curBoundRenderbuffer = newOffscreenColorRB;
|
|
||||||
else if (curBoundRenderbuffer == mOffscreenDepthRB)
|
|
||||||
curBoundRenderbuffer = newOffscreenDepthRB;
|
|
||||||
else if (curBoundRenderbuffer == mOffscreenStencilRB)
|
|
||||||
curBoundRenderbuffer = newOffscreenStencilRB;
|
|
||||||
|
|
||||||
// Replace with the new hotness
|
|
||||||
mOffscreenDrawFBO = newOffscreenDrawFBO;
|
|
||||||
mOffscreenReadFBO = newOffscreenReadFBO;
|
|
||||||
mOffscreenTexture = newOffscreenTexture;
|
|
||||||
mOffscreenColorRB = newOffscreenColorRB;
|
|
||||||
mOffscreenDepthRB = newOffscreenDepthRB;
|
|
||||||
mOffscreenStencilRB = newOffscreenStencilRB;
|
|
||||||
|
|
||||||
mOffscreenSize = aSize;
|
mOffscreenSize = aSize;
|
||||||
mOffscreenActualSize = aSize;
|
mOffscreenActualSize = aSize;
|
||||||
|
|
||||||
mActualFormat = cf;
|
if (firstTime) {
|
||||||
|
// UpdateActualFormat() doesn't work for some reason, with a
|
||||||
|
// FBO bound, even though it should.
|
||||||
|
//UpdateActualFormat();
|
||||||
|
mActualFormat = cf;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (mDebugMode) {
|
printf_stderr("Created offscreen FBO: r: %d g: %d b: %d a: %d depth: %d stencil: %d\n",
|
||||||
printf_stderr("%s %dx%d offscreen FBO: r: %d g: %d b: %d a: %d depth: %d stencil: %d samples: %d\n",
|
|
||||||
firstTime ? "Created" : "Resized",
|
|
||||||
mOffscreenActualSize.width, mOffscreenActualSize.height,
|
|
||||||
mActualFormat.red, mActualFormat.green, mActualFormat.blue, mActualFormat.alpha,
|
mActualFormat.red, mActualFormat.green, mActualFormat.blue, mActualFormat.alpha,
|
||||||
mActualFormat.depth, mActualFormat.stencil, mActualFormat.samples);
|
mActualFormat.depth, mActualFormat.stencil);
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// We're good, and the framebuffer is already attached, so let's
|
// We're good, and the framebuffer is already attached, so let's
|
||||||
// clear out our new framebuffer; otherwise we'll end up displaying
|
// clear out our new framebuffer; otherwise we'll end up displaying
|
||||||
@@ -1356,18 +1186,13 @@ GLContext::ResizeOffscreenFBO(const gfxIntSize& aSize, const bool aUseReadFBO, c
|
|||||||
// can restore them.
|
// can restore them.
|
||||||
fViewport(0, 0, aSize.width, aSize.height);
|
fViewport(0, 0, aSize.width, aSize.height);
|
||||||
|
|
||||||
// Make sure we know that the buffers are new and thus dirty:
|
|
||||||
ForceDirtyFBOs();
|
|
||||||
|
|
||||||
// Clear the new framebuffer with the full viewport
|
// Clear the new framebuffer with the full viewport
|
||||||
fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, GetOffscreenFBO());
|
|
||||||
ClearSafely();
|
ClearSafely();
|
||||||
|
|
||||||
// Ok, now restore the GL state back to what it was before the resize took place.
|
// Ok, now restore the GL state back to what it was before the resize took place.
|
||||||
BindDrawFBO(curBoundFramebufferDraw);
|
|
||||||
BindReadFBO(curBoundFramebufferRead);
|
|
||||||
fBindTexture(LOCAL_GL_TEXTURE_2D, curBoundTexture);
|
fBindTexture(LOCAL_GL_TEXTURE_2D, curBoundTexture);
|
||||||
fBindRenderbuffer(LOCAL_GL_RENDERBUFFER, curBoundRenderbuffer);
|
fBindRenderbuffer(LOCAL_GL_RENDERBUFFER, curBoundRenderbuffer);
|
||||||
|
fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, curBoundFramebuffer);
|
||||||
|
|
||||||
// -don't- restore the viewport the first time through this, since
|
// -don't- restore the viewport the first time through this, since
|
||||||
// the previous one isn't valid.
|
// the previous one isn't valid.
|
||||||
@@ -1380,17 +1205,13 @@ GLContext::ResizeOffscreenFBO(const gfxIntSize& aSize, const bool aUseReadFBO, c
|
|||||||
void
|
void
|
||||||
GLContext::DeleteOffscreenFBO()
|
GLContext::DeleteOffscreenFBO()
|
||||||
{
|
{
|
||||||
fDeleteFramebuffers(1, &mOffscreenDrawFBO);
|
fDeleteFramebuffers(1, &mOffscreenFBO);
|
||||||
fDeleteFramebuffers(1, &mOffscreenReadFBO);
|
|
||||||
fDeleteTextures(1, &mOffscreenTexture);
|
fDeleteTextures(1, &mOffscreenTexture);
|
||||||
fDeleteRenderbuffers(1, &mOffscreenColorRB);
|
|
||||||
fDeleteRenderbuffers(1, &mOffscreenDepthRB);
|
fDeleteRenderbuffers(1, &mOffscreenDepthRB);
|
||||||
fDeleteRenderbuffers(1, &mOffscreenStencilRB);
|
fDeleteRenderbuffers(1, &mOffscreenStencilRB);
|
||||||
|
|
||||||
mOffscreenDrawFBO = 0;
|
mOffscreenFBO = 0;
|
||||||
mOffscreenReadFBO = 0;
|
|
||||||
mOffscreenTexture = 0;
|
mOffscreenTexture = 0;
|
||||||
mOffscreenColorRB = 0;
|
|
||||||
mOffscreenDepthRB = 0;
|
mOffscreenDepthRB = 0;
|
||||||
mOffscreenStencilRB = 0;
|
mOffscreenStencilRB = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -476,11 +476,11 @@ struct THEBES_API ContextFormat
|
|||||||
};
|
};
|
||||||
|
|
||||||
ContextFormat() {
|
ContextFormat() {
|
||||||
memset(this, 0, sizeof(ContextFormat));
|
memset(this, 0, sizeof(*this));
|
||||||
}
|
}
|
||||||
|
|
||||||
ContextFormat(const StandardContextFormat cf) {
|
ContextFormat(const StandardContextFormat cf) {
|
||||||
memset(this, 0, sizeof(ContextFormat));
|
memset(this, 0, sizeof(*this));
|
||||||
switch (cf) {
|
switch (cf) {
|
||||||
case BasicRGBA32:
|
case BasicRGBA32:
|
||||||
red = green = blue = alpha = 8;
|
red = green = blue = alpha = 8;
|
||||||
@@ -519,7 +519,6 @@ struct THEBES_API ContextFormat
|
|||||||
int green, minGreen;
|
int green, minGreen;
|
||||||
int blue, minBlue;
|
int blue, minBlue;
|
||||||
int alpha, minAlpha;
|
int alpha, minAlpha;
|
||||||
int samples;
|
|
||||||
|
|
||||||
int colorBits() const { return red + green + blue; }
|
int colorBits() const { return red + green + blue; }
|
||||||
};
|
};
|
||||||
@@ -548,10 +547,7 @@ public:
|
|||||||
mFlipped(false),
|
mFlipped(false),
|
||||||
mBlitProgram(0),
|
mBlitProgram(0),
|
||||||
mBlitFramebuffer(0),
|
mBlitFramebuffer(0),
|
||||||
mOffscreenDrawFBO(0),
|
mOffscreenFBO(0),
|
||||||
mOffscreenReadFBO(0),
|
|
||||||
mOffscreenFBOsDirty(false),
|
|
||||||
mOffscreenColorRB(0),
|
|
||||||
mOffscreenDepthRB(0),
|
mOffscreenDepthRB(0),
|
||||||
mOffscreenStencilRB(0)
|
mOffscreenStencilRB(0)
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@@ -723,7 +719,7 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!aOffscreen->mOffscreenDrawFBO && !aOffscreen->mOffscreenReadFBO) {
|
if (!aOffscreen->mOffscreenFBO) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -753,8 +749,8 @@ public:
|
|||||||
* Only valid if IsOffscreen() returns true.
|
* Only valid if IsOffscreen() returns true.
|
||||||
*/
|
*/
|
||||||
virtual bool ResizeOffscreen(const gfxIntSize& aNewSize) {
|
virtual bool ResizeOffscreen(const gfxIntSize& aNewSize) {
|
||||||
if (mOffscreenDrawFBO || mOffscreenReadFBO)
|
if (mOffscreenFBO)
|
||||||
return ResizeOffscreenFBO(aNewSize, mOffscreenReadFBO != 0);
|
return ResizeOffscreenFBO(aNewSize);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -785,232 +781,12 @@ public:
|
|||||||
* Only valid if IsOffscreen() returns true.
|
* Only valid if IsOffscreen() returns true.
|
||||||
*/
|
*/
|
||||||
GLuint GetOffscreenFBO() {
|
GLuint GetOffscreenFBO() {
|
||||||
// 0 is interpreted as (off)screen, whether for read or draw operations
|
return mOffscreenFBO;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLuint GetOffscreenTexture() {
|
GLuint GetOffscreenTexture() {
|
||||||
return mOffscreenTexture;
|
return mOffscreenTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool SupportsFramebufferMultisample() {
|
|
||||||
return IsExtensionSupported(EXT_framebuffer_multisample) || IsExtensionSupported(ANGLE_framebuffer_multisample);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool SupportsOffscreenSplit() {
|
|
||||||
return IsExtensionSupported(EXT_framebuffer_blit) || IsExtensionSupported(ANGLE_framebuffer_blit);
|
|
||||||
}
|
|
||||||
|
|
||||||
GLuint GetBoundDrawFBO() {
|
|
||||||
GLint ret = 0;
|
|
||||||
if (SupportsOffscreenSplit())
|
|
||||||
fGetIntegerv(LOCAL_GL_DRAW_FRAMEBUFFER_BINDING_EXT, &ret);
|
|
||||||
else
|
|
||||||
fGetIntegerv(LOCAL_GL_FRAMEBUFFER_BINDING, &ret);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
GLuint GetBoundReadFBO() {
|
|
||||||
GLint ret = 0;
|
|
||||||
if (SupportsOffscreenSplit())
|
|
||||||
fGetIntegerv(LOCAL_GL_READ_FRAMEBUFFER_BINDING_EXT, &ret);
|
|
||||||
else
|
|
||||||
fGetIntegerv(LOCAL_GL_FRAMEBUFFER_BINDING, &ret);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BindDrawFBO(GLuint name) {
|
|
||||||
if (SupportsOffscreenSplit())
|
|
||||||
fBindFramebuffer(LOCAL_GL_DRAW_FRAMEBUFFER_EXT, name);
|
|
||||||
else
|
|
||||||
fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BindReadFBO(GLuint name) {
|
|
||||||
if (SupportsOffscreenSplit())
|
|
||||||
fBindFramebuffer(LOCAL_GL_READ_FRAMEBUFFER_EXT, name);
|
|
||||||
else
|
|
||||||
fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
GLuint SwapBoundDrawFBO(GLuint name) {
|
|
||||||
GLuint prev = GetBoundDrawFBO();
|
|
||||||
BindDrawFBO(name);
|
|
||||||
return prev;
|
|
||||||
}
|
|
||||||
|
|
||||||
GLuint SwapBoundReadFBO(GLuint name) {
|
|
||||||
GLuint prev = GetBoundReadFBO();
|
|
||||||
BindReadFBO(name);
|
|
||||||
return prev;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BindOffscreenDrawBuffer() {
|
|
||||||
BindDrawFBO(mOffscreenDrawFBO);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BindOffscreenReadBuffer() {
|
|
||||||
BindReadFBO(mOffscreenReadFBO);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BindOffscreenBuffers() {
|
|
||||||
BindOffscreenDrawBuffer();
|
|
||||||
BindOffscreenReadBuffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
GLuint mPrevDrawFBOBinding;
|
|
||||||
GLuint mPrevReadFBOBinding;
|
|
||||||
bool mOffscreenFBOsDirty;
|
|
||||||
|
|
||||||
void BeforeGLDrawCall() {
|
|
||||||
// Record and rebind if necessary
|
|
||||||
mPrevDrawFBOBinding = GetBoundDrawFBO();
|
|
||||||
if (mPrevDrawFBOBinding == 0) {
|
|
||||||
BindDrawFBO(mOffscreenDrawFBO);
|
|
||||||
} else if (mPrevDrawFBOBinding != mOffscreenDrawFBO)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Must be after binding the proper FBO
|
|
||||||
if (mOffscreenDrawFBO == mOffscreenReadFBO)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// If we're already dirty, no need to set it again
|
|
||||||
if (mOffscreenFBOsDirty)
|
|
||||||
return;
|
|
||||||
|
|
||||||
mOffscreenFBOsDirty = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AfterGLDrawCall() {
|
|
||||||
if (mPrevDrawFBOBinding == 0) {
|
|
||||||
BindDrawFBO(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void BeforeGLReadCall() {
|
|
||||||
// Record and rebind if necessary
|
|
||||||
mPrevReadFBOBinding = GetBoundReadFBO();
|
|
||||||
if (mPrevReadFBOBinding == 0) {
|
|
||||||
BindReadFBO(mOffscreenReadFBO);
|
|
||||||
} else if (mPrevReadFBOBinding != mOffscreenReadFBO)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Must be after binding the proper FBO
|
|
||||||
if (mOffscreenDrawFBO == mOffscreenReadFBO)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// If we're not dirty, there's no need to blit
|
|
||||||
if (!mOffscreenFBOsDirty)
|
|
||||||
return;
|
|
||||||
|
|
||||||
const bool scissor = fIsEnabled(LOCAL_GL_SCISSOR_TEST);
|
|
||||||
if (scissor)
|
|
||||||
fDisable(LOCAL_GL_SCISSOR_TEST);
|
|
||||||
|
|
||||||
// flip read/draw for blitting
|
|
||||||
GLuint prevDraw = SwapBoundDrawFBO(mOffscreenReadFBO);
|
|
||||||
BindReadFBO(mOffscreenDrawFBO); // We know that Read must already be mOffscreenRead, so no need to write that down
|
|
||||||
|
|
||||||
GLint width = mOffscreenActualSize.width;
|
|
||||||
GLint height = mOffscreenActualSize.height;
|
|
||||||
raw_fBlitFramebuffer(0, 0, width, height,
|
|
||||||
0, 0, width, height,
|
|
||||||
LOCAL_GL_COLOR_BUFFER_BIT,
|
|
||||||
LOCAL_GL_NEAREST);
|
|
||||||
|
|
||||||
BindDrawFBO(prevDraw);
|
|
||||||
BindReadFBO(mOffscreenReadFBO);
|
|
||||||
|
|
||||||
if (scissor)
|
|
||||||
fEnable(LOCAL_GL_SCISSOR_TEST);
|
|
||||||
|
|
||||||
mOffscreenFBOsDirty = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AfterGLReadCall() {
|
|
||||||
if (mPrevReadFBOBinding == 0) {
|
|
||||||
BindReadFBO(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
// Draw call hooks:
|
|
||||||
void fClear(GLbitfield mask) {
|
|
||||||
BeforeGLDrawCall();
|
|
||||||
raw_fClear(mask);
|
|
||||||
AfterGLDrawCall();
|
|
||||||
}
|
|
||||||
|
|
||||||
void fDrawArrays(GLenum mode, GLint first, GLsizei count) {
|
|
||||||
BeforeGLDrawCall();
|
|
||||||
raw_fDrawArrays(mode, first, count);
|
|
||||||
AfterGLDrawCall();
|
|
||||||
}
|
|
||||||
|
|
||||||
void fDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) {
|
|
||||||
BeforeGLDrawCall();
|
|
||||||
raw_fDrawElements(mode, count, type, indices);
|
|
||||||
AfterGLDrawCall();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read call hooks:
|
|
||||||
void fReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) {
|
|
||||||
BeforeGLReadCall();
|
|
||||||
raw_fReadPixels(x, y, width, height, format, type, pixels);
|
|
||||||
AfterGLReadCall();
|
|
||||||
}
|
|
||||||
|
|
||||||
void fCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) {
|
|
||||||
BeforeGLReadCall();
|
|
||||||
raw_fCopyTexImage2D(target, level, internalformat,
|
|
||||||
x, y, width, height, border);
|
|
||||||
AfterGLReadCall();
|
|
||||||
}
|
|
||||||
|
|
||||||
void fCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) {
|
|
||||||
BeforeGLReadCall();
|
|
||||||
raw_fCopyTexSubImage2D(target, level, xoffset, yoffset,
|
|
||||||
x, y, width, height);
|
|
||||||
AfterGLReadCall();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ForceDirtyFBOs() {
|
|
||||||
GLuint draw = SwapBoundReadFBO(mOffscreenDrawFBO);
|
|
||||||
|
|
||||||
BeforeGLDrawCall();
|
|
||||||
// no-op; just pretend we did something
|
|
||||||
AfterGLDrawCall();
|
|
||||||
|
|
||||||
BindDrawFBO(draw);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlitDirtyFBOs() {
|
|
||||||
GLuint read = SwapBoundReadFBO(mOffscreenReadFBO);
|
|
||||||
|
|
||||||
BeforeGLReadCall();
|
|
||||||
// no-op; we just want to make sure the Read FBO is updated if it needs to be
|
|
||||||
AfterGLReadCall();
|
|
||||||
|
|
||||||
BindReadFBO(read);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Before reads from offscreen texture
|
|
||||||
void fFinish() {
|
|
||||||
BeforeGLReadCall();
|
|
||||||
raw_fFinish();
|
|
||||||
AfterGLReadCall();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw/Read
|
|
||||||
void fBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) {
|
|
||||||
BeforeGLDrawCall();
|
|
||||||
BeforeGLReadCall();
|
|
||||||
raw_fBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
|
|
||||||
AfterGLReadCall();
|
|
||||||
AfterGLDrawCall();
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(MOZ_X11) && defined(MOZ_EGL_XRENDER_COMPOSITE)
|
#if defined(MOZ_X11) && defined(MOZ_EGL_XRENDER_COMPOSITE)
|
||||||
virtual gfxASurface* GetOffscreenPixmapSurface()
|
virtual gfxASurface* GetOffscreenPixmapSurface()
|
||||||
{
|
{
|
||||||
@@ -1237,11 +1013,6 @@ public:
|
|||||||
ARB_texture_float,
|
ARB_texture_float,
|
||||||
EXT_unpack_subimage,
|
EXT_unpack_subimage,
|
||||||
OES_standard_derivatives,
|
OES_standard_derivatives,
|
||||||
EXT_framebuffer_blit,
|
|
||||||
ANGLE_framebuffer_blit,
|
|
||||||
EXT_framebuffer_multisample,
|
|
||||||
ANGLE_framebuffer_multisample,
|
|
||||||
OES_rgb8_rgba8,
|
|
||||||
Extensions_Max
|
Extensions_Max
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1321,20 +1092,9 @@ protected:
|
|||||||
|
|
||||||
// helper to create/resize an offscreen FBO,
|
// helper to create/resize an offscreen FBO,
|
||||||
// for offscreen implementations that use FBOs.
|
// for offscreen implementations that use FBOs.
|
||||||
bool ResizeOffscreenFBO(const gfxIntSize& aSize, const bool aUseReadFBO, const bool aDisableAA);
|
bool ResizeOffscreenFBO(const gfxIntSize& aSize);
|
||||||
bool ResizeOffscreenFBO(const gfxIntSize& aSize, const bool aUseReadFBO) {
|
|
||||||
if (ResizeOffscreenFBO(aSize, aUseReadFBO, false))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (!mCreationFormat.samples)
|
|
||||||
return false;
|
|
||||||
printf("ResizeOffscreenFBO failed with AA, retrying without...\n");
|
|
||||||
return ResizeOffscreenFBO(aSize, aUseReadFBO, true);
|
|
||||||
}
|
|
||||||
void DeleteOffscreenFBO();
|
void DeleteOffscreenFBO();
|
||||||
GLuint mOffscreenDrawFBO;
|
GLuint mOffscreenFBO;
|
||||||
GLuint mOffscreenReadFBO;
|
|
||||||
GLuint mOffscreenColorRB;
|
|
||||||
GLuint mOffscreenDepthRB;
|
GLuint mOffscreenDepthRB;
|
||||||
GLuint mOffscreenStencilRB;
|
GLuint mOffscreenStencilRB;
|
||||||
|
|
||||||
@@ -1694,7 +1454,7 @@ public:
|
|||||||
AFTER_GL_CALL;
|
AFTER_GL_CALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void raw_fClear(GLbitfield mask) {
|
void fClear(GLbitfield mask) {
|
||||||
BEFORE_GL_CALL;
|
BEFORE_GL_CALL;
|
||||||
mSymbols.fClear(mask);
|
mSymbols.fClear(mask);
|
||||||
AFTER_GL_CALL;
|
AFTER_GL_CALL;
|
||||||
@@ -1754,13 +1514,13 @@ public:
|
|||||||
AFTER_GL_CALL;
|
AFTER_GL_CALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void raw_fDrawArrays(GLenum mode, GLint first, GLsizei count) {
|
void fDrawArrays(GLenum mode, GLint first, GLsizei count) {
|
||||||
BEFORE_GL_CALL;
|
BEFORE_GL_CALL;
|
||||||
mSymbols.fDrawArrays(mode, first, count);
|
mSymbols.fDrawArrays(mode, first, count);
|
||||||
AFTER_GL_CALL;
|
AFTER_GL_CALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void raw_fDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) {
|
void fDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) {
|
||||||
BEFORE_GL_CALL;
|
BEFORE_GL_CALL;
|
||||||
mSymbols.fDrawElements(mode, count, type, indices);
|
mSymbols.fDrawElements(mode, count, type, indices);
|
||||||
AFTER_GL_CALL;
|
AFTER_GL_CALL;
|
||||||
@@ -1778,7 +1538,7 @@ public:
|
|||||||
AFTER_GL_CALL;
|
AFTER_GL_CALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void raw_fFinish() {
|
void fFinish() {
|
||||||
BEFORE_GL_CALL;
|
BEFORE_GL_CALL;
|
||||||
mSymbols.fFinish();
|
mSymbols.fFinish();
|
||||||
AFTER_GL_CALL;
|
AFTER_GL_CALL;
|
||||||
@@ -1996,7 +1756,7 @@ public:
|
|||||||
AFTER_GL_CALL;
|
AFTER_GL_CALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void raw_fReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) {
|
void fReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) {
|
||||||
BEFORE_GL_CALL;
|
BEFORE_GL_CALL;
|
||||||
mSymbols.fReadPixels(x, y, width, height, format, type, pixels);
|
mSymbols.fReadPixels(x, y, width, height, format, type, pixels);
|
||||||
AFTER_GL_CALL;
|
AFTER_GL_CALL;
|
||||||
@@ -2242,7 +2002,7 @@ public:
|
|||||||
AFTER_GL_CALL;
|
AFTER_GL_CALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void raw_fCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) {
|
void fCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) {
|
||||||
BEFORE_GL_CALL;
|
BEFORE_GL_CALL;
|
||||||
mSymbols.fCopyTexImage2D(target, level, internalformat,
|
mSymbols.fCopyTexImage2D(target, level, internalformat,
|
||||||
x, FixYValue(y, height),
|
x, FixYValue(y, height),
|
||||||
@@ -2250,7 +2010,7 @@ public:
|
|||||||
AFTER_GL_CALL;
|
AFTER_GL_CALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void raw_fCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) {
|
void fCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) {
|
||||||
BEFORE_GL_CALL;
|
BEFORE_GL_CALL;
|
||||||
mSymbols.fCopyTexSubImage2D(target, level, xoffset, yoffset,
|
mSymbols.fCopyTexSubImage2D(target, level, xoffset, yoffset,
|
||||||
x, FixYValue(y, height),
|
x, FixYValue(y, height),
|
||||||
@@ -2332,12 +2092,6 @@ public:
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void raw_fBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) {
|
|
||||||
BEFORE_GL_CALL;
|
|
||||||
mSymbols.fBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
|
|
||||||
AFTER_GL_CALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
realGLboolean fIsRenderbuffer (GLuint renderbuffer) {
|
realGLboolean fIsRenderbuffer (GLuint renderbuffer) {
|
||||||
BEFORE_GL_CALL;
|
BEFORE_GL_CALL;
|
||||||
realGLboolean retval = mSymbols.fIsRenderbuffer(renderbuffer);
|
realGLboolean retval = mSymbols.fIsRenderbuffer(renderbuffer);
|
||||||
@@ -2351,12 +2105,6 @@ public:
|
|||||||
AFTER_GL_CALL;
|
AFTER_GL_CALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void fRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height) {
|
|
||||||
BEFORE_GL_CALL;
|
|
||||||
mSymbols.fRenderbufferStorageMultisample(target, samples, internalFormat, width, height);
|
|
||||||
AFTER_GL_CALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void fDepthRange(GLclampf a, GLclampf b) {
|
void fDepthRange(GLclampf a, GLclampf b) {
|
||||||
BEFORE_GL_CALL;
|
BEFORE_GL_CALL;
|
||||||
if (mIsGLES2) {
|
if (mIsGLES2) {
|
||||||
|
|||||||
@@ -46,7 +46,6 @@
|
|||||||
#include "gfxPlatform.h"
|
#include "gfxPlatform.h"
|
||||||
#include "gfxFailure.h"
|
#include "gfxFailure.h"
|
||||||
#include "prenv.h"
|
#include "prenv.h"
|
||||||
#include "mozilla/Preferences.h"
|
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace gl {
|
namespace gl {
|
||||||
@@ -264,9 +263,6 @@ GLContextCGL::UnbindTex2DOffscreen(GLContext *aOffscreen)
|
|||||||
bool
|
bool
|
||||||
GLContextCGL::ResizeOffscreen(const gfxIntSize& aNewSize)
|
GLContextCGL::ResizeOffscreen(const gfxIntSize& aNewSize)
|
||||||
{
|
{
|
||||||
if (!IsOffscreenSizeAllowed(aNewSize))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (mPBuffer) {
|
if (mPBuffer) {
|
||||||
NSOpenGLPixelBuffer *pb = [[NSOpenGLPixelBuffer alloc]
|
NSOpenGLPixelBuffer *pb = [[NSOpenGLPixelBuffer alloc]
|
||||||
initWithTextureTarget:LOCAL_GL_TEXTURE_2D
|
initWithTextureTarget:LOCAL_GL_TEXTURE_2D
|
||||||
@@ -278,10 +274,6 @@ GLContextCGL::ResizeOffscreen(const gfxIntSize& aNewSize)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ResizeOffscreenFBO(aNewSize, false)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
[mPBuffer release];
|
[mPBuffer release];
|
||||||
mPBuffer = pb;
|
mPBuffer = pb;
|
||||||
|
|
||||||
@@ -297,7 +289,7 @@ GLContextCGL::ResizeOffscreen(const gfxIntSize& aNewSize)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ResizeOffscreenFBO(aNewSize, true);
|
return ResizeOffscreenFBO(aNewSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
class TextureImageCGL : public BasicTextureImage
|
class TextureImageCGL : public BasicTextureImage
|
||||||
@@ -536,7 +528,8 @@ CreateOffscreenPBufferContext(const gfxIntSize& aSize,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static already_AddRefed<GLContextCGL>
|
static already_AddRefed<GLContextCGL>
|
||||||
CreateOffscreenFBOContext(const ContextFormat& aFormat,
|
CreateOffscreenFBOContext(const gfxIntSize& aSize,
|
||||||
|
const ContextFormat& aFormat,
|
||||||
bool aShare = true)
|
bool aShare = true)
|
||||||
{
|
{
|
||||||
if (!sCGLLibrary.EnsureInitialized()) {
|
if (!sCGLLibrary.EnsureInitialized()) {
|
||||||
@@ -564,34 +557,23 @@ already_AddRefed<GLContext>
|
|||||||
GLContextProviderCGL::CreateOffscreen(const gfxIntSize& aSize,
|
GLContextProviderCGL::CreateOffscreen(const gfxIntSize& aSize,
|
||||||
const ContextFormat& aFormat)
|
const ContextFormat& aFormat)
|
||||||
{
|
{
|
||||||
ContextFormat actualFormat(aFormat);
|
|
||||||
actualFormat.samples = 0;
|
|
||||||
|
|
||||||
nsRefPtr<GLContextCGL> glContext;
|
nsRefPtr<GLContextCGL> glContext;
|
||||||
|
|
||||||
NS_ENSURE_TRUE(Preferences::GetRootBranch(), nsnull);
|
glContext = CreateOffscreenPBufferContext(aSize, aFormat);
|
||||||
const bool preferFBOs = Preferences::GetBool("cgl.prefer-fbo", false);
|
if (glContext &&
|
||||||
if (!preferFBOs)
|
glContext->Init())
|
||||||
{
|
{
|
||||||
glContext = CreateOffscreenPBufferContext(aSize, actualFormat);
|
glContext->mOffscreenSize = aSize;
|
||||||
if (glContext &&
|
glContext->mOffscreenActualSize = aSize;
|
||||||
glContext->Init() &&
|
|
||||||
glContext->ResizeOffscreenFBO(aSize, false))
|
|
||||||
{
|
|
||||||
glContext->mOffscreenSize = aSize;
|
|
||||||
glContext->mOffscreenActualSize = aSize;
|
|
||||||
|
|
||||||
printf("GL Offscreen: CGL+PBuffer\n");
|
return glContext.forget();
|
||||||
|
|
||||||
return glContext.forget();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// try a FBO as second choice
|
// try a FBO as second choice
|
||||||
glContext = CreateOffscreenFBOContext(actualFormat);
|
glContext = CreateOffscreenFBOContext(aSize, aFormat);
|
||||||
if (glContext &&
|
if (glContext &&
|
||||||
glContext->Init() &&
|
glContext->Init() &&
|
||||||
glContext->ResizeOffscreenFBO(aSize, true))
|
glContext->ResizeOffscreenFBO(aSize))
|
||||||
{
|
{
|
||||||
return glContext.forget();
|
return glContext.forget();
|
||||||
}
|
}
|
||||||
@@ -620,7 +602,8 @@ GLContextProviderCGL::GetGlobalContext()
|
|||||||
// than 16x16 in size; also 16x16 is POT so that we can do
|
// 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
|
// a FBO with it on older video cards. A FBO context for
|
||||||
// sharing is preferred since it has no associated target.
|
// sharing is preferred since it has no associated target.
|
||||||
gGlobalContext = CreateOffscreenFBOContext(ContextFormat(ContextFormat::BasicRGB24),
|
gGlobalContext = CreateOffscreenFBOContext(gfxIntSize(16, 16),
|
||||||
|
ContextFormat(ContextFormat::BasicRGB24),
|
||||||
false);
|
false);
|
||||||
if (!gGlobalContext || !static_cast<GLContextCGL*>(gGlobalContext.get())->Init()) {
|
if (!gGlobalContext || !static_cast<GLContextCGL*>(gGlobalContext.get())->Init()) {
|
||||||
NS_WARNING("Couldn't init gGlobalContext.");
|
NS_WARNING("Couldn't init gGlobalContext.");
|
||||||
|
|||||||
@@ -1054,9 +1054,6 @@ GLContextEGL::UnbindTex2DOffscreen(GLContext *aOffscreen)
|
|||||||
bool
|
bool
|
||||||
GLContextEGL::ResizeOffscreen(const gfxIntSize& aNewSize)
|
GLContextEGL::ResizeOffscreen(const gfxIntSize& aNewSize)
|
||||||
{
|
{
|
||||||
if (!IsOffscreenSizeAllowed(aNewSize))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (mIsPBuffer) {
|
if (mIsPBuffer) {
|
||||||
gfxIntSize pbsize(aNewSize);
|
gfxIntSize pbsize(aNewSize);
|
||||||
|
|
||||||
@@ -1070,12 +1067,9 @@ GLContextEGL::ResizeOffscreen(const gfxIntSize& aNewSize)
|
|||||||
pbsize);
|
pbsize);
|
||||||
if (!surface) {
|
if (!surface) {
|
||||||
NS_WARNING("Failed to resize pbuffer");
|
NS_WARNING("Failed to resize pbuffer");
|
||||||
return false;
|
return nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ResizeOffscreenFBO(pbsize, false))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
SetOffscreenSize(aNewSize, pbsize);
|
SetOffscreenSize(aNewSize, pbsize);
|
||||||
|
|
||||||
if (mSurface && !mPlatformContext) {
|
if (mSurface && !mPlatformContext) {
|
||||||
@@ -1120,9 +1114,6 @@ GLContextEGL::ResizeOffscreen(const gfxIntSize& aNewSize)
|
|||||||
if (!config) {
|
if (!config) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!ResizeOffscreenFBO(aNewSize, true))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
mThebesSurface = xsurface;
|
mThebesSurface = xsurface;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -1130,13 +1121,10 @@ GLContextEGL::ResizeOffscreen(const gfxIntSize& aNewSize)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MOZ_X11) && defined(MOZ_EGL_XRENDER_COMPOSITE)
|
#if defined(MOZ_X11) && defined(MOZ_EGL_XRENDER_COMPOSITE)
|
||||||
if (ResizeOffscreenPixmapSurface(aNewSize)) {
|
return ResizeOffscreenPixmapSurface(aNewSize);
|
||||||
if (ResizeOffscreenFBO(aNewSize, true))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ResizeOffscreenFBO(aNewSize, true);
|
return ResizeOffscreenFBO(aNewSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2011,15 +1999,13 @@ GLContextEGL::CreateEGLPBufferOffscreenContext(const gfxIntSize& aSize,
|
|||||||
nsTArray<EGLint> attribs(32);
|
nsTArray<EGLint> attribs(32);
|
||||||
int attribAttempt = 0;
|
int attribAttempt = 0;
|
||||||
|
|
||||||
int tryDepthSize = (aFormat.depth > 0) ? 24 : 0;
|
|
||||||
|
|
||||||
TRY_ATTRIBS_AGAIN:
|
TRY_ATTRIBS_AGAIN:
|
||||||
switch (attribAttempt) {
|
switch (attribAttempt) {
|
||||||
case 0:
|
case 0:
|
||||||
FillPBufferAttribs(attribs, aFormat, configCanBindToTexture, 8, tryDepthSize);
|
FillPBufferAttribs(attribs, aFormat, configCanBindToTexture, 8, 24);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
FillPBufferAttribs(attribs, aFormat, configCanBindToTexture, -1, tryDepthSize);
|
FillPBufferAttribs(attribs, aFormat, configCanBindToTexture, -1, 24);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
FillPBufferAttribs(attribs, aFormat, configCanBindToTexture, -1, -1);
|
FillPBufferAttribs(attribs, aFormat, configCanBindToTexture, -1, -1);
|
||||||
@@ -2251,38 +2237,14 @@ GLContextProviderEGL::CreateOffscreen(const gfxIntSize& aSize,
|
|||||||
if (!sEGLLibrary.EnsureInitialized()) {
|
if (!sEGLLibrary.EnsureInitialized()) {
|
||||||
return nsnull;
|
return nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
ContextFormat actualFormat(aFormat);
|
|
||||||
// actualFormat.samples = 0;
|
|
||||||
|
|
||||||
#if defined(ANDROID) || defined(XP_WIN)
|
#if defined(ANDROID) || defined(XP_WIN)
|
||||||
nsRefPtr<GLContextEGL> glContext =
|
return GLContextEGL::CreateEGLPBufferOffscreenContext(aSize, aFormat);
|
||||||
GLContextEGL::CreateEGLPBufferOffscreenContext(aSize, actualFormat);
|
|
||||||
|
|
||||||
if (!glContext)
|
|
||||||
return nsnull;
|
|
||||||
|
|
||||||
if (!glContext->ResizeOffscreenFBO(glContext->OffscreenActualSize(), false))
|
|
||||||
return nsnull;
|
|
||||||
|
|
||||||
printf("GL Offscreen: EGL+PBuffer\n");
|
|
||||||
return glContext.forget();
|
|
||||||
|
|
||||||
#elif defined(MOZ_X11) && defined(MOZ_EGL_XRENDER_COMPOSITE)
|
#elif defined(MOZ_X11) && defined(MOZ_EGL_XRENDER_COMPOSITE)
|
||||||
nsRefPtr<GLContextEGL> glContext =
|
return GLContextEGL::CreateBasicEGLPixmapOffscreenContext(aSize, aFormat);
|
||||||
GLContextEGL::CreateBasicEGLPixmapOffscreenContext(aSize, actualFormat);
|
|
||||||
|
|
||||||
if (!glContext)
|
|
||||||
return nsnull;
|
|
||||||
|
|
||||||
if (!glContext->ResizeOffscreenFBO(glContext->OffscreenActualSize(), true))
|
|
||||||
return nsnull;
|
|
||||||
|
|
||||||
printf("GL Offscreen: EGL+Pixmap\n");
|
|
||||||
return glContext.forget();
|
|
||||||
#elif defined(MOZ_X11)
|
#elif defined(MOZ_X11)
|
||||||
nsRefPtr<GLContextEGL> glContext =
|
nsRefPtr<GLContextEGL> glContext =
|
||||||
GLContextEGL::CreateEGLPixmapOffscreenContext(aSize, actualFormat, true);
|
GLContextEGL::CreateEGLPixmapOffscreenContext(aSize, aFormat, true);
|
||||||
|
|
||||||
if (!glContext) {
|
if (!glContext) {
|
||||||
return nsnull;
|
return nsnull;
|
||||||
@@ -2292,7 +2254,7 @@ GLContextProviderEGL::CreateOffscreen(const gfxIntSize& aSize,
|
|||||||
// render from this
|
// render from this
|
||||||
return nsnull;
|
return nsnull;
|
||||||
}
|
}
|
||||||
if (!gUseBackingSurface && !glContext->ResizeOffscreenFBO(glContext->OffscreenActualSize(), true)) {
|
if (!gUseBackingSurface && !glContext->ResizeOffscreenFBO(aSize)) {
|
||||||
// we weren't able to create the initial
|
// we weren't able to create the initial
|
||||||
// offscreen FBO, so this is dead
|
// offscreen FBO, so this is dead
|
||||||
return nsnull;
|
return nsnull;
|
||||||
|
|||||||
@@ -1237,11 +1237,9 @@ already_AddRefed<GLContext>
|
|||||||
GLContextProviderGLX::CreateOffscreen(const gfxIntSize& aSize,
|
GLContextProviderGLX::CreateOffscreen(const gfxIntSize& aSize,
|
||||||
const ContextFormat& aFormat)
|
const ContextFormat& aFormat)
|
||||||
{
|
{
|
||||||
ContextFormat actualFormat(aFormat);
|
|
||||||
// actualFormat.samples = 0;
|
|
||||||
|
|
||||||
nsRefPtr<GLContextGLX> glContext =
|
nsRefPtr<GLContextGLX> glContext =
|
||||||
CreateOffscreenPixmapContext(aSize, actualFormat, true);
|
CreateOffscreenPixmapContext(aSize, aFormat, true);
|
||||||
|
|
||||||
if (!glContext) {
|
if (!glContext) {
|
||||||
return nsnull;
|
return nsnull;
|
||||||
@@ -1253,7 +1251,7 @@ GLContextProviderGLX::CreateOffscreen(const gfxIntSize& aSize,
|
|||||||
return nsnull;
|
return nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!glContext->ResizeOffscreenFBO(aSize, true)) {
|
if (!glContext->ResizeOffscreenFBO(aSize)) {
|
||||||
// we weren't able to create the initial
|
// we weren't able to create the initial
|
||||||
// offscreen FBO, so this is dead
|
// offscreen FBO, so this is dead
|
||||||
return nsnull;
|
return nsnull;
|
||||||
|
|||||||
@@ -259,10 +259,7 @@ GLContextProviderOSMesa::CreateOffscreen(const gfxIntSize& aSize,
|
|||||||
return nsnull;
|
return nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
ContextFormat actualFormat(aFormat);
|
nsRefPtr<GLContextOSMesa> glContext = new GLContextOSMesa(aFormat);
|
||||||
actualFormat.samples = 0;
|
|
||||||
|
|
||||||
nsRefPtr<GLContextOSMesa> glContext = new GLContextOSMesa(actualFormat);
|
|
||||||
|
|
||||||
if (!glContext->Init(aSize))
|
if (!glContext->Init(aSize))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -48,8 +48,6 @@
|
|||||||
|
|
||||||
#include "prenv.h"
|
#include "prenv.h"
|
||||||
|
|
||||||
#include "mozilla/Preferences.h"
|
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace gl {
|
namespace gl {
|
||||||
|
|
||||||
@@ -400,44 +398,10 @@ GLContextWGL::UnbindTex2DOffscreen(GLContext *aOffscreen)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool
|
|
||||||
GetMaxSize(HDC hDC, int format, gfxIntSize& size)
|
|
||||||
{
|
|
||||||
int query[] = {LOCAL_WGL_MAX_PBUFFER_WIDTH_ARB, LOCAL_WGL_MAX_PBUFFER_HEIGHT_ARB};
|
|
||||||
int result[2];
|
|
||||||
|
|
||||||
// (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int* piAttributes, int *piValues)
|
|
||||||
if (!sWGLLibrary.fGetPixelFormatAttribiv(hDC, format, 0, 2, query, result))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
size.width = result[0];
|
|
||||||
size.height = result[1];
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
|
||||||
IsValidSizeForFormat(HDC hDC, int format, const gfxIntSize& requested)
|
|
||||||
{
|
|
||||||
gfxIntSize max;
|
|
||||||
if (!GetMaxSize(hDC, format, max))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (requested.width > max.width)
|
|
||||||
return false;
|
|
||||||
if (requested.height > max.height)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
GLContextWGL::ResizeOffscreen(const gfxIntSize& aNewSize)
|
GLContextWGL::ResizeOffscreen(const gfxIntSize& aNewSize)
|
||||||
{
|
{
|
||||||
if (mPBuffer) {
|
if (mPBuffer) {
|
||||||
if (!IsValidSizeForFormat(gSharedWindowDC, mPixelFormat, aNewSize))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
int pbattrs[] = {
|
int pbattrs[] = {
|
||||||
LOCAL_WGL_TEXTURE_FORMAT_ARB,
|
LOCAL_WGL_TEXTURE_FORMAT_ARB,
|
||||||
mCreationFormat.alpha > 0 ? LOCAL_WGL_TEXTURE_RGBA_ARB
|
mCreationFormat.alpha > 0 ? LOCAL_WGL_TEXTURE_RGBA_ARB
|
||||||
@@ -469,10 +433,10 @@ GLContextWGL::ResizeOffscreen(const gfxIntSize& aNewSize)
|
|||||||
MakeCurrent();
|
MakeCurrent();
|
||||||
ClearSafely();
|
ClearSafely();
|
||||||
|
|
||||||
return ResizeOffscreenFBO(aNewSize, false);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ResizeOffscreenFBO(aNewSize, true);
|
return ResizeOffscreenFBO(aNewSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GLContextWGL *
|
static GLContextWGL *
|
||||||
@@ -579,9 +543,6 @@ CreatePBufferOffscreenContext(const gfxIntSize& aSize,
|
|||||||
// XXX add back the priority choosing code here
|
// XXX add back the priority choosing code here
|
||||||
int chosenFormat = formats[0];
|
int chosenFormat = formats[0];
|
||||||
|
|
||||||
if (!IsValidSizeForFormat(gSharedWindowDC, chosenFormat, aSize))
|
|
||||||
return nsnull;
|
|
||||||
|
|
||||||
HANDLE pbuffer = sWGLLibrary.fCreatePbuffer(gSharedWindowDC, chosenFormat,
|
HANDLE pbuffer = sWGLLibrary.fCreatePbuffer(gSharedWindowDC, chosenFormat,
|
||||||
aSize.width, aSize.height,
|
aSize.width, aSize.height,
|
||||||
pbattrs.Elements());
|
pbattrs.Elements());
|
||||||
@@ -609,7 +570,8 @@ CreatePBufferOffscreenContext(const gfxIntSize& aSize,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static already_AddRefed<GLContextWGL>
|
static already_AddRefed<GLContextWGL>
|
||||||
CreateWindowOffscreenContext(const ContextFormat& aFormat)
|
CreateWindowOffscreenContext(const gfxIntSize& aSize,
|
||||||
|
const ContextFormat& aFormat)
|
||||||
{
|
{
|
||||||
// CreateWindowOffscreenContext must return a global-shared context
|
// CreateWindowOffscreenContext must return a global-shared context
|
||||||
GLContextWGL *shareContext = GetGlobalContextWGL();
|
GLContextWGL *shareContext = GetGlobalContextWGL();
|
||||||
@@ -650,25 +612,19 @@ GLContextProviderWGL::CreateOffscreen(const gfxIntSize& aSize,
|
|||||||
return nsnull;
|
return nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
ContextFormat actualFormat(aFormat);
|
|
||||||
// actualFormat.samples = 0;
|
|
||||||
|
|
||||||
nsRefPtr<GLContextWGL> glContext;
|
nsRefPtr<GLContextWGL> glContext;
|
||||||
|
|
||||||
// Always try to create a pbuffer context first, because we
|
// Always try to create a pbuffer context first, because we
|
||||||
// want the context isolation.
|
// want the context isolation.
|
||||||
NS_ENSURE_TRUE(Preferences::GetRootBranch(), nsnull);
|
if (sWGLLibrary.fCreatePbuffer &&
|
||||||
const bool preferFBOs = Preferences::GetBool("wgl.prefer-fbo", false);
|
|
||||||
if (!preferFBOs &&
|
|
||||||
sWGLLibrary.fCreatePbuffer &&
|
|
||||||
sWGLLibrary.fChoosePixelFormat)
|
sWGLLibrary.fChoosePixelFormat)
|
||||||
{
|
{
|
||||||
glContext = CreatePBufferOffscreenContext(aSize, actualFormat);
|
glContext = CreatePBufferOffscreenContext(aSize, aFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it failed, then create a window context and use a FBO.
|
// If it failed, then create a window context and use a FBO.
|
||||||
if (!glContext) {
|
if (!glContext) {
|
||||||
glContext = CreateWindowOffscreenContext(actualFormat);
|
glContext = CreateWindowOffscreenContext(aSize, aFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!glContext ||
|
if (!glContext ||
|
||||||
@@ -677,12 +633,15 @@ GLContextProviderWGL::CreateOffscreen(const gfxIntSize& aSize,
|
|||||||
return nsnull;
|
return nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!glContext->ResizeOffscreenFBO(aSize, !glContext->mPBuffer))
|
|
||||||
return nsnull;
|
|
||||||
|
|
||||||
glContext->mOffscreenSize = aSize;
|
glContext->mOffscreenSize = aSize;
|
||||||
glContext->mOffscreenActualSize = aSize;
|
glContext->mOffscreenActualSize = aSize;
|
||||||
|
|
||||||
|
if (!glContext->mPBuffer &&
|
||||||
|
!glContext->ResizeOffscreenFBO(aSize))
|
||||||
|
{
|
||||||
|
return nsnull;
|
||||||
|
}
|
||||||
|
|
||||||
return glContext.forget();
|
return glContext.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -307,11 +307,6 @@ struct GLContextSymbols
|
|||||||
typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGE) (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height);
|
typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGE) (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height);
|
||||||
PFNGLRENDERBUFFERSTORAGE fRenderbufferStorage;
|
PFNGLRENDERBUFFERSTORAGE fRenderbufferStorage;
|
||||||
|
|
||||||
typedef void (GLAPIENTRY * PFNGLBLITFRAMEBUFFER) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
|
|
||||||
PFNGLBLITFRAMEBUFFER fBlitFramebuffer;
|
|
||||||
typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLE) (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height);
|
|
||||||
PFNGLRENDERBUFFERSTORAGEMULTISAMPLE fRenderbufferStorageMultisample;
|
|
||||||
|
|
||||||
|
|
||||||
/* These are different between GLES2 and desktop GL; we hide those differences, use the GL
|
/* These are different between GLES2 and desktop GL; we hide those differences, use the GL
|
||||||
* names, but the most limited data type.
|
* names, but the most limited data type.
|
||||||
|
|||||||
@@ -3291,7 +3291,6 @@ pref("webgl.verbose", false);
|
|||||||
pref("webgl.prefer-native-gl", false);
|
pref("webgl.prefer-native-gl", false);
|
||||||
pref("webgl.min_capability_mode", false);
|
pref("webgl.min_capability_mode", false);
|
||||||
pref("webgl.disable-extensions", false);
|
pref("webgl.disable-extensions", false);
|
||||||
pref("webgl.msaa-level", 2);
|
|
||||||
|
|
||||||
#ifdef XP_WIN
|
#ifdef XP_WIN
|
||||||
// The default TCP send window on Windows is too small, and autotuning only occurs on receive
|
// The default TCP send window on Windows is too small, and autotuning only occurs on receive
|
||||||
|
|||||||
Reference in New Issue
Block a user