29 :(UIImage*)
image rmesThreshold:(double)rmesThreshold {
31 os_log_error(OS_LOG_DEFAULT, "GOLDEN DIFF FAILED: image does not exists.");
32 return NO;
33 }
34 CGImageRef imageRefA = [self.image CGImage];
35 CGImageRef imageRefB = [image CGImage];
36
37 NSUInteger widthA = CGImageGetWidth(imageRefA);
38 NSUInteger heightA = CGImageGetHeight(imageRefA);
39 NSUInteger widthB = CGImageGetWidth(imageRefB);
40 NSUInteger heightB = CGImageGetHeight(imageRefB);
41
42 if (widthA != widthB || heightA != heightB) {
43 os_log_error(OS_LOG_DEFAULT, "GOLDEN DIFF FAILED: images sizes do not match.");
44 return NO;
45 }
46 NSUInteger bytesPerPixel = 4;
47 NSUInteger
size = widthA * heightA * bytesPerPixel;
48 NSMutableData* rawA = [NSMutableData dataWithLength:size];
49 NSMutableData* rawB = [NSMutableData dataWithLength:size];
50
51 if (!rawA || !rawB) {
52 os_log_error(OS_LOG_DEFAULT, "GOLDEN DIFF FAILED: image data length do not match.");
53 return NO;
54 }
55
56 CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
57
58 NSUInteger bytesPerRow = bytesPerPixel * widthA;
59 NSUInteger bitsPerComponent = 8;
60 CGContextRef contextA =
61 CGBitmapContextCreate(rawA.mutableBytes, widthA, heightA, bitsPerComponent, bytesPerRow,
62 colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
63
64 CGContextDrawImage(contextA, CGRectMake(0, 0, widthA, heightA), imageRefA);
65 CGContextRelease(contextA);
66
67 CGContextRef contextB =
68 CGBitmapContextCreate(rawB.mutableBytes, widthA, heightA, bitsPerComponent, bytesPerRow,
69 colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
70 CGColorSpaceRelease(colorSpace);
71
72 CGContextDrawImage(contextB, CGRectMake(0, 0, widthA, heightA), imageRefB);
73 CGContextRelease(contextB);
74
75 const char* apos = rawA.mutableBytes;
76 const char* bpos = rawB.mutableBytes;
77 double sum = 0.0;
78 for (
size_t i = 0;
i <
size; ++
i, ++apos, ++bpos) {
79
80 if (*apos == 0 && *bpos == 0 &&
i % 4 == 0) {
82 apos += 3;
83 bpos += 3;
84 } else {
85 double aval = *apos;
86 double bval = *bpos;
87 double diff = aval - bval;
88 sum += diff * diff;
89 }
90 }
91 double rmse = sqrt(sum / size);
92 if (rmse > rmesThreshold) {
93 os_log_error(
94 OS_LOG_DEFAULT,
95 "GOLDEN DIFF FAILED: image diff greater than threshold. Current diff: %@, threshold: %@",
96 @(rmse), @(rmesThreshold));
97 return NO;
98 }
99 return YES;
100}
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size