{ 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];drain();[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); // Reproduce FCP's action clock offset while OSC and redraw use different clocks. host->_time=CMTimeMake(39,25);selectShape();undo=base->_undoStarts; [osc mouseDownAtPositionX:152 positionY:307 activePart:1 modifiers:0 forceUpdate:&update atTime:kCMTimeZero];drain(); [osc mouseDraggedAtPositionX:432 positionY:181 activePart:1 modifiers:0 forceUpdate:&update atTime:kCMTimeZero]; [osc drawOSCWithWidth:640 height:400 activePart:1 destinationImage:overlay atTime:host->_time]; run.record(@"native-osc-shape-keeps-draft-across-different-redraw-clock",[[plugin toolCanvasMaskAtTime:host->_time][@"shapeStarted"]boolValue]); [osc mouseUpAtPositionX:488 positionY:149.5 activePart:1 modifiers:0 forceUpdate:&update atTime:kCMTimeZero];drain(); p=DYMaskAtTime(DYSharedMaskWithID(DYReadTools(base,host->_time).document,maskID),kCMTimeZero); run.record(@"native-osc-mask-release-saves-with-different-action-clock",fabs(p.centerX-.5)<1e-5&&fabs(p.centerY-.45)<1e-5&&fabs(p.width-.6)<1e-5&&fabs(p.height-.5)<1e-5&&base->_undoStarts==undo+1&&base->_undoEnds==undo+1); NSData *archive=[NSKeyedArchiver archivedDataWithRootObject:DYReadTools(base,host->_time) requiringSecureCoding:YES error:nil];DYToolDocument *restored=[NSKeyedUnarchiver unarchivedObjectOfClass:DYToolDocument.class fromData:archive error:nil]; run.record(@"native-osc-drawn-mask-persists-after-secure-reopen",[restored.document isEqual:DYReadTools(base,host->_time).document]); [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]; } { DYWorkspaceDiagnosticHost *base=[[[DYWorkspaceDiagnosticHost alloc]init]autorelease];DYCreateParameters(base,&error); DYToolCanvasProbe *host=[[[DYToolCanvasProbe alloc]init]autorelease];host->_base=base;host->_time=kCMTimeZero; id plugin=(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.systemUptime osc=(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]; id viewer=[(id)osc valueForKey:@"viewerControls"];NSRect button=NSZeroRect; for(NSDictionary *a in [viewer valueForKey:@"areas"])if([a[@"toolType"]isEqual:@"cloneStamp"])button=[a[@"rect"]rectValue]; Pixels rendered=read(overlay,gpu);NSUInteger opaque=0; for(NSUInteger i=0;i<640*400;i++)opaque+=rendered[4*i+3]>.01; run.record(@"native-osc-renders-the-cropped-toolbar-on-a-transparent-texture",!NSIsEmptyRect(button)&&opaque>100&&opaque<640*400*.08&&rendered[(200*640+320)*4+3]==0,@{@"opaquePixels":@(opaque)}); BOOL update=NO; auto down=[&](double x,double y){NSInteger part=0;[osc hitTestOSCAtMousePositionX:x mousePositionY:y activePart:&part atTime:kCMTimeZero];[osc mouseDownAtPositionX:x positionY:y activePart:part modifiers:0 forceUpdate:&update atTime:kCMTimeZero];return part;}; auto up=[&](double x,double y,NSInteger part){[osc mouseUpAtPositionX:x positionY:y activePart:part modifiers:0 forceUpdate:&update atTime:kCMTimeZero];}; auto click=[&](double x,double y){NSInteger part=down(x,y);up(x,y,part);}; int undo=base->_undoStarts; click(NSMidX(button),400-NSMidY(button)); click(180,291.25); // normalized source (0.25, 0.25) NSInteger part=down(348,244); [osc mouseDraggedAtPositionX:460 positionY:181 activePart:part modifiers:0 forceUpdate:&update atTime:kCMTimeZero]; CMTime actionTime=CMTimeMake(39,25); [osc drawOSCWithWidth:640 height:400 activePart:part destinationImage:overlay atTime:actionTime]; host->_time=actionTime; up(460,181,part); [osc drawOSCWithWidth:640 height:400 activePart:part destinationImage:overlay atTime:actionTime]; run.record(@"native-osc-stamp-preview-survives-async-save-and-different-render-time", [[(id)osc valueForKey:@"stampSaving"]boolValue]&&[[viewer valueForKey:@"stampArmed"]boolValue]&& [[(id)osc valueForKey:@"stampHasSource"]boolValue]&&!DYSharedMasks(DYReadTools(base,kCMTimeZero).document).count); drain(); NSDictionary *stamp=[DYSharedMasks(DYReadTools(host,kCMTimeZero).document) firstObject]; NSArray *source=[[stamp[@"stampSource"]copy]autorelease]; DYMaskParameters target=DYMaskAtTime(stamp,kCMTimeZero); run.record(@"native-osc-creates-one-stamp-and-one-undo-from-source-click-and-drag",source.count==4&&fabs([source[0]doubleValue]-.25)<1e-6&&fabs([source[1]doubleValue]-.25)<1e-6&&fabs(target.centerX-.65)<1e-6&&fabs(target.centerY-.5)<1e-6&&base->_undoStarts==undo+1&&base->_undoEnds==undo+1); run.record(@"native-osc-stamp-selects-saved-overlay-when-action-time-differs", stamp&&[[plugin toolCanvasMaskAtTime:actionTime][@"id"]isEqual:stamp[@"id"]]&& ![[viewer valueForKey:@"stampArmed"]boolValue]&&![[(id)osc valueForKey:@"stampSaving"]boolValue]); [osc drawOSCWithWidth:640 height:400 activePart:0 destinationImage:overlay atTime:kCMTimeZero]; NSString *stampID=[[stamp[@"id"]copy]autorelease]; NSMutableDictionary *tracked=DYMutablePlist(DYReadTools(host,kCMTimeZero).document); NSMutableDictionary *trackedStamp=(id)DYSharedMaskWithID(tracked,stampID); DYMaskParameters moved=target;moved.centerX+=.05f; NSArray *keys=@[DYMaskKey(kCMTimeZero,target,NO,1),DYMaskKey(CMTimeMake(1,25),moved,NO,1)]; trackedStamp[@"keys"]=keys;DYWriteTools(host,tracked,kCMTimeZero); [plugin pluginState:&state atTime:kCMTimeZero quality:(FxQuality)0 error:&error]; [osc drawOSCWithWidth:640 height:400 activePart:0 destinationImage:overlay atTime:kCMTimeZero]; undo=base->_undoStarts; part=down(180,291.25); [osc mouseDraggedAtPositionX:236 positionY:259.75 activePart:part modifiers:0 forceUpdate:&update atTime:kCMTimeZero]; NSArray *preview=[plugin toolCanvasMaskAtTime:kCMTimeZero][@"stampSource"]; up(236,259.75,part);drain(); NSDictionary *edited=DYSharedMaskWithID(DYReadTools(host,kCMTimeZero).document,stampID); NSArray *relocated=DYStampSourceAtTime(edited,kCMTimeZero); run.record(@"native-osc-source-drag-keys-current-frame-and-preserves-other-tracking-keys",part==7&&fabs([relocated[0]doubleValue]-.35)<1e-6&&fabs([relocated[1]doubleValue]-.35)<1e-6&&fabs([relocated[0]doubleValue]-[preview[0]doubleValue])<1e-6&&fabs([relocated[1]doubleValue]-[preview[1]doubleValue])<1e-6&&[edited[@"stampSource"]isEqual:source]&&[edited[@"parameters"]isEqual:trackedStamp[@"parameters"]]&&[edited[@"keys"]count]==keys.count&&[edited[@"keys"][0][@"stampManualSource"]boolValue]&&[edited[@"keys"][1]isEqual:keys[1]]&&base->_undoStarts==undo+1&&base->_undoEnds==undo+1,@{@"part":@(part),@"source":relocated?:@[],@"keys":@([edited[@"keys"]count]),@"undoGroups":@(base->_undoStarts-undo)}); [osc drawOSCWithWidth:640 height:400 activePart:0 destinationImage:overlay atTime:kCMTimeZero]; part=down(236,259.75); [osc mouseDraggedAtPositionX:270 positionY:240 activePart:part modifiers:0 forceUpdate:&update atTime:kCMTimeZero]; BOOL handled=NO; [osc keyDownAtPositionX:270 positionY:240 keyPressed:27 modifiers:0 forceUpdate:&update didHandle:&handled atTime:kCMTimeZero]; drain(); run.record(@"native-osc-escape-cancels-the-stamp-source-drag-without-another-undo",handled&&[DYSharedMaskWithID(DYReadTools(host,kCMTimeZero).document,stampID)isEqual:edited]&&base->_undoStarts==undo+1); [osc drawOSCWithWidth:640 height:400 activePart:0 destinationImage:overlay atTime:kCMTimeZero]; BOOL rotationHandle=NO; for(NSDictionary *handle in [(id)osc valueForKey:@"handles"])rotationHandle|=[handle[@"part"]integerValue]==6; part=down(348,244); [osc mouseDraggedAtPositionX:320 positionY:260 activePart:part modifiers:0 forceUpdate:&update atTime:kCMTimeZero]; up(320,260,part);drain(); NSDictionary *resized=DYSharedMaskWithID(DYReadTools(host,kCMTimeZero).document,stampID); DYMaskParameters enlarged=DYMaskAtTime(resized,kCMTimeZero); run.record(@"native-osc-stamp-resizes-coverage-without-rotation-handle-or-track-changes",!rotationHandle&&part==2&&enlarged.width>target.width&&enlarged.height>target.height&&enlarged.centerX==target.centerX&&enlarged.centerY==target.centerY&&[resized[@"keys"]isEqual:edited[@"keys"]]); [osc drawOSCWithWidth:640 height:400 activePart:0 destinationImage:overlay atTime:kCMTimeZero]; undo=base->_undoStarts; part=down(404,212.5); [osc mouseDraggedAtPositionX:460 positionY:196.75 activePart:part modifiers:0 forceUpdate:&update atTime:kCMTimeZero]; up(460,196.75,part);drain(); NSDictionary *repositioned=DYSharedMaskWithID(DYReadTools(host,kCMTimeZero).document,stampID); NSArray *editedKeys=repositioned[@"keys"]; DYMaskParameters trackedCenter=DYMaskAtTime(repositioned,kCMTimeZero); run.record(@"native-osc-stamp-target-move-saves-the-canvas-key-with-a-different-action-time", part==1&&fabs(trackedCenter.centerX-.75)<1e-6&&fabs(trackedCenter.centerY-.55)<1e-6&& editedKeys.count==2&&[editedKeys[0][@"manual"]boolValue]&&[editedKeys[1]isEqual:keys[1]]&& base->_undoStarts==undo+1&&base->_undoEnds==undo+1); host->_time=kCMTimeZero; click(251,104);drain(); // top-down viewport y=30...345, forward button is x=212...290. run.record(@"native-osc-stamp-forward-action-starts-the-existing-host-tracker",host->_forwardStarts==1&&host->_backwardStarts==0); [plugin cleanupAnalysis:nil];drain(); NSDictionary *beforeRejected=[[DYReadTools(base,kCMTimeZero).document copy]autorelease]; base->_rejectToolsWrites=YES; click(NSMidX(button),400-NSMidY(button)); click(180,291.25); part=down(348,244);up(460,181,part);drain(); run.record(@"native-osc-stamp-rejected-write-keeps-the-draft-and-existing-document", [beforeRejected isEqual:DYReadTools(base,kCMTimeZero).document]&& [[viewer valueForKey:@"stampArmed"]boolValue]&&[[(id)osc valueForKey:@"stampHasSource"]boolValue]&& [(id)osc valueForKey:@"stampFailure"]!=nil); base->_rejectToolsWrites=NO; part=down(348,244);up(460,181,part);drain(); NSArray *afterRetry=DYSharedMasks(DYReadTools(base,kCMTimeZero).document); run.record(@"native-osc-stamp-retries-with-the-same-source-and-saves-once", afterRetry.count==DYSharedMasks(beforeRejected).count+1&& [afterRetry.lastObject[@"stampSource"]isEqual:source]&&![[viewer valueForKey:@"stampArmed"]boolValue]); NSString *untrackedID=[[afterRetry.lastObject[@"id"]copy]autorelease]; [osc drawOSCWithWidth:640 height:400 activePart:0 destinationImage:overlay atTime:kCMTimeZero]; host->_time=actionTime; undo=base->_undoStarts; part=down(404,212.5); [osc mouseDraggedAtPositionX:460 positionY:196.75 activePart:part modifiers:0 forceUpdate:&update atTime:kCMTimeZero]; up(460,196.75,part);drain(); NSDictionary *untracked=DYSharedMaskWithID(DYReadTools(host,kCMTimeZero).document,untrackedID); DYMaskParameters untrackedCenter=DYMaskAtTime(untracked,kCMTimeZero); run.record(@"native-osc-untracked-stamp-target-saves-in-place-with-a-different-action-time", part==1&&fabs(untrackedCenter.centerX-.75)<1e-6&&fabs(untrackedCenter.centerY-.55)<1e-6&& ![untracked[@"keys"]count]&&[untracked[@"stampSource"]isEqual:source]&& base->_undoStarts==undo+1&&base->_undoEnds==undo+1); [(id)osc release];[(id)plugin release]; }