From owner-p4-projects@FreeBSD.ORG Tue Nov 27 21:02:12 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id D471EEBA; Tue, 27 Nov 2012 21:02:11 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 70F4AEB8 for ; Tue, 27 Nov 2012 21:02:11 +0000 (UTC) (envelope-from brooks@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:4f8:fff6::2d]) by mx1.freebsd.org (Postfix) with ESMTP id 55F0E8FC15 for ; Tue, 27 Nov 2012 21:02:11 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.5/8.14.5) with ESMTP id qARL2BOD033326 for ; Tue, 27 Nov 2012 21:02:11 GMT (envelope-from brooks@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.5/8.14.5/Submit) id qARL2B0S033323 for perforce@freebsd.org; Tue, 27 Nov 2012 21:02:11 GMT (envelope-from brooks@freebsd.org) Date: Tue, 27 Nov 2012 21:02:11 GMT Message-Id: <201211272102.qARL2B0S033323@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to brooks@freebsd.org using -f From: Brooks Davis Subject: PERFORCE change 219854 for review To: Perforce Change Reviews Precedence: bulk X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.14 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Nov 2012 21:02:12 -0000 http://p4web.freebsd.org/@@219854?ac=10 Change 219854 by brooks@brooks_zenith on 2012/11/27 21:01:59 Use an hour glass icon as an the busy indicator rather than a red square. Ignore files without .png extensions. Affected files ... .. //depot/projects/ctsrd/cheribsd/src/ctsrd/cheripoint/cheripoint.c#11 edit Differences ... ==== //depot/projects/ctsrd/cheribsd/src/ctsrd/cheripoint/cheripoint.c#11 (text+ko) ==== @@ -57,7 +57,7 @@ #define vred(v) fb_colour((v), 0, 0) #define red vred(0xFF) -#define FB_BUSY fb_fill_region(red, 0, 0, header_height - 1, header_height - 1) +#define ICON_WH 32 enum mtl_display_mode { MTL_DM_800x480, /* Full touch screen */ @@ -68,6 +68,7 @@ int sb_vis = 0; uint32_t header_height; +uint32_t *busyarea, *hourglass; enum sbtype sb = SB_CHERI; enum mtl_display_mode res = MTL_DM_720x480; static int zombies_waiting = 0; @@ -87,6 +88,68 @@ } static void +init_busy(void) +{ + int pfd; + struct iboxstate *is; + + if ((busyarea = malloc(sizeof(uint32_t) * 32 * 32)) == NULL) + err(1, "malloc of busyarea failed"); + + if ((pfd = open("/usr/share/images/icons.png", O_RDONLY)) == -1) + err(1, "Failed to open icons.png"); + if ((is = png_read_start(pfd, 32, 2048, -1, SB_NONE)) == NULL) + errx(1, "Failed to start PNG decode for icons.png"); + if (png_read_finish(is) != 0) + errx(1, "png_read_finish() failed for icons.png"); + + if ((hourglass = malloc(sizeof(uint32_t) * 32 * 32)) == NULL) + err(1, "malloc of hourglass failed"); + memcpy(hourglass, __DEVOLATILE(uint32_t *, + is->buffer + (32 * 32 * 20)), sizeof(uint32_t) * 32 * 32); + iboxstate_free(is); +} + +static void +busy(int init) +{ + int c, r; + + if (init) + memcpy(busyarea, hourglass, + sizeof(uint32_t) * ICON_WH * ICON_WH); + else + /* + * Save all parts of the busy area that don't match the + * hourglass. + */ + for (r = 0; r < ICON_WH; r++) + for(c = 0; c < ICON_WH; c++) + if (pfbp[r * fb_width + c] != + hourglass[r * ICON_WH + c]) + busyarea[r * ICON_WH + c] = + pfbp[r * fb_width + c]; + /* Draw the hourglass */ + fb_post_region(hourglass, 0, 0, ICON_WH, ICON_WH); +} + +static void +unbusy(void) +{ + int c, r; + + busy(0); + + /* Restore the parts that don't match the hourglass */ + for (r = 0; r < ICON_WH; r++) + for(c = 0; c < ICON_WH; c++) + if (busyarea[r * ICON_WH + c] != + hourglass[r * ICON_WH + c]) + pfbp[r * fb_width + c] = + busyarea[r * ICON_WH + c]; +} + +static void set_display_mode(enum mtl_display_mode dm) { @@ -386,7 +449,7 @@ printf("rendering cover\n"); - FB_BUSY; + busy(1); if ((pfd = openat(dfd, cover, O_RDONLY)) == -1) { warn("Failed to open %s", cover); @@ -414,6 +477,8 @@ fb_rectangle(red, 2, 0, 0, is->width, is->height); iboxstate_free(is); + unbusy(); + return (0); } @@ -433,7 +498,7 @@ printf("rendering slide %s\n", slide); - FB_BUSY; + busy(1); if ((pfd = openat(dfd, slide, O_RDONLY)) == -1) { warn("Failed to open %s", slide); @@ -454,7 +519,7 @@ return (-1); } fb_fill_region(white, 0, 0, fb_width, fb_height); - FB_BUSY; + busy(0); fb_post_region(__DEVOLATILE(uint32_t *, is->buffer), slide_fcol + ((slide_width - is->width) / 2), header_height, is->width, is->height < slide_height ? is->height : slide_height); @@ -480,7 +545,7 @@ } iboxstate_free(is); - FB_BUSY; + busy(0); /* put an SRI logo in the lower left corner */ if ((pfd = open("/usr/share/images/sri.png", O_RDONLY)) == -1) { @@ -570,6 +635,8 @@ 0, hdris->width, hdris->height); iboxstate_free(hdris); + unbusy(); + return (error); } @@ -763,6 +830,7 @@ fb_fill_region(white, 0, 0, fb_width, fb_height); fb_fade2on(); fb_load_syscons_font(NULL, "/usr/share/syscons/fonts/iso-8x16.fnt"); + init_busy(); if (forkflag) { if ((slidep = mmap(NULL, sizeof(int), PROT_READ|PROT_WRITE, @@ -790,6 +858,9 @@ /* XXX: doesn't support symlinks */ if (entry->d_type != DT_REG) continue; + /* Skip obvious non-PNGs */ + if (fnmatch("*.[pP][nN][gG]", entry->d_name, 0) != 0) + continue; if (fnmatch("*-cover-*.png", entry->d_name, 0) == 0) addslide(&ncovers, &maxcovers, &covers, entry->d_name);