{ DYDiagnosticManager *base=[[[DYDiagnosticManager alloc]init]autorelease];DYCreateParameters(base,&error);DYToolCanvasProbe *host=[[[DYToolCanvasProbe alloc]init]autorelease];host->_base=base;host->_time=kCMTimeZero; NSMutableDictionary *doc=DYMutablePlist([[[DYToolDocument alloc]init]autorelease].document);NSDictionary *mask=DYNewMask(DYMaskRectangle);doc[@"baseMasks"][@"hsl"]=[NSMutableArray arrayWithObject:mask];DYWriteTools(base,doc,kCMTimeZero); idplugin=(id)[[NSClassFromString(@"DYPlugIn")alloc]initWithAPIManager:host];[plugin scheduleToolCanvasRegistration];NSData *state=nil;[plugin pluginState:&state atTime:kCMTimeZero quality:(FxQuality)0 error:&error]; auto drain=[](){double end=NSProcessInfo.processInfo.systemUptime+.1;while(NSProcessInfo.processInfo.systemUptimeosc=(id)[[NSClassFromString(@"DYToolOSC")alloc]initWithAPIManager:host];DYDiagnosticTile *overlay=[[[DYDiagnosticTile alloc]initWithDevice:gpu width:640 height:400]autorelease];[osc drawOSCWithWidth:640 height:400 activePart:0 destinationImage:overlay atTime:kCMTimeZero];Pixels pixels=read(overlay,gpu);NSUInteger opaque=0;BOOL finite=YES;for(NSUInteger i=0;i<640*400;i++){float a=pixels[i*4+3];opaque+=a>.01;finite&=std::isfinite(a);}run.record(@"native-osc-real-metal-overlay-transparent-around-controls",finite&&opaque>100&&opaque<640*400*.2,@{@"coveredPixels":@(opaque)}); NSInteger part=0;[osc hitTestOSCAtMousePositionX:320 mousePositionY:212.5 activePart:&part atTime:kCMTimeZero];run.record(@"native-osc-object-to-canvas-center-hit",part==1); int undo=base->_undoStarts;BOOL update=NO;[osc mouseDownAtPositionX:320 positionY:212.5 activePart:1 modifiers:0 forceUpdate:&update atTime:kCMTimeZero];[osc mouseDraggedAtPositionX:348 positionY:196.75 activePart:1 modifiers:0 forceUpdate:&update atTime:kCMTimeZero];[osc mouseUpAtPositionX:348 positionY:196.75 activePart:1 modifiers:0 forceUpdate:&update atTime:kCMTimeZero];drain();NSDictionary *moved=DYReadTools(base,kCMTimeZero).document[@"baseMasks"][@"hsl"][0];DYMaskParameters p=DYMaskAtTime(moved,kCMTimeZero);run.record(@"native-osc-drag-writes-independent-normalized-geometry",fabs(p.centerX-.55)<1e-5&&fabs(p.centerY-.55)<1e-5,@{@"x":@(p.centerX),@"y":@(p.centerY)});run.record(@"native-osc-drag-commits-one-undo-after-callback",base->_undoStarts==undo+1&&base->_undoStarts==base->_undoEnds); NSDictionary *before=[DYReadTools(base,kCMTimeZero).document copy];[plugin adoptToolCanvasDocument:before];[osc mouseDownAtPositionX:348 positionY:196.75 activePart:1 modifiers:0 forceUpdate:&update atTime:kCMTimeZero];[osc mouseDraggedAtPositionX:370 positionY:180 activePart:1 modifiers:0 forceUpdate:&update atTime:kCMTimeZero];BOOL handled=NO;[osc keyDownAtPositionX:370 positionY:180 keyPressed:27 modifiers:0 forceUpdate:&update didHandle:&handled atTime:kCMTimeZero];drain();run.record(@"native-osc-escape-discards-draft-without-host-edit",[before isEqual:DYReadTools(base,kCMTimeZero).document]&&base->_undoStarts==undo+1);[before release];[osc release];[plugin release]; } { DYDiagnosticManager*base=[[[DYDiagnosticManager alloc]init]autorelease];DYCreateParameters(base,&error);DYToolCanvasProbe*host=[[[DYToolCanvasProbe alloc]init]autorelease];host->_base=base;host->_time=kCMTimeZero; NSMutableDictionary*doc=DYMutablePlist(DYReadTools(base,kCMTimeZero).document);NSDictionary*mask=DYNewMask(DYMaskRectangle);doc[@"baseMasks"][@"hsl"]=[NSMutableArray arrayWithObject:mask];DYWriteTools(base,doc,kCMTimeZero); idplugin=(id)[[NSClassFromString(@"DYPlugIn")alloc]initWithAPIManager:host];[plugin scheduleToolCanvasRegistration];NSData*state=nil;[plugin pluginState:&state atTime:kCMTimeZero quality:(FxQuality)0 error:&error]; auto drain=[](){double end=NSProcessInfo.processInfo.systemUptime+.06;while(NSProcessInfo.processInfo.systemUptimeosc=(id)[[NSClassFromString(@"DYToolOSC")alloc]initWithAPIManager:host];DYDiagnosticTile*overlay=[[[DYDiagnosticTile alloc]initWithDevice:gpu width:640 height:400]autorelease];[osc drawOSCWithWidth:640 height:400 activePart:0 destinationImage:overlay atTime:kCMTimeZero];BOOL update=NO;NSInteger part=0; // Open the curve from the vertical rail, then place its editor across the // mask drag destination. The ongoing mask gesture must retain ownership. id viewer=[(id)osc valueForKey:@"viewerControls"];NSDictionary*curveButton=nil;for(NSDictionary*a in [viewer valueForKey:@"areas"])if([a[@"toolType"]isEqual:@"curve"])curveButton=a; NSRect br=[curveButton[@"rect"]rectValue];double bx=NSMidX(br),by=400-NSMidY(br);[osc hitTestOSCAtMousePositionX:bx mousePositionY:by activePart:&part atTime:kCMTimeZero];[osc mouseDownAtPositionX:bx positionY:by activePart:part modifiers:0 forceUpdate:&update atTime:kCMTimeZero];[osc mouseUpAtPositionX:bx positionY:by activePart:part modifiers:0 forceUpdate:&update atTime:kCMTimeZero]; id panel=[[viewer valueForKey:@"panels"]lastObject];[panel setValue:[NSValue valueWithPoint:NSMakePoint(.63,.03)]forKey:@"position"]; [osc drawOSCWithWidth:640 height:400 activePart:0 destinationImage:overlay atTime:kCMTimeZero];int undo=base->_undoStarts; [osc hitTestOSCAtMousePositionX:260 mousePositionY:212.5 activePart:&part atTime:kCMTimeZero];[osc mouseDownAtPositionX:260 positionY:212.5 activePart:part modifiers:0 forceUpdate:&update atTime:kCMTimeZero]; [osc hitTestOSCAtMousePositionX:450 mousePositionY:200 activePart:&part atTime:kCMTimeZero];BOOL insideViewer=part>=20000;[osc mouseDraggedAtPositionX:450 positionY:200 activePart:part modifiers:0 forceUpdate:&update atTime:kCMTimeZero];[osc mouseUpAtPositionX:450 positionY:200 activePart:part modifiers:0 forceUpdate:&update atTime:kCMTimeZero];drain(); DYMaskParameters p=DYMaskAtTime(DYReadTools(base,kCMTimeZero).document[@"baseMasks"][@"hsl"][0],kCMTimeZero); run.record(@"native-osc-mask-gesture-keeps-capture-when-crossing-the-open-viewer-panel",insideViewer&&fabs(p.centerX-(.5+190./560))<1e-5&&fabs(p.centerY-(.5+12.5/315))<1e-5&&base->_undoStarts==undo+1&&base->_undoEnds==undo+1); BOOL oldToolbarRemoved=YES;for(NSInteger i=0;i<9;i++)oldToolbarRemoved&=NSIsEmptyRect([(id)osc toolbarRectForItem:i]); run.record(@"native-osc-removes-all-nine-background-mask-toolbar-buttons",oldToolbarRemoved); [(id)osc setValue:@{@"drawing":@YES}forKey:@"mask"];BOOL penActionsBounded=YES; for(NSRect view:{NSMakeRect(400,310,480,100),NSMakeRect(0,0,120,80),NSMakeRect(-100,-50,400,300)}){ [(id)osc setValue:[NSValue valueWithRect:view]forKey:@"imageRect"];[(id)osc setValue:@2 forKey:@"uiScale"];NSRect visible=NSIntersectionRect(view,NSMakeRect(0,0,640,400)); for(NSInteger i=9;i<=10;i++)penActionsBounded&=NSContainsRect(visible,[(id)osc toolbarRectForItem:i]);} run.record(@"native-osc-keeps-only-two-pen-actions-bounded-at-bottom",penActionsBounded); NSColor *white=[NSColor colorWithSRGBRed:.82 green:.64 blue:.52 alpha:1]; auto whiteBalance=[&](CMTime time){[NSNotificationCenter.defaultCenter postNotificationName:@"DYWhiteBalanceColor" object:host userInfo:@{@"time":[(NSDictionary*)CMTimeCopyAsDictionary(time,kCFAllocatorDefault) autorelease],@"color":white}];drain();}; NSDictionary *beforeWhite=[[base->_values copy]autorelease];undo=base->_undoStarts;whiteBalance(CMTimeMake(1,24)); run.record(@"canvas-white-balance-cannot-write-after-the-playhead-moves",[beforeWhite isEqual:base->_values]&&base->_undoStarts==undo); whiteBalance(kCMTimeZero);DYUniforms balanced;DYReadUniforms(host,kCMTimeZero,&balanced); float temp=0,tint=0;[DYColorTables neutralizeColor:(vector_float3){.82f,.64f,.52f} temperature:&temp tint:&tint]; run.record(@"canvas-white-balance-uses-existing-solver-and-one-undo",fabs(balanced.temperature-temp)<1e-4&&fabs(balanced.tint-tint)<1e-4&&base->_undoStarts==undo+1&&base->_undoEnds==undo+1); [osc release];[plugin release];drain(); } { // Rectangle and ellipse creation use a frozen author object and a live local // draft. The one saved geometry is shared by every assigned module. DYDiagnosticManager *base=[[[DYDiagnosticManager alloc]init]autorelease];DYCreateParameters(base,&error);DYToolCanvasProbe *host=[[[DYToolCanvasProbe alloc]init]autorelease];host->_base=base;host->_time=kCMTimeZero; NSMutableDictionary *doc=DYMutablePlist(DYReadTools(base,kCMTimeZero).document);NSDictionary *mask=DYAddSharedMask(doc,DYMaskRectangle);NSString *maskID=[[mask[@"id"]copy]autorelease];DYSetSharedMaskAssigned(doc,maskID,@"base:hsl",YES);DYSetSharedMaskAssigned(doc,maskID,@"base:spider",YES);DYWriteTools(base,doc,kCMTimeZero); idplugin=(id)[[NSClassFromString(@"DYPlugIn")alloc]initWithAPIManager:host];[plugin scheduleToolCanvasRegistration];NSData *state=nil;[plugin pluginState:&state atTime:kCMTimeZero quality:(FxQuality)0 error:&error]; auto drain=[](){double end=NSProcessInfo.processInfo.systemUptime+.07;while(NSProcessInfo.processInfo.systemUptimeosc=(id)[[NSClassFromString(@"DYToolOSC")alloc]initWithAPIManager:host];DYDiagnosticTile *overlay=[[[DYDiagnosticTile alloc]initWithDevice:gpu width:640 height:400]autorelease];[osc drawOSCWithWidth:640 height:400 activePart:0 destinationImage:overlay atTime:kCMTimeZero];NSInteger part=0;BOOL update=NO,handled=NO; [osc hitTestOSCAtMousePositionX:152 mousePositionY:307 activePart:&part atTime:kCMTimeZero];NSDictionary *snapshot=[plugin toolCanvasMaskAtTime:kCMTimeZero];run.record(@"native-osc-new-shape-can-start-anywhere-and-hides-default-box",part==1&&[snapshot[@"drawShape"]boolValue]&&![snapshot[@"shapeStarted"]boolValue]&&[[(id)osc valueForKey:@"handles"]count]==0); NSDictionary *before=[[DYReadTools(base,kCMTimeZero).document copy]autorelease];int undo=base->_undoStarts; [osc mouseDownAtPositionX:152 positionY:307 activePart:part modifiers:0 forceUpdate:&update atTime:kCMTimeZero];[osc mouseDraggedAtPositionX:432 positionY:181 activePart:1 modifiers:0 forceUpdate:&update atTime:kCMTimeZero];snapshot=[plugin toolCanvasMaskAtTime:kCMTimeZero];DYMaskParameters p;[snapshot[@"parameters"]getBytes:&p length:sizeof(p)]; run.record(@"native-osc-shape-drag-updates-local-bbox-without-author-or-undo-write",[snapshot[@"shapeStarted"]boolValue]&&fabs(p.centerX-.45)<1e-5&&fabs(p.centerY-.4)<1e-5&&fabs(p.width-.5)<1e-5&&fabs(p.height-.4)<1e-5&&[before isEqual:DYReadTools(base,kCMTimeZero).document]&&base->_undoStarts==undo); [osc mouseUpAtPositionX:488 positionY:149.5 activePart:1 modifiers:0 forceUpdate:&update atTime:kCMTimeZero];drain();NSDictionary *saved=DYReadTools(base,kCMTimeZero).document;NSDictionary *hsl=DYMasksForTool(saved,@"base:hsl").firstObject,*spider=DYMasksForTool(saved,@"base:spider").firstObject;p=DYMaskAtTime(hsl,kCMTimeZero); run.record(@"native-osc-shape-release-commits-final-bbox-once-to-all-shared-modules",hsl==spider&&fabs(p.centerX-.5)<1e-5&&fabs(p.centerY-.45)<1e-5&&fabs(p.width-.6)<1e-5&&fabs(p.height-.5)<1e-5&&p.kind==DYMaskRectangle&&base->_undoStarts==undo+1&&base->_undoEnds==undo+1&&![[plugin toolCanvasMaskAtTime:kCMTimeZero][@"drawShape"]boolValue]); before=[[saved copy]autorelease];undo=base->_undoStarts;selectShape();[osc mouseDownAtPositionX:180 positionY:280 activePart:1 modifiers:0 forceUpdate:&update atTime:kCMTimeZero];[osc mouseDraggedAtPositionX:400 positionY:160 activePart:1 modifiers:0 forceUpdate:&update atTime:kCMTimeZero];[osc keyDownAtPositionX:400 positionY:160 keyPressed:27 modifiers:0 forceUpdate:&update didHandle:&handled atTime:kCMTimeZero];drain(); run.record(@"native-osc-shape-escape-keeps-author-and-all-shared-bindings",handled&&[before isEqual:DYReadTools(base,kCMTimeZero).document]&&base->_undoStarts==undo&&![[plugin toolCanvasMaskAtTime:kCMTimeZero][@"drawShape"]boolValue]); selectShape();[osc mouseDownAtPositionX:180 positionY:280 activePart:1 modifiers:0 forceUpdate:&update atTime:kCMTimeZero];[osc mouseUpAtPositionX:180 positionY:280 activePart:1 modifiers:0 forceUpdate:&update atTime:kCMTimeZero];drain();run.record(@"native-osc-shape-click-without-area-does-not-write-or-create-undo",[before isEqual:DYReadTools(base,kCMTimeZero).document]&&base->_undoStarts==undo); selectShape();[osc mouseDownAtPositionX:180 positionY:280 activePart:1 modifiers:0 forceUpdate:&update atTime:kCMTimeZero];[osc mouseDraggedAtPositionX:400 positionY:160 activePart:1 modifiers:0 forceUpdate:&update atTime:kCMTimeZero];host->_time=CMTimeMake(1,24);[plugin toolCanvasMaskAtTime:host->_time];[osc mouseUpAtPositionX:400 positionY:160 activePart:1 modifiers:0 forceUpdate:&update atTime:host->_time];drain();run.record(@"native-osc-shape-playhead-change-cancels-before-write",[before isEqual:DYReadTools(base,kCMTimeZero).document]&&base->_undoStarts==undo&&![[plugin toolCanvasMaskAtTime:host->_time][@"drawShape"]boolValue]);host->_time=kCMTimeZero; selectShape();[osc mouseDownAtPositionX:180 positionY:280 activePart:1 modifiers:0 forceUpdate:&update atTime:kCMTimeZero];[osc mouseUpAtPositionX:400 positionY:160 activePart:1 modifiers:0 forceUpdate:&update atTime:kCMTimeZero];host->_time=CMTimeMake(1,24);drain();run.record(@"native-osc-queued-shape-commit-rechecks-host-playhead",[before isEqual:DYReadTools(base,kCMTimeZero).document]&&base->_undoStarts==undo);host->_time=kCMTimeZero; doc=DYMutablePlist(DYReadTools(base,kCMTimeZero).document);NSMutableDictionary *ellipse=(id)DYSharedMaskWithID(doc,maskID);p=DYMaskAtTime(ellipse,kCMTimeZero);p.kind=DYMaskEllipse;ellipse[@"parameters"]=[NSData dataWithBytes:&p length:sizeof(p)];DYWriteTools(base,doc,kCMTimeZero);selectShape();undo=base->_undoStarts; [osc mouseDownAtPositionX:488 positionY:149.5 activePart:1 modifiers:0 forceUpdate:&update atTime:kCMTimeZero];[osc mouseUpAtPositionX:208 positionY:275.5 activePart:1 modifiers:0 forceUpdate:&update atTime:kCMTimeZero];drain();p=DYMaskAtTime(DYSharedMaskWithID(DYReadTools(base,kCMTimeZero).document,maskID),kCMTimeZero);run.record(@"native-osc-ellipse-draws-reverse-direction-with-positive-shared-extents",p.kind==DYMaskEllipse&&fabs(p.centerX-.55)<1e-5&&fabs(p.centerY-.5)<1e-5&&fabs(p.width-.5)<1e-5&&fabs(p.height-.4)<1e-5&&base->_undoStarts==undo+1&&base->_undoEnds==undo+1); [osc release];[plugin release];drain(); } { DYDiagnosticManager *base=[[[DYDiagnosticManager alloc]init]autorelease];DYCreateParameters(base,nil); DYToolCanvasProbe *host=[[[DYToolCanvasProbe alloc]init]autorelease];host->_base=base;host->_time=kCMTimeZero; id plugin=(id)[[NSClassFromString(@"DYPlugIn")alloc]initWithAPIManager:host]; DYDiagnosticTile *src=[[[DYDiagnosticTile alloc]initWithDevice:gpu width:16 height:16]autorelease],*dst=[[[DYDiagnosticTile alloc]initWithDevice:gpu width:16 height:16]autorelease]; Pixels pixels(16*16*4);for(size_t i=0;i bridge=[(id)plugin valueForKey:@"viewerParameterBridge"]; auto histogram=[&]()->NSData*{NSData *state=nil;NSError *failure=nil; if(![plugin pluginState:&state atTime:kCMTimeZero quality:(FxQuality)0 error:&failure])return nil; if(![(id)plugin renderDestinationImage:dst sourceImages:@[src] pluginState:state atTime:kCMTimeZero error:&failure])return nil; return [bridge canvasHistogramAtTime:kCMTimeZero]; }; NSData *before=histogram(); for(NSDictionary *d in DYDescriptors())if([@[@"masterX0",@"curveY0"]containsObject:d[@"key"]]) [(id)base setFloatValue:[d[@"key"]isEqual:@"masterX0"]?.5:32 toParameter:[d[@"pid"]unsignedIntValue] atTime:kCMTimeZero]; NSData *after=histogram(); run.record(@"canvas-curve-histogram-updates-from-final-output-at-the-same-playhead",before.length==sizeof(DYHistogram)&&after.length==sizeof(DYHistogram)&&![before isEqual:after]&&![bridge canvasHistogramAtTime:CMTimeMake(1,24)]); [plugin release]; }