diff options
author | Keith Whitwell <keithw@vmware.com> | 2009-05-07 19:48:06 +0100 |
---|---|---|
committer | Keith Whitwell <keithw@vmware.com> | 2009-05-08 10:04:14 +0100 |
commit | d5c2ad8514ce8064d83febf647c9e726788b7924 (patch) | |
tree | 4ffde99d8e6e0eafd57ede40cbde705c1f508151 /src/mesa/state_tracker/st_cb_texture.c | |
parent | 6826bad6a75e78729dd472ea26c87787c90ada4c (diff) |
mesa/st: keep surface_copy arguments positive
The src/dest x,y, and w,h arguments of the pipe->surface_copy
function are unsigned and the drivers aren't expecting negative
(or extremly-large unsigned) values as inputs. Trim the requests
at the state-tracker level before passing down.
Diffstat (limited to 'src/mesa/state_tracker/st_cb_texture.c')
-rw-r--r-- | src/mesa/state_tracker/st_cb_texture.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 98f109fc65..b182106fd5 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -1337,6 +1337,34 @@ st_copy_texsubimage(GLcontext *ctx, return; } + if (srcX < 0) { + width -= -srcX; + destX += -srcX; + srcX = 0; + } + + if (srcY < 0) { + height -= -srcY; + destY += -srcY; + srcY = 0; + } + + if (destX < 0) { + width -= -destX; + srcX += -destX; + destX = 0; + } + + if (destY < 0) { + height -= -destY; + srcY += -destY; + destY = 0; + } + + if (width < 0 || height < 0) + return; + + assert(strb); assert(strb->surface); assert(stImage->pt); |