// Production render tests for the ordered chain and spatial privacy operator. { NSDictionary *v4=DYUnifiedColorDefaults();run.need(@"unified-v4-valid-and-distinct-from-v3",DYManagedColorValid(v4,nil)&&DYUnifiedColorState(v4)&&![v4 isEqual:DYPrimaryColorDefaults()]); NSMutableDictionary *doc=DYMutablePlist(DYInitialToolDocument(nil));run.record(@"unified-default-output-is-last",[DYUnifiedRenderOrder(doc).lastObject isEqual:@"output"]); NSDictionary *node=DYInsertTool(doc,@"curve",@"base:hsl");doc[@"outputAfter"]=node[@"id"]; NSArray *order=DYUnifiedRenderOrder(doc);run.record(@"unified-output-follows-stable-uuid",[order indexOfObject:@"output"]==[order indexOfObject:node[@"id"]]+1&&DYValidToolDocument(doc)); DYRemoveTool(doc,node[@"id"]);run.record(@"unified-deleting-anchor-keeps-valid-output-order",DYValidToolDocument(doc)&&[doc[@"outputAfter"]isEqual:@"base:hsl"]); doc[@"outputAfter"]=@"unknown";run.record(@"unified-rejects-unknown-output-anchor",!DYValidToolDocument(doc));doc=DYMutablePlist(DYInitialToolDocument(nil)); const NSUInteger w=64,h=48;DYDiagnosticTile *src=[[[DYDiagnosticTile alloc]initWithDevice:gpu width:w height:h]autorelease],*dst=[[[DYDiagnosticTile alloc]initWithDevice:gpu width:w height:h]autorelease]; auto decode=[](float x){return x<=.04045f?x/12.92f:powf((x+.055f)/1.055f,2.4f);}; Pixels chart(w*h*4);for(NSUInteger i=0;i2.9&&difference(plain,modified).nonfinite==0); NSMutableDictionary *zero=DYMutablePlist(DYNewMask(DYMaskRectangle));DYMaskParameters p=DYMaskAtTime(zero,kCMTimeZero);p.strength=0;zero[@"parameters"]=[NSData dataWithBytes:&p length:sizeof(p)];doc[@"baseMasks"][@"hsl"]=@[zero]; Pixels masked=frame(changed,doc,@"unified-zero-mask");run.record(@"unified-zero-mask-is-exact-neutral",difference(masked,plain).maximum==0);[doc[@"baseMasks"]removeObjectForKey:@"hsl"]; { NSMutableDictionary *strengthDoc=DYMutablePlist(DYInitialToolDocument(nil));BOOL defaultsOK=YES;for(NSString *type in DYToolTypes())defaultsOK&=DYToolStrength(strengthDoc,[@"base:" stringByAppendingString:type])==1;run.record(@"module-strength-old-documents-default-to-full-without-migration",defaultsOK); DYSetToolStrength(strengthDoc,@"base:base",0);Pixels strengthZero=frame(exposure,strengthDoc,@"module-strength-base-zero-render");run.record(@"module-strength-zero-preserves-negative-superwhite-and-alpha",difference(strengthZero,plain).maximum==0); DYSetToolStrength(strengthDoc,@"base:base",.5);Pixels half=frame(exposure,strengthDoc,@"module-strength-base-half-render");double worst=0;for(NSUInteger i=0;i.001,@{@"difference":@(difference(last,middle).maximum)}); { Pixels patch(w*h*4); for(size_t i=0;i.001&& difference(originalKey,withoutHSL).maximum==0&&difference(layerKey,unmaskedHSL).maximum==0); } DYDiagnosticManager *host=[[[DYDiagnosticManager alloc]init]autorelease];DYCreateParameters(host,nil);DYAssetState *assets=[[[DYAssetState alloc]init]autorelease];assets.colorManagement=v4;DYWriteAssets(host,assets,kCMTimeZero); DYInspector *view=[[[DYInspector alloc]initWithAPIManager:host]autorelease];[view refresh];[view setFrameSize:NSMakeSize(400,400)];[view layoutSubtreeIfNeeded];NSDictionary *output=nil;for(NSDictionary *card in [view valueForKey:@"cards"])if([card[@"section"][@"key"]isEqual:@"output"])output=card; run.record(@"unified-inspector-output-visible-at-chain-tail",output&&![output[@"view"]isHidden]&&NSMaxY([output[@"view"]frame])>NSMaxY([[[view valueForKey:@"cards"]firstObject][@"view"]frame])); [(NSButton*)output[@"repeatButton"]performClick:nil];run.record(@"unified-output-arrow-persists-and-creates-one-undo",[DYReadTools(host,kCMTimeZero).document[@"outputAfter"]isEqual:@"base:film"]&&host->_undoStarts==1&&host->_undoEnds==1); } { const NSUInteger w=128,h=96;DYDiagnosticTile *src=[[[DYDiagnosticTile alloc]initWithDevice:gpu width:w height:h]autorelease],*dst=[[[DYDiagnosticTile alloc]initWithDevice:gpu width:w height:h]autorelease];Pixels chart(w*h*4); for(NSUInteger y=0;y15&&x<48&&y>35&&y<60)inside=MAX(inside,delta);if(x>75)outside=MAX(outside,delta);} run.record(@"mosaic-changes-selection-and-preserves-outside",inside>.05&&outside==0,@{@"inside":@(inside),@"outside":@(outside)}); DYMaskParameters moved=p;moved.centerX=.75;mask[@"keys"]=@[DYMaskKey(kCMTimeZero,p,YES,1),DYMaskKey(CMTimeMake(1,1),moved,YES,1)]; Pixels tracked=frame(DYToolRenderSnapshot(doc,CMTimeMake(1,1)),@"mosaic-follow-existing-tracking");run.record(@"mosaic-tracked-selection-vacates-previous-region",tracked[(48*w+31)*4+2]==baseline[(48*w+31)*4+2]&&tracked[(48*w+95)*4+2]!=baseline[(48*w+95)*4+2]); doc[@"mosaic"]=@{@"source":@"mask",@"maskID":NSUUID.UUID.UUIDString,@"enabled":@YES,@"size":@96};Pixels missing=frame(DYToolRenderSnapshot(doc,kCMTimeZero),@"mosaic-missing-mask");run.record(@"mosaic-missing-mask-does-not-cover-whole-frame",difference(missing,baseline).maximum==0); NSURL *cube=[NSURL fileURLWithPath:[runtime stringByAppendingPathComponent:@"mosaic-refused.cube"]];run.record(@"mosaic-refuses-incomplete-cube-export",![renderer exportLUT:cube uniforms:u paths:@{} spider:nil tools:doc colorManagement:nil error:&e]&&e); NSMutableDictionary *bad=DYMutablePlist(doc);bad[@"mosaic"][@"size"]=@0;run.record(@"mosaic-invalid-block-size-rejected",!DYValidToolDocument(bad)); }