Commit 79fd1e9f by Frank Henigman Committed by Commit Bot

Clip TextureGL::copySubImage to framebuffer.

Ensure the underlying GL does not modify areas of the texture that correspond to areas outside the framebuffer, as required for WebGL. Enable corresponding test. BUG=angleproject:1815 Change-Id: I6092d39e43868902de7ae3aee430deea3b3ff8a1 Reviewed-on: https://chromium-review.googlesource.com/538295 Commit-Queue: Frank Henigman <fjhenigman@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 3244736a
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "common/bitset_utils.h" #include "common/bitset_utils.h"
#include "common/debug.h" #include "common/debug.h"
#include "common/utilities.h" #include "common/utilities.h"
#include "libANGLE/Context.h"
#include "libANGLE/State.h" #include "libANGLE/State.h"
#include "libANGLE/angletypes.h" #include "libANGLE/angletypes.h"
#include "libANGLE/formatutils.h" #include "libANGLE/formatutils.h"
...@@ -593,12 +594,24 @@ gl::Error TextureGL::copyImage(const gl::Context *context, ...@@ -593,12 +594,24 @@ gl::Error TextureGL::copyImage(const gl::Context *context,
gl::Error TextureGL::copySubImage(const gl::Context *context, gl::Error TextureGL::copySubImage(const gl::Context *context,
GLenum target, GLenum target,
size_t level, size_t level,
const gl::Offset &destOffset, const gl::Offset &origDestOffset,
const gl::Rectangle &sourceArea, const gl::Rectangle &origSourceArea,
const gl::Framebuffer *source) const gl::Framebuffer *source)
{ {
const FramebufferGL *sourceFramebufferGL = GetImplAs<FramebufferGL>(source); const FramebufferGL *sourceFramebufferGL = GetImplAs<FramebufferGL>(source);
// Clip source area to framebuffer.
const gl::Extents fbSize = sourceFramebufferGL->getState().getReadAttachment()->getSize();
gl::Rectangle sourceArea;
if (!ClipRectangle(origSourceArea, gl::Rectangle(0, 0, fbSize.width, fbSize.height),
&sourceArea))
{
// nothing to do
return gl::NoError();
}
gl::Offset destOffset(origDestOffset.x + sourceArea.x - origSourceArea.x,
origDestOffset.y + sourceArea.y - origSourceArea.y, origDestOffset.z);
mStateManager->bindTexture(getTarget(), mTextureID); mStateManager->bindTexture(getTarget(), mTextureID);
mStateManager->bindFramebuffer(GL_READ_FRAMEBUFFER, sourceFramebufferGL->getFramebufferID()); mStateManager->bindFramebuffer(GL_READ_FRAMEBUFFER, sourceFramebufferGL->getFramebufferID());
......
...@@ -263,7 +263,10 @@ TEST_P(WebGLReadOutsideFramebufferTest, ReadPixels) ...@@ -263,7 +263,10 @@ TEST_P(WebGLReadOutsideFramebufferTest, ReadPixels)
// the corresponding source pixel is outside the framebuffer. // the corresponding source pixel is outside the framebuffer.
TEST_P(WebGLReadOutsideFramebufferTest, CopyTexSubImage2D) TEST_P(WebGLReadOutsideFramebufferTest, CopyTexSubImage2D)
{ {
// Main(&WebGLReadOutsideFramebufferTest::TestCopyTexSubImage2D, false); if (IsOpenGL() || IsOpenGLES())
{
Main(&WebGLReadOutsideFramebufferTest::TestCopyTexSubImage2D, false);
}
} }
// Check that copyTexImage2D sets (0,0,0,0) for pixels outside the framebuffer. // Check that copyTexImage2D sets (0,0,0,0) for pixels outside the framebuffer.
......
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