PERFORCE change 219802 for review

Brooks Davis brooks at FreeBSD.org
Thu Nov 15 23:55:54 UTC 2012


http://p4web.freebsd.org/@@219802?ac=10

Change 219802 by brooks at brooks_zenith on 2012/11/15 23:55:22

	Add a busy indicator when rendering slides.  Change the
	rendering order to draw the main image first and to not
	start drawing other than the busy indicator before the main
	image is loaded.  Preserve the decode, draw, decode, ...
	sequence in an effort to show the relative speed of
	sandboxing technologies.

Affected files ...

.. //depot/projects/ctsrd/cheribsd/src/ctsrd/cheripoint/cheripoint.c#9 edit

Differences ...

==== //depot/projects/ctsrd/cheribsd/src/ctsrd/cheripoint/cheripoint.c#9 (text+ko) ====

@@ -51,13 +51,14 @@
 #include <syslog.h>
 #include <unistd.h>
 
-
 #define vwhite(v)       fb_colour((v), (v), (v))
 #define black           vwhite(0)
 #define white           vwhite(0xFF)
 #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)
+
 enum mtl_display_mode {
 	MTL_DM_800x480,		/* Full touch screen */
 	MTL_DM_720x480,		/* Full 480p HDMI out */
@@ -66,6 +67,7 @@
 };
 
 int sb_vis = 0;
+uint32_t header_height;
 enum sbtype sb = SB_CHERI;
 enum mtl_display_mode res = MTL_DM_720x480;
 static int zombies_waiting = 0;
@@ -384,7 +386,7 @@
 
 	printf("rendering cover\n");
 
-	fb_fill_region(white, 0, 0, fb_width, fb_height);
+	FB_BUSY;
 
 	if ((pfd = openat(dfd, cover, O_RDONLY)) == -1) {
 		warn("Failed to open %s", cover);
@@ -399,6 +401,7 @@
 		warnx("png_read_finish() failed for %s", cover);
 		return (-1);
 	}
+	fb_fill_region(white, 0, 0, fb_width, fb_height);
 	fb_post_region(__DEVOLATILE(uint32_t *, is->buffer), 0, 0,
 	    is->width, is->height);
 	if (is->width < (uint)fb_width) {
@@ -423,14 +426,59 @@
 	size_t olen;
 	char sntext[8];
 	uint32_t *snimage;
-	uint32_t r, header_height;
-	struct iboxstate *is;
+	uint32_t r;
+	struct iboxstate *is, *hdris;
 
 	error = 0;
 
 	printf("rendering slide %s\n", slide);
 
+	FB_BUSY;
+
+	if ((pfd = openat(dfd, slide, O_RDONLY)) == -1) {
+		warn("Failed to open %s", slide);
+		return (-1);
+	}
+	if (sb == SB_CHERI) {
+		olen = sizeof(sv1);
+		sysctlbyname("security.cheri.syscall_violations",
+		    &sv1, &olen, NULL, 0);
+	}
+	if ((is = png_read_start(pfd, slide_width, fb_height, slidenum,
+	    sb)) == NULL) {
+		warn("Failed to start PNG decode for %s", slide);
+		return (-1);
+	}
+	if (png_read_finish(is) != 0) {
+		warnx("png_read_finish() failed for %s", slide);
+		return (-1);
+	}
 	fb_fill_region(white, 0, 0, fb_width, fb_height);
+	FB_BUSY;
+	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);
+	if (sb_vis && sb != SB_NONE)
+		fb_rectangle(red, 2,
+		    slide_fcol + ((slide_width - is->width) / 2),
+		    header_height, is->width,
+		    is->height < slide_height ? is->height : slide_height);
+	switch (sb) {
+	case SB_CAPSICUM:
+		if (is->error == 99)
+			error = 99;
+		break;
+	case SB_CHERI:
+		olen = sizeof(sv2);
+		sysctlbyname("security.cheri.syscall_violations",
+		    &sv2, &olen, NULL, 0);
+		if (sv1 != sv2)
+			error = 99;
+		break;
+	default:
+		break;
+	}
+	iboxstate_free(is);
 
 	/*
 	 * Draw the header with image at the upper right.  Assume
@@ -441,25 +489,26 @@
 		warn("Failed to open header.png");
 		return (-1);
 	}
-	if ((is = png_read_start(pfd, slide_width, fb_height, -1, sb)) ==
+	if ((hdris = png_read_start(pfd, slide_width, fb_height, -1, sb)) ==
 	    NULL) {
 		warn("Failed to start PNG decode for header.png");
 		return (-1);
 	}
-	if (png_read_finish(is) != 0) {
+	if (png_read_finish(hdris) != 0) {
 		warnx("png_read_finish() failed for header.png");
 		return (-1);
 	}
 	/* Fill in the header's background. */
