Track both clone stamp regions and render their relative zoom
这个提交包含在:
1 父节点
78b4c5f962
当前提交
52a7422004
14 个文件已更改
+379
-30
没有与搜索条件相匹配的文件
@@ -66,5 +66,79 @@
|
||||
[NSNotificationCenter.defaultCenter postNotificationName:@"DYToolTrackingStatus" object:host userInfo:@{@"node":@"shared",@"mask":sharedID,@"message":@"共享跟踪状态"}];BOOL statusVisible=[[[panel valueForKey:@"_status"]stringValue]isEqual:@"共享跟踪状态"];
|
||||
run.record(@"shared-mask-inspector-alias-activates-canvas-and-receives-canonical-status",aliasActive&&statusVisible&&[[(NSObject*)plugin valueForKey:@"_selectedToolNode"]isEqual:@"shared"]);
|
||||
}
|
||||
{
|
||||
NSMutableDictionary *stampDoc=DYMutablePlist([[[DYToolDocument alloc]init]autorelease].document);
|
||||
NSMutableDictionary *stamp=(id)DYAddSharedMask(stampDoc,DYMaskEllipse);
|
||||
NSString *stampID=stamp[@"id"];
|
||||
DYMaskParameters target=DYMaskAtTime(stamp,kCMTimeZero);
|
||||
target.centerX=.75f;target.centerY=.5f;target.width=.32f;target.height=.54f;
|
||||
stamp[@"parameters"]=[NSData dataWithBytes:&target length:sizeof(target)];
|
||||
stamp[@"stampSource"]=@[@.25,@.5,@.32,@.54];
|
||||
auto noise=[](int x,int y){
|
||||
uint32_t n=uint32_t(x)*73856093u^uint32_t(y)*19349663u;
|
||||
n^=n>>13;n*=1274126177u;
|
||||
return .15f+.7f*((n>>8)&255)/255.f;
|
||||
};
|
||||
auto pairedFrame=[&](int step,bool flatSource){
|
||||
Pixels pixels(tw*th*4);
|
||||
for(NSUInteger y=0;y<th;y++)for(NSUInteger x=0;x<tw;x++){
|
||||
bool source=x<tw/2;
|
||||
float cx=tw*(source?.25f:.75f),cy=th*.5f,scale=1+step*(source?-.025f:.035f);
|
||||
float u=(cx+(float(x)-cx-step*(source?-1.5f:2.f))/scale)/4;
|
||||
float v=(cy+(float(y)-cy-step*(source?1.f:-.75f))/scale)/4;
|
||||
int ix=int(floorf(u)),iy=int(floorf(v));float fx=u-ix,fy=v-iy;
|
||||
float top=noise(ix,iy)*(1-fx)+noise(ix+1,iy)*fx;
|
||||
float bottom=noise(ix,iy+1)*(1-fx)+noise(ix+1,iy+1)*fx;
|
||||
float code=source&&flatSource?.4f:top*(1-fy)+bottom*fy;
|
||||
float linear=powf((code+.055f)/1.055f,2.4f);
|
||||
auto index=(y*tw+x)*4;pixels[index]=pixels[index+1]=pixels[index+2]=linear;pixels[index+3]=1;
|
||||
}
|
||||
[[frame metalTextureForDevice:gpu]replaceRegion:MTLRegionMake2D(0,0,tw,th) mipmapLevel:0 withBytes:pixels.data() bytesPerRow:tw*8];
|
||||
};
|
||||
auto requestStamp=[&](int start){
|
||||
host->_time=timeAt(start);host->_state=kFxAnalysisState_NotAnalyzing;
|
||||
[plugin toolTrackRequested:[NSNotification notificationWithName:@"DYToolTrack" object:host userInfo:@{@"node":@"shared",@"mask":stampID,@"direction":@1}]];
|
||||
return [plugin desiredAnalysisTimeRange:&desired forInputWithTimeRange:inputRange error:nil]&&
|
||||
[plugin setupAnalysisForTimeRange:desired frameDuration:timeAt(1) error:nil];
|
||||
};
|
||||
auto finish=[&](){host->_state=kFxAnalysisState_AnalysisCompleted;[plugin cleanupAnalysis:nil];drain();};
|
||||
DYWriteTools(base,stampDoc,kCMTimeZero);
|
||||
int beforeStamp=base->_undoStarts;
|
||||
BOOL paired=requestStamp(0);
|
||||
NSError *pairError=nil;
|
||||
for(int i=0;i<6&&paired;i++){pairedFrame(i,false);paired&=[plugin analyzeFrame:frame atTime:timeAt(i) error:&pairError];}
|
||||
finish();
|
||||
NSDictionary *saved=DYSharedMaskWithID(DYReadTools(base,kCMTimeZero).document,stampID);
|
||||
DYStampMotion motion=DYStampMotionAtTime(saved,timeAt(5));
|
||||
DYMaskParameters covered=DYMaskAtTime(saved,timeAt(5));
|
||||
NSArray *sampled=DYStampSourceAtTime(saved,timeAt(5));
|
||||
run.record(@"host-clone-stamp-follows-two-independent-centers-and-scales",
|
||||
paired&&[saved[@"keys"] count]==6&&motion.active&&
|
||||
fabs(covered.centerX-(.75+10./tw))<.006&&fabs(covered.centerY-(.5-3.75/th))<.008&&
|
||||
fabs([sampled[0] doubleValue]-(.25-7.5/tw))<.006&&fabs([sampled[1] doubleValue]-(.5+5./th))<.008&&
|
||||
fabs(motion.targetScaleX-1.175)<.045&&fabs(motion.targetScaleY-1.175)<.045&&
|
||||
fabs(motion.sourceScaleX-.875)<.04&&fabs(motion.sourceScaleY-.875)<.04&&base->_undoStarts==beforeStamp+1,
|
||||
@{@"keys":@([saved[@"keys"] count]),@"source":sampled?:@[],@"target":@[@(covered.centerX),@(covered.centerY)],
|
||||
@"sourceScale":@[@(motion.sourceScaleX),@(motion.sourceScaleY)],
|
||||
@"targetScale":@[@(motion.targetScaleX),@(motion.targetScaleY)],@"error":reason(pairError)});
|
||||
DYStampMotion restart=DYStampMotionAtTime(saved,timeAt(2));
|
||||
paired=requestStamp(2);
|
||||
for(int i=2;i<6&&paired;i++){pairedFrame(i,false);paired&=[plugin analyzeFrame:frame atTime:timeAt(i) error:nil];}
|
||||
finish();
|
||||
saved=DYSharedMaskWithID(DYReadTools(base,kCMTimeZero).document,stampID);
|
||||
DYStampMotion resumed=DYStampMotionAtTime(saved,timeAt(2));
|
||||
run.record(@"host-clone-stamp-restarts-from-current-paired-scale",
|
||||
paired&&[saved[@"keys"] count]==6&&resumed.active&&restart.sourceScaleX==resumed.sourceScaleX&&restart.targetScaleX==resumed.targetScaleX);
|
||||
DYWriteTools(base,stampDoc,kCMTimeZero);
|
||||
paired=requestStamp(0);
|
||||
for(int i=0;i<3&&paired;i++){pairedFrame(i,false);paired&=[plugin analyzeFrame:frame atTime:timeAt(i) error:nil];}
|
||||
pairedFrame(3,true);NSError *sourceLoss=nil;
|
||||
BOOL ended=![plugin analyzeFrame:frame atTime:timeAt(3) error:&sourceLoss];
|
||||
finish();
|
||||
saved=DYSharedMaskWithID(DYReadTools(base,kCMTimeZero).document,stampID);
|
||||
run.record(@"host-clone-stamp-source-loss-stops-both-tracks-at-last-paired-frame",
|
||||
paired&&ended&&[saved[@"keys"] count]==3&&[sourceLoss.domain isEqual:FxPlugErrorDomain]&&
|
||||
sourceLoss.code==kFxError_UserCancelled&&[sourceLoss.localizedDescription containsString:@"取样区域"]);
|
||||
}
|
||||
[plugin release];
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户