Apple's open-source XNU kernel on Android phones: its own loader and drivers, Metal on the Adreno. Runs from RAM; a reboot gives the phone back to Android.
C
eagl: no draw without a program reads the texture it draws into, so launch images are not black
vcvkk0b08cbe6f797
diff --git a/userland/build.sh b/userland/build.shindex b97cb83..c3434b1 100755--- a/userland/build.sh+++ b/userland/build.sh@@ -109,6 +109,7 @@ if [ -d $IOS/rootfs/usr/lib ]; then$DYN -framework CoreFoundation -lMobileGestalt -o obj/mg_test src/mg_test.c$DYN -o obj/cpu_test src/cpu_test.c$DYN -framework CoreFoundation -framework IOSurface -o obj/cow_test src/cow_test.c+ $DYN -framework CoreFoundation -framework CoreGraphics -framework ImageIO -o obj/snap_test src/snap_test.c$DYN -fobjc-arc -framework Foundation -framework SystemConfiguration -o obj/net_test src/net_test.m# (the keychain answers only a program that has a keychain access group: signed with one, if ldid is there)$DYN -framework CoreFoundation -framework Security -o obj/keychain_test src/keychain_test.c &&@@ -142,6 +143,7 @@ if [ -d $IOS/rootfs/usr/lib ]; thencp obj/hello_dyn obj/svc_test obj/surf_test obj/rwtouch obj/mg_test root/bin/[ -f obj/cpu_test ] && cp obj/cpu_test root/bin/ # (a prebuilt/ from before this program has none)[ -f obj/cow_test ] && cp obj/cow_test root/bin/+ [ -f obj/snap_test ] && cp obj/snap_test root/bin/[ -f obj/net_test ] && cp obj/net_test root/bin/[ -f obj/keychain_test ] && cp obj/keychain_test root/bin/[ -f obj/wifipw_test ] && cp obj/wifipw_test root/bin/diff --git a/userland/rc.jobs.launch b/userland/rc.jobs.launchnew file mode 100644index 0000000..67e32a5--- /dev/null+++ b/userland/rc.jobs.launch@@ -0,0 +1,9 @@+# Commands run by the launchd job com.redwood.demo (see com.redwood.demo.plist).+# The first launch of an application (RC_JOBS=rc.jobs.launch, a run of about a minute and a half):+# Settings opened and left, then the pictures SpringBoard keeps of it looked at as files (snap_test:+# its launch images, light and dark, upright and on its side, and the snapshot it took on the way out),+# then Maps. The zoom that opens each starts from its launch image; with boot-arg rec_secs=60 it can+# be watched frame by frame. Its launch images used to come out black (see plain_draw_begin() in eagl.c).+/redwood/bin/rwtouch wait 40 swipe 0.5 0.985 0.5 0.3 200 wait 6 tap 0.615 0.71 wait 8 swipe 0.5 0.985 0.5 0.3 200 wait 5+/redwood/bin/snap_test /private/var/mobile/Library/SplashBoard/Snapshots/com.apple.Preferences+/redwood/bin/rwtouch tap 0.845 0.59 wait 12diff --git a/userland/src/eagl.c b/userland/src/eagl.cindex 29ac850..83f868e 100644--- a/userland/src/eagl.c+++ b/userland/src/eagl.c@@ -1922,7 +1922,16 @@ plain_draw_begin(struct eagl *e, GLint enabled[4])}return false;}- if (!plain_draws || (plain_draws == 1 && e->bound[0] == 0) || reads_what_it_writes(e)) {+ /*+ * Nor is any other draw with no program that would read the very texture it draws into. The+ * window server's snapshots end with one: function 61 ("edr", by its numbers the display's+ * headroom, infinite: nothing to change) over the whole picture, with that picture as its+ * texture. Drawn as the picture it is given, it read what the GPU had not yet written out of+ * its own memory -- nothing -- and wrote that over everything: every launch image SpringBoard+ * keeps came out black, and with it the zoom that opens an application the first time.+ */+ if (!plain_draws || (plain_draws == 1 && e->bound[0] == 0) || reads_what_it_writes(e) ||+ (e->colour != 0 && e->colour == e->bound[0])) {census_draw(e, function, CENSUS_NOT_DRAWN);return false;}diff --git a/userland/src/snap_test.c b/userland/src/snap_test.cnew file mode 100644index 0000000..b401bf8--- /dev/null+++ b/userland/src/snap_test.c@@ -0,0 +1,82 @@+/*+ * snap_test: what the pictures SpringBoard keeps of applications look like -- their launch images+ * and their snapshots (Library/SplashBoard/Snapshots), as files.+ *+ * usage: snap_test DIRECTORY...+ * Every JPEG, PNG or other picture ImageIO can read under the directories is decoded and drawn+ * into 8 x 8 pixels; the line it gets says its size, its average colour and opacity, and how+ * many of those 64 pixels are near black. (A launch image of a light application that comes out+ * black was the question: the zoom that opens an application showed black at its first launch.)+ */+#include <CoreFoundation/CoreFoundation.h>+#include <CoreGraphics/CoreGraphics.h>+#include <ImageIO/ImageIO.h>+#include <sys/stat.h>+#include <fts.h>+#include <stdio.h>+#include <string.h>++static void+look(const char *path)+{+ CFURLRef url = CFURLCreateFromFileSystemRepresentation(NULL, (const UInt8 *)path, (CFIndex)strlen(path), false);+ CGImageSourceRef source = url != NULL ? CGImageSourceCreateWithURL(url, NULL) : NULL;+ CGImageRef image = source != NULL && CGImageSourceGetCount(source) > 0 ? CGImageSourceCreateImageAtIndex(source, 0, NULL) : NULL;+ uint8_t pixels[8 * 8 * 4];+ unsigned long sum[4] = { 0, 0, 0, 0 };+ unsigned dark = 0;++ if (image == NULL) {+ printf("snap_test: %s: NOT READ\n", path);+ } else {+ CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB();+ CGContextRef context = CGBitmapContextCreate(pixels, 8, 8, 8, 32, space, kCGImageAlphaPremultipliedLast);++ memset(pixels, 0, sizeof(pixels));+ CGContextDrawImage(context, CGRectMake(0, 0, 8, 8), image);+ for (unsigned i = 0; i < 64; i++) {+ for (unsigned c = 0; c < 4; c++) {+ sum[c] += pixels[4 * i + c];+ }+ dark += pixels[4 * i] < 16 && pixels[4 * i + 1] < 16 && pixels[4 * i + 2] < 16;+ }+ printf("snap_test: %s: %zu x %zu, average %lu %lu %lu opacity %lu, %u of 64 near black\n", path, CGImageGetWidth(image),+ CGImageGetHeight(image), sum[0] / 64, sum[1] / 64, sum[2] / 64, sum[3] / 64, dark);+ CGContextRelease(context);+ CGColorSpaceRelease(space);+ CGImageRelease(image);+ }+ if (source != NULL) {+ CFRelease(source);+ }+ if (url != NULL) {+ CFRelease(url);+ }+}++int+main(int argc, char **argv)+{+ FTS *walk;+ FTSENT *entry;++ if (argc < 2) {+ fprintf(stderr, "usage: snap_test DIRECTORY...\n");+ return 2;+ }+ walk = fts_open(argv + 1, FTS_PHYSICAL | FTS_NOCHDIR, NULL);+ while (walk != NULL && (entry = fts_read(walk)) != NULL) {+ const char *dot = strrchr(entry->fts_name, '.');++ if (entry->fts_info == FTS_F && dot != NULL && (strcmp(dot, ".jpeg") == 0 || strcmp(dot, ".jpg") == 0 ||+ strcmp(dot, ".png") == 0 || strcmp(dot, ".ktx") == 0 || strcmp(dot, ".atx") == 0)) {+ look(entry->fts_path);+ } else if (entry->fts_info == FTS_F) {+ printf("snap_test: %s: %lld bytes, not a picture by its name\n", entry->fts_path, (long long)entry->fts_statp->st_size);+ }+ }+ if (walk != NULL) {+ fts_close(walk);+ }+ return 0;+}