Commit afce829a by Geoff Lang

Sync pixel pack state before glReadPixels in FramebufferGL.

Fixes conformance/reading/read-pixels-pack-alignment.html BUG=angleproject:885 Change-Id: I48f1598d9a67f3980d2ff86307eb107ec7506776 Reviewed-on: https://chromium-review.googlesource.com/275691Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarKenneth Russell <kbr@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent aef1663f
......@@ -258,13 +258,11 @@ GLenum FramebufferGL::getImplementationColorReadType() const
gl::Error FramebufferGL::readPixels(const gl::State &state, const gl::Rectangle &area, GLenum format, GLenum type, GLvoid *pixels) const
{
const gl::PixelPackState &packState = state.getPackState();
// TODO: set pack state
if (packState.rowLength != 0 || packState.skipRows != 0 || packState.skipPixels != 0)
if (packState.pixelBuffer.get() != nullptr)
{
UNIMPLEMENTED();
return gl::Error(GL_INVALID_OPERATION, "invalid pixel store parameters in readPixels");
}
mStateManager->setPixelPackState(packState.alignment, packState.rowLength, packState.skipRows, packState.skipPixels);
mStateManager->bindFramebuffer(GL_READ_FRAMEBUFFER, mFramebufferID);
mFunctions->readPixels(area.x, area.y, area.width, area.height, format, type, pixels);
......
......@@ -30,6 +30,10 @@ StateManagerGL::StateManagerGL(const FunctionsGL *functions, const gl::Caps &ren
mTextures(),
mUnpackAlignment(4),
mUnpackRowLength(0),
mPackAlignment(4),
mPackRowLength(0),
mPackSkipRows(0),
mPackSkipPixels(0),
mFramebuffers(),
mRenderbuffer(0),
mScissorTestEnabled(false),
......@@ -246,6 +250,33 @@ void StateManagerGL::setPixelUnpackState(GLint alignment, GLint rowLength)
}
}
void StateManagerGL::setPixelPackState(GLint alignment, GLint rowLength, GLint skipRows, GLint skipPixels)
{
if (mPackAlignment != alignment)
{
mPackAlignment = alignment;
mFunctions->pixelStorei(GL_PACK_ALIGNMENT, mPackAlignment);
}
if (mPackRowLength != rowLength)
{
mPackRowLength = rowLength;
mFunctions->pixelStorei(GL_PACK_ROW_LENGTH, mPackRowLength);
}
if (mPackSkipRows != skipRows)
{
mPackSkipRows = rowLength;
mFunctions->pixelStorei(GL_PACK_SKIP_ROWS, mPackSkipRows);
}
if (mPackSkipPixels != skipPixels)
{
mPackSkipPixels = skipPixels;
mFunctions->pixelStorei(GL_PACK_SKIP_PIXELS, mPackSkipPixels);
}
}
void StateManagerGL::bindFramebuffer(GLenum type, GLuint framebuffer)
{
if (type == GL_FRAMEBUFFER)
......
......@@ -46,6 +46,7 @@ class StateManagerGL : angle::NonCopyable
void activeTexture(size_t unit);
void bindTexture(GLenum type, GLuint texture);
void setPixelUnpackState(GLint alignment, GLint rowLength);
void setPixelPackState(GLint alignment, GLint rowLength, GLint skipRows, GLint skipPixels);
void bindFramebuffer(GLenum type, GLuint framebuffer);
void bindRenderbuffer(GLenum type, GLuint renderbuffer);
......@@ -116,6 +117,11 @@ class StateManagerGL : angle::NonCopyable
GLint mUnpackAlignment;
GLint mUnpackRowLength;
GLint mPackAlignment;
GLint mPackRowLength;
GLint mPackSkipRows;
GLint mPackSkipPixels;
std::map<GLenum, GLuint> mFramebuffers;
GLuint mRenderbuffer;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment