Commit eb9baabb by Jamie Madill

Pass pack state arguments instead of split parameters.

Similar to unpack state, the PixelPackState struct encapsulates all the parameters related to pixel pack buffers. Passing the packstate makes functions more consise. BUG=angle:511 Change-Id: If6954a5085e9b8f828cfc8892a73e7c7514b0c8a Reviewed-on: https://chromium-review.googlesource.com/191032Reviewed-by: 's avatarShannon Woods <shannonwoods@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 1eb5bd76
...@@ -2944,9 +2944,9 @@ void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height, ...@@ -2944,9 +2944,9 @@ void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height,
bool isSized = IsSizedInternalFormat(format, mClientVersion); bool isSized = IsSizedInternalFormat(format, mClientVersion);
GLenum sizedInternalFormat = (isSized ? format : GetSizedInternalFormat(format, type, mClientVersion)); GLenum sizedInternalFormat = (isSized ? format : GetSizedInternalFormat(format, type, mClientVersion));
GLuint outputPitch = GetRowPitch(sizedInternalFormat, type, mClientVersion, width, getPackAlignment()); GLuint outputPitch = GetRowPitch(sizedInternalFormat, type, mClientVersion, width, mState.pack.alignment);
mRenderer->readPixels(framebuffer, x, y, width, height, format, type, outputPitch, getPackReverseRowOrder(), getPackAlignment(), pixels); mRenderer->readPixels(framebuffer, x, y, width, height, format, type, outputPitch, mState.pack, pixels);
} }
void Context::drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei instances) void Context::drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei instances)
......
...@@ -1708,7 +1708,7 @@ bool IsStencilRenderingSupported(GLenum internalFormat, const Context *context) ...@@ -1708,7 +1708,7 @@ bool IsStencilRenderingSupported(GLenum internalFormat, const Context *context)
GLuint GetRowPitch(GLenum internalFormat, GLenum type, GLuint clientVersion, GLsizei width, GLint alignment) GLuint GetRowPitch(GLenum internalFormat, GLenum type, GLuint clientVersion, GLsizei width, GLint alignment)
{ {
ASSERT(alignment > 0 && isPow2(alignment)); ASSERT(alignment > 0 && isPow2(alignment));
return (GetBlockSize(internalFormat, type, clientVersion, width, 1) + alignment - 1) & ~(alignment - 1); return rx::roundUp(GetBlockSize(internalFormat, type, clientVersion, width, 1), static_cast<GLuint>(alignment));
} }
GLuint GetDepthPitch(GLenum internalFormat, GLenum type, GLuint clientVersion, GLsizei width, GLsizei height, GLint alignment) GLuint GetDepthPitch(GLenum internalFormat, GLenum type, GLuint clientVersion, GLsizei width, GLsizei height, GLint alignment)
......
...@@ -234,8 +234,8 @@ class Renderer ...@@ -234,8 +234,8 @@ class Renderer
virtual bool blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &readRect, gl::Framebuffer *drawTarget, const gl::Rectangle &drawRect, virtual bool blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &readRect, gl::Framebuffer *drawTarget, const gl::Rectangle &drawRect,
const gl::Rectangle *scissor, bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter) = 0; const gl::Rectangle *scissor, bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter) = 0;
virtual void readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, virtual void readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
GLsizei outputPitch, bool packReverseRowOrder, GLint packAlignment, void* pixels) = 0; GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, void* pixels) = 0;
// RenderTarget creation // RenderTarget creation
virtual RenderTarget *createRenderTarget(SwapChain *swapChain, bool depth) = 0; virtual RenderTarget *createRenderTarget(SwapChain *swapChain, bool depth) = 0;
......
...@@ -286,8 +286,10 @@ void Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y ...@@ -286,8 +286,10 @@ void Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y
GLsizei rowOffset = gl::GetPixelBytes(mActualFormat, clientVersion) * xoffset; GLsizei rowOffset = gl::GetPixelBytes(mActualFormat, clientVersion) * xoffset;
void *dataOffset = static_cast<unsigned char*>(mappedImage.pData) + mappedImage.RowPitch * yoffset + rowOffset + zoffset * mappedImage.DepthPitch; void *dataOffset = static_cast<unsigned char*>(mappedImage.pData) + mappedImage.RowPitch * yoffset + rowOffset + zoffset * mappedImage.DepthPitch;
mRenderer->readPixels(source, x, y, width, height, gl::GetFormat(mInternalFormat, clientVersion), GLenum format = gl::GetFormat(mInternalFormat, clientVersion);
gl::GetType(mInternalFormat, clientVersion), mappedImage.RowPitch, false, 4, dataOffset); GLenum type = gl::GetType(mInternalFormat, clientVersion);
mRenderer->readPixels(source, x, y, width, height, format, type, mappedImage.RowPitch, gl::PixelPackState(), dataOffset);
unmap(); unmap();
} }
......
...@@ -3254,8 +3254,8 @@ bool Renderer11::blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &read ...@@ -3254,8 +3254,8 @@ bool Renderer11::blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &read
return true; return true;
} }
void Renderer11::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void Renderer11::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
GLsizei outputPitch, bool packReverseRowOrder, GLint packAlignment, void* pixels) GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, void* pixels)
{ {
ID3D11Texture2D *colorBufferTexture = NULL; ID3D11Texture2D *colorBufferTexture = NULL;
unsigned int subresourceIndex = 0; unsigned int subresourceIndex = 0;
...@@ -3270,8 +3270,7 @@ void Renderer11::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsi ...@@ -3270,8 +3270,7 @@ void Renderer11::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsi
area.width = width; area.width = width;
area.height = height; area.height = height;
readTextureData(colorBufferTexture, subresourceIndex, area, format, type, outputPitch, readTextureData(colorBufferTexture, subresourceIndex, area, format, type, outputPitch, pack, pixels);
packReverseRowOrder, packAlignment, pixels);
SafeRelease(colorBufferTexture); SafeRelease(colorBufferTexture);
} }
...@@ -3315,9 +3314,8 @@ TextureStorage *Renderer11::createTextureStorage2DArray(GLenum internalformat, b ...@@ -3315,9 +3314,8 @@ TextureStorage *Renderer11::createTextureStorage2DArray(GLenum internalformat, b
return new TextureStorage11_2DArray(this, internalformat, renderTarget, width, height, depth, levels); return new TextureStorage11_2DArray(this, internalformat, renderTarget, width, height, depth, levels);
} }
void Renderer11::readTextureData(ID3D11Texture2D *texture, unsigned int subResource, const gl::Rectangle &area, void Renderer11::readTextureData(ID3D11Texture2D *texture, unsigned int subResource, const gl::Rectangle &area, GLenum format,
GLenum format, GLenum type, GLsizei outputPitch, bool packReverseRowOrder, GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, void *pixels)
GLint packAlignment, void *pixels)
{ {
ASSERT(area.width >= 0); ASSERT(area.width >= 0);
ASSERT(area.height >= 0); ASSERT(area.height >= 0);
...@@ -3416,7 +3414,7 @@ void Renderer11::readTextureData(ID3D11Texture2D *texture, unsigned int subResou ...@@ -3416,7 +3414,7 @@ void Renderer11::readTextureData(ID3D11Texture2D *texture, unsigned int subResou
unsigned char *source; unsigned char *source;
int inputPitch; int inputPitch;
if (packReverseRowOrder) if (pack.reverseRowOrder)
{ {
source = static_cast<unsigned char*>(mapping.pData) + mapping.RowPitch * (safeArea.height - 1); source = static_cast<unsigned char*>(mapping.pData) + mapping.RowPitch * (safeArea.height - 1);
inputPitch = -static_cast<int>(mapping.RowPitch); inputPitch = -static_cast<int>(mapping.RowPitch);
......
...@@ -182,8 +182,8 @@ class Renderer11 : public Renderer ...@@ -182,8 +182,8 @@ class Renderer11 : public Renderer
virtual bool blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &readRect, gl::Framebuffer *drawTarget, const gl::Rectangle &drawRect, virtual bool blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &readRect, gl::Framebuffer *drawTarget, const gl::Rectangle &drawRect,
const gl::Rectangle *scissor, bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter); const gl::Rectangle *scissor, bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter);
virtual void readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, virtual void readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
GLsizei outputPitch, bool packReverseRowOrder, GLint packAlignment, void* pixels); GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, void* pixels);
// RenderTarget creation // RenderTarget creation
virtual RenderTarget *createRenderTarget(SwapChain *swapChain, bool depth); virtual RenderTarget *createRenderTarget(SwapChain *swapChain, bool depth);
...@@ -243,9 +243,8 @@ class Renderer11 : public Renderer ...@@ -243,9 +243,8 @@ class Renderer11 : public Renderer
void drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer); void drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer);
void drawTriangleFan(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer, int instances); void drawTriangleFan(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer, int instances);
void readTextureData(ID3D11Texture2D *texture, unsigned int subResource, const gl::Rectangle &area, void readTextureData(ID3D11Texture2D *texture, unsigned int subResource, const gl::Rectangle &area, GLenum format,
GLenum format, GLenum type, GLsizei outputPitch, bool packReverseRowOrder, GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, void *pixels);
GLint packAlignment, void *pixels);
rx::Range getViewportBounds() const; rx::Range getViewportBounds() const;
......
...@@ -3113,9 +3113,11 @@ bool Renderer9::blitRect(gl::Framebuffer *readFramebuffer, const gl::Rectangle & ...@@ -3113,9 +3113,11 @@ bool Renderer9::blitRect(gl::Framebuffer *readFramebuffer, const gl::Rectangle &
return true; return true;
} }
void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
GLsizei outputPitch, bool packReverseRowOrder, GLint packAlignment, void* pixels) GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, void* pixels)
{ {
ASSERT(pack.pixelBuffer.get() == NULL);
RenderTarget9 *renderTarget = NULL; RenderTarget9 *renderTarget = NULL;
IDirect3DSurface9 *surface = NULL; IDirect3DSurface9 *surface = NULL;
gl::Renderbuffer *colorbuffer = framebuffer->getColorbuffer(0); gl::Renderbuffer *colorbuffer = framebuffer->getColorbuffer(0);
...@@ -3148,7 +3150,7 @@ void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsiz ...@@ -3148,7 +3150,7 @@ void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsiz
HRESULT result; HRESULT result;
IDirect3DSurface9 *systemSurface = NULL; IDirect3DSurface9 *systemSurface = NULL;
bool directToPixels = !packReverseRowOrder && packAlignment <= 4 && getShareHandleSupport() && bool directToPixels = !pack.reverseRowOrder && pack.alignment <= 4 && getShareHandleSupport() &&
x == 0 && y == 0 && UINT(width) == desc.Width && UINT(height) == desc.Height && x == 0 && y == 0 && UINT(width) == desc.Width && UINT(height) == desc.Height &&
desc.Format == D3DFMT_A8R8G8B8 && format == GL_BGRA_EXT && type == GL_UNSIGNED_BYTE; desc.Format == D3DFMT_A8R8G8B8 && format == GL_BGRA_EXT && type == GL_UNSIGNED_BYTE;
if (directToPixels) if (directToPixels)
...@@ -3222,7 +3224,7 @@ void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsiz ...@@ -3222,7 +3224,7 @@ void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsiz
unsigned char *source; unsigned char *source;
int inputPitch; int inputPitch;
if (packReverseRowOrder) if (pack.reverseRowOrder)
{ {
source = ((unsigned char*)lock.pBits) + lock.Pitch * (rect.bottom - rect.top - 1); source = ((unsigned char*)lock.pBits) + lock.Pitch * (rect.bottom - rect.top - 1);
inputPitch = -lock.Pitch; inputPitch = -lock.Pitch;
......
...@@ -187,8 +187,8 @@ class Renderer9 : public Renderer ...@@ -187,8 +187,8 @@ class Renderer9 : public Renderer
virtual bool blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &readRect, gl::Framebuffer *drawTarget, const gl::Rectangle &drawRect, virtual bool blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &readRect, gl::Framebuffer *drawTarget, const gl::Rectangle &drawRect,
const gl::Rectangle *scissor, bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter); const gl::Rectangle *scissor, bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter);
virtual void readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, virtual void readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
GLsizei outputPitch, bool packReverseRowOrder, GLint packAlignment, void* pixels); GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, void* pixels);
// RenderTarget creation // RenderTarget creation
virtual RenderTarget *createRenderTarget(SwapChain *swapChain, bool depth); virtual RenderTarget *createRenderTarget(SwapChain *swapChain, bool depth);
......
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