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;
|
||||
}
|
||||
|
||||
// If we already have a gl context, then we just need to resize it
|
||||
if (gl) {
|
||||
gl->ResizeOffscreen(gfxIntSize(width, height)); // Doesn't matter if it succeeds (soft-fail)
|
||||
// It's unlikely that we'll get a proper-sized context if we recreate if we didn't on resize
|
||||
|
||||
// If we already have a gl context, then we just need to resize
|
||||
// FB0.
|
||||
if (gl &&
|
||||
gl->ResizeOffscreen(gfxIntSize(width, height)))
|
||||
{
|
||||
// everything's good, we're done here
|
||||
mWidth = gl->OffscreenActualSize().width;
|
||||
mHeight = gl->OffscreenActualSize().height;
|
||||
mWidth = width;
|
||||
mHeight = height;
|
||||
mResetLayer = true;
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -601,11 +601,6 @@ WebGLContext::SetDimensions(PRInt32 width, PRInt32 height)
|
||||
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")) {
|
||||
preferEGL = true;
|
||||
}
|
||||
@@ -903,7 +898,7 @@ WebGLContext::GetContextAttributes(jsval *aResult)
|
||||
NULL, NULL, JSPROP_ENUMERATE) ||
|
||||
!JS_DefineProperty(cx, obj, "stencil", cf.stencil > 0 ? JSVAL_TRUE : JSVAL_FALSE,
|
||||
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) ||
|
||||
!JS_DefineProperty(cx, obj, "premultipliedAlpha",
|
||||
mOptions.premultipliedAlpha ? JSVAL_TRUE : JSVAL_FALSE,
|
||||
|
||||
@@ -310,7 +310,7 @@ struct WebGLContextOptions {
|
||||
// these are defaults
|
||||
WebGLContextOptions()
|
||||
: alpha(true), depth(true), stencil(false),
|
||||
premultipliedAlpha(true), antialias(true),
|
||||
premultipliedAlpha(true), antialias(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/glsl/misc/glsl-long-variable-names.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/reading/read-pixels-test.html
|
||||
conformance/renderbuffers/framebuffer-object-attachment.html
|
||||
conformance/renderbuffers/renderbuffer-initialization.html
|
||||
conformance/textures/texture-mips.html
|
||||
conformance/uniforms/gl-uniform-bool.html
|
||||
conformance/more/functions/copyTexImage2D.html
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
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/premultiplyalpha-test.html
|
||||
conformance/glsl/misc/glsl-function-nodes.html
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
conformance/canvas/buffer-preserve-test.html
|
||||
conformance/canvas/drawingbuffer-static-canvas-test.html
|
||||
conformance/canvas/drawingbuffer-test.html
|
||||
conformance/context/premultiplyalpha-test.html
|
||||
conformance/glsl/functions/glsl-function-atan.html
|
||||
conformance/glsl/functions/glsl-function-atan-xy.html
|
||||
|
||||
@@ -1111,7 +1111,7 @@ BasicCanvasLayer::UpdateSurface(gfxASurface* aDestSurface)
|
||||
mGLContext->MakeCurrent();
|
||||
|
||||
#if defined (MOZ_X11) && defined (MOZ_EGL_XRENDER_COMPOSITE)
|
||||
mGLContext->Finish();
|
||||
mGLContext->fFinish();
|
||||
gfxASurface* offscreenSurface = mGLContext->GetOffscreenPixmapSurface();
|
||||
|
||||
// XRender can only blend premuliplied alpha, so only allow xrender
|
||||
|
||||
@@ -172,10 +172,6 @@ CanvasLayerOGL::UpdateSurface()
|
||||
}
|
||||
#endif
|
||||
|
||||
if (mCanvasGLContext) {
|
||||
mCanvasGLContext->MakeCurrent();
|
||||
mCanvasGLContext->fFinish();
|
||||
}
|
||||
mOGLManager->MakeCurrent();
|
||||
|
||||
if (mCanvasGLContext &&
|
||||
|
||||
@@ -377,33 +377,6 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
|
||||
(mSymbols.fMapBuffer && mSymbols.fUnmapBuffer),
|
||||
"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];
|
||||
|
||||
fGetIntegerv(LOCAL_GL_SCISSOR_BOX, v);
|
||||
@@ -465,11 +438,6 @@ static const char *sExtensionNames[] = {
|
||||
"GL_ARB_texture_float",
|
||||
"GL_EXT_unpack_subimage",
|
||||
"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
|
||||
};
|
||||
|
||||
@@ -1018,89 +986,66 @@ PRUint32 TiledTextureImage::GetTileCount()
|
||||
}
|
||||
|
||||
bool
|
||||
GLContext::ResizeOffscreenFBO(const gfxIntSize& aSize, const bool aUseReadFBO, const bool aDisableAA)
|
||||
GLContext::ResizeOffscreenFBO(const gfxIntSize& aSize)
|
||||
{
|
||||
if (!IsOffscreenSizeAllowed(aSize))
|
||||
return false;
|
||||
|
||||
MakeCurrent();
|
||||
|
||||
const bool alpha = mCreationFormat.alpha > 0;
|
||||
const int depth = mCreationFormat.depth;
|
||||
const int stencil = mCreationFormat.stencil;
|
||||
int samples = mCreationFormat.samples;
|
||||
bool alpha = mCreationFormat.alpha > 0;
|
||||
int depth = mCreationFormat.depth;
|
||||
int stencil = mCreationFormat.stencil;
|
||||
|
||||
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 curBoundRenderbuffer = 0;
|
||||
GLuint curBoundFramebuffer = 0;
|
||||
|
||||
GLint viewport[4];
|
||||
|
||||
const bool useDepthStencil =
|
||||
bool useDepthStencil =
|
||||
!mIsGLES2 || IsExtensionSupported(OES_packed_depth_stencil);
|
||||
|
||||
// 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_FRAMEBUFFER_BINDING, (GLint*) &curBoundFramebuffer);
|
||||
fGetIntegerv(LOCAL_GL_RENDERBUFFER_BINDING, (GLint*) &curBoundRenderbuffer);
|
||||
fGetIntegerv(LOCAL_GL_VIEWPORT, viewport);
|
||||
|
||||
// the context format of what we're defining
|
||||
// This becomes mActualFormat on success
|
||||
ContextFormat cf(mCreationFormat);
|
||||
// the context format of what we're defining;
|
||||
// for some reason, UpdateActualFormat isn't working with a bound FBO.
|
||||
ContextFormat cf;
|
||||
|
||||
// Create everything we need for the resize, so if it fails, we haven't broken anything
|
||||
// If successful, these new resized objects will replace their associated member vars in GLContext
|
||||
GLuint newOffscreenDrawFBO = 0;
|
||||
GLuint newOffscreenReadFBO = 0;
|
||||
GLuint newOffscreenTexture = 0;
|
||||
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);
|
||||
// If this is the first time we're going through this, we need
|
||||
// to create the objects we'll use. Otherwise, just bind them.
|
||||
if (firstTime) {
|
||||
fGenTextures(1, &mOffscreenTexture);
|
||||
fBindTexture(LOCAL_GL_TEXTURE_2D, mOffscreenTexture);
|
||||
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);
|
||||
|
||||
fGenFramebuffers(1, &mOffscreenFBO);
|
||||
fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, mOffscreenFBO);
|
||||
|
||||
if (depth && stencil && useDepthStencil) {
|
||||
fGenRenderbuffers(1, &mOffscreenDepthRB);
|
||||
} else {
|
||||
if (depth) {
|
||||
fGenRenderbuffers(1, &mOffscreenDepthRB);
|
||||
}
|
||||
|
||||
if (stencil) {
|
||||
fGenRenderbuffers(1, &mOffscreenStencilRB);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fBindTexture(LOCAL_GL_TEXTURE_2D, mOffscreenTexture);
|
||||
fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, mOffscreenFBO);
|
||||
}
|
||||
|
||||
// resize the FBO components
|
||||
if (alpha) {
|
||||
fTexImage2D(LOCAL_GL_TEXTURE_2D,
|
||||
0,
|
||||
@@ -1136,37 +1081,12 @@ GLContext::ResizeOffscreenFBO(const gfxIntSize& aSize, const bool aUseReadFBO, c
|
||||
#endif
|
||||
cf.alpha = 0;
|
||||
}
|
||||
}
|
||||
cf.samples = samples;
|
||||
|
||||
// Allocate color buffer
|
||||
if (useDrawMSFBO) {
|
||||
GLenum colorFormat;
|
||||
if (!mIsGLES2 || IsExtensionSupported(OES_rgb8_rgba8))
|
||||
colorFormat = alpha ? LOCAL_GL_RGBA8 : LOCAL_GL_RGB8;
|
||||
else
|
||||
colorFormat = alpha ? LOCAL_GL_RGBA4 : LOCAL_GL_RGB565;
|
||||
|
||||
fBindRenderbuffer(LOCAL_GL_RENDERBUFFER, newOffscreenColorRB);
|
||||
fRenderbufferStorageMultisample(LOCAL_GL_RENDERBUFFER,
|
||||
samples,
|
||||
colorFormat,
|
||||
aSize.width, aSize.height);
|
||||
}
|
||||
|
||||
// Allocate depth and stencil buffers
|
||||
if (depth && stencil && useDepthStencil) {
|
||||
fBindRenderbuffer(LOCAL_GL_RENDERBUFFER, newOffscreenDepthRB);
|
||||
if (useDrawMSFBO) {
|
||||
fRenderbufferStorageMultisample(LOCAL_GL_RENDERBUFFER,
|
||||
samples,
|
||||
LOCAL_GL_DEPTH24_STENCIL8,
|
||||
aSize.width, aSize.height);
|
||||
} else {
|
||||
fBindRenderbuffer(LOCAL_GL_RENDERBUFFER, mOffscreenDepthRB);
|
||||
fRenderbufferStorage(LOCAL_GL_RENDERBUFFER,
|
||||
LOCAL_GL_DEPTH24_STENCIL8,
|
||||
aSize.width, aSize.height);
|
||||
}
|
||||
cf.depth = 24;
|
||||
cf.stencil = 8;
|
||||
} else {
|
||||
@@ -1188,167 +1108,77 @@ GLContext::ResizeOffscreenFBO(const gfxIntSize& aSize, const bool aUseReadFBO, c
|
||||
cf.depth = 24;
|
||||
}
|
||||
|
||||
fBindRenderbuffer(LOCAL_GL_RENDERBUFFER, newOffscreenDepthRB);
|
||||
if (useDrawMSFBO) {
|
||||
fRenderbufferStorageMultisample(LOCAL_GL_RENDERBUFFER,
|
||||
samples,
|
||||
depthType,
|
||||
fBindRenderbuffer(LOCAL_GL_RENDERBUFFER, mOffscreenDepthRB);
|
||||
fRenderbufferStorage(LOCAL_GL_RENDERBUFFER, depthType,
|
||||
aSize.width, aSize.height);
|
||||
} else {
|
||||
fRenderbufferStorage(LOCAL_GL_RENDERBUFFER,
|
||||
depthType,
|
||||
aSize.width, aSize.height);
|
||||
}
|
||||
}
|
||||
|
||||
if (stencil) {
|
||||
fBindRenderbuffer(LOCAL_GL_RENDERBUFFER, newOffscreenStencilRB);
|
||||
if (useDrawMSFBO) {
|
||||
fRenderbufferStorageMultisample(LOCAL_GL_RENDERBUFFER,
|
||||
samples,
|
||||
LOCAL_GL_STENCIL_INDEX8,
|
||||
aSize.width, aSize.height);
|
||||
} else {
|
||||
fBindRenderbuffer(LOCAL_GL_RENDERBUFFER, mOffscreenStencilRB);
|
||||
fRenderbufferStorage(LOCAL_GL_RENDERBUFFER,
|
||||
LOCAL_GL_STENCIL_INDEX8,
|
||||
aSize.width, aSize.height);
|
||||
}
|
||||
cf.stencil = 8;
|
||||
}
|
||||
}
|
||||
|
||||
// Now assemble the FBO
|
||||
fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, newOffscreenDrawFBO); // If we're not using a separate draw FBO, this will be the read FBO
|
||||
if (useDrawMSFBO) {
|
||||
fFramebufferRenderbuffer(LOCAL_GL_FRAMEBUFFER,
|
||||
// Now assemble the FBO, if we're creating one
|
||||
// for the first time.
|
||||
if (firstTime) {
|
||||
fFramebufferTexture2D(LOCAL_GL_FRAMEBUFFER,
|
||||
LOCAL_GL_COLOR_ATTACHMENT0,
|
||||
LOCAL_GL_RENDERBUFFER,
|
||||
newOffscreenColorRB);
|
||||
}
|
||||
LOCAL_GL_TEXTURE_2D,
|
||||
mOffscreenTexture,
|
||||
0);
|
||||
|
||||
if (depth && stencil && useDepthStencil) {
|
||||
fFramebufferRenderbuffer(LOCAL_GL_FRAMEBUFFER,
|
||||
LOCAL_GL_DEPTH_ATTACHMENT,
|
||||
LOCAL_GL_RENDERBUFFER,
|
||||
newOffscreenDepthRB);
|
||||
mOffscreenDepthRB);
|
||||
fFramebufferRenderbuffer(LOCAL_GL_FRAMEBUFFER,
|
||||
LOCAL_GL_STENCIL_ATTACHMENT,
|
||||
LOCAL_GL_RENDERBUFFER,
|
||||
newOffscreenDepthRB);
|
||||
mOffscreenDepthRB);
|
||||
} else {
|
||||
if (depth) {
|
||||
fFramebufferRenderbuffer(LOCAL_GL_FRAMEBUFFER,
|
||||
LOCAL_GL_DEPTH_ATTACHMENT,
|
||||
LOCAL_GL_RENDERBUFFER,
|
||||
newOffscreenDepthRB);
|
||||
mOffscreenDepthRB);
|
||||
}
|
||||
|
||||
if (stencil) {
|
||||
fFramebufferRenderbuffer(LOCAL_GL_FRAMEBUFFER,
|
||||
LOCAL_GL_STENCIL_ATTACHMENT,
|
||||
LOCAL_GL_RENDERBUFFER,
|
||||
newOffscreenStencilRB);
|
||||
mOffscreenStencilRB);
|
||||
}
|
||||
}
|
||||
|
||||
if (aUseReadFBO) {
|
||||
fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, newOffscreenReadFBO);
|
||||
fFramebufferTexture2D(LOCAL_GL_FRAMEBUFFER,
|
||||
LOCAL_GL_COLOR_ATTACHMENT0,
|
||||
LOCAL_GL_TEXTURE_2D,
|
||||
newOffscreenTexture,
|
||||
0);
|
||||
}
|
||||
|
||||
// We should be all resized. Check for framebuffer completeness.
|
||||
GLenum status;
|
||||
bool framebuffersComplete = true;
|
||||
|
||||
fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, newOffscreenDrawFBO);
|
||||
status = fCheckFramebufferStatus(LOCAL_GL_FRAMEBUFFER);
|
||||
GLenum status = fCheckFramebufferStatus(LOCAL_GL_FRAMEBUFFER);
|
||||
if (status != LOCAL_GL_FRAMEBUFFER_COMPLETE) {
|
||||
NS_WARNING("DrawFBO: Incomplete");
|
||||
#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]);
|
||||
|
||||
NS_WARNING("Error resizing offscreen framebuffer -- framebuffer not complete");
|
||||
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;
|
||||
mOffscreenActualSize = aSize;
|
||||
|
||||
if (firstTime) {
|
||||
// UpdateActualFormat() doesn't work for some reason, with a
|
||||
// FBO bound, even though it should.
|
||||
//UpdateActualFormat();
|
||||
mActualFormat = cf;
|
||||
|
||||
#ifdef DEBUG
|
||||
if (mDebugMode) {
|
||||
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,
|
||||
printf_stderr("Created offscreen FBO: r: %d g: %d b: %d a: %d depth: %d stencil: %d\n",
|
||||
mActualFormat.red, mActualFormat.green, mActualFormat.blue, mActualFormat.alpha,
|
||||
mActualFormat.depth, mActualFormat.stencil, mActualFormat.samples);
|
||||
}
|
||||
mActualFormat.depth, mActualFormat.stencil);
|
||||
#endif
|
||||
}
|
||||
|
||||
// We're good, and the framebuffer is already attached, so let's
|
||||
// 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.
|
||||
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
|
||||
fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, GetOffscreenFBO());
|
||||
ClearSafely();
|
||||
|
||||
// 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);
|
||||
fBindRenderbuffer(LOCAL_GL_RENDERBUFFER, curBoundRenderbuffer);
|
||||
fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, curBoundFramebuffer);
|
||||
|
||||
// -don't- restore the viewport the first time through this, since
|
||||
// the previous one isn't valid.
|
||||
@@ -1380,17 +1205,13 @@ GLContext::ResizeOffscreenFBO(const gfxIntSize& aSize, const bool aUseReadFBO, c
|
||||
void
|
||||
GLContext::DeleteOffscreenFBO()
|
||||
{
|
||||
fDeleteFramebuffers(1, &mOffscreenDrawFBO);
|
||||
fDeleteFramebuffers(1, &mOffscreenReadFBO);
|
||||
fDeleteFramebuffers(1, &mOffscreenFBO);
|
||||
fDeleteTextures(1, &mOffscreenTexture);
|
||||
fDeleteRenderbuffers(1, &mOffscreenColorRB);
|
||||
fDeleteRenderbuffers(1, &mOffscreenDepthRB);
|
||||
fDeleteRenderbuffers(1, &mOffscreenStencilRB);
|
||||
|
||||
mOffscreenDrawFBO = 0;
|
||||
mOffscreenReadFBO = 0;
|
||||
mOffscreenFBO = 0;
|
||||
mOffscreenTexture = 0;
|
||||
mOffscreenColorRB = 0;
|
||||
mOffscreenDepthRB = 0;
|
||||
mOffscreenStencilRB = 0;
|
||||
}
|
||||
|
||||
@@ -476,11 +476,11 @@ struct THEBES_API ContextFormat
|
||||
};
|
||||
|
||||
ContextFormat() {
|
||||
memset(this, 0, sizeof(ContextFormat));
|
||||
memset(this, 0, sizeof(*this));
|
||||
}
|
||||
|
||||
ContextFormat(const StandardContextFormat cf) {
|
||||
memset(this, 0, sizeof(ContextFormat));
|
||||
memset(this, 0, sizeof(*this));
|
||||
switch (cf) {
|
||||
case BasicRGBA32:
|
||||
red = green = blue = alpha = 8;
|
||||
@@ -519,7 +519,6 @@ struct THEBES_API ContextFormat
|
||||
int green, minGreen;
|
||||
int blue, minBlue;
|
||||
int alpha, minAlpha;
|
||||
int samples;
|
||||
|
||||
int colorBits() const { return red + green + blue; }
|
||||
};
|
||||
@@ -548,10 +547,7 @@ public:
|
||||
mFlipped(false),
|
||||
mBlitProgram(0),
|
||||
mBlitFramebuffer(0),
|
||||
mOffscreenDrawFBO(0),
|
||||
mOffscreenReadFBO(0),
|
||||
mOffscreenFBOsDirty(false),
|
||||
mOffscreenColorRB(0),
|
||||
mOffscreenFBO(0),
|
||||
mOffscreenDepthRB(0),
|
||||
mOffscreenStencilRB(0)
|
||||
#ifdef DEBUG
|
||||
@@ -723,7 +719,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!aOffscreen->mOffscreenDrawFBO && !aOffscreen->mOffscreenReadFBO) {
|
||||
if (!aOffscreen->mOffscreenFBO) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -753,8 +749,8 @@ public:
|
||||
* Only valid if IsOffscreen() returns true.
|
||||
*/
|
||||
virtual bool ResizeOffscreen(const gfxIntSize& aNewSize) {
|
||||
if (mOffscreenDrawFBO || mOffscreenReadFBO)
|
||||
return ResizeOffscreenFBO(aNewSize, mOffscreenReadFBO != 0);
|
||||
if (mOffscreenFBO)
|
||||
return ResizeOffscreenFBO(aNewSize);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -785,232 +781,12 @@ public:
|
||||
* Only valid if IsOffscreen() returns true.
|
||||
*/
|
||||
GLuint GetOffscreenFBO() {
|
||||
// 0 is interpreted as (off)screen, whether for read or draw operations
|
||||
return 0;
|
||||
return mOffscreenFBO;
|
||||
}
|
||||
|
||||
GLuint GetOffscreenTexture() {
|
||||
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)
|
||||
virtual gfxASurface* GetOffscreenPixmapSurface()
|
||||
{
|
||||
@@ -1237,11 +1013,6 @@ public:
|
||||
ARB_texture_float,
|
||||
EXT_unpack_subimage,
|
||||
OES_standard_derivatives,
|
||||
EXT_framebuffer_blit,
|
||||
ANGLE_framebuffer_blit,
|
||||
EXT_framebuffer_multisample,
|
||||
ANGLE_framebuffer_multisample,
|
||||
OES_rgb8_rgba8,
|
||||
Extensions_Max
|
||||
};
|
||||
|
||||
@@ -1321,20 +1092,9 @@ protected:
|
||||
|
||||
// helper to create/resize an offscreen FBO,
|
||||
// for offscreen implementations that use FBOs.
|
||||
bool ResizeOffscreenFBO(const gfxIntSize& aSize, const bool aUseReadFBO, const bool aDisableAA);
|
||||
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);
|
||||
}
|
||||
bool ResizeOffscreenFBO(const gfxIntSize& aSize);
|
||||
void DeleteOffscreenFBO();
|
||||
GLuint mOffscreenDrawFBO;
|
||||
GLuint mOffscreenReadFBO;
|
||||
GLuint mOffscreenColorRB;
|
||||
GLuint mOffscreenFBO;
|
||||
GLuint mOffscreenDepthRB;
|
||||
GLuint mOffscreenStencilRB;
|
||||
|
||||
@@ -1694,7 +1454,7 @@ public:
|
||||
AFTER_GL_CALL;
|
||||
}
|
||||
|
||||
void raw_fClear(GLbitfield mask) {
|
||||
void fClear(GLbitfield mask) {
|
||||
BEFORE_GL_CALL;
|
||||
mSymbols.fClear(mask);
|
||||
AFTER_GL_CALL;
|
||||
@@ -1754,13 +1514,13 @@ public:
|
||||
AFTER_GL_CALL;
|
||||
}
|
||||
|
||||
void raw_fDrawArrays(GLenum mode, GLint first, GLsizei count) {
|
||||
void fDrawArrays(GLenum mode, GLint first, GLsizei count) {
|
||||
BEFORE_GL_CALL;
|
||||
mSymbols.fDrawArrays(mode, first, count);
|
||||
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;
|
||||
mSymbols.fDrawElements(mode, count, type, indices);
|
||||
AFTER_GL_CALL;
|
||||
@@ -1778,7 +1538,7 @@ public:
|
||||
AFTER_GL_CALL;
|
||||
}
|
||||
|
||||
void raw_fFinish() {
|
||||
void fFinish() {
|
||||
BEFORE_GL_CALL;
|
||||
mSymbols.fFinish();
|
||||
AFTER_GL_CALL;
|
||||
@@ -1996,7 +1756,7 @@ public:
|
||||
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;
|
||||
mSymbols.fReadPixels(x, y, width, height, format, type, pixels);
|
||||
AFTER_GL_CALL;
|
||||
@@ -2242,7 +2002,7 @@ public:
|
||||
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;
|
||||
mSymbols.fCopyTexImage2D(target, level, internalformat,
|
||||
x, FixYValue(y, height),
|
||||
@@ -2250,7 +2010,7 @@ public:
|
||||
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;
|
||||
mSymbols.fCopyTexSubImage2D(target, level, xoffset, yoffset,
|
||||
x, FixYValue(y, height),
|
||||
@@ -2332,12 +2092,6 @@ public:
|
||||
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) {
|
||||
BEFORE_GL_CALL;
|
||||
realGLboolean retval = mSymbols.fIsRenderbuffer(renderbuffer);
|
||||
@@ -2351,12 +2105,6 @@ public:
|
||||
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) {
|
||||
BEFORE_GL_CALL;
|
||||
if (mIsGLES2) {
|
||||
|
||||
@@ -46,7 +46,6 @@
|
||||
#include "gfxPlatform.h"
|
||||
#include "gfxFailure.h"
|
||||
#include "prenv.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gl {
|
||||
@@ -264,9 +263,6 @@ GLContextCGL::UnbindTex2DOffscreen(GLContext *aOffscreen)
|
||||
bool
|
||||
GLContextCGL::ResizeOffscreen(const gfxIntSize& aNewSize)
|
||||
{
|
||||
if (!IsOffscreenSizeAllowed(aNewSize))
|
||||
return false;
|
||||
|
||||
if (mPBuffer) {
|
||||
NSOpenGLPixelBuffer *pb = [[NSOpenGLPixelBuffer alloc]
|
||||
initWithTextureTarget:LOCAL_GL_TEXTURE_2D
|
||||
@@ -278,10 +274,6 @@ GLContextCGL::ResizeOffscreen(const gfxIntSize& aNewSize)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ResizeOffscreenFBO(aNewSize, false)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
[mPBuffer release];
|
||||
mPBuffer = pb;
|
||||
|
||||
@@ -297,7 +289,7 @@ GLContextCGL::ResizeOffscreen(const gfxIntSize& aNewSize)
|
||||
return true;
|
||||
}
|
||||
|
||||
return ResizeOffscreenFBO(aNewSize, true);
|
||||
return ResizeOffscreenFBO(aNewSize);
|
||||
}
|
||||
|
||||
class TextureImageCGL : public BasicTextureImage
|
||||
@@ -536,7 +528,8 @@ CreateOffscreenPBufferContext(const gfxIntSize& aSize,
|
||||
}
|
||||
|
||||
static already_AddRefed<GLContextCGL>
|
||||
CreateOffscreenFBOContext(const ContextFormat& aFormat,
|
||||
CreateOffscreenFBOContext(const gfxIntSize& aSize,
|
||||
const ContextFormat& aFormat,
|
||||
bool aShare = true)
|
||||
{
|
||||
if (!sCGLLibrary.EnsureInitialized()) {
|
||||
@@ -564,34 +557,23 @@ 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, actualFormat);
|
||||
glContext = CreateOffscreenPBufferContext(aSize, aFormat);
|
||||
if (glContext &&
|
||||
glContext->Init() &&
|
||||
glContext->ResizeOffscreenFBO(aSize, false))
|
||||
glContext->Init())
|
||||
{
|
||||
glContext->mOffscreenSize = aSize;
|
||||
glContext->mOffscreenActualSize = aSize;
|
||||
|
||||
printf("GL Offscreen: CGL+PBuffer\n");
|
||||
|
||||
return glContext.forget();
|
||||
}
|
||||
}
|
||||
|
||||
// try a FBO as second choice
|
||||
glContext = CreateOffscreenFBOContext(actualFormat);
|
||||
glContext = CreateOffscreenFBOContext(aSize, aFormat);
|
||||
if (glContext &&
|
||||
glContext->Init() &&
|
||||
glContext->ResizeOffscreenFBO(aSize, true))
|
||||
glContext->ResizeOffscreenFBO(aSize))
|
||||
{
|
||||
return glContext.forget();
|
||||
}
|
||||
@@ -620,7 +602,8 @@ 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(ContextFormat(ContextFormat::BasicRGB24),
|
||||
gGlobalContext = CreateOffscreenFBOContext(gfxIntSize(16, 16),
|
||||
ContextFormat(ContextFormat::BasicRGB24),
|
||||
false);
|
||||
if (!gGlobalContext || !static_cast<GLContextCGL*>(gGlobalContext.get())->Init()) {
|
||||
NS_WARNING("Couldn't init gGlobalContext.");
|
||||
|
||||
@@ -1054,9 +1054,6 @@ GLContextEGL::UnbindTex2DOffscreen(GLContext *aOffscreen)
|
||||
bool
|
||||
GLContextEGL::ResizeOffscreen(const gfxIntSize& aNewSize)
|
||||
{
|
||||
if (!IsOffscreenSizeAllowed(aNewSize))
|
||||
return false;
|
||||
|
||||
if (mIsPBuffer) {
|
||||
gfxIntSize pbsize(aNewSize);
|
||||
|
||||
@@ -1070,12 +1067,9 @@ GLContextEGL::ResizeOffscreen(const gfxIntSize& aNewSize)
|
||||
pbsize);
|
||||
if (!surface) {
|
||||
NS_WARNING("Failed to resize pbuffer");
|
||||
return false;
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
if (!ResizeOffscreenFBO(pbsize, false))
|
||||
return false;
|
||||
|
||||
SetOffscreenSize(aNewSize, pbsize);
|
||||
|
||||
if (mSurface && !mPlatformContext) {
|
||||
@@ -1120,9 +1114,6 @@ GLContextEGL::ResizeOffscreen(const gfxIntSize& aNewSize)
|
||||
if (!config) {
|
||||
return false;
|
||||
}
|
||||
if (!ResizeOffscreenFBO(aNewSize, true))
|
||||
return false;
|
||||
|
||||
mThebesSurface = xsurface;
|
||||
|
||||
return true;
|
||||
@@ -1130,13 +1121,10 @@ GLContextEGL::ResizeOffscreen(const gfxIntSize& aNewSize)
|
||||
#endif
|
||||
|
||||
#if defined(MOZ_X11) && defined(MOZ_EGL_XRENDER_COMPOSITE)
|
||||
if (ResizeOffscreenPixmapSurface(aNewSize)) {
|
||||
if (ResizeOffscreenFBO(aNewSize, true))
|
||||
return true;
|
||||
}
|
||||
return ResizeOffscreenPixmapSurface(aNewSize);
|
||||
#endif
|
||||
|
||||
return ResizeOffscreenFBO(aNewSize, true);
|
||||
return ResizeOffscreenFBO(aNewSize);
|
||||
}
|
||||
|
||||
|
||||
@@ -2011,15 +1999,13 @@ GLContextEGL::CreateEGLPBufferOffscreenContext(const gfxIntSize& aSize,
|
||||
nsTArray<EGLint> attribs(32);
|
||||
int attribAttempt = 0;
|
||||
|
||||
int tryDepthSize = (aFormat.depth > 0) ? 24 : 0;
|
||||
|
||||
TRY_ATTRIBS_AGAIN:
|
||||
switch (attribAttempt) {
|
||||
case 0:
|
||||
FillPBufferAttribs(attribs, aFormat, configCanBindToTexture, 8, tryDepthSize);
|
||||
FillPBufferAttribs(attribs, aFormat, configCanBindToTexture, 8, 24);
|
||||
break;
|
||||
case 1:
|
||||
FillPBufferAttribs(attribs, aFormat, configCanBindToTexture, -1, tryDepthSize);
|
||||
FillPBufferAttribs(attribs, aFormat, configCanBindToTexture, -1, 24);
|
||||
break;
|
||||
case 2:
|
||||
FillPBufferAttribs(attribs, aFormat, configCanBindToTexture, -1, -1);
|
||||
@@ -2252,37 +2238,13 @@ GLContextProviderEGL::CreateOffscreen(const gfxIntSize& aSize,
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
ContextFormat actualFormat(aFormat);
|
||||
// actualFormat.samples = 0;
|
||||
|
||||
#if defined(ANDROID) || defined(XP_WIN)
|
||||
nsRefPtr<GLContextEGL> glContext =
|
||||
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();
|
||||
|
||||
return GLContextEGL::CreateEGLPBufferOffscreenContext(aSize, aFormat);
|
||||
#elif defined(MOZ_X11) && defined(MOZ_EGL_XRENDER_COMPOSITE)
|
||||
nsRefPtr<GLContextEGL> glContext =
|
||||
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();
|
||||
return GLContextEGL::CreateBasicEGLPixmapOffscreenContext(aSize, aFormat);
|
||||
#elif defined(MOZ_X11)
|
||||
nsRefPtr<GLContextEGL> glContext =
|
||||
GLContextEGL::CreateEGLPixmapOffscreenContext(aSize, actualFormat, true);
|
||||
GLContextEGL::CreateEGLPixmapOffscreenContext(aSize, aFormat, true);
|
||||
|
||||
if (!glContext) {
|
||||
return nsnull;
|
||||
@@ -2292,7 +2254,7 @@ GLContextProviderEGL::CreateOffscreen(const gfxIntSize& aSize,
|
||||
// render from this
|
||||
return nsnull;
|
||||
}
|
||||
if (!gUseBackingSurface && !glContext->ResizeOffscreenFBO(glContext->OffscreenActualSize(), true)) {
|
||||
if (!gUseBackingSurface && !glContext->ResizeOffscreenFBO(aSize)) {
|
||||
// we weren't able to create the initial
|
||||
// offscreen FBO, so this is dead
|
||||
return nsnull;
|
||||
|
||||
@@ -1237,11 +1237,9 @@ already_AddRefed<GLContext>
|
||||
GLContextProviderGLX::CreateOffscreen(const gfxIntSize& aSize,
|
||||
const ContextFormat& aFormat)
|
||||
{
|
||||
ContextFormat actualFormat(aFormat);
|
||||
// actualFormat.samples = 0;
|
||||
|
||||
nsRefPtr<GLContextGLX> glContext =
|
||||
CreateOffscreenPixmapContext(aSize, actualFormat, true);
|
||||
CreateOffscreenPixmapContext(aSize, aFormat, true);
|
||||
|
||||
if (!glContext) {
|
||||
return nsnull;
|
||||
@@ -1253,7 +1251,7 @@ GLContextProviderGLX::CreateOffscreen(const gfxIntSize& aSize,
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
if (!glContext->ResizeOffscreenFBO(aSize, true)) {
|
||||
if (!glContext->ResizeOffscreenFBO(aSize)) {
|
||||
// we weren't able to create the initial
|
||||
// offscreen FBO, so this is dead
|
||||
return nsnull;
|
||||
|
||||
@@ -259,10 +259,7 @@ GLContextProviderOSMesa::CreateOffscreen(const gfxIntSize& aSize,
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
ContextFormat actualFormat(aFormat);
|
||||
actualFormat.samples = 0;
|
||||
|
||||
nsRefPtr<GLContextOSMesa> glContext = new GLContextOSMesa(actualFormat);
|
||||
nsRefPtr<GLContextOSMesa> glContext = new GLContextOSMesa(aFormat);
|
||||
|
||||
if (!glContext->Init(aSize))
|
||||
{
|
||||
|
||||
@@ -48,8 +48,6 @@
|
||||
|
||||
#include "prenv.h"
|
||||
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
namespace mozilla {
|
||||
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
|
||||
GLContextWGL::ResizeOffscreen(const gfxIntSize& aNewSize)
|
||||
{
|
||||
if (mPBuffer) {
|
||||
if (!IsValidSizeForFormat(gSharedWindowDC, mPixelFormat, aNewSize))
|
||||
return false;
|
||||
|
||||
int pbattrs[] = {
|
||||
LOCAL_WGL_TEXTURE_FORMAT_ARB,
|
||||
mCreationFormat.alpha > 0 ? LOCAL_WGL_TEXTURE_RGBA_ARB
|
||||
@@ -469,10 +433,10 @@ GLContextWGL::ResizeOffscreen(const gfxIntSize& aNewSize)
|
||||
MakeCurrent();
|
||||
ClearSafely();
|
||||
|
||||
return ResizeOffscreenFBO(aNewSize, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
return ResizeOffscreenFBO(aNewSize, true);
|
||||
return ResizeOffscreenFBO(aNewSize);
|
||||
}
|
||||
|
||||
static GLContextWGL *
|
||||
@@ -579,9 +543,6 @@ CreatePBufferOffscreenContext(const gfxIntSize& aSize,
|
||||
// XXX add back the priority choosing code here
|
||||
int chosenFormat = formats[0];
|
||||
|
||||
if (!IsValidSizeForFormat(gSharedWindowDC, chosenFormat, aSize))
|
||||
return nsnull;
|
||||
|
||||
HANDLE pbuffer = sWGLLibrary.fCreatePbuffer(gSharedWindowDC, chosenFormat,
|
||||
aSize.width, aSize.height,
|
||||
pbattrs.Elements());
|
||||
@@ -609,7 +570,8 @@ CreatePBufferOffscreenContext(const gfxIntSize& aSize,
|
||||
}
|
||||
|
||||
static already_AddRefed<GLContextWGL>
|
||||
CreateWindowOffscreenContext(const ContextFormat& aFormat)
|
||||
CreateWindowOffscreenContext(const gfxIntSize& aSize,
|
||||
const ContextFormat& aFormat)
|
||||
{
|
||||
// CreateWindowOffscreenContext must return a global-shared context
|
||||
GLContextWGL *shareContext = GetGlobalContextWGL();
|
||||
@@ -650,25 +612,19 @@ GLContextProviderWGL::CreateOffscreen(const gfxIntSize& aSize,
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
ContextFormat actualFormat(aFormat);
|
||||
// actualFormat.samples = 0;
|
||||
|
||||
nsRefPtr<GLContextWGL> glContext;
|
||||
|
||||
// Always try to create a pbuffer context first, because we
|
||||
// want the context isolation.
|
||||
NS_ENSURE_TRUE(Preferences::GetRootBranch(), nsnull);
|
||||
const bool preferFBOs = Preferences::GetBool("wgl.prefer-fbo", false);
|
||||
if (!preferFBOs &&
|
||||
sWGLLibrary.fCreatePbuffer &&
|
||||
if (sWGLLibrary.fCreatePbuffer &&
|
||||
sWGLLibrary.fChoosePixelFormat)
|
||||
{
|
||||
glContext = CreatePBufferOffscreenContext(aSize, actualFormat);
|
||||
glContext = CreatePBufferOffscreenContext(aSize, aFormat);
|
||||
}
|
||||
|
||||
// If it failed, then create a window context and use a FBO.
|
||||
if (!glContext) {
|
||||
glContext = CreateWindowOffscreenContext(actualFormat);
|
||||
glContext = CreateWindowOffscreenContext(aSize, aFormat);
|
||||
}
|
||||
|
||||
if (!glContext ||
|
||||
@@ -677,12 +633,15 @@ GLContextProviderWGL::CreateOffscreen(const gfxIntSize& aSize,
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
if (!glContext->ResizeOffscreenFBO(aSize, !glContext->mPBuffer))
|
||||
return nsnull;
|
||||
|
||||
glContext->mOffscreenSize = aSize;
|
||||
glContext->mOffscreenActualSize = aSize;
|
||||
|
||||
if (!glContext->mPBuffer &&
|
||||
!glContext->ResizeOffscreenFBO(aSize))
|
||||
{
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
return glContext.forget();
|
||||
}
|
||||
|
||||
|
||||
@@ -307,11 +307,6 @@ struct GLContextSymbols
|
||||
typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGE) (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height);
|
||||
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
|
||||
* names, but the most limited data type.
|
||||
|
||||
@@ -3291,7 +3291,6 @@ pref("webgl.verbose", false);
|
||||
pref("webgl.prefer-native-gl", false);
|
||||
pref("webgl.min_capability_mode", false);
|
||||
pref("webgl.disable-extensions", false);
|
||||
pref("webgl.msaa-level", 2);
|
||||
|
||||
#ifdef XP_WIN
|
||||
// The default TCP send window on Windows is too small, and autotuning only occurs on receive
|
||||
|
||||
Reference in New Issue
Block a user