mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backout 471244c106e9:634be002dbc9 (bug 1012407)
This commit is contained in:
parent
c3996058b5
commit
bdeb376055
@ -307,24 +307,11 @@ CompositorOGL::Initialize()
|
||||
mGLContext->fGenBuffers(1, &mQuadVBO);
|
||||
mGLContext->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, mQuadVBO);
|
||||
|
||||
// 4 quads, with the number of the quad (vertexID) encoded in w.
|
||||
GLfloat vertices[] = {
|
||||
0.0f, 0.0f, 0.0f, 0.0f,
|
||||
1.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 1.0f, 0.0f, 0.0f,
|
||||
1.0f, 1.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 1.0f,
|
||||
1.0f, 0.0f, 0.0f, 1.0f,
|
||||
0.0f, 1.0f, 0.0f, 1.0f,
|
||||
1.0f, 1.0f, 0.0f, 1.0f,
|
||||
0.0f, 0.0f, 0.0f, 2.0f,
|
||||
1.0f, 0.0f, 0.0f, 2.0f,
|
||||
0.0f, 1.0f, 0.0f, 2.0f,
|
||||
1.0f, 1.0f, 0.0f, 2.0f,
|
||||
0.0f, 0.0f, 0.0f, 3.0f,
|
||||
1.0f, 0.0f, 0.0f, 3.0f,
|
||||
0.0f, 1.0f, 0.0f, 3.0f,
|
||||
1.0f, 1.0f, 0.0f, 3.0f,
|
||||
/* First quad vertices */
|
||||
0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f,
|
||||
/* Then quad texcoords */
|
||||
0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f,
|
||||
};
|
||||
HeapCopyOfStackArray<GLfloat> verticesOnHeap(vertices);
|
||||
mGLContext->fBufferData(LOCAL_GL_ARRAY_BUFFER,
|
||||
@ -397,17 +384,20 @@ DecomposeIntoNoRepeatRects(const Rect& aRect,
|
||||
{
|
||||
Rect texCoordRect = aTexCoordRect;
|
||||
|
||||
// Move the texture coordinates within the range (0,1). For GL_REPEAT this
|
||||
// doesn't matter but the code below assumes it.
|
||||
texCoordRect.x -= uint32_t(texCoordRect.x);
|
||||
texCoordRect.y -= uint32_t(texCoordRect.y);
|
||||
// We want to normalize here instead of clamp because the rects we were
|
||||
// given assume GL_REPEAT, which we explicitly won't use and instead
|
||||
// manually split into sub-rects.
|
||||
while (texCoordRect.x >= 1.0f)
|
||||
texCoordRect.x -= 1.0f;
|
||||
while (texCoordRect.y >= 1.0f)
|
||||
texCoordRect.y -= 1.0f;
|
||||
|
||||
// If the texture should be flipped, it will have negative height. Detect that
|
||||
// here and compensate for it. We will flip each rect as we emit it.
|
||||
bool flipped = false;
|
||||
if (texCoordRect.height < 0) {
|
||||
flipped = true;
|
||||
texCoordRect.y += texCoordRect.height;
|
||||
texCoordRect.y = texCoordRect.YMost();
|
||||
texCoordRect.height = -texCoordRect.height;
|
||||
}
|
||||
|
||||
@ -534,7 +524,9 @@ CompositorOGL::BindAndDrawQuadWithTextureRect(ShaderProgramOGL *aProg,
|
||||
aTexCoordRect,
|
||||
layerRects,
|
||||
textureRects);
|
||||
BindAndDrawQuads(aProg, rects, layerRects, textureRects);
|
||||
for (int n = 0; n < rects; ++n) {
|
||||
BindAndDrawQuad(aProg, layerRects[n], textureRects[n]);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -1498,27 +1490,26 @@ CompositorOGL::BindQuadVBO() {
|
||||
|
||||
void
|
||||
CompositorOGL::QuadVBOVerticesAttrib(GLuint aAttribIndex) {
|
||||
mGLContext->fVertexAttribPointer(aAttribIndex, 4,
|
||||
LOCAL_GL_FLOAT, LOCAL_GL_FALSE, 0,
|
||||
(GLvoid*) 0);
|
||||
mGLContext->fVertexAttribPointer(aAttribIndex, 2,
|
||||
LOCAL_GL_FLOAT, LOCAL_GL_FALSE, 0,
|
||||
(GLvoid*) QuadVBOVertexOffset());
|
||||
}
|
||||
|
||||
void
|
||||
CompositorOGL::QuadVBOTexCoordsAttrib(GLuint aAttribIndex) {
|
||||
mGLContext->fVertexAttribPointer(aAttribIndex, 4,
|
||||
LOCAL_GL_FLOAT, LOCAL_GL_FALSE, 0,
|
||||
(GLvoid*) 0);
|
||||
mGLContext->fVertexAttribPointer(aAttribIndex, 2,
|
||||
LOCAL_GL_FLOAT, LOCAL_GL_FALSE, 0,
|
||||
(GLvoid*) QuadVBOTexCoordOffset());
|
||||
}
|
||||
|
||||
void
|
||||
CompositorOGL::BindAndDrawQuads(ShaderProgramOGL *aProg,
|
||||
int aQuads,
|
||||
const Rect* aLayerRects,
|
||||
const Rect* aTextureRects)
|
||||
CompositorOGL::BindAndDrawQuad(ShaderProgramOGL *aProg,
|
||||
const Rect& aLayerRect,
|
||||
const Rect& aTextureRect)
|
||||
{
|
||||
NS_ASSERTION(aProg->HasInitialized(), "Shader program not correctly initialized");
|
||||
|
||||
aProg->SetLayerRects(aLayerRects);
|
||||
aProg->SetLayerRect(aLayerRect);
|
||||
|
||||
GLuint vertAttribIndex = aProg->AttribLocation(ShaderProgramOGL::VertexCoordAttrib);
|
||||
GLuint texCoordAttribIndex = aProg->AttribLocation(ShaderProgramOGL::TexCoordAttrib);
|
||||
@ -1530,11 +1521,11 @@ CompositorOGL::BindAndDrawQuads(ShaderProgramOGL *aProg,
|
||||
QuadVBOTexCoordsAttrib(texCoordAttribIndex);
|
||||
mGLContext->fEnableVertexAttribArray(texCoordAttribIndex);
|
||||
|
||||
aProg->SetTextureRects(aTextureRects);
|
||||
aProg->SetTextureRect(aTextureRect);
|
||||
}
|
||||
|
||||
mGLContext->fEnableVertexAttribArray(vertAttribIndex);
|
||||
mGLContext->fDrawArrays(LOCAL_GL_TRIANGLE_STRIP, 0, 4 * aQuads);
|
||||
mGLContext->fDrawArrays(LOCAL_GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
|
||||
GLuint
|
||||
|
@ -362,22 +362,15 @@ private:
|
||||
GLuint aSourceFrameBuffer,
|
||||
GLuint *aFBO, GLuint *aTexture);
|
||||
|
||||
GLintptr QuadVBOVertexOffset() { return 0; }
|
||||
GLintptr QuadVBOTexCoordOffset() { return sizeof(float)*4*2; }
|
||||
|
||||
void BindQuadVBO();
|
||||
void QuadVBOVerticesAttrib(GLuint aAttribIndex);
|
||||
void QuadVBOTexCoordsAttrib(GLuint aAttribIndex);
|
||||
void BindAndDrawQuads(ShaderProgramOGL *aProg,
|
||||
int aQuads,
|
||||
const gfx::Rect* aLayerRect,
|
||||
const gfx::Rect* aTextureRect);
|
||||
void BindAndDrawQuad(ShaderProgramOGL *aProg,
|
||||
const gfx::Rect& aLayerRect,
|
||||
const gfx::Rect& aTextureRect = gfx::Rect(0.0f, 0.0f, 1.0f, 1.0f)) {
|
||||
gfx::Rect layerRects[4];
|
||||
gfx::Rect textureRects[4];
|
||||
layerRects[0] = aLayerRect;
|
||||
textureRects[0] = aTextureRect;
|
||||
BindAndDrawQuads(aProg, 1, layerRects, textureRects);
|
||||
}
|
||||
const gfx::Rect& aTextureRect = gfx::Rect(0.0f, 0.0f, 1.0f, 1.0f));
|
||||
void BindAndDrawQuadWithTextureRect(ShaderProgramOGL *aProg,
|
||||
const gfx::Rect& aRect,
|
||||
const gfx::Rect& aTexCoordRect,
|
||||
|
@ -32,10 +32,10 @@ AddUniforms(ProgramProfileOGL& aProfile)
|
||||
static const char *sKnownUniformNames[] = {
|
||||
"uLayerTransform",
|
||||
"uMaskTransform",
|
||||
"uLayerRects",
|
||||
"uLayerRect",
|
||||
"uMatrixProj",
|
||||
"uTextureTransform",
|
||||
"uTextureRects",
|
||||
"uTextureRect",
|
||||
"uRenderTargetOffset",
|
||||
"uLayerOpacity",
|
||||
"uTexture",
|
||||
@ -146,7 +146,7 @@ ProgramProfileOGL::GetProfileFor(ShaderConfigOGL aConfig)
|
||||
AddUniforms(result);
|
||||
|
||||
vs << "uniform mat4 uMatrixProj;" << endl;
|
||||
vs << "uniform vec4 uLayerRects[4];" << endl;
|
||||
vs << "uniform vec4 uLayerRect;" << endl;
|
||||
vs << "uniform mat4 uLayerTransform;" << endl;
|
||||
vs << "uniform vec4 uRenderTargetOffset;" << endl;
|
||||
|
||||
@ -154,8 +154,8 @@ ProgramProfileOGL::GetProfileFor(ShaderConfigOGL aConfig)
|
||||
|
||||
if (!(aConfig.mFeatures & ENABLE_RENDER_COLOR)) {
|
||||
vs << "uniform mat4 uTextureTransform;" << endl;
|
||||
vs << "uniform vec4 uTextureRects[4];" << endl;
|
||||
vs << "attribute vec4 aTexCoord;" << endl;
|
||||
vs << "uniform vec4 uTextureRect;" << endl;
|
||||
vs << "attribute vec2 aTexCoord;" << endl;
|
||||
vs << "varying vec2 vTexCoord;" << endl;
|
||||
}
|
||||
|
||||
@ -166,9 +166,7 @@ ProgramProfileOGL::GetProfileFor(ShaderConfigOGL aConfig)
|
||||
}
|
||||
|
||||
vs << "void main() {" << endl;
|
||||
vs << " int vertexID = int(aVertexCoord.w);" << endl;
|
||||
vs << " vec4 layerRect = uLayerRects[vertexID];" << endl;
|
||||
vs << " vec4 finalPosition = vec4(aVertexCoord.xy * layerRect.zw + layerRect.xy, 0.0, 1.0);" << endl;
|
||||
vs << " vec4 finalPosition = vec4(aVertexCoord.xy * uLayerRect.zw + uLayerRect.xy, 0.0, 1.0);" << endl;
|
||||
vs << " finalPosition = uLayerTransform * finalPosition;" << endl;
|
||||
vs << " finalPosition.xyz /= finalPosition.w;" << endl;
|
||||
|
||||
@ -186,8 +184,7 @@ ProgramProfileOGL::GetProfileFor(ShaderConfigOGL aConfig)
|
||||
vs << " finalPosition = uMatrixProj * finalPosition;" << endl;
|
||||
|
||||
if (!(aConfig.mFeatures & ENABLE_RENDER_COLOR)) {
|
||||
vs << " vec4 textureRect = uTextureRects[vertexID];" << endl;
|
||||
vs << " vec2 texCoord = aTexCoord.xy * textureRect.zw + textureRect.xy;" << endl;
|
||||
vs << " vec2 texCoord = aTexCoord * uTextureRect.zw + uTextureRect.xy;" << endl;
|
||||
vs << " vTexCoord = (uTextureTransform * vec4(texCoord, 0.0, 1.0)).xy;" << endl;
|
||||
}
|
||||
|
||||
|
@ -52,10 +52,10 @@ public:
|
||||
|
||||
LayerTransform = 0,
|
||||
MaskTransform,
|
||||
LayerRects,
|
||||
LayerRect,
|
||||
MatrixProj,
|
||||
TextureTransform,
|
||||
TextureRects,
|
||||
TextureRect,
|
||||
RenderTargetOffset,
|
||||
LayerOpacity,
|
||||
Texture,
|
||||
@ -322,12 +322,9 @@ public:
|
||||
SetMatrixUniform(KnownUniform::MaskTransform, aMatrix);
|
||||
}
|
||||
|
||||
void SetLayerRects(const gfx::Rect* aRects) {
|
||||
float vals[16] = { aRects[0].x, aRects[0].y, aRects[0].width, aRects[0].height,
|
||||
aRects[1].x, aRects[1].y, aRects[1].width, aRects[1].height,
|
||||
aRects[2].x, aRects[2].y, aRects[2].width, aRects[2].height,
|
||||
aRects[3].x, aRects[3].y, aRects[3].width, aRects[3].height };
|
||||
SetUniform(KnownUniform::LayerRects, 16, vals);
|
||||
void SetLayerRect(const gfx::Rect& aRect) {
|
||||
float vals[4] = { float(aRect.x), float(aRect.y), float(aRect.width), float(aRect.height) };
|
||||
SetUniform(KnownUniform::LayerRect, 4, vals);
|
||||
}
|
||||
|
||||
void SetProjectionMatrix(const gfx::Matrix4x4& aMatrix) {
|
||||
@ -339,12 +336,9 @@ public:
|
||||
SetMatrixUniform(KnownUniform::TextureTransform, aMatrix);
|
||||
}
|
||||
|
||||
void SetTextureRects(const gfx::Rect* aRects) {
|
||||
float vals[16] = { aRects[0].x, aRects[0].y, aRects[0].width, aRects[0].height,
|
||||
aRects[1].x, aRects[1].y, aRects[1].width, aRects[1].height,
|
||||
aRects[2].x, aRects[2].y, aRects[2].width, aRects[2].height,
|
||||
aRects[3].x, aRects[3].y, aRects[3].width, aRects[3].height };
|
||||
SetUniform(KnownUniform::TextureRects, 16, vals);
|
||||
void SetTextureRect(const gfx::Rect& aRect) {
|
||||
float vals[4] = { float(aRect.x), float(aRect.y), float(aRect.width), float(aRect.height) };
|
||||
SetUniform(KnownUniform::TextureRect, 4, vals);
|
||||
}
|
||||
|
||||
void SetRenderOffset(const nsIntPoint& aOffset) {
|
||||
@ -477,7 +471,6 @@ protected:
|
||||
case 2: mGL->fUniform2fv(ku.mLocation, 1, ku.mValue.f16v); break;
|
||||
case 3: mGL->fUniform3fv(ku.mLocation, 1, ku.mValue.f16v); break;
|
||||
case 4: mGL->fUniform4fv(ku.mLocation, 1, ku.mValue.f16v); break;
|
||||
case 16: mGL->fUniform4fv(ku.mLocation, 4, ku.mValue.f16v); break;
|
||||
default:
|
||||
NS_NOTREACHED("Bogus aLength param");
|
||||
}
|
||||
|
@ -2810,14 +2810,8 @@ GLPresenter::BindAndDrawQuad(ShaderProgramOGL *aProgram,
|
||||
{
|
||||
mGLContext->MakeCurrent();
|
||||
|
||||
gfx::Rect layerRects[4];
|
||||
gfx::Rect textureRects[4];
|
||||
|
||||
layerRects[0] = aLayerRect;
|
||||
textureRects[0] = aTextureRect;
|
||||
|
||||
aProgram->SetLayerRects(layerRects);
|
||||
aProgram->SetTextureRects(textureRects);
|
||||
aProgram->SetLayerRect(aLayerRect);
|
||||
aProgram->SetTextureRect(aTextureRect);
|
||||
|
||||
GLuint vertAttribIndex = aProgram->AttribLocation(ShaderProgramOGL::VertexCoordAttrib);
|
||||
GLuint texCoordAttribIndex = aProgram->AttribLocation(ShaderProgramOGL::TexCoordAttrib);
|
||||
|
Loading…
Reference in New Issue
Block a user