Bug 741730 - Remove USE_GLES2 - r=romaxa

This commit is contained in:
Benoit Jacob 2012-04-10 11:49:21 -04:00
Родитель b1ec60fb23
Коммит 3ec34c8a72
4 изменённых файлов: 143 добавлений и 165 удалений

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

@ -2338,11 +2338,7 @@ GLContext::UploadSurfaceToTexture(gfxASurface *aSurface,
PRInt32 stride = imageSurface->Stride(); PRInt32 stride = imageSurface->Stride();
#ifndef USE_GLES2 internalformat = mIsGLES2 ? format : LOCAL_GL_RGBA;
internalformat = LOCAL_GL_RGBA;
#else
internalformat = format;
#endif
nsIntRegionRectIterator iter(paintRegion); nsIntRegionRectIterator iter(paintRegion);
const nsIntRect *iterRect; const nsIntRect *iterRect;
@ -2410,52 +2406,94 @@ GLContext::TexImage2D(GLenum target, GLint level, GLint internalformat,
GLint pixelsize, GLint border, GLenum format, GLint pixelsize, GLint border, GLenum format,
GLenum type, const GLvoid *pixels) GLenum type, const GLvoid *pixels)
{ {
#ifdef USE_GLES2 if (mIsGLES2) {
NS_ASSERTION(format == internalformat, NS_ASSERTION(format == internalformat,
"format and internalformat not the same for glTexImage2D on GLES2"); "format and internalformat not the same for glTexImage2D on GLES2");
if (!CanUploadNonPowerOfTwo() if (!CanUploadNonPowerOfTwo()
&& (stride != width * pixelsize && (stride != width * pixelsize
|| !IsPowerOfTwo(width) || !IsPowerOfTwo(width)
|| !IsPowerOfTwo(height))) { || !IsPowerOfTwo(height))) {
// Pad out texture width and height to the next power of two // Pad out texture width and height to the next power of two
// as we don't support/want non power of two texture uploads // as we don't support/want non power of two texture uploads
GLsizei paddedWidth = NextPowerOfTwo(width); GLsizei paddedWidth = NextPowerOfTwo(width);
GLsizei paddedHeight = NextPowerOfTwo(height); GLsizei paddedHeight = NextPowerOfTwo(height);
GLvoid* paddedPixels = new unsigned char[paddedWidth * paddedHeight * pixelsize]; GLvoid* paddedPixels = new unsigned char[paddedWidth * paddedHeight * pixelsize];
// Pad out texture data to be in a POT sized buffer for uploading to // Pad out texture data to be in a POT sized buffer for uploading to
// a POT sized texture // a POT sized texture
CopyAndPadTextureData(pixels, paddedPixels, width, height, CopyAndPadTextureData(pixels, paddedPixels, width, height,
paddedWidth, paddedHeight, stride, pixelsize); paddedWidth, paddedHeight, stride, pixelsize);
fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT,
NS_MIN(GetAddressAlignment((ptrdiff_t)paddedPixels),
GetAddressAlignment((ptrdiff_t)paddedWidth * pixelsize)));
fTexImage2D(target,
border,
internalformat,
paddedWidth,
paddedHeight,
border,
format,
type,
paddedPixels);
fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT, 4);
delete[] static_cast<unsigned char*>(paddedPixels);
return;
}
if (stride == width * pixelsize) {
fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT,
NS_MIN(GetAddressAlignment((ptrdiff_t)pixels),
GetAddressAlignment((ptrdiff_t)stride)));
fTexImage2D(target,
border,
internalformat,
width,
height,
border,
format,
type,
pixels);
fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT, 4);
} else {
// Use GLES-specific workarounds for GL_UNPACK_ROW_LENGTH; these are
// implemented in TexSubImage2D.
fTexImage2D(target,
border,
internalformat,
width,
height,
border,
format,
type,
NULL);
TexSubImage2D(target,
level,
0,
0,
width,
height,
stride,
pixelsize,
format,
type,
pixels);
}
} else {
// desktop GL (non-ES) path
fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT, fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT,
NS_MIN(GetAddressAlignment((ptrdiff_t)paddedPixels), NS_MIN(GetAddressAlignment((ptrdiff_t)pixels),
GetAddressAlignment((ptrdiff_t)paddedWidth * pixelsize))); GetAddressAlignment((ptrdiff_t)stride)));
int rowLength = stride/pixelsize;
fPixelStorei(LOCAL_GL_UNPACK_ROW_LENGTH, rowLength);
fTexImage2D(target, fTexImage2D(target,
border, level,
internalformat,
paddedWidth,
paddedHeight,
border,
format,
type,
paddedPixels);
fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT, 4);
delete[] static_cast<unsigned char*>(paddedPixels);
return;
}
if (stride == width * pixelsize) {
fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT,
NS_MIN(GetAddressAlignment((ptrdiff_t)pixels),
GetAddressAlignment((ptrdiff_t)stride)));
fTexImage2D(target,
border,
internalformat, internalformat,
width, width,
height, height,
@ -2463,49 +2501,9 @@ GLContext::TexImage2D(GLenum target, GLint level, GLint internalformat,
format, format,
type, type,
pixels); pixels);
fPixelStorei(LOCAL_GL_UNPACK_ROW_LENGTH, 0);
fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT, 4); fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT, 4);
} else {
// Use GLES-specific workarounds for GL_UNPACK_ROW_LENGTH; these are
// implemented in TexSubImage2D.
fTexImage2D(target,
border,
internalformat,
width,
height,
border,
format,
type,
NULL);
TexSubImage2D(target,
level,
0,
0,
width,
height,
stride,
pixelsize,
format,
type,
pixels);
} }
#else
fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT,
NS_MIN(GetAddressAlignment((ptrdiff_t)pixels),
GetAddressAlignment((ptrdiff_t)stride)));
int rowLength = stride/pixelsize;
fPixelStorei(LOCAL_GL_UNPACK_ROW_LENGTH, rowLength);
fTexImage2D(target,
level,
internalformat,
width,
height,
border,
format,
type,
pixels);
fPixelStorei(LOCAL_GL_UNPACK_ROW_LENGTH, 0);
fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT, 4);
#endif
} }
void void
@ -2515,49 +2513,50 @@ GLContext::TexSubImage2D(GLenum target, GLint level,
GLint pixelsize, GLenum format, GLint pixelsize, GLenum format,
GLenum type, const GLvoid* pixels) GLenum type, const GLvoid* pixels)
{ {
#ifdef USE_GLES2 if (mIsGLES2) {
if (stride == width * pixelsize) { if (stride == width * pixelsize) {
fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT, fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT,
NS_MIN(GetAddressAlignment((ptrdiff_t)pixels), NS_MIN(GetAddressAlignment((ptrdiff_t)pixels),
GetAddressAlignment((ptrdiff_t)stride))); GetAddressAlignment((ptrdiff_t)stride)));
fTexSubImage2D(target, fTexSubImage2D(target,
level, level,
xoffset, xoffset,
yoffset, yoffset,
width, width,
height, height,
format, format,
type, type,
pixels); pixels);
fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT, 4); fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT, 4);
} else if (IsExtensionSupported(EXT_unpack_subimage)) { } else if (IsExtensionSupported(EXT_unpack_subimage)) {
TexSubImage2DWithUnpackSubimageGLES(target, level, xoffset, yoffset, TexSubImage2DWithUnpackSubimageGLES(target, level, xoffset, yoffset,
width, height, stride, width, height, stride,
pixelsize, format, type, pixels); pixelsize, format, type, pixels);
} else {
TexSubImage2DWithoutUnpackSubimage(target, level, xoffset, yoffset,
width, height, stride,
pixelsize, format, type, pixels);
}
} else { } else {
TexSubImage2DWithoutUnpackSubimage(target, level, xoffset, yoffset, // desktop GL (non-ES) path
width, height, stride, fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT,
pixelsize, format, type, pixels); NS_MIN(GetAddressAlignment((ptrdiff_t)pixels),
GetAddressAlignment((ptrdiff_t)stride)));
int rowLength = stride/pixelsize;
fPixelStorei(LOCAL_GL_UNPACK_ROW_LENGTH, rowLength);
fTexSubImage2D(target,
level,
xoffset,
yoffset,
width,
height,
format,
type,
pixels);
fPixelStorei(LOCAL_GL_UNPACK_ROW_LENGTH, 0);
fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT, 4);
} }
#else
fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT,
NS_MIN(GetAddressAlignment((ptrdiff_t)pixels),
GetAddressAlignment((ptrdiff_t)stride)));
int rowLength = stride/pixelsize;
fPixelStorei(LOCAL_GL_UNPACK_ROW_LENGTH, rowLength);
fTexSubImage2D(target,
level,
xoffset,
yoffset,
width,
height,
format,
type,
pixels);
fPixelStorei(LOCAL_GL_UNPACK_ROW_LENGTH, 0);
fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT, 4);
#endif
} }
void void

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

