Commit af11b53a by Corentin Wallez Committed by Commit Bot

FramebufferNULL::readPixels: write pixels for tests

BUG=602737 Change-Id: I8c24985358dcd297cb437c501b7a3944e36d98de Reviewed-on: https://chromium-review.googlesource.com/644210Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
parent e49058e7
...@@ -107,4 +107,14 @@ gl::Error BufferNULL::getIndexRange(GLenum type, ...@@ -107,4 +107,14 @@ gl::Error BufferNULL::getIndexRange(GLenum type,
return gl::NoError(); return gl::NoError();
} }
uint8_t *BufferNULL::getDataPtr()
{
return mData.data();
}
const uint8_t *BufferNULL::getDataPtr() const
{
return mData.data();
}
} // namespace rx } // namespace rx
...@@ -52,6 +52,9 @@ class BufferNULL : public BufferImpl ...@@ -52,6 +52,9 @@ class BufferNULL : public BufferImpl
bool primitiveRestartEnabled, bool primitiveRestartEnabled,
gl::IndexRange *outRange) override; gl::IndexRange *outRange) override;
uint8_t *getDataPtr();
const uint8_t *getDataPtr() const;
private: private:
std::vector<uint8_t> mData; std::vector<uint8_t> mData;
......
...@@ -9,7 +9,9 @@ ...@@ -9,7 +9,9 @@
#include "libANGLE/renderer/null/FramebufferNULL.h" #include "libANGLE/renderer/null/FramebufferNULL.h"
#include "libANGLE/Context.h"
#include "libANGLE/formatutils.h" #include "libANGLE/formatutils.h"
#include "libANGLE/renderer/null/BufferNULL.h"
#include "common/debug.h" #include "common/debug.h"
...@@ -111,11 +113,60 @@ GLenum FramebufferNULL::getImplementationColorReadType(const gl::Context *contex ...@@ -111,11 +113,60 @@ GLenum FramebufferNULL::getImplementationColorReadType(const gl::Context *contex
} }
gl::Error FramebufferNULL::readPixels(const gl::Context *context, gl::Error FramebufferNULL::readPixels(const gl::Context *context,
const gl::Rectangle &area, const gl::Rectangle &origArea,
GLenum format, GLenum format,
GLenum type, GLenum type,
void *pixels) const void *ptrOrOffset) const
{ {
const gl::PixelPackState &packState = context->getGLState().getPackState();
// Get the pointer to write to from the argument or the pack buffer
GLubyte *pixels = nullptr;
if (packState.pixelBuffer.get() != nullptr)
{
BufferNULL *pixelBuffer = GetImplAs<BufferNULL>(packState.pixelBuffer.get());
pixels = reinterpret_cast<GLubyte *>(pixelBuffer->getDataPtr());
pixels += reinterpret_cast<intptr_t>(ptrOrOffset);
}
else
{
pixels = reinterpret_cast<GLubyte *>(ptrOrOffset);
}
// Clip read area to framebuffer.
const gl::Extents fbSize = getState().getReadAttachment()->getSize();
const gl::Rectangle fbRect(0, 0, fbSize.width, fbSize.height);
gl::Rectangle area;
if (!ClipRectangle(origArea, fbRect, &area))
{
// nothing to read
return gl::NoError();
}
// Compute size of unclipped rows and initial skip
const gl::InternalFormat &glFormat = gl::GetInternalFormatInfo(format, type);
GLuint rowBytes = 0;
ANGLE_TRY_RESULT(
glFormat.computeRowPitch(type, origArea.width, packState.alignment, packState.rowLength),
rowBytes);
GLuint skipBytes = 0;
ANGLE_TRY_RESULT(glFormat.computeSkipBytes(rowBytes, 0, packState, false), skipBytes);
pixels += skipBytes;
// Skip OOB region up to first in bounds pixel
int leftClip = area.x - origArea.x;
int topClip = area.y - origArea.y;
pixels += leftClip * glFormat.pixelBytes + topClip * rowBytes;
// Write the in-bounds readpixels data with non-zero values
for (GLint y = area.y; y < area.y + area.height; ++y)
{
memset(pixels, 42, glFormat.pixelBytes * area.width);
pixels += rowBytes;
}
return gl::NoError(); return gl::NoError();
} }
......
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