Cover the seventh canvas tool and handle FCP callback timing

这个提交包含在:
mac 于 2026-11-06 11:33:06 +08:00 提交
1 父节点 320f4c5f91
当前提交 a2a6e57c13
4 个文件已更改
+23 -10

没有与搜索条件相匹配的文件

+2 -1
查看文件
@@ -5,7 +5,8 @@
inline double DYLevelDelta(CGPoint first, CGPoint second, double aspect, bool vertical) {
const double angle = std::atan2(second.y - first.y, (second.x - first.x) * aspect);
return std::remainder((vertical ? M_PI_2 : 0.) - angle, M_PI);
const double delta = std::remainder((vertical ? M_PI_2 : 0.) - angle, M_PI);
return delta <= -M_PI_2 + 1e-12 ? M_PI_2 : delta;
}
// Coordinates are normalized to a top-down image. Rotation is measured in
+11 -8
查看文件
@@ -23,12 +23,11 @@
_levelHasFirst=_levelDown=_levelSecondPress=NO;
[_levelFailure release];_levelFailure=nil;
}
- (void)updateLevelFrom:(DYPlugIn *)plugin time:(CMTime)time {
- (void)updateLevelFrom:(DYPlugIn *)plugin {
double angle=0;
double fallback=NSWidth(_imageRect)>0&&NSHeight(_imageRect)>0?NSWidth(_imageRect)/NSHeight(_imageRect):1;
_level=plugin?[plugin toolCanvasLevelForAspect:fallback rotation:&angle]:DYLevelTransform(0,fallback);
if(_levelMode!=_viewerControls.levelMode||_levelAngle!=angle||
(_levelHasFirst&&CMTIME_IS_NUMERIC(time)&&CMTimeCompare(time,_levelTime)!=0))[self clearLevelLine];
if(_levelMode!=_viewerControls.levelMode||_levelAngle!=angle)[self clearLevelLine];
_levelMode=_viewerControls.levelMode;_levelAngle=angle;
}
- (NSPoint)displayUV:(NSPoint)point {
@@ -59,6 +58,10 @@
if(type==NSEventTypeKeyDown&&key==27){
_viewerControls.levelMode=0;[self clearLevelLine];return YES;
}
// FCP's drawing and event callbacks may report different sample times.
// Compare events only and leave room for the host's sub-frame drift.
if(_levelHasFirst&&(type==NSEventTypeLeftMouseDown||type==NSEventTypeLeftMouseUp)&&
(time.epoch!=_levelTime.epoch||fabs(CMTimeGetSeconds(CMTimeSubtract(time,_levelTime)))>.05))[self clearLevelLine];
if(type==NSEventTypeLeftMouseDown&&part==10015){
if(_levelSaving)return YES;
[_levelFailure release];_levelFailure=nil;
@@ -172,7 +175,7 @@
id<FxOnScreenControlAPI_v4>api=[_apiManager apiForProtocol:@protocol(FxOnScreenControlAPI_v4)];double lx=0,ly=0,ux=0,uy=0;[api convertPointFromSpace:kFxDrawingCoordinates_OBJECT fromX:0 fromY:0 toSpace:kFxDrawingCoordinates_CANVAS toX:&lx toY:&ly];[api convertPointFromSpace:kFxDrawingCoordinates_OBJECT fromX:1 fromY:1 toSpace:kFxDrawingCoordinates_CANVAS toX:&ux toY:&uy];_imageRect=NSMakeRect(lx,_height-uy,ux-lx,uy-ly);_uiScale=[api respondsToSelector:@selector(backingScaleFactor)]?MAX(1.,MIN(3.,[api backingScaleFactor])):1.;
DYPlugIn *plugin=[self pluginAtTime:time];NSDictionary *mask=[plugin toolCanvasMaskAtTime:time];NSInteger route=(plugin?1:0)+(mask?2:0);if(route!=_lastRoute||_drawCount++<2){_lastRoute=route;os_log(OS_LOG_DEFAULT,"dayu_tool_osc_route plugin=%{public}d mask=%{public}d width=%{public}.2f height=%{public}.2f",plugin!=nil,mask!=nil,_imageRect.size.width,_imageRect.size.height);}[_mask release];_mask=[mask copy];[_handles removeAllObjects];[_outline release];_outline=nil;
[_viewerControls setBridge:[plugin viewerParameterBridge]];[_viewerControls setViewport:_imageRect];[_viewerControls prepareWithSize:NSMakeSize(canvasWidth,_height) scale:_uiScale atTime:time];
[self updateLevelFrom:plugin time:time];
[self updateLevelFrom:plugin];
if(_levelMode)mask=nil;
if(plugin&&canvasWidth>0&&_height>0&&canvasWidth<16384&&_height<16384&&_imageRect.size.width>0&&_imageRect.size.height>0){
NSRect region=mask||_viewerControls.stampArmed||_levelMode?NSMakeRect(0,0,canvasWidth,_height):NSIntegralRect([_viewerControls drawingBounds]);
@@ -223,11 +226,11 @@
for(NSDictionary *h in _handles){NSPoint q=[h[@"point"]pointValue];if(hypot(q.x-point.x,q.y-point.y)<=9*_uiScale)return [h[@"part"]integerValue];}
if(p.kind==DYMaskBezier||p.kind==DYMaskLinearGradient||[_outline containsPoint:point])return 1;return 0;
}
- (void)hitTestOSCAtMousePositionX:(double)x mousePositionY:(double)y activePart:(NSInteger*)part atTime:(CMTime)time{@synchronized(self){DYPlugIn*plugin=[self pluginAtTime:time];[_viewerControls setBridge:[plugin viewerParameterBridge]];[_viewerControls setViewport:_imageRect];[_viewerControls prepareWithSize:NSMakeSize(_canvasWidth,_height) scale:_uiScale atTime:time];NSDictionary *fresh=[plugin toolCanvasMaskAtTime:time];[_mask release];_mask=[fresh copy];[self updateLevelFrom:plugin time:time];NSInteger hit=[self partAtPoint:NSMakePoint(x,_height-y)];if(part)*part=hit;if(_hitDiagnostics++<16)os_log(OS_LOG_DEFAULT,"dayu_tool_osc_hit x=%{public}.2f y=%{public}.2f height=%{public}.2f rect=%{public}.2f,%{public}.2f,%{public}.2f,%{public}.2f mask=%{public}d hit=%{public}ld",x,y,_height,_imageRect.origin.x,_imageRect.origin.y,_imageRect.size.width,_imageRect.size.height,_mask!=nil,(long)hit);}}
- (void)hitTestOSCAtMousePositionX:(double)x mousePositionY:(double)y activePart:(NSInteger*)part atTime:(CMTime)time{@synchronized(self){DYPlugIn*plugin=[self pluginAtTime:time];[_viewerControls setBridge:[plugin viewerParameterBridge]];[_viewerControls setViewport:_imageRect];[_viewerControls prepareWithSize:NSMakeSize(_canvasWidth,_height) scale:_uiScale atTime:time];NSDictionary *fresh=[plugin toolCanvasMaskAtTime:time];[_mask release];_mask=[fresh copy];[self updateLevelFrom:plugin];NSInteger hit=[self partAtPoint:NSMakePoint(x,_height-y)];if(part)*part=hit;if(_hitDiagnostics++<16)os_log(OS_LOG_DEFAULT,"dayu_tool_osc_hit x=%{public}.2f y=%{public}.2f height=%{public}.2f rect=%{public}.2f,%{public}.2f,%{public}.2f,%{public}.2f mask=%{public}d hit=%{public}ld",x,y,_height,_imageRect.origin.x,_imageRect.origin.y,_imageRect.size.width,_imageRect.size.height,_mask!=nil,(long)hit);}}
- (BOOL)event:(NSEventType)type x:(double)x y:(double)y part:(NSInteger)part modifiers:(FxModifierKeys)modifiers key:(unichar)key time:(CMTime)time {@synchronized(self){
DYPlugIn *plugin=[self pluginAtTime:time];if(_eventDiagnostics++<12)os_log(OS_LOG_DEFAULT,"dayu_tool_osc_event type=%{public}ld part=%{public}ld x=%{public}.2f y=%{public}.2f plugin=%{public}d",(long)type,(long)part,x,y,plugin!=nil);[_viewerControls setBridge:[plugin viewerParameterBridge]];[_viewerControls setViewport:_imageRect];[_viewerControls prepareWithSize:NSMakeSize(_canvasWidth,_height) scale:_uiScale atTime:time];NSPoint canvasPoint=NSMakePoint(x,_height-y);
if(_maskCapturing&&plugin!=_maskCaptureOwner){_maskCapturing=NO;_maskCaptureOwner=nil;return NO;}
[self updateLevelFrom:plugin time:time];
[self updateLevelFrom:plugin];
if(_stampSaving)return YES;
if([self handleLevelEvent:type point:canvasPoint part:part key:key time:time plugin:plugin])return YES;
if(!_viewerControls.stampArmed)[self clearStampCreation];
@@ -276,7 +279,7 @@
if(type==NSEventTypeKeyDown&&key==27&&[_viewerControls capturing])return [_viewerControls finishCapture];
BOOL penAction=type==NSEventTypeLeftMouseDown&&(part==10009||part==10010);
if(!ownedMask&&!penAction&&type!=NSEventTypeKeyDown&&[_viewerControls event:type point:canvasPoint atTime:time]){
[self updateLevelFrom:plugin time:time];
[self updateLevelFrom:plugin];
if(_viewerControls.levelResetRequested){_viewerControls.levelResetRequested=NO;[self commitLevel:0 plugin:plugin];}
return YES;
}
@@ -291,7 +294,7 @@
- (void)mouseUpAtPositionX:(double)x positionY:(double)y activePart:(NSInteger)part modifiers:(FxModifierKeys)m forceUpdate:(BOOL*)update atTime:(CMTime)t{BOOL result=[self event:NSEventTypeLeftMouseUp x:x y:y part:part modifiers:m key:0 time:t];if(update)*update=result;}
- (void)keyDownAtPositionX:(double)x positionY:(double)y keyPressed:(unsigned short)key modifiers:(FxModifierKeys)m forceUpdate:(BOOL*)update didHandle:(BOOL*)handled atTime:(CMTime)t{BOOL result=(key==27||key==13||key==10||key==3||key==8||key==127)&&[self event:NSEventTypeKeyDown x:x y:y part:1 modifiers:m key:key time:t];if(update)*update=result;if(handled)*handled=result;}
- (void)mouseMovedAtPositionX:(double)x positionY:(double)y activePart:(NSInteger)part modifiers:(FxModifierKeys)m forceUpdate:(BOOL*)update atTime:(CMTime)t{@synchronized(self){
DYPlugIn*plugin=[self pluginAtTime:t];[_viewerControls setBridge:[plugin viewerParameterBridge]];[_viewerControls setViewport:_imageRect];[_viewerControls prepareWithSize:NSMakeSize(_canvasWidth,_height) scale:_uiScale atTime:t];[self updateLevelFrom:plugin time:t];NSPoint point=NSMakePoint(x,_height-y);NSInteger viewerHit=[_viewerControls partAtPoint:point];BOOL redraw=[_viewerControls mouseMoved:point];NSDictionary *mask=[plugin toolCanvasMaskAtTime:t];BOOL drawing=[mask[@"drawing"]boolValue]||[mask[@"drawShape"]boolValue];NSCursor *cursor=[_viewerControls headerAtPoint:point]?([_viewerControls capturing]?NSCursor.closedHandCursor:NSCursor.openHandCursor):viewerHit?NSCursor.pointingHandCursor:(part==10014||part==10015)?NSCursor.crosshairCursor:part>=10000?NSCursor.pointingHandCursor:(drawing||part>=1000)?NSCursor.crosshairCursor:part?NSCursor.openHandCursor:NSCursor.arrowCursor;[[_apiManager apiForProtocol:@protocol(FxOnScreenControlAPI_v4)]setCursor:cursor];if(_levelMode&&_levelHasFirst&&!_levelDown&&!_levelSaving&&!viewerHit&&part==10015){
DYPlugIn*plugin=[self pluginAtTime:t];[_viewerControls setBridge:[plugin viewerParameterBridge]];[_viewerControls setViewport:_imageRect];[_viewerControls prepareWithSize:NSMakeSize(_canvasWidth,_height) scale:_uiScale atTime:t];[self updateLevelFrom:plugin];NSPoint point=NSMakePoint(x,_height-y);NSInteger viewerHit=[_viewerControls partAtPoint:point];BOOL redraw=[_viewerControls mouseMoved:point];NSDictionary *mask=[plugin toolCanvasMaskAtTime:t];BOOL drawing=[mask[@"drawing"]boolValue]||[mask[@"drawShape"]boolValue];NSCursor *cursor=[_viewerControls headerAtPoint:point]?([_viewerControls capturing]?NSCursor.closedHandCursor:NSCursor.openHandCursor):viewerHit?NSCursor.pointingHandCursor:(part==10014||part==10015)?NSCursor.crosshairCursor:part>=10000?NSCursor.pointingHandCursor:(drawing||part>=1000)?NSCursor.crosshairCursor:part?NSCursor.openHandCursor:NSCursor.arrowCursor;[[_apiManager apiForProtocol:@protocol(FxOnScreenControlAPI_v4)]setCursor:cursor];if(_levelMode&&_levelHasFirst&&!_levelDown&&!_levelSaving&&!viewerHit&&part==10015){
_levelLast=[self clampedDisplayUV:point];redraw=YES;
}else if(!_levelMode&&[mask[@"drawing"]boolValue]&&!viewerHit)[self event:NSEventTypeMouseMoved x:x y:y part:part modifiers:m key:0 time:t];
if(update)*update=redraw||(!_levelMode&&[mask[@"drawing"]boolValue])||_stampNeedsRedraw;_stampNeedsRedraw=NO;
@@ -20,6 +20,14 @@ static void DYDrawDistortionGrid(NSRect rect,NSColor *color){
}
[color setStroke];[grid stroke];
}
static void DYDrawLevel(NSRect rect,NSColor *ink){
CGFloat size=NSWidth(rect),x=NSMinX(rect),y=NSMinY(rect);
NSBezierPath *guide=[NSBezierPath bezierPath];
[guide moveToPoint:NSMakePoint(x+size*.12,y+size*.75)];[guide lineToPoint:NSMakePoint(x+size*.88,y+size*.75)];
[guide moveToPoint:NSMakePoint(x+size*.19,y+size*.56)];[guide lineToPoint:NSMakePoint(x+size*.81,y+size*.22)];
guide.lineWidth=MAX(1.,size*.085);guide.lineCapStyle=NSLineCapStyleRound;
[ink setStroke];[guide stroke];
}
static void DYDrawCloneStamp(NSRect rect,NSColor *color){
CGFloat side=NSWidth(rect),x=NSMinX(rect),y=NSMinY(rect);
NSBezierPath *handle=[NSBezierPath bezierPathWithRoundedRect:NSMakeRect(x+side*.31,y+side*.05,side*.38,side*.43) xRadius:side*.16 yRadius:side*.16];
@@ -130,6 +138,7 @@ NSRect bounds=NSMakeRect(0,0,size.width,size.height),v=_hasViewport?NSIntersecti
NSRect glyph=NSMakeRect(NSMidX(r)-side/2,NSMidY(r)-side/2,side,side);
if([a[@"symbol"]isEqual:@"pincushion-grid"])DYDrawDistortionGrid(NSInsetRect(glyph,1,1),ink);
else if([a[@"symbol"]isEqual:@"clone-stamp"])DYDrawCloneStamp(glyph,ink);
else if([a[@"symbol"]isEqual:@"level"])DYDrawLevel(glyph,ink);
else{
NSImage *icon=[NSImage imageWithSystemSymbolName:a[@"symbol"] accessibilityDescription:a[@"title"]];
NSImageSymbolConfiguration *configuration=[[NSImageSymbolConfiguration configurationWithPointSize:14*s weight:NSFontWeightRegular]configurationByApplyingConfiguration:[NSImageSymbolConfiguration configurationWithPaletteColors:@[ink]]];
@@ -12,7 +12,7 @@
publish();int undo=base->_undoStarts;NSDictionary *initial=[[base->_values copy]autorelease];
NSMutableSet *types=[NSMutableSet set];NSInteger masks=0;CGFloat lastX=-1,y=-1;BOOL horizontal=YES;
for(NSDictionary *a in [controls valueForKey:@"areas"]){if([a[@"kind"]isEqual:@"mask"])masks++;if([a[@"kind"]isEqual:@"tool"]){NSRect r=[a[@"rect"]rectValue];if(lastX>=0)horizontal&=r.origin.x>lastX&&r.origin.y==y;lastX=r.origin.x;y=r.origin.y;[types addObject:a[@"toolType"]];}}
run.record(@"viewer-lower-right-rail-has-six-image-tools-and-three-persistent-mask-shapes",horizontal&&lastX>size.width*.8&&y>size.height*.9&&[types isEqual:[NSSet setWithArray:@[@"curve",@"lens",@"skin",@"look",@"whiteBalance",@"cloneStamp"]]]&&masks==3&&[[controls valueForKey:@"panels"]count]==0);
run.record(@"viewer-lower-right-rail-has-seven-image-tools-and-three-persistent-mask-shapes",horizontal&&lastX>size.width*.8&&y>size.height*.9&&[types isEqual:[NSSet setWithArray:@[@"curve",@"lens",@"skin",@"look",@"whiteBalance",@"cloneStamp",@"level"]]]&&masks==3&&[[controls valueForKey:@"panels"]count]==0);
NSDictionary *stamp=areaFor(controls,@"tool",@"cloneStamp");
click(stamp);BOOL armed=controls.stampArmed;click(stamp);
run.record(@"viewer-stamp-arms-and-disarms-without-changing-the-grade",armed&&!controls.stampArmed&&[initial isEqual:base->_values]&&base->_undoStarts==undo);