-	for (r = 0; r < is->height; r++)
-		fb_fill_region(is->buffer[r * is->width], 0, r, fb_width, 1);
-	fb_post_region(__DEVOLATILE(uint32_t *, is->buffer),
-	    slide_fcol + slide_width - is->width, 0, is->width, is->height);
+	for (r = 0; r < hdris->height; r++)
+		fb_fill_region(hdris->buffer[r * hdris->width], 0, r,
+		fb_width, 1);
+	fb_post_region(__DEVOLATILE(uint32_t *, hdris->buffer),
+	    slide_fcol + slide_width - hdris->width, 0, hdris->width,
+	    hdris->height);
+	FB_BUSY;
 	if (sb_vis && sb != SB_NONE)
-		fb_rectangle(red, 2, slide_fcol + slide_width - is->width,
-		    0, is->width, is->height);
-	header_height = is->height;
-	iboxstate_free(is);
+		fb_rectangle(red, 2, slide_fcol + slide_width - hdris->width,
+		    0, hdris->width, hdris->height);
 
 	/* put an SRI logo in the lower left corner */
 	if ((pfd = open("/usr/share/images/sri.png", O_RDONLY)) == -1) {
@@ -502,49 +551,6 @@
 		    fb_height - is->height, is->width, is->height);
 	iboxstate_free(is);
 
-	if ((pfd = openat(dfd, slide, O_RDONLY)) == -1) {
-		warn("Failed to open %s", slide);
-		return (-1);
-	}
-	if (sb == SB_CHERI) {
-		olen = sizeof(sv1);
-		sysctlbyname("security.cheri.syscall_violations",
-		    &sv1, &olen, NULL, 0);
-	}
-	if ((is = png_read_start(pfd, slide_width, fb_height, slidenum,
-	    sb)) == NULL) {
-		warn("Failed to start PNG decode for %s", slide);
-		return (-1);
-	}
-	if (png_read_finish(is) != 0) {
-		warnx("png_read_finish() failed for %s", slide);
-		return (-1);
-	}
-	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);
-	if (sb_vis && sb != SB_NONE)
-		fb_rectangle(red, 2,
-		    slide_fcol + ((slide_width - is->width) / 2),
-		    header_height, is->width,
-		    is->height < slide_height ? is->height : slide_height);
-	switch (sb) {
-	case SB_CAPSICUM:
-		if (is->error == 99)
-			error = 99;
-		break;
-	case SB_CHERI:
-		olen = sizeof(sv2);
-		sysctlbyname("security.cheri.syscall_violations",
-		    &sv2, &olen, NULL, 0);
-		if (sv1 != sv2)
-			error = 99;
-		break;
-	default:
-		break;
-	}
-	iboxstate_free(is);
-
 	f_width = fb_get_font_width();
 	f_height = fb_get_font_height();
 	if ((uint)slidenum < (sizeof(sntext) - 1) * 10) {
@@ -562,6 +568,16 @@
 			free(snimage);
 	}
 
+	/* Drawing done, redraw header to clear FB_BUSY */
+	fb_post_region(__DEVOLATILE(uint32_t *, hdris->buffer),
+	    slide_fcol + slide_width - hdris->width, 0, hdris->width,
+	    hdris->height);
+	/* Fill in the header's background. */
+	for (r = 0; r < hdris->height; r++)
+		fb_fill_region(hdris->buffer[r * hdris->width], 0, r,
+		fb_width, 1);
+	iboxstate_free(hdris);
+
 	return (error);
 }
 
@@ -704,6 +720,22 @@
 	}
 }
 
+static void
+init_header_height(void)
+{
+	int pfd;
+	struct iboxstate *is;
+
+	if ((pfd = open("/usr/share/images/header.png", O_RDONLY)) == -1)
+		err(1, "Failed to open header.png");
+	if ((is = png_read_start(pfd, slide_width, fb_height, -1, sb)) == NULL)
+		errx(1, "Failed to start PNG decode for header.png");
+	if (png_read_finish(is) != 0)
+		errx(1, "png_read_finish() failed for header.png");
+	header_height = is->height;
+	iboxstate_free(is);
+}
+
 int
 main(int argc, char **argv)
 {
@@ -754,6 +786,7 @@
         busy_indicator();
 
 	set_display_mode(res);
+	init_header_height();
 
 	printf("reading slides\n");
 


More information about the p4-projects mailing list