Commit ab04e6a7 by Frank Henigman Committed by Commit Bot

Clip TextureD3D_2D::copySubImage to framebuffer.

WebGL CopyTexSubImage does not allow touching parts of the texture that correspond to area outside the framebuffer, so we clip the read area to the framebuffer. The clipping also avoids problems with code lower down that isn't prepared for read areas not entirely within the framebuffer. Enable corresponding test. BUG=angleproject:1815 Change-Id: I411223669dae2a456dfc3e22acda907b73177988 Reviewed-on: https://chromium-review.googlesource.com/527411 Commit-Queue: Frank Henigman <fjhenigman@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 79fd1e9f
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "common/utilities.h" #include "common/utilities.h"
#include "libANGLE/Buffer.h" #include "libANGLE/Buffer.h"
#include "libANGLE/Config.h" #include "libANGLE/Config.h"
#include "libANGLE/Context.h"
#include "libANGLE/Framebuffer.h" #include "libANGLE/Framebuffer.h"
#include "libANGLE/Image.h" #include "libANGLE/Image.h"
#include "libANGLE/Surface.h" #include "libANGLE/Surface.h"
...@@ -21,8 +22,8 @@ ...@@ -21,8 +22,8 @@
#include "libANGLE/renderer/d3d/BufferD3D.h" #include "libANGLE/renderer/d3d/BufferD3D.h"
#include "libANGLE/renderer/d3d/EGLImageD3D.h" #include "libANGLE/renderer/d3d/EGLImageD3D.h"
#include "libANGLE/renderer/d3d/ImageD3D.h" #include "libANGLE/renderer/d3d/ImageD3D.h"
#include "libANGLE/renderer/d3d/RendererD3D.h"
#include "libANGLE/renderer/d3d/RenderTargetD3D.h" #include "libANGLE/renderer/d3d/RenderTargetD3D.h"
#include "libANGLE/renderer/d3d/RendererD3D.h"
#include "libANGLE/renderer/d3d/SurfaceD3D.h" #include "libANGLE/renderer/d3d/SurfaceD3D.h"
#include "libANGLE/renderer/d3d/TextureStorage.h" #include "libANGLE/renderer/d3d/TextureStorage.h"
...@@ -1075,11 +1076,21 @@ gl::Error TextureD3D_2D::copyImage(const gl::Context *context, ...@@ -1075,11 +1076,21 @@ gl::Error TextureD3D_2D::copyImage(const gl::Context *context,
gl::Error TextureD3D_2D::copySubImage(const gl::Context *context, gl::Error TextureD3D_2D::copySubImage(const gl::Context *context,
GLenum target, GLenum target,
size_t imageLevel, size_t imageLevel,
const gl::Offset &destOffset, const gl::Offset &origDestOffset,
const gl::Rectangle &sourceArea, const gl::Rectangle &origSourceArea,
const gl::Framebuffer *source) const gl::Framebuffer *source)
{ {
ASSERT(target == GL_TEXTURE_2D && destOffset.z == 0); ASSERT(target == GL_TEXTURE_2D && origDestOffset.z == 0);
gl::Extents fbSize = source->getReadColorbuffer()->getSize();
gl::Rectangle sourceArea;
if (!ClipRectangle(origSourceArea, gl::Rectangle(0, 0, fbSize.width, fbSize.height),
&sourceArea))
{
return gl::NoError();
}
const gl::Offset destOffset(origDestOffset.x + sourceArea.x - origSourceArea.x,
origDestOffset.y + sourceArea.y - origSourceArea.y, 0);
// can only make our texture storage to a render target if level 0 is defined (with a width & height) and // can only make our texture storage to a render target if level 0 is defined (with a width & height) and
// the current level we're copying to is defined (with appropriate format, width & height) // the current level we're copying to is defined (with appropriate format, width & height)
......
...@@ -263,10 +263,7 @@ TEST_P(WebGLReadOutsideFramebufferTest, ReadPixels) ...@@ -263,10 +263,7 @@ 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)
{ {
if (IsOpenGL() || IsOpenGLES())
{
Main(&WebGLReadOutsideFramebufferTest::TestCopyTexSubImage2D, false); 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