From 6ef38faa19f5228632ed6be439909ef21d49e5c0 Mon Sep 17 00:00:00 2001 From: mac Date: Mon, 9 Nov 2026 11:27:40 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9A=94=E7=A6=BB=E8=BF=9E=E7=BB=AD=E8=9C=98?= =?UTF-8?q?=E8=9B=9B=E7=9B=98=E6=89=8B=E5=8A=BF=E5=B9=B6=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E5=9B=9E=E5=BD=92=E6=B5=8B=E8=AF=95=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 大鱼调色/Plugin/DYDiagnostics.mm | 6 ++--- 大鱼调色/Plugin/DYViewerParameterBridge.inc.h | 25 +++++++++++-------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/大鱼调色/Plugin/DYDiagnostics.mm b/大鱼调色/Plugin/DYDiagnostics.mm index bf1887d..3194bf1 100644 --- a/大鱼调色/Plugin/DYDiagnostics.mm +++ b/大鱼调色/Plugin/DYDiagnostics.mm @@ -355,9 +355,9 @@ extern "C" int DYRunDiagnostics(void) { @autoreleasepool { [disc mouseDown:mouseFor(disc,NSEventTypeLeftMouseDown,burstStart)]; NSPoint nextPoint=NSMakePoint(burstStart.x+9,burstStart.y+3); [disc mouseDragged:mouseFor(disc,NSEventTypeLeftMouseDragged,nextPoint)]; - NSDate *deadline=[NSDate dateWithTimeIntervalSinceNow:.2]; - while(uiHost->_assetWrites==writesBeforeBurst+1&&[deadline timeIntervalSinceNow]>0) - [[NSRunLoop currentRunLoop]runMode:NSDefaultRunLoopMode beforeDate:deadline]; + NSDate *spiderDeadline=[NSDate dateWithTimeIntervalSinceNow:.2]; + while(uiHost->_assetWrites==writesBeforeBurst+1&&[spiderDeadline timeIntervalSinceNow]>0) + [[NSRunLoop currentRunLoop]runMode:NSDefaultRunLoopMode beforeDate:spiderDeadline]; run.record(@"spider-paused-drag-writes-live-before-release",uiHost->_assetWrites==writesBeforeBurst+2&&[disc.meshData isEqual:DYReadAssets(uiHost,kCMTimeZero).spiderMesh]); DYAssetState *external=[[DYReadAssets(uiHost,kCMTimeZero)copy]autorelease]; auto externalMesh=dy::neutralMesh(6,6); diff --git a/大鱼调色/Plugin/DYViewerParameterBridge.inc.h b/大鱼调色/Plugin/DYViewerParameterBridge.inc.h index 81d4ac6..a7d7b75 100644 --- a/大鱼调色/Plugin/DYViewerParameterBridge.inc.h +++ b/大鱼调色/Plugin/DYViewerParameterBridge.inc.h @@ -68,8 +68,8 @@ static BOOL DYViewerSanitizeValue(NSDictionary *d,double input,double *output) { NSDictionary *_snapshot,*_sourceDocument;NSString *_selectedNode; CMTime _snapshotTime; BOOL _invalidated,_validationScheduled; - uint64_t _requestSequence,_requestedGesture,_completedGesture,_pendingSpiderGesture; - NSData *_pendingSpiderMesh; + uint64_t _requestSequence,_requestedGesture,_completedGesture; + NSMutableDictionary *_pendingSpiderMeshes; // The fields below are confined to the main queue. id _writerHost,_writerTarget; @@ -89,7 +89,7 @@ static BOOL DYViewerSanitizeValue(NSDictionary *d,double input,double *output) { // the queued block keeps the bridge alive until its host group is closed. NSCAssert(!_writerUndoOpen,@"Viewer parameter group must be closed before teardown"); [NSNotificationCenter.defaultCenter removeObserver:self];[_renderer release];[_selectedNode release];[_snapshot release];[_sourceDocument release];[_writerHost release];[_writerTarget release]; - [_writerDescriptors release];[_writerLastValues release];[_writerCompanions release];[_writerNode release];[_writerType release];[_pendingSpiderMesh release];[super dealloc]; + [_writerDescriptors release];[_writerLastValues release];[_writerCompanions release];[_writerNode release];[_writerType release];[_pendingSpiderMeshes release];[super dealloc]; } - (void)publishAssets:(DYAssetState*)assets atTime:(CMTime)time { @synchronized(self){if(_invalidated||!_snapshot||CMTimeCompare(time,_snapshotTime)!=0)return;NSMutableDictionary *next=[[_snapshot mutableCopy]autorelease];next[@"spider"]=assets.spiderMesh?:[NSData data];[_snapshot release];_snapshot=[next copy];} @@ -311,10 +311,12 @@ static BOOL DYViewerSanitizeValue(NSDictionary *d,double input,double *output) { - (void)flushSpiderGesture:(uint64_t)gesture { NSData *mesh=nil; @synchronized(self){ - if(_invalidated||_pendingSpiderGesture!=gesture)return; - mesh=[_pendingSpiderMesh autorelease];_pendingSpiderMesh=nil;_pendingSpiderGesture=0; + if(_invalidated)return; + NSNumber *key=@(gesture); + mesh=[[_pendingSpiderMeshes[key]retain]autorelease]; + [_pendingSpiderMeshes removeObjectForKey:key]; } - if(_writerGesture!=gesture||!_writerSpider||[mesh isEqual:_writerLastMesh])return; + if(!mesh||_writerGesture!=gesture||!_writerSpider||[mesh isEqual:_writerLastMesh])return; ida=[_writerTarget apiForProtocol:@protocol(FxCustomParameterActionAPI_v4)]; if(!a){[self closeWriter];return;} BOOL changed=NO,failed=NO; @@ -344,10 +346,11 @@ static BOOL DYViewerSanitizeValue(NSDictionary *d,double input,double *output) { @synchronized(self){ if(_invalidated||!_requestedGesture)return; uint64_t gesture=_requestedGesture; - [_pendingSpiderMesh release];_pendingSpiderMesh=[mesh copy]; - if(_pendingSpiderGesture==gesture)return; - _pendingSpiderGesture=gesture; - dispatch_async(dispatch_get_main_queue(),^{[self flushSpiderGesture:gesture];}); + NSNumber *key=@(gesture); + if(!_pendingSpiderMeshes)_pendingSpiderMeshes=[NSMutableDictionary new]; + BOOL scheduled=_pendingSpiderMeshes[key]!=nil; + _pendingSpiderMeshes[key]=[[mesh copy]autorelease]; + if(!scheduled)dispatch_async(dispatch_get_main_queue(),^{[self flushSpiderGesture:gesture];}); } } - (void)writeValues:(NSDictionary*)values gesture:(uint64_t)gesture { @@ -485,7 +488,7 @@ static BOOL DYViewerSanitizeValue(NSDictionary *d,double input,double *output) { @synchronized(self){return !_invalidated&&gesture>_completedGesture;} } - (void)invalidate { - @synchronized(self){if(_invalidated)return;_invalidated=YES;_requestedGesture=0;_pendingSpiderGesture=0;[_pendingSpiderMesh release];_pendingSpiderMesh=nil;_apiManager=nil;} + @synchronized(self){if(_invalidated)return;_invalidated=YES;_requestedGesture=0;[_pendingSpiderMeshes removeAllObjects];_apiManager=nil;} dispatch_async(dispatch_get_main_queue(),^{[self closeWriter];}); } @end