From owner-svn-src-all@freebsd.org Fri Apr 19 20:29:50 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 425141578037; Fri, 19 Apr 2019 20:29:50 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DA9086A563; Fri, 19 Apr 2019 20:29:49 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B0FE839BA; Fri, 19 Apr 2019 20:29:49 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x3JKTnV2026913; Fri, 19 Apr 2019 20:29:49 GMT (envelope-from bde@FreeBSD.org) Received: (from bde@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x3JKTn8R026912; Fri, 19 Apr 2019 20:29:49 GMT (envelope-from bde@FreeBSD.org) Message-Id: <201904192029.x3JKTn8R026912@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bde set sender to bde@FreeBSD.org using -f From: Bruce Evans Date: Fri, 19 Apr 2019 20:29:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r346416 - head/lib/libvgl X-SVN-Group: head X-SVN-Commit-Author: bde X-SVN-Commit-Paths: head/lib/libvgl X-SVN-Commit-Revision: 346416 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: DA9086A563 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.96)[-0.963,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Apr 2019 20:29:50 -0000 Author: bde Date: Fri Apr 19 20:29:49 2019 New Revision: 346416 URL: https://svnweb.freebsd.org/changeset/base/346416 Log: Fix copying of overlapping bitmaps. The cases of copying within the screen bitmap and within a single MEMBUF were broken when first source line is before the first destination line and the sub-bitmaps overlap. The fix just copies horizontal lines in reverse order when the first source line is before the first destination line. This switches directions unnecessarily in some cases, but the switch is about as fast as doing a precise detection of overlaps. When the first lines are the same, there can be undetected overlap in the horizontal direction. The old code already handles this mostly accidentally by using bcopy() for MEMBUFs and by copying through a temporary buffer for the screen bitmap although the latter is sub-optimal in direct modes. Modified: head/lib/libvgl/bitmap.c Modified: head/lib/libvgl/bitmap.c ============================================================================== --- head/lib/libvgl/bitmap.c Fri Apr 19 20:23:39 2019 (r346415) +++ head/lib/libvgl/bitmap.c Fri Apr 19 20:29:49 2019 (r346416) @@ -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; srclineBitmap+(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