146 行
22 KiB
C++
146 行
22 KiB
C++
{
|
|
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);
|
|
id<DYToolCanvasHostProbe>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<end)[[NSRunLoop mainRunLoop]runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:.005]];};drain();
|
|
NSDictionary *snapshot=[plugin toolCanvasMaskAtTime:kCMTimeZero];run.record(@"canvas-cold-load-selects-saved-mask-from-immutable-snapshot",[snapshot[@"id"]isEqual:mask[@"id"]]&&[snapshot[@"parameters"]length]==sizeof(DYMaskParameters));
|
|
[NSNotificationCenter.defaultCenter postNotificationName:@"DYToolCanvasSelection" object:host userInfo:@{@"node":@"base:hsl",@"mask":mask[@"id"],@"document":doc}];
|
|
id<FxOnScreenControl_v4>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];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);
|
|
id<DYToolCanvasHostProbe>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+.06;while(NSProcessInfo.processInfo.systemUptime<end)[[NSRunLoop mainRunLoop]runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:.002]];};drain();
|
|
id<FxOnScreenControl_v4>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];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);
|
|
id<DYToolCanvasHostProbe>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+.07;while(NSProcessInfo.processInfo.systemUptime<end)[[NSRunLoop mainRunLoop]runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:.002]];};drain();
|
|
auto selectShape=[&](){[NSNotificationCenter.defaultCenter postNotificationName:@"DYToolCanvasSelection" object:host userInfo:@{@"node":@"shared",@"mask":maskID,@"document":DYReadTools(base,kCMTimeZero).document,@"drawShape":@YES}];};selectShape();
|
|
id<FxOnScreenControl_v4>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];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<DYToolCanvasHostProbe> 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<pixels.size();i++)pixels[i]=i%4==3?1:.18f;
|
|
[[src metalTextureForDevice:gpu]replaceRegion:MTLRegionMake2D(0,0,16,16)mipmapLevel:0 withBytes:pixels.data()bytesPerRow:16*8];
|
|
id<DYViewerParameterProbe> 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<FxTileableEffect>)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<FxParameterSettingAPI_v6>)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];
|
|
}
|
|
|
|
|
|
{
|
|
DYDiagnosticManager *base=[[[DYDiagnosticManager alloc]init]autorelease];DYCreateParameters(base,&error);
|
|
DYToolCanvasProbe *host=[[[DYToolCanvasProbe alloc]init]autorelease];host->_base=base;host->_time=kCMTimeZero;
|
|
id<DYToolCanvasHostProbe> 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<end)[[NSRunLoop mainRunLoop]runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:.005]];};drain();
|
|
id<FxOnScreenControl_v4> 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];
|
|
up(460,181,part);drain();
|
|
NSDictionary *stamp=[DYSharedMasks(DYReadTools(host,kCMTimeZero).document) firstObject];NSArray *source=stamp[@"stampSource"];
|
|
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);
|
|
[osc drawOSCWithWidth:640 height:400 activePart:0 destinationImage:overlay atTime:kCMTimeZero];
|
|
NSMutableDictionary *tracked=DYMutablePlist(DYReadTools(host,kCMTimeZero).document);
|
|
NSMutableDictionary *trackedStamp=(id)DYSharedMaskWithID(tracked,stamp[@"id"]);
|
|
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,stamp[@"id"]);
|
|
NSArray *relocated=edited[@"stampSource"];
|
|
run.record(@"native-osc-drag-moves-only-the-stamp-source-and-keeps-tracking-keys",part==7&&fabs([relocated[0]doubleValue]-.35)<1e-6&&fabs([relocated[1]doubleValue]-.35)<1e-6&&[relocated isEqual:preview]&&[edited[@"parameters"]isEqual:trackedStamp[@"parameters"]]&&[edited[@"keys"]isEqual:keys]&&base->_undoStarts==undo+1&&base->_undoEnds==undo+1);
|
|
[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,stamp[@"id"])[@"stampSource"]isEqual:relocated]&&base->_undoStarts==undo+1);
|
|
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();[(id)osc release];[(id)plugin release];
|
|
}
|