mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1016086 - Part 2: Save/restore attribute state in blit helper (r=Bas)
This commit is contained in:
parent
08e124e6a7
commit
02d7f6f1f9
@ -146,26 +146,14 @@ GLBlitTextureImageHelper::BlitTextureImage(TextureImage *aSrc, const nsIntRect&
|
||||
|
||||
ScopedBindTextureUnit autoTexUnit(mGL, LOCAL_GL_TEXTURE0);
|
||||
ScopedBindTexture autoTex(mGL, aSrc->GetTextureID());
|
||||
|
||||
mGL->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, 0);
|
||||
|
||||
mGL->fVertexAttribPointer(0, 2, LOCAL_GL_FLOAT, LOCAL_GL_FALSE, 0, rects.vertCoords().Elements());
|
||||
mGL->fVertexAttribPointer(1, 2, LOCAL_GL_FLOAT, LOCAL_GL_FALSE, 0, rects.texCoords().Elements());
|
||||
|
||||
mGL->fEnableVertexAttribArray(0);
|
||||
mGL->fEnableVertexAttribArray(1);
|
||||
ScopedVertexAttribPointer autoAttrib0(mGL, 0, 2, LOCAL_GL_FLOAT, LOCAL_GL_FALSE, 0, 0, rects.vertCoords().Elements());
|
||||
ScopedVertexAttribPointer autoAttrib1(mGL, 1, 2, LOCAL_GL_FLOAT, LOCAL_GL_FALSE, 0, 0, rects.texCoords().Elements());
|
||||
|
||||
mGL->fDrawArrays(LOCAL_GL_TRIANGLES, 0, rects.elements());
|
||||
|
||||
mGL->fDisableVertexAttribArray(0);
|
||||
mGL->fDisableVertexAttribArray(1);
|
||||
|
||||
} while (aSrc->NextTile());
|
||||
} while (aDst->NextTile());
|
||||
|
||||
mGL->fVertexAttribPointer(0, 2, LOCAL_GL_FLOAT, LOCAL_GL_FALSE, 0, nullptr);
|
||||
mGL->fVertexAttribPointer(1, 2, LOCAL_GL_FLOAT, LOCAL_GL_FALSE, 0, nullptr);
|
||||
|
||||
// unbind the previous texture from the framebuffer
|
||||
SetBlitFramebufferForDestTexture(0);
|
||||
|
||||
|
@ -330,5 +330,76 @@ void ScopedScissorRect::UnwrapImpl()
|
||||
mSavedScissorRect[3]);
|
||||
}
|
||||
|
||||
/* ScopedVertexAttribPointer **************************************************/
|
||||
|
||||
ScopedVertexAttribPointer::ScopedVertexAttribPointer(GLContext* aGL,
|
||||
GLuint index,
|
||||
GLint size,
|
||||
GLenum type,
|
||||
realGLboolean normalized,
|
||||
GLsizei stride,
|
||||
GLuint buffer,
|
||||
const GLvoid* pointer)
|
||||
: ScopedGLWrapper<ScopedVertexAttribPointer>(aGL)
|
||||
{
|
||||
WrapImpl(index);
|
||||
mGL->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, buffer);
|
||||
mGL->fVertexAttribPointer(index, size, type, normalized, stride, pointer);
|
||||
mGL->fEnableVertexAttribArray(index);
|
||||
}
|
||||
|
||||
ScopedVertexAttribPointer::ScopedVertexAttribPointer(GLContext* aGL,
|
||||
GLuint index)
|
||||
: ScopedGLWrapper<ScopedVertexAttribPointer>(aGL)
|
||||
{
|
||||
WrapImpl(index);
|
||||
}
|
||||
|
||||
void
|
||||
ScopedVertexAttribPointer::WrapImpl(GLuint index)
|
||||
{
|
||||
mAttribIndex = index;
|
||||
|
||||
/*
|
||||
* mGL->fGetVertexAttribiv takes:
|
||||
* VERTEX_ATTRIB_ARRAY_ENABLED
|
||||
* VERTEX_ATTRIB_ARRAY_SIZE,
|
||||
* VERTEX_ATTRIB_ARRAY_STRIDE,
|
||||
* VERTEX_ATTRIB_ARRAY_TYPE,
|
||||
* VERTEX_ATTRIB_ARRAY_NORMALIZED,
|
||||
* VERTEX_ATTRIB_ARRAY_BUFFER_BINDING,
|
||||
* CURRENT_VERTEX_ATTRIB
|
||||
*
|
||||
* CURRENT_VERTEX_ATTRIB is vertex shader state. \o/
|
||||
* Others appear to be vertex array state,
|
||||
* or alternatively in the internal vertex array state
|
||||
* for a buffer object.
|
||||
*/
|
||||
|
||||
mGL->fGetVertexAttribiv(mAttribIndex, LOCAL_GL_VERTEX_ATTRIB_ARRAY_ENABLED, &mAttribEnabled);
|
||||
mGL->fGetVertexAttribiv(mAttribIndex, LOCAL_GL_VERTEX_ATTRIB_ARRAY_SIZE, &mAttribSize);
|
||||
mGL->fGetVertexAttribiv(mAttribIndex, LOCAL_GL_VERTEX_ATTRIB_ARRAY_STRIDE, &mAttribStride);
|
||||
mGL->fGetVertexAttribiv(mAttribIndex, LOCAL_GL_VERTEX_ATTRIB_ARRAY_TYPE, &mAttribType);
|
||||
mGL->fGetVertexAttribiv(mAttribIndex, LOCAL_GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &mAttribNormalized);
|
||||
mGL->fGetVertexAttribiv(mAttribIndex, LOCAL_GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, &mAttribBufferBinding);
|
||||
mGL->fGetVertexAttribPointerv(mAttribIndex, LOCAL_GL_VERTEX_ATTRIB_ARRAY_POINTER, &mAttribPointer);
|
||||
|
||||
// Note that uniform values are program state, so we don't need to rebind those.
|
||||
|
||||
mGL->GetUIntegerv(LOCAL_GL_ARRAY_BUFFER_BINDING, &mBoundBuffer);
|
||||
}
|
||||
|
||||
void
|
||||
ScopedVertexAttribPointer::UnwrapImpl()
|
||||
{
|
||||
mGL->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, mAttribBufferBinding);
|
||||
mGL->fVertexAttribPointer(mAttribIndex, mAttribSize, mAttribType, mAttribNormalized, mAttribStride, mAttribPointer);
|
||||
if (mAttribEnabled)
|
||||
mGL->fEnableVertexAttribArray(mAttribIndex);
|
||||
else
|
||||
mGL->fDisableVertexAttribArray(mAttribIndex);
|
||||
mGL->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, mBoundBuffer);
|
||||
}
|
||||
|
||||
} /* namespace gl */
|
||||
} /* namespace mozilla */
|
||||
|
@ -277,6 +277,32 @@ protected:
|
||||
void UnwrapImpl();
|
||||
};
|
||||
|
||||
struct ScopedVertexAttribPointer
|
||||
: public ScopedGLWrapper<ScopedVertexAttribPointer>
|
||||
{
|
||||
friend struct ScopedGLWrapper<ScopedVertexAttribPointer>;
|
||||
|
||||
protected:
|
||||
GLuint mAttribIndex;
|
||||
GLint mAttribEnabled;
|
||||
GLint mAttribSize;
|
||||
GLint mAttribStride;
|
||||
GLint mAttribType;
|
||||
GLint mAttribNormalized;
|
||||
GLint mAttribBufferBinding;
|
||||
void* mAttribPointer;
|
||||
GLuint mBoundBuffer;
|
||||
|
||||
public:
|
||||
ScopedVertexAttribPointer(GLContext* aGL, GLuint index, GLint size, GLenum type, realGLboolean normalized,
|
||||
GLsizei stride, GLuint buffer, const GLvoid* pointer);
|
||||
explicit ScopedVertexAttribPointer(GLContext* aGL, GLuint index);
|
||||
|
||||
protected:
|
||||
void WrapImpl(GLuint index);
|
||||
void UnwrapImpl();
|
||||
};
|
||||
|
||||
} /* namespace gl */
|
||||
} /* namespace mozilla */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user