@ -68,10 +68,6 @@
#include "nsAutoPtr.h" #include "nsAutoPtr.h"
#include "nsThreadUtils.h" #include "nsThreadUtils.h"
#if defined(MOZ_PLATFORM_MAEMO) || defined(ANDROID) || defined(MOZ_EGL_XRENDER_COMPOSITE)
#define USE_GLES2 1
#endif
typedef char realGLboolean; typedef char realGLboolean;
#include "GLContextSymbols.h" #include "GLContextSymbols.h"
@ -531,11 +527,7 @@ public:
mOffscreenFBOsDirty(false), mOffscreenFBOsDirty(false),
mInitialized(false), mInitialized(false),
mIsOffscreen(aIsOffscreen), mIsOffscreen(aIsOffscreen),
#ifdef USE_GLES2
mIsGLES2(true),
#else
mIsGLES2(false), mIsGLES2(false),
#endif
mIsGlobalSharedContext(false), mIsGlobalSharedContext(false),
mHasRobustness(false), mHasRobustness(false),
mContextLost(false), mContextLost(false),

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

@ -153,13 +153,6 @@ EXPORTS_mozilla/layers += ShadowLayerUtilsX11.h
CPPSRCS += ShadowLayerUtilsX11.cpp CPPSRCS += ShadowLayerUtilsX11.cpp
endif #} endif #}
# Enable GLES2.0 under maemo
ifdef MOZ_X11
ifdef MOZ_PLATFORM_MAEMO
DEFINES += -DUSE_GLES2
endif
endif
ifdef MOZ_ENABLE_D3D10_LAYER ifdef MOZ_ENABLE_D3D10_LAYER
EXPORTS_mozilla/layers += ShadowLayerUtilsD3D10.h EXPORTS_mozilla/layers += ShadowLayerUtilsD3D10.h
DEFINES += -DMOZ_ENABLE_D3D10_LAYER DEFINES += -DMOZ_ENABLE_D3D10_LAYER

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

