summaryrefslogtreecommitdiff
path: root/lib/libvgl
diff options
context:
space:
mode:
authorBruce Evans <bde@FreeBSD.org>2019-04-19 20:29:49 +0000
committerBruce Evans <bde@FreeBSD.org>2019-04-19 20:29:49 +0000
commit1e4abf1d4c711217c54859d7374ab81625e2c7ca (patch)
tree757b0c5f0a7d460a11fe42d3cbbd8a2d58f53d1d /lib/libvgl
parentbd48a010437816c67bce2c451e85cd041109256f (diff)
downloadsrc-test2-1e4abf1d4c711217c54859d7374ab81625e2c7ca.tar.gz
src-test2-1e4abf1d4c711217c54859d7374ab81625e2c7ca.zip
Notes
Diffstat (limited to 'lib/libvgl')
-rw-r--r--lib/libvgl/bitmap.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/libvgl/bitmap.c b/lib/libvgl/bitmap.c
index c5af0c645259..76e206ac56c0 100644
--- a/lib/libvgl/bitmap.c
+++ b/lib/libvgl/bitmap.c
@@ -269,7 +269,7 @@ int
__VGLBitmapCopy(VGLBitmap *src, int srcx, int srcy,
VGLBitmap *dst, int dstx, int dsty, int width, int hight)
{
- int srcline, dstline;
+ int srcline, dstline, yend, yextra, ystep;
if (srcx>src->VXsize || srcy>src->VYsize
|| dstx>dst->VXsize || dsty>dst->VYsize)
@@ -296,8 +296,17 @@ __VGLBitmapCopy(VGLBitmap *src, int srcx, int srcy,
hight=dst->VYsize-dsty;
if (width < 0 || hight < 0)
return -1;
+ yend = srcy + hight;
+ yextra = 0;
+ ystep = 1;
+ if (src->Bitmap == dst->Bitmap && srcy < dsty) {
+ yend = srcy;
+ yextra = hight - 1;
+ ystep = -1;
+ }
if (src->Type == MEMBUF) {
- for (srcline=srcy, dstline=dsty; srcline<srcy+hight; srcline++, dstline++) {
+ for (srcline = srcy + yextra, dstline = dsty + yextra; srcline != yend;
+ srcline += ystep, dstline += ystep) {
WriteVerticalLine(dst, dstx, dstline, width,
src->Bitmap+(srcline*src->VXsize+srcx)*dst->PixelBytes);
}
@@ -319,7 +328,8 @@ __VGLBitmapCopy(VGLBitmap *src, int srcx, int srcy,
} else {
p = buffer;
}
- for (srcline=srcy, dstline=dsty; srcline<srcy+hight; srcline++, dstline++) {
+ for (srcline = srcy + yextra, dstline = dsty + yextra; srcline != yend;
+ srcline += ystep, dstline += ystep) {
ReadVerticalLine(src, srcx, srcline, width, p);
WriteVerticalLine(dst, dstx, dstline, width, p);
}