зеркало из https://github.com/mozilla/pjs.git
Bug 741730 - Remove USE_GLES2 - r=romaxa
This commit is contained in:
Родитель
d83877bc22
Коммит
aabaa2c453
|
@ -2338,11 +2338,7 @@ GLContext::UploadSurfaceToTexture(gfxASurface *aSurface,
|
|||
|
||||
PRInt32 stride = imageSurface->Stride();
|
||||
|
||||
#ifndef USE_GLES2
|
||||
internalformat = LOCAL_GL_RGBA;
|
||||
#else
|
||||
internalformat = format;
|
||||
#endif
|
||||
internalformat = mIsGLES2 ? format : LOCAL_GL_RGBA;
|
||||
|
||||
nsIntRegionRectIterator iter(paintRegion);
|
||||
const nsIntRect *iterRect;
|
||||
|
@ -2410,52 +2406,94 @@ GLContext::TexImage2D(GLenum target, GLint level, GLint internalformat,
|
|||
GLint pixelsize, GLint border, GLenum format,
|
||||
GLenum type, const GLvoid *pixels)
|
||||
{
|
||||
#ifdef USE_GLES2
|
||||
if (mIsGLES2) {
|
||||
|
||||
NS_ASSERTION(format == internalformat,
|
||||
"format and internalformat not the same for glTexImage2D on GLES2");
|
||||
NS_ASSERTION(format == internalformat,
|
||||
"format and internalformat not the same for glTexImage2D on GLES2");
|
||||
|
||||
if (!CanUploadNonPowerOfTwo()
|
||||
&& (stride != width * pixelsize
|
||||
|| !IsPowerOfTwo(width)
|
||||
|| !IsPowerOfTwo(height))) {
|
||||
if (!CanUploadNonPowerOfTwo()
|
||||
&& (stride != width * pixelsize
|
||||
|| !IsPowerOfTwo(width)
|
||||
|| !IsPowerOfTwo(height))) {
|
||||
|
||||
// Pad out texture width and height to the next power of two
|
||||
// as we don't support/want non power of two texture uploads
|
||||
GLsizei paddedWidth = NextPowerOfTwo(width);
|
||||
GLsizei paddedHeight = NextPowerOfTwo(height);
|
||||
// Pad out texture width and height to the next power of two
|
||||
// as we don't support/want non power of two texture uploads
|
||||
GLsizei paddedWidth = NextPowerOfTwo(width);
|
||||
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
|
||||
// a POT sized texture
|
||||
CopyAndPadTextureData(pixels, paddedPixels, width, height,
|
||||
paddedWidth, paddedHeight, stride, pixelsize);
|
||||
// Pad out texture data to be in a POT sized buffer for uploading to
|
||||
// a POT sized texture
|
||||
CopyAndPadTextureData(pixels, paddedPixels, width, height,
|
||||
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,
|
||||
NS_MIN(GetAddressAlignment((ptrdiff_t)paddedPixels),
|
||||
GetAddressAlignment((ptrdiff_t)paddedWidth * pixelsize)));
|
||||
NS_MIN(GetAddressAlignment((ptrdiff_t)pixels),
|
||||
GetAddressAlignment((ptrdiff_t)stride)));
|
||||
int rowLength = stride/pixelsize;
|
||||
fPixelStorei(LOCAL_GL_UNPACK_ROW_LENGTH, rowLength);
|
||||
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,
|
||||
level,
|
||||
internalformat,
|
||||
width,
|
||||
height,
|
||||
|
@ -2463,49 +2501,9 @@ GLContext::TexImage2D(GLenum target, GLint level, GLint internalformat,
|
|||
format,
|
||||
type,
|
||||
pixels);
|
||||
fPixelStorei(LOCAL_GL_UNPACK_ROW_LENGTH, 0);
|
||||
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
|
||||
|
@ -2515,49 +2513,50 @@ GLContext::TexSubImage2D(GLenum target, GLint level,
|
|||
GLint pixelsize, GLenum format,
|
||||
GLenum type, const GLvoid* pixels)
|
||||
{
|
||||
#ifdef USE_GLES2
|
||||
if (stride == width * pixelsize) {
|
||||
fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT,
|
||||
NS_MIN(GetAddressAlignment((ptrdiff_t)pixels),
|
||||
GetAddressAlignment((ptrdiff_t)stride)));
|
||||
fTexSubImage2D(target,
|
||||
level,
|
||||
xoffset,
|
||||
yoffset,
|
||||
width,
|
||||
height,
|
||||
format,
|
||||
type,
|
||||
pixels);
|
||||
fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT, 4);
|
||||
} else if (IsExtensionSupported(EXT_unpack_subimage)) {
|
||||
TexSubImage2DWithUnpackSubimageGLES(target, level, xoffset, yoffset,
|
||||
width, height, stride,
|
||||
pixelsize, format, type, pixels);
|
||||
if (mIsGLES2) {
|
||||
if (stride == width * pixelsize) {
|
||||
fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT,
|
||||
NS_MIN(GetAddressAlignment((ptrdiff_t)pixels),
|
||||
GetAddressAlignment((ptrdiff_t)stride)));
|
||||
fTexSubImage2D(target,
|
||||
level,
|
||||
xoffset,
|
||||
yoffset,
|
||||
width,
|
||||
height,
|
||||
format,
|
||||
type,
|
||||
pixels);
|
||||
fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT, 4);
|
||||
} else if (IsExtensionSupported(EXT_unpack_subimage)) {
|
||||
TexSubImage2DWithUnpackSubimageGLES(target, level, xoffset, yoffset,
|
||||
width, height, stride,
|
||||
pixelsize, format, type, pixels);
|
||||
|
||||
} else {
|
||||
TexSubImage2DWithoutUnpackSubimage(target, level, xoffset, yoffset,
|
||||
width, height, stride,
|
||||
pixelsize, format, type, pixels);
|
||||
}
|
||||
} else {
|
||||
TexSubImage2DWithoutUnpackSubimage(target, level, xoffset, yoffset,
|
||||
width, height, stride,
|
||||
pixelsize, format, type, pixels);
|
||||
// desktop GL (non-ES) path
|
||||
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);
|
||||
}
|
||||
#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
|
||||
|
|
|
@ -68,10 +68,6 @@
|
|||
#include "nsAutoPtr.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
#if defined(MOZ_PLATFORM_MAEMO) || defined(ANDROID) || defined(MOZ_EGL_XRENDER_COMPOSITE)
|
||||
#define USE_GLES2 1
|
||||
#endif
|
||||
|
||||
typedef char realGLboolean;
|
||||
|
||||
#include "GLContextSymbols.h"
|
||||
|
@ -531,11 +527,7 @@ public:
|
|||
mOffscreenFBOsDirty(false),
|
||||
mInitialized(false),
|
||||
mIsOffscreen(aIsOffscreen),
|
||||
#ifdef USE_GLES2
|
||||
mIsGLES2(true),
|
||||
#else
|
||||
mIsGLES2(false),
|
||||
#endif
|
||||
mIsGlobalSharedContext(false),
|
||||
mHasRobustness(false),
|
||||
mContextLost(false),
|
||||
|
|
|
@ -153,13 +153,6 @@ EXPORTS_mozilla/layers += ShadowLayerUtilsX11.h
|
|||
CPPSRCS += ShadowLayerUtilsX11.cpp
|
||||
endif #}
|
||||
|
||||
# Enable GLES2.0 under maemo
|
||||
ifdef MOZ_X11
|
||||
ifdef MOZ_PLATFORM_MAEMO
|
||||
DEFINES += -DUSE_GLES2
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef MOZ_ENABLE_D3D10_LAYER
|
||||
EXPORTS_mozilla/layers += ShadowLayerUtilsD3D10.h
|
||||
DEFINES += -DMOZ_ENABLE_D3D10_LAYER
|
||||
|
|
|
@ -259,15 +259,16 @@ LayerManagerOGL::Initialize(nsRefPtr<GLContext> aContext, bool force)
|
|||
|
||||
GLenum textureTargets[] = {
|
||||
LOCAL_GL_TEXTURE_2D,
|
||||
#ifndef USE_GLES2
|
||||
LOCAL_GL_TEXTURE_RECTANGLE_ARB
|
||||
#endif
|
||||
mGLContext->IsGLES2() ? LOCAL_GL_TEXTURE_RECTANGLE_ARB : 0
|
||||
};
|
||||
|
||||
mFBOTextureTarget = LOCAL_GL_NONE;
|
||||
|
||||
for (PRUint32 i = 0; i < ArrayLength(textureTargets); i++) {
|
||||
GLenum target = textureTargets[i];
|
||||
if (!target)
|
||||
continue;
|
||||
|
||||
mGLContext->fGenTextures(1, &mBackBufferTexture);
|
||||
mGLContext->fBindTexture(target, mBackBufferTexture);
|
||||
mGLContext->fTexParameteri(target,
|
||||
|
@ -1050,16 +1051,16 @@ LayerManagerOGL::CopyToTarget(gfxContext *aTarget)
|
|||
mGLContext->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER,
|
||||
mGLContext->IsDoubleBuffered() ? 0 : mBackBufferFBO);
|
||||
|
||||
#ifndef USE_GLES2
|
||||
// GLES2 promises that binding to any custom FBO will attach
|
||||
// to GL_COLOR_ATTACHMENT0 attachment point.
|
||||
if (mGLContext->IsDoubleBuffered()) {
|
||||
mGLContext->fReadBuffer(LOCAL_GL_BACK);
|
||||
if (!mGLContext->IsGLES2()) {
|
||||
// GLES2 promises that binding to any custom FBO will attach
|
||||
// to GL_COLOR_ATTACHMENT0 attachment point.
|
||||
if (mGLContext->IsDoubleBuffered()) {
|
||||
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,
|
||||
"Image Surfaces being created with weird stride!");
|
||||
|
@ -1118,19 +1119,6 @@ GetFrameBufferInternalFormat(GLContext* gl,
|
|||
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
|
||||
LayerManagerOGL::CreateFBOWithTexture(const nsIntRect& aRect, InitMode aInit,
|
||||
GLuint aCurrentFrameBuffer,
|
||||
|
@ -1141,6 +1129,7 @@ LayerManagerOGL::CreateFBOWithTexture(const nsIntRect& aRect, InitMode aInit,
|
|||
mGLContext->fActiveTexture(LOCAL_GL_TEXTURE0);
|
||||
mGLContext->fGenTextures(1, &tex);
|
||||
mGLContext->fBindTexture(mFBOTextureTarget, tex);
|
||||
|
||||
if (aInit == InitModeCopy) {
|
||||
// We're going to create an RGBA temporary fbo. But to
|
||||
// CopyTexImage() from the current framebuffer, the framebuffer's
|
||||
|
@ -1149,7 +1138,12 @@ LayerManagerOGL::CreateFBOWithTexture(const nsIntRect& aRect, InitMode aInit,
|
|||
// if it's incompatible.
|
||||
GLenum format =
|
||||
GetFrameBufferInternalFormat(gl(), aCurrentFrameBuffer, mWidget);
|
||||
if (AreFormatsCompatibleForCopyTexImage2D(format, LOCAL_GL_RGBA)) {
|
||||
|
||||
bool isFormatCompatibleWithRGBA
|
||||
= gl()->IsGLES2() ? (format == LOCAL_GL_RGBA)
|
||||
: true;
|
||||
|
||||
if (isFormatCompatibleWithRGBA) {
|
||||
mGLContext->fCopyTexImage2D(mFBOTextureTarget,
|
||||
0,
|
||||
LOCAL_GL_RGBA,
|
||||
|
|
Загрузка…
Ссылка в новой задаче