From owner-svn-src-head@freebsd.org Tue Sep 3 14:07:37 2019 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 66F62DD758; Tue, 3 Sep 2019 14:07:15 +0000 (UTC) (envelope-from yuripv@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [96.47.72.132]) (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 "freefall.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46N80M05CFz4QPs; Tue, 3 Sep 2019 14:07:14 +0000 (UTC) (envelope-from yuripv@freebsd.org) Received: by freefall.freebsd.org (Postfix, from userid 1452) id A60DB1B348; Tue, 3 Sep 2019 14:06:33 +0000 (UTC) X-Original-To: yuripv@localmail.freebsd.org Delivered-To: yuripv@localmail.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [96.47.72.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client CN "mx1.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by freefall.freebsd.org (Postfix) with ESMTPS id D6B851E004; Sun, 21 Apr 2019 16:17:39 +0000 (UTC) (envelope-from owner-src-committers@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2610:1c1:1:6074::16:84]) (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 "freefall.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46D20770E8; Sun, 21 Apr 2019 16:17:39 +0000 (UTC) (envelope-from owner-src-committers@freebsd.org) Received: by freefall.freebsd.org (Postfix, from userid 538) id 1A2F41DFE3; Sun, 21 Apr 2019 16:17:39 +0000 (UTC) Delivered-To: src-committers@localmail.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [96.47.72.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client CN "mx1.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by freefall.freebsd.org (Postfix) with ESMTPS id CC2071DFE1 for ; Sun, 21 Apr 2019 16:17:36 +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 A9FE3770E2; Sun, 21 Apr 2019 16:17:36 +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 8535C27BF7; Sun, 21 Apr 2019 16:17:36 +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 x3LGHanZ019370; Sun, 21 Apr 2019 16:17:36 GMT (envelope-from bde@FreeBSD.org) Received: (from bde@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x3LGHZ4i019365; Sun, 21 Apr 2019 16:17:35 GMT (envelope-from bde@FreeBSD.org) Message-Id: <201904211617.x3LGHZ4i019365@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bde set sender to bde@FreeBSD.org using -f From: Bruce Evans To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r346488 - head/lib/libvgl X-SVN-Group: head X-SVN-Commit-Author: bde X-SVN-Commit-Paths: head/lib/libvgl X-SVN-Commit-Revision: 346488 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk X-Loop: FreeBSD.org Sender: owner-src-committers@freebsd.org X-Rspamd-Queue-Id: 46D20770E8 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)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.959,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] Status: O X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Date: Tue, 03 Sep 2019 14:07:37 -0000 X-Original-Date: Sun, 21 Apr 2019 16:17:35 +0000 (UTC) X-List-Received-Date: Tue, 03 Sep 2019 14:07:37 -0000 Author: bde Date: Sun Apr 21 16:17:35 2019 New Revision: 346488 URL: https://svnweb.freebsd.org/changeset/base/346488 Log: Use a shadow buffer and never read from the frame buffer. Remove large slow code for reading from the frame buffer. Reading from the frame buffer is usually much slower than writing to the frame buffer. Typically 10 to 100 times slower. It old modes, it takes many more PIOs, and in newer modes with no PIOs writes are often write-combined while reads remain uncached. Reading from the frame buffer is not very common, so this change doesn't give speedups of 10 to 100 times. My main test case is a floodfill() function that reads about as many pixels as it writes. The speedups are typically a factor of 2 to 4. Duplicating writes to the shadow buffer is slower when no reads from the frame buffer are done, but reads are often done for the pixels under the mouse cursor, and doing these reads from the shadow buffer more than compensates for the overhead of writing the shadow buffer in at least the slower modes. Management of the mouse cursor also becomes simpler. The shadow buffer doesn't take any extra memory, except twice as much in old 4-plane modes. A buffer for holding a copy of the frame buffer was allocated up front for use in the screen switching signal handler. This wasn't changed when the handler was made async-signal safe. Use the same buffer the shadow (but make it twice as large in the 4-plane modes), and remove large special code for writing it as well as large special code for reading ut. It used to have a rawer format in the 4-plane modes. Now it has a bitmap format which takes twice as much memory but can be written almost as fast without special code. VIDBUFs that are not the whole frame buffer were never supported, and the change depends on this. Check for invalid VIDBUFs in some places and do nothing. The removed code did something not so good. Modified: head/lib/libvgl/bitmap.c head/lib/libvgl/main.c head/lib/libvgl/mouse.c head/lib/libvgl/simple.c head/lib/libvgl/vgl.h Modified: head/lib/libvgl/bitmap.c ============================================================================== --- head/lib/libvgl/bitmap.c Sun Apr 21 14:45:18 2019 (r346487) +++ head/lib/libvgl/bitmap.c Sun Apr 21 16:17:35 2019 (r346488) @@ -163,108 +163,6 @@ WriteVerticalLine(VGLBitmap *dst, int x, int y, int wi } } -static void -ReadVerticalLine(VGLBitmap *src, int x, int y, int width, byte *line) -{ - int i, bit, pos, count, planepos, start_offset, end_offset, offset; - int width2, len; - byte *address; - byte *VGLPlane[4]; - - switch (src->Type) { - case VIDBUF4S: - start_offset = (x & 0x07); - end_offset = (x + width) & 0x07; - count = (width + start_offset) / 8; - if (end_offset) - count++; - VGLPlane[0] = VGLBuf; - VGLPlane[1] = VGLPlane[0] + count; - VGLPlane[2] = VGLPlane[1] + count; - VGLPlane[3] = VGLPlane[2] + count; - for (i=0; i<4; i++) { - outb(0x3ce, 0x04); - outb(0x3cf, i); - pos = VGLAdpInfo.va_line_width*y + x/8; - for (width2 = count; width2 > 0; ) { - offset = VGLSetSegment(pos); - len = min(VGLAdpInfo.va_window_size - offset, width2); - bcopy(src->Bitmap + offset, &VGLPlane[i][count - width2], len); - pos += len; - width2 -= len; - } - } - goto read_planar; - case VIDBUF4: - address = src->Bitmap + VGLAdpInfo.va_line_width * y + x/8; - start_offset = (x & 0x07); - end_offset = (x + width) & 0x07; - count = (width + start_offset) / 8; - if (end_offset) - count++; - VGLPlane[0] = VGLBuf; - VGLPlane[1] = VGLPlane[0] + count; - VGLPlane[2] = VGLPlane[1] + count; - VGLPlane[3] = VGLPlane[2] + count; - for (i=0; i<4; i++) { - outb(0x3ce, 0x04); - outb(0x3cf, i); - bcopy(address, &VGLPlane[i][0], count); - } -read_planar: - pos = 0; - planepos = 0; - bit = 7 - start_offset; - while (pos < width) { - for (; bit >= 0 && pos < width; bit--, pos++) { - line[pos] = (VGLPlane[0][planepos] & (1<Bitmap + VGLAdpInfo.va_line_width * y + x/4; - for (i=0; i<4; i++) { - outb(0x3ce, 0x04); - outb(0x3cf, (x + i)%4); - for (planepos=0, pos=i; posPixelBytes; - pos = (src->VXsize * y + x) * src->PixelBytes; - while (width > 0) { - offset = VGLSetSegment(pos); - i = min(VGLAdpInfo.va_window_size - offset, width); - bcopy(src->Bitmap + offset, line, i); - line += i; - pos += i; - width -= i; - } - break; - case MEMBUF: - case VIDBUF8: - case VIDBUF16: - case VIDBUF24: - case VIDBUF32: - address = src->Bitmap + (src->VXsize * y + x) * src->PixelBytes; - bcopy(address, line, width * src->PixelBytes); - break; - default: - ; - } -} - int __VGLBitmapCopy(VGLBitmap *src, int srcx, int srcy, VGLBitmap *dst, int dstx, int dsty, int width, int hight) @@ -304,38 +202,11 @@ __VGLBitmapCopy(VGLBitmap *src, int srcx, int srcy, yextra = hight - 1; ystep = -1; } - if (src->Type == MEMBUF) { - 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); - } + 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); } - else if (dst->Type == MEMBUF) { - for (srcline=srcy, dstline=dsty; srclineBitmap+(dstline*dst->VXsize+dstx)*src->PixelBytes); - } - } - else { - byte buffer[2048]; /* XXX */ - byte *p; - - if (width * src->PixelBytes > sizeof(buffer)) { - p = malloc(width * src->PixelBytes); - if (p == NULL) - return 1; - } else { - p = buffer; - } - 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); - } - if (width * src->PixelBytes > sizeof(buffer)) - free(p); - } return 0; } @@ -345,12 +216,20 @@ VGLBitmapCopy(VGLBitmap *src, int srcx, int srcy, { int error; + if (src == VGLDisplay) + src = &VGLVDisplay; if (src->Type != MEMBUF) - VGLMouseFreeze(srcx, srcy, width, hight, 0); - if (dst->Type != MEMBUF) + return -1; /* invalid */ + if (dst == VGLDisplay) { VGLMouseFreeze(dstx, dsty, width, hight, 0); + __VGLBitmapCopy(src, srcx, srcy, &VGLVDisplay, dstx, dsty, width, hight); + src = &VGLVDisplay; + srcx = dstx; + srcy = dsty; + } else if (dst->Type != MEMBUF) + return -1; /* invalid */ error = __VGLBitmapCopy(src, srcx, srcy, dst, dstx, dsty, width, hight); - if (src->Type != MEMBUF || dst->Type != MEMBUF) + if (dst == VGLDisplay) VGLMouseUnFreeze(); return error; } Modified: head/lib/libvgl/main.c ============================================================================== --- head/lib/libvgl/main.c Sun Apr 21 14:45:18 2019 (r346487) +++ head/lib/libvgl/main.c Sun Apr 21 16:17:35 2019 (r346488) @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #define max(x, y) (((x) > (y)) ? (x) : (y)) VGLBitmap *VGLDisplay; +VGLBitmap VGLVDisplay; video_info_t VGLModeInfo; video_adapter_info_t VGLAdpInfo; byte *VGLBuf; @@ -334,6 +335,13 @@ VGLInit(int mode) } VGLDisplay->Bitmap = VGLMem; + VGLVDisplay = *VGLDisplay; + VGLVDisplay.Type = MEMBUF; + if (VGLModeInfo.vi_depth < 8) + VGLVDisplay.Bitmap = malloc(2 * VGLBufSize); + else + VGLVDisplay.Bitmap = VGLBuf; + VGLSavePalette(); #ifdef LIBVGL_DEBUG @@ -365,10 +373,6 @@ VGLCheckSwitch() exit(0); } while (VGLSwitchPending) { - unsigned int offset; - unsigned int len; - int i; - VGLSwitchPending = 0; if (VGLOnDisplay) { if (VGLModeInfo.vi_mem_model != V_INFO_MM_DIRECT) @@ -440,98 +444,12 @@ VGLCheckSwitch() VGLRestoreBorder(); VGLMouseRestore(); VGLPanScreen(VGLDisplay, VGLDisplay->Xorigin, VGLDisplay->Yorigin); - switch (VGLDisplay->Type) { - case VIDBUF4S: - outb(0x3c6, 0xff); - outb(0x3ce, 0x01); outb(0x3cf, 0x00); /* set/reset enable */ - outb(0x3ce, 0x08); outb(0x3cf, 0xff); /* bit mask */ - for (offset = 0; offset < VGLBufSize/VGLModeInfo.vi_planes; - offset += len) { - VGLSetSegment(offset); - len = min(VGLBufSize/VGLModeInfo.vi_planes - offset, - VGLAdpInfo.va_window_size); - for (i = 0; i < VGLModeInfo.vi_planes; i++) { - outb(0x3c4, 0x02); - outb(0x3c5, 0x01<VXsize, VGLDisplay->VYsize); VGLRestorePalette(); ioctl(0, VT_RELDISP, VT_ACKACQ); } else { - switch (VGLDisplay->Type) { - case VIDBUF4S: - for (offset = 0; offset < VGLBufSize/VGLModeInfo.vi_planes; - offset += len) { - VGLSetSegment(offset); - len = min(VGLBufSize/VGLModeInfo.vi_planes - offset, - VGLAdpInfo.va_window_size); - for (i = 0; i < VGLModeInfo.vi_planes; i++) { - outb(0x3ce, 0x04); - outb(0x3cf, i); - bcopy(VGLMem, &VGLBuf[i*VGLBufSize/VGLModeInfo.vi_planes + offset], - len); - } - } - break; - case VIDBUF4: - case VIDBUF8X: - /* - * NOTE: the saved buffer is NOT in the MEMBUF format which - * the ordinary memory bitmap object is stored in. XXX - */ - for (i = 0; i < VGLModeInfo.vi_planes; i++) { - outb(0x3ce, 0x04); - outb(0x3cf, i); - bcopy(VGLMem, &VGLBuf[i*VGLAdpInfo.va_window_size], - VGLAdpInfo.va_window_size); - } - break; - case VIDBUF8: - case VIDBUF8S: - case VIDBUF16: - case VIDBUF16S: - case VIDBUF24: - case VIDBUF24S: - case VIDBUF32: - case VIDBUF32S: - for (offset = 0; offset < VGLBufSize; offset += len) { - VGLSetSegment(offset); - len = min(VGLBufSize - offset, VGLAdpInfo.va_window_size); - bcopy(VGLMem, &VGLBuf[offset], len); - } - break; - } VGLMem = MAP_FAILED; munmap(VGLDisplay->Bitmap, VGLAdpInfo.va_window_size); ioctl(0, VGLOldMode, 0); Modified: head/lib/libvgl/mouse.c ============================================================================== --- head/lib/libvgl/mouse.c Sun Apr 21 14:45:18 2019 (r346487) +++ head/lib/libvgl/mouse.c Sun Apr 21 16:17:35 2019 (r346488) @@ -82,9 +82,6 @@ static VGLBitmap VGLMouseStdAndMask = static VGLBitmap VGLMouseStdOrMask = VGLBITMAP_INITIALIZER(MEMBUF, MOUSE_IMG_SIZE, MOUSE_IMG_SIZE, StdOrMask); static VGLBitmap *VGLMouseAndMask, *VGLMouseOrMask; -static byte map[MOUSE_IMG_SIZE*MOUSE_IMG_SIZE*4]; -static VGLBitmap VGLMouseSave = - VGLBITMAP_INITIALIZER(MEMBUF, MOUSE_IMG_SIZE, MOUSE_IMG_SIZE, map); static int VGLMouseVisible = 0; static int VGLMouseShown = 0; static int VGLMouseXpos = 0; @@ -117,10 +114,9 @@ VGLMousePointerShow() gdcidx = inb(0x3ce); 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*VGLDisplay->PixelBytes); + buffer.PixelBytes = VGLDisplay->PixelBytes; + __VGLBitmapCopy(&VGLVDisplay, VGLMouseXpos, VGLMouseYpos, + &buffer, 0, 0, MOUSE_IMG_SIZE, MOUSE_IMG_SIZE); for (pos = 0; pos < MOUSE_IMG_SIZE*MOUSE_IMG_SIZE; pos++) for (i = 0; i < VGLDisplay->PixelBytes; i++) { pos1 = pos * VGLDisplay->PixelBytes + i; @@ -154,8 +150,8 @@ VGLMousePointerHide() gdcidx = inb(0x3ce); gdcval = inb(0x3cf); } - __VGLBitmapCopy(&VGLMouseSave, 0, 0, VGLDisplay, - VGLMouseXpos, VGLMouseYpos, MOUSE_IMG_SIZE, MOUSE_IMG_SIZE); + __VGLBitmapCopy(&VGLVDisplay, VGLMouseXpos, VGLMouseYpos, VGLDisplay, + VGLMouseXpos, VGLMouseYpos, MOUSE_IMG_SIZE, MOUSE_IMG_SIZE); if (VGLModeInfo.vi_mem_model != V_INFO_MM_DIRECT) { outb(0x3c4, crtcidx); outb(0x3c5, crtcval); @@ -302,8 +298,6 @@ VGLMouseStatus(int *x, int *y, char *buttons) int VGLMouseFreeze(int x, int y, int width, int hight, u_long color) { - int i, xstride, ystride; - INTOFF(); if (width > 1 || hight > 1 || (color & 0xc0000000) == 0) { /* bitmap */ if (VGLMouseShown == 1) { @@ -327,20 +321,7 @@ 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) { - xstride = VGLDisplay->PixelBytes; - ystride = MOUSE_IMG_SIZE * xstride; - if (color & 0x40000000) { /* Get */ - color = 0; - for (i = xstride - 1; i >= 0; i--) - color = (color << 8) | - VGLMouseSave.Bitmap[(y-VGLMouseYpos)*ystride+ - (x-VGLMouseXpos)*xstride+i]; - return 0x40000000 | (color & 0xffffff); - } else { /* Set */ - color &= 0xffffff; /* discard flag and other garbage */ - for (i = 0; i < xstride; i++, color >>= 8) - VGLMouseSave.Bitmap[(y-VGLMouseYpos)*ystride+ - (x-VGLMouseXpos)*xstride+i] = color; + if (color & 0x80000000) { /* Set */ if (VGLMouseAndMask->Bitmap [(y-VGLMouseYpos)*MOUSE_IMG_SIZE+(x-VGLMouseXpos)]) { return 1; Modified: head/lib/libvgl/simple.c ============================================================================== --- head/lib/libvgl/simple.c Sun Apr 21 14:45:18 2019 (r346487) +++ head/lib/libvgl/simple.c Sun Apr 21 16:17:35 2019 (r346488) @@ -55,6 +55,8 @@ VGLSetXY(VGLBitmap *object, int x, int y, u_long color VGLCheckSwitch(); if (x>=0 && xVXsize && y>=0 && yVYsize) { + if (object == VGLDisplay) + VGLSetXY(&VGLVDisplay, x, y, color); if (object->Type == MEMBUF || !VGLMouseFreeze(x, y, 1, 1, 0x80000000 | color)) { offset = (y * object->VXsize + x) * object->PixelBytes; @@ -113,78 +115,37 @@ static u_long __VGLGetXY(VGLBitmap *object, int x, int y) { int offset; - int i; u_long color; - byte mask; offset = (y * object->VXsize + x) * object->PixelBytes; - switch (object->Type) { - case VIDBUF8S: - case VIDBUF16S: - case VIDBUF24S: - case VIDBUF32S: - offset = VGLSetSegment(offset); - /* FALLTHROUGH */ - case MEMBUF: - case VIDBUF8: - case VIDBUF16: - case VIDBUF24: - case VIDBUF32: - switch (object->PixelBytes) { - case 1: - memcpy(&color, &object->Bitmap[offset], 1); - return le32toh(color) & 0xff; - case 2: - memcpy(&color, &object->Bitmap[offset], 2); - return le32toh(color) & 0xffff; - case 3: - memcpy(&color, &object->Bitmap[offset], 3); - return le32toh(color) & 0xffffff; - case 4: - memcpy(&color, &object->Bitmap[offset], 4); - return le32toh(color); - } - break; - case VIDBUF8X: - outb(0x3ce, 0x04); outb(0x3cf, x & 0x3); - return object->Bitmap[(unsigned)(VGLAdpInfo.va_line_width*y)+(x/4)]; - case VIDBUF4S: - offset = VGLSetSegment(y*VGLAdpInfo.va_line_width + x/8); - goto get_planar; - case VIDBUF4: - offset = y*VGLAdpInfo.va_line_width + x/8; -get_planar: - color = 0; - mask = 0x80 >> (x%8); - for (i = 0; i < VGLModeInfo.vi_planes; i++) { - outb(0x3ce, 0x04); outb(0x3cf, i); - color |= (((volatile VGLBitmap *)object)->Bitmap[offset] & mask) ? - (1 << i) : 0; - } - return color; + switch (object->PixelBytes) { + case 1: + memcpy(&color, &object->Bitmap[offset], 1); + return le32toh(color) & 0xff; + case 2: + memcpy(&color, &object->Bitmap[offset], 2); + return le32toh(color) & 0xffff; + case 3: + memcpy(&color, &object->Bitmap[offset], 3); + return le32toh(color) & 0xffffff; + case 4: + memcpy(&color, &object->Bitmap[offset], 4); + return le32toh(color); } - return 0; /* XXX black? */ + return 0; /* invalid */ } u_long VGLGetXY(VGLBitmap *object, int x, int y) { - u_long color; - VGLCheckSwitch(); if (x<0 || x>=object->VXsize || y<0 || y>=object->VYsize) return 0; - if (object->Type != MEMBUF) { - color = VGLMouseFreeze(x, y, 1, 1, 0x40000000); - if (color & 0x40000000) { - VGLMouseUnFreeze(); - return color & 0xffffff; - } - } - color = __VGLGetXY(object, x, y); + if (object == VGLDisplay) + object = &VGLVDisplay; if (object->Type != MEMBUF) - VGLMouseUnFreeze(); - return color; + return 0; /* invalid */ + return __VGLGetXY(object, x, y); } /* @@ -493,8 +454,11 @@ VGLClear(VGLBitmap *object, u_long color) int i; VGLCheckSwitch(); - if (object->Type != MEMBUF) + if (object == VGLDisplay) { VGLMouseFreeze(0, 0, object->Xsize, object->Ysize, color); + VGLClear(&VGLVDisplay, color); + } else if (object->Type != MEMBUF) + return; /* invalid */ switch (object->Type) { case MEMBUF: case VIDBUF8: @@ -545,7 +509,7 @@ VGLClear(VGLBitmap *object, u_long color) outb(0x3ce, 0x05); outb(0x3cf, 0x00); break; } - if (object->Type != MEMBUF) + if (object == VGLDisplay) VGLMouseUnFreeze(); } Modified: head/lib/libvgl/vgl.h ============================================================================== --- head/lib/libvgl/vgl.h Sun Apr 21 14:45:18 2019 (r346487) +++ head/lib/libvgl/vgl.h Sun Apr 21 16:17:35 2019 (r346488) @@ -100,6 +100,7 @@ typedef struct VGLObject { extern video_adapter_info_t VGLAdpInfo; extern video_info_t VGLModeInfo; extern VGLBitmap *VGLDisplay; +extern VGLBitmap VGLVDisplay; extern byte *VGLBuf; /*