@ -259,15 +259,16 @@ LayerManagerOGL::Initialize(nsRefPtr<GLContext> aContext, bool force)
GLenum textureTargets[] = { GLenum textureTargets[] = {
LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_2D,
#ifndef USE_GLES2 mGLContext->IsGLES2() ? LOCAL_GL_TEXTURE_RECTANGLE_ARB : 0
LOCAL_GL_TEXTURE_RECTANGLE_ARB
#endif
}; };
mFBOTextureTarget = LOCAL_GL_NONE; mFBOTextureTarget = LOCAL_GL_NONE;
for (PRUint32 i = 0; i < ArrayLength(textureTargets); i++) { for (PRUint32 i = 0; i < ArrayLength(textureTargets); i++) {
GLenum target = textureTargets[i]; GLenum target = textureTargets[i];
if (!target)
continue;
mGLContext->fGenTextures(1, &mBackBufferTexture); mGLContext->fGenTextures(1, &mBackBufferTexture);
mGLContext->fBindTexture(target, mBackBufferTexture); mGLContext->fBindTexture(target, mBackBufferTexture);
mGLContext->fTexParameteri(target, mGLContext->fTexParameteri(target,
@ -1050,16 +1051,16 @@ LayerManagerOGL::CopyToTarget(gfxContext *aTarget)
mGLContext->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, mGLContext->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER,
mGLContext->IsDoubleBuffered() ? 0 : mBackBufferFBO); mGLContext->IsDoubleBuffered() ? 0 : mBackBufferFBO);
#ifndef USE_GLES2 if (!mGLContext->IsGLES2()) {
// GLES2 promises that binding to any custom FBO will attach // GLES2 promises that binding to any custom FBO will attach
// to GL_COLOR_ATTACHMENT0 attachment point. // to GL_COLOR_ATTACHMENT0 attachment point.
if (mGLContext->IsDoubleBuffered()) { if (mGLContext->IsDoubleBuffered()) {
mGLContext->fReadBuffer(LOCAL_GL_BACK); mGLContext->fReadBuffer(LOCAL_GL_BACK);
}
else {
mGLContext->fReadBuffer(LOCAL_GL_COLOR_ATTACHMENT0);
}
} }
else {
mGLContext->fReadBuffer(LOCAL_GL_COLOR_ATTACHMENT0);
}
#endif
NS_ASSERTION(imageSurface->Stride() == width * 4, NS_ASSERTION(imageSurface->Stride() == width * 4,
"Image Surfaces being created with weird stride!"); "Image Surfaces being created with weird stride!");
@ -1118,19 +1119,6 @@ GetFrameBufferInternalFormat(GLContext* gl,
return LOCAL_GL_RGBA; return LOCAL_GL_RGBA;
} }
static bool
AreFormatsCompatibleForCopyTexImage2D(GLenum aF1, GLenum aF2)
{
// GL requires that the implementation has to handle copies between
// different formats, so all are "compatible". GLES does not
// require that.
#ifdef USE_GLES2
return (aF1 == aF2);
#else
return true;
#endif
}
void void
LayerManagerOGL::CreateFBOWithTexture(const nsIntRect& aRect, InitMode aInit, LayerManagerOGL::CreateFBOWithTexture(const nsIntRect& aRect, InitMode aInit,
GLuint aCurrentFrameBuffer, GLuint aCurrentFrameBuffer,
@ -1141,6 +1129,7 @@ LayerManagerOGL::CreateFBOWithTexture(const nsIntRect& aRect, InitMode aInit,
mGLContext->fActiveTexture(LOCAL_GL_TEXTURE0); mGLContext->fActiveTexture(LOCAL_GL_TEXTURE0);
mGLContext->fGenTextures(1, &tex); mGLContext->fGenTextures(1, &tex);
mGLContext->fBindTexture(mFBOTextureTarget, tex); mGLContext->fBindTexture(mFBOTextureTarget, tex);
if (aInit == InitModeCopy) { if (aInit == InitModeCopy) {
// We're going to create an RGBA temporary fbo. But to // We're going to create an RGBA temporary fbo. But to
// CopyTexImage() from the current framebuffer, the framebuffer's // CopyTexImage() from the current framebuffer, the framebuffer's
@ -1149,7 +1138,12 @@ LayerManagerOGL::CreateFBOWithTexture(const nsIntRect& aRect, InitMode aInit,
// if it's incompatible. // if it's incompatible.
GLenum format = GLenum format =
GetFrameBufferInternalFormat(gl(), aCurrentFrameBuffer, mWidget); GetFrameBufferInternalFormat(gl(), aCurrentFrameBuffer, mWidget);
if (AreFormatsCompatibleForCopyTexImage2D(format, LOCAL_GL_RGBA)) {
bool isFormatCompatibleWithRGBA
= gl()->IsGLES2() ? (format == LOCAL_GL_RGBA)
: true;
if (isFormatCompatibleWithRGBA) {
mGLContext->fCopyTexImage2D(mFBOTextureTarget, mGLContext->fCopyTexImage2D(mFBOTextureTarget,
0, 0,
LOCAL_GL_RGBA, LOCAL_GL_RGBA,