From owner-svn-src-all@freebsd.org Wed Mar 27 08:02:56 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 A35E7154777E; Wed, 27 Mar 2019 08:02:56 +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 483276A9AB; Wed, 27 Mar 2019 08:02:56 +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 1EDE34714; Wed, 27 Mar 2019 08:02:56 +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 x2R82utd014211; Wed, 27 Mar 2019 08:02:56 GMT (envelope-from bde@FreeBSD.org) Received: (from bde@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2R82tmk014209; Wed, 27 Mar 2019 08:02:55 GMT (envelope-from bde@FreeBSD.org) Message-Id: <201903270802.x2R82tmk014209@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bde set sender to bde@FreeBSD.org using -f From: Bruce Evans Date: Wed, 27 Mar 2019 08:02:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345568 - head/lib/libvgl X-SVN-Group: head X-SVN-Commit-Author: bde X-SVN-Commit-Paths: head/lib/libvgl X-SVN-Commit-Revision: 345568 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 483276A9AB 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(-0.99)[-0.991,0]; NEURAL_HAM_SHORT(-0.97)[-0.974,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: Wed, 27 Mar 2019 08:02:57 -0000 Author: bde Date: Wed Mar 27 08:02:55 2019 New Revision: 345568 URL: https://svnweb.freebsd.org/changeset/base/345568 Log: Fix copying of bitmaps in depths > 8. This fix is complete, except different depths for the source and target are not supported. The bits for higher numbered planes (mostly for red) were either not copied or were copied to lower numbered planes for nearby pixels. Quick fix for creation of mouse cursor bitmaps in all depths. This fix is only complete for the default lightwhite cursor with a black frame. Even the lightwhite and black colors are hard to find. The templates use 0xff for lightwhite, but that means brightblue in the simplest mode (Truecolor depth 24). Other modes are even more complicated -- they are singly or doubly indirect throught palette(s) and changing of the palettes by applications is supported. Details: Replicate the template value for Truecolor modes to fill out the target depth (and more for depths not a multiple of 8). Do this for every drawing of the cursor so that it sort of works for mouse cursor bitmaps set by applications. Use 0xf for lightwhite in most other modes. Only do this for the default cursor so that it doesn't affect mouse cursor bitmaps set by applications. 0xf mostly works because it was originally for CGA lightwhite and is emulated using 1 or 2 indirections on EGA and VGA. 0x3f (EGA white) and 0xff (VGA black) direct palette indexes mostly don't work since backwards compatibility inhibits or prevents them representing lightwhite. But 0x3f (EGA white) must be used for mode 37 (VGA_MODEX) (320x240x8 V) since this mode is closer to EGA than VGA. Modified: head/lib/libvgl/bitmap.c head/lib/libvgl/mouse.c Modified: head/lib/libvgl/bitmap.c ============================================================================== --- head/lib/libvgl/bitmap.c Wed Mar 27 03:02:54 2019 (r345567) +++ head/lib/libvgl/bitmap.c Wed Mar 27 08:02:55 2019 (r345568) @@ -325,13 +325,13 @@ __VGLBitmapCopy(VGLBitmap *src, int srcx, int srcy, if (src->Type == MEMBUF) { for (srcline=srcy, dstline=dsty; srclineBitmap+(srcline*src->VXsize)+srcx)); + src->Bitmap+(srcline*src->VXsize+srcx)*dst->PixelBytes); } } else if (dst->Type == MEMBUF) { for (srcline=srcy, dstline=dsty; srclineBitmap+(dstline*dst->VXsize)+dstx)); + dst->Bitmap+(dstline*dst->VXsize+dstx)*src->PixelBytes); } } else { Modified: head/lib/libvgl/mouse.c ============================================================================== --- head/lib/libvgl/mouse.c Wed Mar 27 03:02:54 2019 (r345567) +++ head/lib/libvgl/mouse.c Wed Mar 27 08:02:55 2019 (r345568) @@ -99,7 +99,7 @@ VGLMousePointerShow() VGLBitmap buffer = VGLBITMAP_INITIALIZER(MEMBUF, MOUSE_IMG_SIZE, MOUSE_IMG_SIZE, buf); byte crtcidx, crtcval, gdcidx, gdcval; - int pos; + int i, pos, pos1; if (!VGLMouseVisible) { VGLMouseVisible = 1; @@ -109,10 +109,15 @@ VGLMousePointerShow() gdcval = inb(0x3cf); __VGLBitmapCopy(VGLDisplay, VGLMouseXpos, VGLMouseYpos, &VGLMouseSave, 0, 0, MOUSE_IMG_SIZE, MOUSE_IMG_SIZE); - bcopy(VGLMouseSave.Bitmap, buffer.Bitmap, MOUSE_IMG_SIZE*MOUSE_IMG_SIZE); + bcopy(VGLMouseSave.Bitmap, buffer.Bitmap, + MOUSE_IMG_SIZE*MOUSE_IMG_SIZE*VGLDisplay->PixelBytes); for (pos = 0; pos < MOUSE_IMG_SIZE*MOUSE_IMG_SIZE; pos++) - buffer.Bitmap[pos]=(buffer.Bitmap[pos]&~(VGLMouseAndMask->Bitmap[pos])) | - VGLMouseOrMask->Bitmap[pos]; + for (i = 0; i < VGLDisplay->PixelBytes; i++) { + pos1 = pos * VGLDisplay->PixelBytes + i; + buffer.Bitmap[pos1] = (buffer.Bitmap[pos1] & + ~VGLMouseAndMask->Bitmap[pos]) | + VGLMouseOrMask->Bitmap[pos]; + } __VGLBitmapCopy(&buffer, 0, 0, VGLDisplay, VGLMouseXpos, VGLMouseYpos, MOUSE_IMG_SIZE, MOUSE_IMG_SIZE); outb(0x3c4, crtcidx); @@ -205,8 +210,22 @@ int VGLMouseInit(int mode) { struct mouse_info mouseinfo; - int error; + int error, i, mask; + switch (VGLModeInfo.vi_mem_model) { + case V_INFO_MM_PACKED: + case V_INFO_MM_PLANAR: + mask = 0x0f; + break; + case V_INFO_MM_VGAX: + mask = 0x3f; + break; + default: + mask = 0xff; + break; + } + for (i = 0; i < 256; i++) + VGLMouseStdOrMask.Bitmap[i] &= mask; VGLMouseSetStdImage(); mouseinfo.operation = MOUSE_MODE; mouseinfo.u.mode.signal = SIGUSR2; @@ -236,6 +255,8 @@ VGLMouseStatus(int *x, int *y, char *buttons) int VGLMouseFreeze(int x, int y, int width, int hight, u_long color) { + int i, xstride, ystride; + if (!VGLMouseFrozen) { VGLMouseFrozen = 1; if (width > 1 || hight > 1) { /* bitmap */ @@ -260,8 +281,11 @@ VGLMouseFreeze(int x, int y, int width, int hight, u_l if (VGLMouseShown && x >= VGLMouseXpos && x < VGLMouseXpos + MOUSE_IMG_SIZE && y >= VGLMouseYpos && y < VGLMouseYpos + MOUSE_IMG_SIZE) { - VGLMouseSave.Bitmap[(y-VGLMouseYpos)*MOUSE_IMG_SIZE+(x-VGLMouseXpos)] = - (color); + xstride = VGLDisplay->PixelBytes; + ystride = MOUSE_IMG_SIZE * xstride; + for (i = 0; i < xstride; i++, color >>= 8) + VGLMouseSave.Bitmap[(y-VGLMouseYpos)*ystride+ + (x-VGLMouseXpos)*xstride+i] = color; if (VGLMouseAndMask->Bitmap [(y-VGLMouseYpos)*MOUSE_IMG_SIZE+(x-VGLMouseXpos)]) { return 1;