diff --git a/research/CanvasTools-20261105.md b/research/CanvasTools-20261105.md index 27a84a7..7b6a24e 100644 --- a/research/CanvasTools-20261105.md +++ b/research/CanvasTools-20261105.md @@ -16,3 +16,13 @@ 交付必须完成 Release、Developer ID、Apple Accepted、票据、唯一安装及正式路径自检、宿主功能验收、PKG 与 Release 下载校验、远端独立恢复。额度重置由用户手动操作。 状态:研究与实现中,尚未交付新版。 + +## 实现检查点 + +HSL八色三轴图形、蜘蛛网格拖动/固定/复位/分辨率、半透明绘制与降低透明度替代、曲线直方图已连接原参数。蜘蛛自定义资产扩展了主队列冲突保护。主面板按显示状态隐藏未使用的附加模块,保存过的有效参数自动显示;画布工具入口可以恢复已删除类型。 + +FCP-BeautyGirl 参考提交 `42fecaa3b55471fea928339127d53484663d4057`,MIT 许可证见同目录 FCPBeautyGirl-MIT.txt。参考 Vision revision 3、76点、皮肤支持区与五官排除的思路;未引入美颜、瘦脸或目标二进制。 + +mFilmLook 3.1.4 arm64 SHA-256 `b1cee1dffd3b490afa0c22db646404b018a0aaadf70d9a6827e95cb178c74357`。REA Ghidra 12.1.4 观察到 Lens Distortion、ParamLensDistortionEnable/Strength、RenderDistortionKernel,证据 `ev_77ca21689086d3b977243f1b81b3833a89b9e48aa5cd3e38594572abad5296a2`、`ev_5c4653c5bdd4316ec067c530085235c5c37733b2490065ed6d5ea855611057a7`。本项目独立编写反向径向采样,不宣称已证明目标GPU逐像素等价。 + +Uniform 仅在原1312字节之后追加32字节,旧参数ID与完整前缀不变;新增独立镜头模块、肤色范围预览及默认人脸限定。当前编译/验证中,未安装。 diff --git a/research/FCPBeautyGirl-MIT.txt b/research/FCPBeautyGirl-MIT.txt new file mode 100644 index 0000000..33cd4e5 --- /dev/null +++ b/research/FCPBeautyGirl-MIT.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Dayu + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/tools/build_masked_kernel.py b/tools/build_masked_kernel.py index 92391b7..ed6244c 100644 --- a/tools/build_masked_kernel.py +++ b/tools/build_masked_kernel.py @@ -65,4 +65,8 @@ entry: ret <3 x float> %result } ''' - return source+'\n'+body+'\n'+segment+'\n'+skin + # Expose the existing color-selection arithmetic for a matching preview. + weight = re.search(r'define internal fastcc <3 x float> @_ZL19applySkinProtection.*?\n\}', source, re.S).group() + weight = weight.replace('define internal fastcc <3 x float> @_ZL19applySkinProtectionDv3_fS_RU11MTLconstantK17DYUniforms', 'define float @dy_skinWeight', 1) + weight = weight[:weight.index('v135:')] + 'v135:\n br label %v153\nv153:\n %weight = phi float [ 0.000000e+00, %v3 ], [ %v133, %v135 ], [ 0.000000e+00, %v46 ]\n ret float %weight\n}\n' + return source+'\n'+body+'\n'+segment+'\n'+skin+'\n'+weight diff --git a/大鱼调色.xcodeproj/project.pbxproj b/大鱼调色.xcodeproj/project.pbxproj index 17a71d5..79b9820 100644 --- a/大鱼调色.xcodeproj/project.pbxproj +++ b/大鱼调色.xcodeproj/project.pbxproj @@ -387,6 +387,8 @@ "-framework", MetalPerformanceShaders, "-framework", + Vision, + "-framework", QuartzCore, "-lcompression", "-lz", @@ -421,6 +423,8 @@ "-framework", MetalPerformanceShaders, "-framework", + Vision, + "-framework", QuartzCore, "-lcompression", "-lz", @@ -449,6 +453,8 @@ "-framework", MetalPerformanceShaders, "-framework", + Vision, + "-framework", QuartzCore, "-lcompression", "-lz", @@ -476,6 +482,8 @@ "-framework", MetalPerformanceShaders, "-framework", + Vision, + "-framework", QuartzCore, "-lcompression", "-lz", diff --git a/大鱼调色/Plugin/DYFaceRender.inc.h b/大鱼调色/Plugin/DYFaceRender.inc.h new file mode 100644 index 0000000..9b2e7ab --- /dev/null +++ b/大鱼调色/Plugin/DYFaceRender.inc.h @@ -0,0 +1,47 @@ +// Authored adaptation of Vision face support in FCP-BeautyGirl (MIT). +// Geometry is rebuilt from this input frame; no previous-shot mask is reused. +- (void)prepareFaceSupport:(FxImageTile*)source { + [_faceEntries release];_faceEntries=nil;std::vector entries; + FxRect image=source.imagePixelBounds,tile=source.tilePixelBounds; + if(image.left!=tile.left||image.right!=tile.right||image.top!=tile.top||image.bottom!=tile.bottom)return; + NSMutableDictionary *device=[self device:source.deviceRegistryID error:nil];idtexture=[source metalTextureForDevice:device[@"device"]];if(!texture)return; + if(!_faceContext)_faceContext=[[CIContext contextWithMTLDevice:device[@"device"] options:@{kCIContextCacheIntermediates:@NO}]retain]; + CGColorSpaceRef linear=CGColorSpaceCreateWithName(kCGColorSpaceLinearSRGB); + CIImage *input=[CIImage imageWithMTLTexture:texture options:@{kCIImageColorSpace:(id)linear}];CGColorSpaceRelease(linear);if(!input)return; + // FxPlug's bottom-left textures need the same visual orientation as mask UV. + if(source.imageOrigin==kFxImageOrigin_BOTTOM_LEFT)input=[input imageByApplyingTransform:CGAffineTransformMake(1,0,0,-1,0,input.extent.size.height)]; + CGFloat scale=MIN(1.,960./MAX(input.extent.size.width,input.extent.size.height));input=[input imageByApplyingTransform:CGAffineTransformMakeScale(scale,scale)]; + CGColorSpaceRef srgb=CGColorSpaceCreateWithName(kCGColorSpaceSRGB);CGImageRef cg=[_faceContext createCGImage:input fromRect:input.extent format:kCIFormatRGBA8 colorSpace:srgb];CGColorSpaceRelease(srgb);if(!cg)return; + VNDetectFaceLandmarksRequest *request=[VNDetectFaceLandmarksRequest new];request.revision=VNDetectFaceLandmarksRequestRevision3;request.constellation=VNRequestFaceLandmarksConstellation76Points; + VNImageRequestHandler *handler=[[VNImageRequestHandler alloc]initWithCGImage:cg orientation:kCGImagePropertyOrientationUp options:@{}];CGImageRelease(cg); + if([handler performRequests:@[request] error:nil])for(VNFaceObservation *face in request.results){ + if(entries.size()>64||face.confidence<.5||!face.landmarks.faceContour.pointCount)continue;CGRect box=face.boundingBox;if(box.size.width<.015||box.size.height<.015)continue; + DYToolMaskEntry support{};support.section=-100;support.mask.parameters=dyDefaultMaskParameters();auto &p=support.mask.parameters;p.kind=DYMaskBezier;p.centerX=CGRectGetMidX(box);p.centerY=1-CGRectGetMidY(box);p.width=box.size.width;p.height=box.size.height;p.feather=.1; + auto &path=support.mask.path;VNFaceLandmarkRegion2D *contour=face.landmarks.faceContour; + for(NSUInteger i=0;ipath.x[0];for(int i=0;i<=12;i++){float t=i/12.f,x=forward?1-t:t;path.x[path.count]=x-.5;path.y[path.count]=-.28-.28*sinf(t*M_PI);path.count++;}entries.push_back(support); + for(VNFaceLandmarkRegion2D *region in @[face.landmarks.leftEye?:[NSNull null],face.landmarks.rightEye?:[NSNull null],face.landmarks.outerLips?:[NSNull null],face.landmarks.leftEyebrow?:[NSNull null],face.landmarks.rightEyebrow?:[NSNull null]]){ + if(![region isKindOfClass:VNFaceLandmarkRegion2D.class]||!region.pointCount)continue;CGFloat loX=1,loY=1,hiX=0,hiY=0;for(NSUInteger i=0;i.5&&u.skinFaceOnly>.5)||u.skinVisualize>.5;for(NSDictionary *node in tools[@"layers"]){DYUniforms layer=DYToolUniforms(node);face|=[node[@"type"]isEqual:@"skin"]&&layer.skinProtection.x>.5&&layer.skinFaceOnly>.5;} + if(face&&!_exporting)[self prepareFaceSupport:src];else{[_faceEntries release];_faceEntries=nil;} + BOOL ok=[self renderToolsSource:src destination:dst uniforms:u paths:paths spider:spider tools:tools error:error]; + if(ok&&u.skinVisualize>.5&&!DYBaseToolRemoved(tools,@"skin")){ + NSMutableDictionary *entry=[self device:dst.deviceRegistryID error:error];idd=entry[@"device"];idoutput=[dst metalTextureForDevice:d],input=[src metalTextureForDevice:d]; + MTLTextureDescriptor *desc=[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:output.pixelFormat width:output.width height:output.height mipmapped:NO];desc.storageMode=MTLStorageModePrivate;desc.usage=MTLTextureUsageShaderRead|MTLTextureUsageShaderWrite|MTLTextureUsageRenderTarget;idpreview=[d newTextureWithDescriptor:desc]; + if(!preview)return fail(error,@"无法分配肤色区域预览");DYToolMaskHeader header{};header.section=3;header.faceOnly=u.skinFaceOnly>.5;idmasks=[self maskBuffer:tools[@"baseMasks"] tile:src device:d header:&header];idcb=[entry[@"queue"]commandBuffer];idce=[cb computeCommandEncoder];[ce setComputePipelineState:entry[@"dySkinOverlay"]];[ce setTexture:input atIndex:0];[ce setTexture:output atIndex:1];[ce setTexture:preview atIndex:2];[ce setBuffer:masks offset:0 atIndex:0];[ce setBytes:&header length:sizeof(header) atIndex:1];[ce setBytes:&u length:sizeof(u) atIndex:2];[ce dispatchThreads:MTLSizeMake(output.width,output.height,1)threadsPerThreadgroup:MTLSizeMake(16,16,1)];[ce endEncoding];[cb commit];[cb waitUntilCompleted]; + DYExportTile *tile=[[DYExportTile alloc]initWithTexture:preview registry:d.registryID];[tile setBounds:dst.tilePixelBounds origin:dst.imageOrigin];[tile setPixelAspect:dst.pixelAspect];ok=cb.status==MTLCommandBufferStatusCompleted&&[self copyTile:tile to:dst entry:entry error:error];[tile release];[preview release]; + } + return ok; +}} +- (BOOL)renderLens:(FxImageTile*)source destination:(FxImageTile*)destination uniforms:(DYUniforms)u masks:(NSArray*)masks entry:(NSDictionary*)entry error:(NSError**)error { + idd=entry[@"device"];idbefore=[source metalTextureForDevice:d],output=[destination metalTextureForDevice:d]; + idcb=[entry[@"queue"]commandBuffer];idce=[cb computeCommandEncoder];[ce setComputePipelineState:entry[@"dyLensRepair"]];[ce setTexture:before atIndex:0];[ce setTexture:output atIndex:1];[ce setBytes:&u length:sizeof(u) atIndex:0];float aspect=before.width*source.pixelAspect/MAX(1.,(double)before.height);[ce setBytes:&aspect length:sizeof(aspect) atIndex:1];[ce dispatchThreads:MTLSizeMake(output.width,output.height,1)threadsPerThreadgroup:MTLSizeMake(16,16,1)];[ce endEncoding];[cb commit];[cb waitUntilCompleted];if(cb.status!=MTLCommandBufferStatusCompleted)return fail(error,cb.error.localizedDescription); + if(!masks.count)return YES;MTLTextureDescriptor *desc=[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:output.pixelFormat width:output.width height:output.height mipmapped:NO];desc.storageMode=MTLStorageModePrivate;desc.usage=MTLTextureUsageShaderRead|MTLTextureUsageShaderWrite|MTLTextureUsageRenderTarget;idblend=[d newTextureWithDescriptor:desc];if(!blend)return fail(error,@"无法分配修复蒙版");DYToolMaskHeader h{};h.section=(int)[DYToolTypes()indexOfObject:@"lens"];idbuffer=[self maskBuffer:@{@"lens":masks}tile:source device:d header:&h];cb=[entry[@"queue"]commandBuffer];[self encodeBlend:before after:output output:blend masks:buffer header:h entry:entry commands:cb];[cb commit];[cb waitUntilCompleted];DYExportTile *tile=[[DYExportTile alloc]initWithTexture:blend registry:d.registryID];[tile setBounds:destination.tilePixelBounds origin:destination.imageOrigin];[tile setPixelAspect:destination.pixelAspect];BOOL ok=cb.status==MTLCommandBufferStatusCompleted&&[self copyTile:tile to:destination entry:entry error:error];[tile release];[blend release];return ok; +} diff --git a/大鱼调色/Plugin/DYGrade.metal b/大鱼调色/Plugin/DYGrade.metal index d36fd28..7b02891 100644 --- a/大鱼调色/Plugin/DYGrade.metal +++ b/大鱼调色/Plugin/DYGrade.metal @@ -145,7 +145,7 @@ inline float dyToolCoverage(float2 uv,float3 source,device const DYToolMaskEntry float a=dyToolMask(x,y,source,masks[i].mask); if(!found){coverage=masks[i].combine==1?1-a:a;found=true;} else if(masks[i].combine==1)coverage*=1-a;else if(masks[i].combine==2)coverage*=a;else coverage=1-(1-coverage)*(1-a); - }return clamp(coverage,0.f,1.f); + }if(section==3&&h.faceOnly){float face=0;for(uint i=0;i sourc #include "DYFilmKernels.inc.h" #include "DYManagedKernels.inc.h" #include "DYPrimaryKernels.inc.h" + +// Inverse radial sampling; alpha stays premultiplied through interpolation. +kernel void dyLensRepair(texture2d source [[texture(0)]],texture2d output [[texture(1)]],constant DYUniforms& u [[buffer(0)]],constant float& aspect [[buffer(1)]],uint2 p [[thread_position_in_grid]]){ + if(p.x>=output.get_width()||p.y>=output.get_height())return;float2 uv=(float2(p)+.5f)/float2(output.get_width(),output.get_height()),center=float2(u.lensCenterX,u.lensCenterY);float2 q=(uv-center)/max(1.f,u.lensScale),metric=q*float2(aspect,1);float2 corner=max(center,1-center)*float2(aspect,1);float radius=dot(metric,metric)/max(1e-6f,dot(corner,corner));float2 sample=center+q*(1+clamp(u.lensStrength,-100.f,100.f)*.0025f*radius); + constexpr sampler f(coord::normalized,address::clamp_to_zero,filter::linear);output.write(source.sample(f,sample),p); +} +extern "C" float dy_skinWeight(float3 color,float3 reference,constant DYUniforms& uniforms); +kernel void dySkinOverlay(texture2d source [[texture(0)]],texture2d graded [[texture(1)]],texture2d output [[texture(2)]],device const DYToolMaskEntry* masks [[buffer(0)]],constant DYToolMaskHeader& h [[buffer(1)]],constant DYUniforms& u [[buffer(2)]],uint2 p [[thread_position_in_grid]]){ + if(p.x>=output.get_width()||p.y>=output.get_height())return;float4 a=source.read(p),b=graded.read(p);float3 encoded=dyToolEncode(a.a>0?a.rgb/a.a:float3(0));float2 uv=(float2(p)+.5f)/float2(output.get_width(),output.get_height());float weight=dy_skinWeight(encoded,encoded,u)*dyToolCoverage(uv,encoded,masks,h,3)*clamp(u.skinProtection.y*.01f,0.f,1.f);float gray=dot(b.a>0?b.rgb/b.a:float3(0),float3(.2126,.7152,.0722));float3 color=mix(float3(gray*.3f),float3(1,.15f,.04f),weight*.85f);output.write(float4(color*b.a,b.a),p); +} diff --git a/大鱼调色/Plugin/DYInspector.mm b/大鱼调色/Plugin/DYInspector.mm index ad287f6..ec8ab1d 100644 --- a/大鱼调色/Plugin/DYInspector.mm +++ b/大鱼调色/Plugin/DYInspector.mm @@ -217,7 +217,7 @@ static NSArray *DYPresentationSections(void) { for(NSString *key in @[@"temperature",@"tint",@"exposure",@"contrast",@"highlights",@"shadows",@"whites",@"blacks",@"texture",@"clarity",@"dehaze",@"vibrance",@"saturation",@"skinEnabled",@"copyAutoGrade"]){NSDictionary*d=byKey[key];if(d)[rows addObject:d];} base[@"rows"]=rows;base[@"extraEnabled"]=bySection[@"color"][@"enabled"]; base[@"title"]=@"基础调整"; - return @[primary,bySection[@"spider"],base,bySection[@"skin"],bySection[@"look"],bySection[@"hsl"],bySection[@"curve"],bySection[@"grading"],bySection[@"primaries"],bySection[@"levels"],bySection[@"blackwhite"],bySection[@"balance"],bySection[@"mixer"],bySection[@"film"]]; + return @[primary,bySection[@"spider"],base,bySection[@"skin"],bySection[@"look"],bySection[@"hsl"],bySection[@"curve"],bySection[@"grading"],bySection[@"primaries"],bySection[@"levels"],bySection[@"blackwhite"],bySection[@"balance"],bySection[@"mixer"],bySection[@"film"],bySection[@"lens"]]; } @@ -527,6 +527,7 @@ static NSImage *DYWheelImage(void) { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(modelChanged:) name:@"DYModelChanged" object:_manager]; [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(themeChanged:) name:DYThemeDidChange object:nil]; [NSWorkspace.sharedWorkspace.notificationCenter addObserver:self selector:@selector(themeChanged:) name:NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification object:nil]; + if(!_embedded)[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(revealViewerTool:) name:@"DYViewerToolRequested" object:_manager]; if(!_embedded)[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(openWorkspace:) name:@"DYColorWorkspaceRequested" object:_manager]; if(_renderer)[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(previewChanged:) name:@"DYPreviewDidChange" object:_renderer]; [self themeChanged:nil]; @@ -708,7 +709,7 @@ static NSImage *DYWheelImage(void) { } for(NSView *row in body)if(![ordered containsObject:row])row.hidden=YES;body=ordered; } - NSMutableDictionary *record=[NSMutableDictionary dictionaryWithDictionary:@{@"section":section,@"view":card,@"header":header,@"enabled":enabled,@"reset":reset,@"body":body,@"collapsed":@(![@[@"primary",@"spider",@"base"]containsObject:key])}]; + NSMutableDictionary *record=[NSMutableDictionary dictionaryWithDictionary:@{@"section":section,@"view":card,@"header":header,@"enabled":enabled,@"reset":reset,@"body":body,@"collapsed":@YES}]; if([key isEqual:@"look"]){NSButton *add=DYButton(@"+",self,@selector(addLook:));add.bordered=NO;add.font=[NSFont boldSystemFontOfSize:20];add.accessibilityLabel=@"添加风格 LUT";[card addSubview:add];record[@"add"]=add;} id host=_embedded?[(DYToolManager*)_manager host]:_manager; NSString *nodeID=_embedded?[(DYToolManager*)_manager nodeID]:[@"base:" stringByAppendingString:key]; @@ -852,7 +853,11 @@ static NSImage *DYWheelImage(void) { for(NSView *row in c[@"body"])row.alphaValue=enabled?1:.45; } id maskHost=_embedded?[(DYToolManager*)_manager host]:_manager;NSDictionary *tools=DYReadTools(maskHost,t).document;for(NSDictionary *card in _cards){ - BOOL removed=!_embedded&&DYBaseToolRemoved(tools,card[@"section"][@"key"]);groupingChanged|=[card[@"removed"]boolValue]!=removed;((NSMutableDictionary *)card)[@"removed"]=@(removed); + NSString *type=card[@"section"][@"key"];BOOL visible=YES; + if(!_embedded){DYInspectorToken *token=nil;[get getCustomParameterValue:&token fromParameter:DYInspectorParameterID atTime:t];visible=[@[@"primary",@"base",@"spider",@"hsl"]containsObject:type]||[token.folds[[@"visible:" stringByAppendingString:type]]boolValue]; + if(!visible){for(NSDictionary*d in DYBaseToolDescriptors(type)){double value=[d[@"default"]doubleValue];[get getFloatValue:&value fromParameter:[d[@"pid"]unsignedIntValue]atTime:t];if(std::isfinite(value)&&fabs(value-[d[@"default"]doubleValue])>1e-6){visible=YES;break;}}if([tools[@"baseMasks"][type]count])visible=YES;if([type isEqual:@"look"]&&DYReadAssets(_manager,t).paths.count)visible=YES;} + } + BOOL removed=!_embedded&&(DYBaseToolRemoved(tools,type)||!visible);groupingChanged|=[card[@"removed"]boolValue]!=removed;((NSMutableDictionary *)card)[@"removed"]=@(removed); [card[@"maskPanel"]refreshWithDocument:tools time:t]; NSString *nodeID=_embedded?[(DYToolManager*)_manager nodeID]:[@"base:" stringByAppendingString:card[@"section"][@"key"]];NSUInteger count=[DYMasksForTool(tools,nodeID) count]; [(DYMaskCountBadge*)card[@"maskBadge"]setCount:count];NSString *hint=count?[NSString stringWithFormat:@"已有 %lu 个蒙版;点击添加独立蒙版",(unsigned long)count]:@"添加本工具的独立蒙版"; diff --git a/大鱼调色/Plugin/DYModel.mm b/大鱼调色/Plugin/DYModel.mm index 98937da..7c11fba 100644 --- a/大鱼调色/Plugin/DYModel.mm +++ b/大鱼调色/Plugin/DYModel.mm @@ -136,7 +136,7 @@ static void initialize(){static dispatch_once_t once;dispatch_once(&once,^{ section(@"spider",@"蜘蛛盘校色仪",offsetof(DYUniforms,spiderSectionEnabled),@[scalar(@"spiderMix",@"蜘蛛盘混合",offsetof(DYUniforms,spiderMix),0,1,1)]); section(@"base",@"基础调色",136,[[[base subarrayWithRange:NSMakeRange(0,6)]arrayByAddingObjectsFromArray:[base subarrayWithRange:NSMakeRange(10,3)]]arrayByAddingObject:copyAuto],1); section(@"color",@"白平衡与颜色",140,@[base[6],base[7],base[9],base[8]],1); - section(@"skin",@"肤色保护",464,@[scalar(@"skinStrength",@"保护程度",468,0,100,60),scalar(@"skinHue",@"肤色色相",472,0,60,28)],1); + section(@"skin",@"肤色保护",464,@[scalar(@"skinStrength",@"保护程度",468,0,100,60),scalar(@"skinHue",@"肤色色相",472,0,60,28),row(@"skinFaceOnly",@"仅保护人脸肤色",offsetof(DYUniforms,skinFaceOnly),0,1,1,@"bool"),row(@"skinVisualize",@"显示肤色保护区域",offsetof(DYUniforms,skinVisualize),0,1,0,@"bool")],1); NSMutableArray*look=[NSMutableArray arrayWithObject:scalar(@"postLUTStrength",@"风格 1 强度",60,0,1,1)]; for(int i=0;i<4;i++){[look addObject:row([NSString stringWithFormat:@"look%dEnabled",i+2],[NSString stringWithFormat:@"风格 %d 启用",i+2],160+i*4,0,1,1,@"bool")];[look addObject:scalar([NSString stringWithFormat:@"look%dStrength",i+2],[NSString stringWithFormat:@"风格 %d 强度",i+2],64+i*4,0,1,1)];} section(@"look",@"风格 LUT",144,look); @@ -189,6 +189,7 @@ static void initialize(){static dispatch_once_t once;dispatch_once(&once,^{ [descriptors replaceObjectAtIndex:descriptors.count-1 withObject:printLook];[film addObject:printLook]; NSMutableDictionary *printStrength=[[row(@"filmPrintStrength",@"印片强度",offsetof(DYUniforms,filmPrint)+sizeof(float),0,1,1,@"float")mutableCopy]autorelease];printStrength[@"filmTab"]=@5;[descriptors replaceObjectAtIndex:descriptors.count-1 withObject:printStrength];[film addObject:printStrength]; section(@"film",@"胶片模拟",offsetof(DYUniforms,film)+offsetof(DYFilmSettings,enabled),film); + section(@"lens",@"镜头畸变修复",offsetof(DYUniforms,lensSectionEnabled),@[scalar(@"lensStrength",@"畸变校正",offsetof(DYUniforms,lensStrength),-100,100,0),scalar(@"lensScale",@"画面缩放",offsetof(DYUniforms,lensScale),1,2,1),scalar(@"lensCenterX",@"光学中心 X",offsetof(DYUniforms,lensCenterX),0,1,.5),scalar(@"lensCenterY",@"光学中心 Y",offsetof(DYUniforms,lensCenterY),0,1,.5)]); #undef FR #undef FE });} diff --git a/大鱼调色/Plugin/DYPlugIn.mm b/大鱼调色/Plugin/DYPlugIn.mm index 012ab5b..6d2a46c 100644 --- a/大鱼调色/Plugin/DYPlugIn.mm +++ b/大鱼调色/Plugin/DYPlugIn.mm @@ -30,7 +30,7 @@ - (NSView*)createViewForParameterID:(UInt32)pid{[self scheduleToolCanvasRegistration];return pid==DYInspectorParameterID?[[DYInspector alloc]initWithAPIManager:_apiManager renderer:_renderer]:[[NSView alloc]initWithFrame:NSZeroRect];} - (BOOL)parameterChanged:(UInt32)pid atTime:(CMTime)t error:(NSError**)e{if(pid==DYToolsParameterID)[self adoptToolCanvasDocument:DYReadTools(_apiManager,t).document];if(pid==DYToolsParameterID||pid==2013||pid==2014||(pid>=2236&&pid<2400)||pid==DYAssetsParameterID)[_renderer invalidatePreview];dispatch_async(dispatch_get_main_queue(),^{[NSNotificationCenter.defaultCenter postNotificationName:DYModelChanged object:self.apiManager];});return YES;} - (BOOL)pluginState:(NSData**)state atTime:(CMTime)t quality:(FxQuality)q error:(NSError**)e{ - DYUniforms u;DYReadUniforms(_apiManager,t,&u);CMTime frameDuration=kCMTimeInvalid,origin=kCMTimeZero;idtiming=[_apiManager apiForProtocol:@protocol(FxTimingAPI_v4)];if([timing respondsToSelector:@selector(frameDuration:)])[timing frameDuration:&frameDuration];if([timing respondsToSelector:@selector(startTimeForEffect:)])[timing startTimeForEffect:&origin];int64_t frame=DYFilmFrameIndex(t,frameDuration,origin);u.filmFrameKey=DYFilmFrameKey(frame,u.film.grainHold,u.film.grainSeed);DYAssetState*a=DYReadAssets(_apiManager,t);DYToolDocument *tools=DYReadTools(_apiManager,t);[self adoptToolCanvasDocument:tools.document];[_viewerParameterBridge publishUniforms:&u document:tools.document atTime:t];double copyAuto=0;[[_apiManager apiForProtocol:@protocol(FxParameterRetrievalAPI_v6)]getFloatValue:©Auto fromParameter:8800 atTime:t];NSMutableDictionary *snapshot=DYMutablePlist(DYToolRenderSnapshot(tools.document,t));for(NSMutableDictionary *node in snapshot[@"layers"]){DYUniforms layer=DYToolUniforms(node);if([node[@"type"]isEqual:@"film"])node[@"filmFrameKey"]=@(DYFilmFrameKey(frame,layer.film.grainHold,layer.film.grainSeed));}NSInteger primaries=-1;idgamut=[_apiManager apiForProtocol:@protocol(FxColorGamutAPI_v2)];if([gamut respondsToSelector:@selector(colorPrimaries)])primaries=gamut.colorPrimaries;NSDictionary*s=@{@"colorManagement":a.colorManagement?:@{},@"hostPrimaries":@(primaries),@"schema":@2,@"tools":snapshot,@"copyAuto":@(copyAuto>.5),@"uniforms":[NSData dataWithBytes:&u length:sizeof(u)],@"paths":a.paths?:@{},@"spider":a.spiderMesh?:[NSData data]};*state=[NSPropertyListSerialization dataWithPropertyList:s format:NSPropertyListBinaryFormat_v1_0 options:0 error:e];return *state!=nil; + DYUniforms u;DYReadUniforms(_apiManager,t,&u);CMTime frameDuration=kCMTimeInvalid,origin=kCMTimeZero;idtiming=[_apiManager apiForProtocol:@protocol(FxTimingAPI_v4)];if([timing respondsToSelector:@selector(frameDuration:)])[timing frameDuration:&frameDuration];if([timing respondsToSelector:@selector(startTimeForEffect:)])[timing startTimeForEffect:&origin];int64_t frame=DYFilmFrameIndex(t,frameDuration,origin);u.filmFrameKey=DYFilmFrameKey(frame,u.film.grainHold,u.film.grainSeed);DYAssetState*a=DYReadAssets(_apiManager,t);DYToolDocument *tools=DYReadTools(_apiManager,t);[self adoptToolCanvasDocument:tools.document];[_viewerParameterBridge publishUniforms:&u document:tools.document atTime:t];[_viewerParameterBridge publishAssets:a histogram:[_renderer histogram] atTime:t];double copyAuto=0;[[_apiManager apiForProtocol:@protocol(FxParameterRetrievalAPI_v6)]getFloatValue:©Auto fromParameter:8800 atTime:t];NSMutableDictionary *snapshot=DYMutablePlist(DYToolRenderSnapshot(tools.document,t));for(NSMutableDictionary *node in snapshot[@"layers"]){DYUniforms layer=DYToolUniforms(node);if([node[@"type"]isEqual:@"film"])node[@"filmFrameKey"]=@(DYFilmFrameKey(frame,layer.film.grainHold,layer.film.grainSeed));}NSInteger primaries=-1;idgamut=[_apiManager apiForProtocol:@protocol(FxColorGamutAPI_v2)];if([gamut respondsToSelector:@selector(colorPrimaries)])primaries=gamut.colorPrimaries;NSDictionary*s=@{@"colorManagement":a.colorManagement?:@{},@"hostPrimaries":@(primaries),@"schema":@2,@"tools":snapshot,@"copyAuto":@(copyAuto>.5),@"uniforms":[NSData dataWithBytes:&u length:sizeof(u)],@"paths":a.paths?:@{},@"spider":a.spiderMesh?:[NSData data]};*state=[NSPropertyListSerialization dataWithPropertyList:s format:NSPropertyListBinaryFormat_v1_0 options:0 error:e];return *state!=nil; } - (BOOL)destinationImageRect:(FxRect*)rect sourceImages:(NSArray*)src destinationImage:(FxImageTile*)dst pluginState:(NSData*)s atTime:(CMTime)t error:(NSError**)e{if(!src.count)return NO;*rect=src[0].imagePixelBounds;return YES;} - (BOOL)sourceTileRect:(FxRect*)rect sourceImageIndex:(NSUInteger)i sourceImages:(NSArray*)src destinationTileRect:(FxRect)dstRect destinationImage:(FxImageTile*)dst pluginState:(NSData*)s atTime:(CMTime)t error:(NSError**)e{if(i>=src.count)return NO;*rect=src[i].imagePixelBounds;return YES;} diff --git a/大鱼调色/Plugin/DYRenderer.mm b/大鱼调色/Plugin/DYRenderer.mm index 37bd33d..e69c348 100644 --- a/大鱼调色/Plugin/DYRenderer.mm +++ b/大鱼调色/Plugin/DYRenderer.mm @@ -11,6 +11,8 @@ #include "DYToolGPU.h" #include "DYFilmMath.h" #import +#import +#import #import #import "DYColorTables.h" #import "DYLUTLibrary.h" @@ -112,7 +114,7 @@ static NSArray *DYPrimaryActiveFinishing(DYUniforms u,NSDictionary *paths,NSData CFTimeInterval _lastPreview; BOOL _exporting; NSDictionary *_toolDocument,*_colorContext,*_exportManagedState; - BOOL _managedFinishing; + BOOL _managedFinishing;NSData *_faceEntries;CIContext *_faceContext; dispatch_queue_t _scopeQueue; BOOL _scopeEnabled,_scopeWorkerRunning; NSUInteger _scopeGeneration; @@ -127,9 +129,10 @@ static NSArray *DYPrimaryActiveFinishing(DYUniforms u,NSDictionary *paths,NSData #include "DYFilmRender.inc.h" #include "DYPrimaryRender.inc.h" #include "DYManagedRender.inc.h" +#include "DYFaceRender.inc.h" #include "DYToolRender.inc.h" - (instancetype)init{if((self=[super init])){_previewLock=[NSObject new];_scopeQueue=dispatch_queue_create("com.dayu.color.final-output-scopes",DISPATCH_QUEUE_SERIAL);_devices=[NSMutableDictionary new];_luts=[NSMutableDictionary new];_preparedLUTs=[NSMutableDictionary new];_activeLUTPaths=[NSSet new];_lutPreparationQueue=dispatch_queue_create("com.dayu.color.lut-upload",DISPATCH_QUEUE_SERIAL);dispatch_set_target_queue(_lutPreparationQueue,dispatch_get_global_queue(QOS_CLASS_USER_INITIATED,0));_tables=[DYColorTables new];}return self;} -- (void)dealloc{[_scopePending release];[_scopePreview release];[_scopeMetadata release];[_scopeProfile release];dispatch_release(_scopeQueue);[_devices release];[_luts release];[_preparedLUTs release];[_activeLUTPaths release];dispatch_release(_lutPreparationQueue);[_tables release];[_preview release];[_lookLUTPreview release];[_histogram release];[_colorContext release];[_previewLock release];[super dealloc];} +- (void)dealloc{[_faceEntries release];[_faceContext release];[_scopePending release];[_scopePreview release];[_scopeMetadata release];[_scopeProfile release];dispatch_release(_scopeQueue);[_devices release];[_luts release];[_preparedLUTs release];[_activeLUTPaths release];dispatch_release(_lutPreparationQueue);[_tables release];[_preview release];[_lookLUTPreview release];[_histogram release];[_colorContext release];[_previewLock release];[super dealloc];} - (void)trimPreparedLUTsKeeping:(NSString *)path { if(_preparedLUTs.count<=12)return; for(NSString *key in _preparedLUTs.allKeys)if(![_activeLUTPaths containsObject:key]&&![key isEqualToString:path])[_preparedLUTs removeObjectForKey:key]; @@ -163,7 +166,7 @@ static NSArray *DYPrimaryActiveFinishing(DYUniforms u,NSDictionary *paths,NSData NSURL*url=[[NSBundle bundleForClass:self.class]URLForResource:@"default" withExtension:@"metallib"]; idlib=[d newLibraryWithURL:url error:err];if(!lib){[d release];return nil;} idq=[d newCommandQueue];entry=[NSMutableDictionary dictionaryWithDictionary:@{@"device":d,@"library":lib,@"queue":q,@"pipelines":[NSMutableDictionary dictionary]}]; - for(NSString*fn in @[@"dyUnpremultiply",@"dyWhitesSceneStatistics",@"dyLUTExportKernel",@"dyInputAnalysis",@"dyScopeSample",@"dyColorManagement",@"dyToolBlend",@"dyToolSkin",@"dyFilmPoint",@"dyFilmNoise",@"dyFilmSparseBlur",@"dyFilmBloomEdges",@"dyFilmMix",@"dyFilmPrint"]){idf=[lib newFunctionWithName:fn];if(!f){fail(err,[fn stringByAppendingString:@" 缺失"]);[lib release];[q release];[d release];return nil;}uint64_t pipelineSpan=DYBetaSpanBegin(@"gpu_pipeline",@{@"pipeline":fn,@"gpu":d.name?:@"unknown"});idp=[d newComputePipelineStateWithFunction:f error:err];DYBetaSpanEnd(pipelineSpan,@{@"status":p?@"passed":@"failed"});[f release];if(!p){[lib release];[q release];[d release];return nil;}entry[fn]=p;[p release];} + for(NSString*fn in @[@"dyLensRepair",@"dySkinOverlay",@"dyUnpremultiply",@"dyWhitesSceneStatistics",@"dyLUTExportKernel",@"dyInputAnalysis",@"dyScopeSample",@"dyColorManagement",@"dyToolBlend",@"dyToolSkin",@"dyFilmPoint",@"dyFilmNoise",@"dyFilmSparseBlur",@"dyFilmBloomEdges",@"dyFilmMix",@"dyFilmPrint"]){idf=[lib newFunctionWithName:fn];if(!f){fail(err,[fn stringByAppendingString:@" 缺失"]);[lib release];[q release];[d release];return nil;}uint64_t pipelineSpan=DYBetaSpanBegin(@"gpu_pipeline",@{@"pipeline":fn,@"gpu":d.name?:@"unknown"});idp=[d newComputePipelineStateWithFunction:f error:err];DYBetaSpanEnd(pipelineSpan,@{@"status":p?@"passed":@"failed"});[f release];if(!p){[lib release];[q release];[d release];return nil;}entry[fn]=p;[p release];} float identity[32];for(int z=0;z<2;z++)for(int y=0;y<2;y++)for(int x=0;x<2;x++){int i=((z*2+y)*2+x)*4;identity[i]=x;identity[i+1]=y;identity[i+2]=z;identity[i+3]=1;}idneutral=texture3D(d,identity,2);if(!neutral){fail(err,@"无法分配中性 LUT");return nil;}entry[@"identity"]=neutral; // Preparing before the first frame may use registry 0. Reuse those pipelines // when the host subsequently supplies that device's actual registry ID. @@ -214,7 +217,7 @@ static NSArray *DYPrimaryActiveFinishing(DYUniforms u,NSDictionary *paths,NSData } if([e[@"spiderActive"]boolValue]){spiderBuffer=e[@"spiderBuffer"];spiderSize={ [e[@"spiderHues"]intValue],[e[@"spiderRings"]intValue]};} } - DYToolMaskHeader maskHeader{};idmaskBuffer=(masks.count||segmented)?[self maskBuffer:masks tile:src device:d header:&maskHeader]:nil;BOOL hasMasks=maskHeader.count>0;if((hasMasks||segmented)&&!maskBuffer)return fail(err,@"无法分配蒙版缓冲区"); + DYToolMaskHeader maskHeader{};idmaskBuffer=(masks.count||segmented||u.skinFaceOnly>.5||_faceEntries.length)?[self maskBuffer:masks tile:src device:d header:&maskHeader]:nil;maskHeader.faceOnly=u.skinFaceOnly>.5;BOOL hasMasks=maskHeader.count>0||maskHeader.faceOnly;if((hasMasks||segmented)&&!maskBuffer)return fail(err,@"无法分配蒙版缓冲区"); NSMutableDictionary*ps=e[@"pipelines"];NSString*format=[NSString stringWithFormat:@"%lu-%d-%d",(unsigned long)output.pixelFormat,hasMasks,segmented];idpipeline=ps[format];if(!pipeline){MTLRenderPipelineDescriptor*p=[MTLRenderPipelineDescriptor new];p.vertexFunction=[e[@"library"]newFunctionWithName:@"dyVertex"];p.fragmentFunction=[e[@"library"]newFunctionWithName:segmented?@"dySegmentFragment":hasMasks?@"dyMaskedFragment":@"dyFragment"];p.colorAttachments[0].pixelFormat=output.pixelFormat;pipeline=[d newRenderPipelineStateWithDescriptor:p error:err];[p.vertexFunction release];[p.fragmentFunction release];[p release];if(!pipeline)return NO;ps[format]=pipeline;[pipeline release];} MTLTextureDescriptor*td=[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA16Float width:input.width height:input.height mipmapped:NO];td.storageMode=MTLStorageModePrivate;td.usage=MTLTextureUsageShaderRead|MTLTextureUsageShaderWrite;idstraight=[d newTextureWithDescriptor:td];if(!straight)return fail(err,@"无法分配调色缓冲区"); idcb=[e[@"queue"]commandBuffer];idce=[cb computeCommandEncoder];[ce setComputePipelineState:e[@"dyUnpremultiply"]];[ce setTexture:input atIndex:0];[ce setTexture:straight atIndex:1];[ce dispatchThreads:MTLSizeMake(input.width,input.height,1) threadsPerThreadgroup:MTLSizeMake(16,16,1)];[ce endEncoding]; diff --git a/大鱼调色/Plugin/DYToolGPU.h b/大鱼调色/Plugin/DYToolGPU.h index eaf013c..b824cea 100644 --- a/大鱼调色/Plugin/DYToolGPU.h +++ b/大鱼调色/Plugin/DYToolGPU.h @@ -1,5 +1,5 @@ #pragma once #include "MaskCore/DYMaskOperator.h" struct DYToolMaskEntry {DYResolvedMask mask;int section,combine;}; -struct DYToolMaskHeader {unsigned count;float offsetX,offsetY,scaleX,scaleY;int section,premultiplied;}; +struct DYToolMaskHeader {unsigned count;float offsetX,offsetY,scaleX,scaleY;int section,premultiplied,faceOnly;}; struct DYToolStageRange {int first,last,suppressBlackWhite;}; diff --git a/大鱼调色/Plugin/DYToolInspector.inc.h b/大鱼调色/Plugin/DYToolInspector.inc.h index 4e56d2b..c33aeb5 100644 --- a/大鱼调色/Plugin/DYToolInspector.inc.h +++ b/大鱼调色/Plugin/DYToolInspector.inc.h @@ -14,6 +14,11 @@ if(sender.tag<0||sender.tag>=_cards.count)return;idhost=_embedded?[(DYToolManager*)_manager host]:_manager;ida=[host apiForProtocol:@protocol(FxCustomParameterActionAPI_v4)];if(!a)return;[a startAction:self]; NSString *addedID=nil;@try{NSMutableDictionary *doc=DYMutablePlist(DYReadTools(host,a.currentTime).document);if([doc[@"layers"]count]>=DYToolLimit){[self showError:@"最多可添加 32 个独立工具层。"];return;}NSString *type=_cards[sender.tag][@"section"][@"key"],*anchor=_embedded?[(DYToolManager*)_manager nodeID]:[@"base:" stringByAppendingString:type];NSMutableDictionary *node=(id)DYInsertTool(doc,type,anchor);if(!node)return;if(DYPrimaryColorState(DYReadAssets(host,a.currentTime).colorManagement)){DYUniforms root;DYReadUniforms(host,a.currentTime,&root);DYSeedPrimaryWorkingSpace(node,root.cm.workingTransfer,root.cm.workingGamut);}addedID=[node[@"id"]copy];idundo=[host apiForProtocol:@protocol(FxUndoAPI)];[undo startUndoGroup:@"再加一层初始化工具"];DYWriteTools(host,doc,a.currentTime);[undo endUndoGroup];}@finally{[a endAction:self];}[NSNotificationCenter.defaultCenter postNotificationName:DYModelChanged object:host userInfo:@{@"scrollToTool":addedID?:@""}];[addedID release]; } +- (void)revealViewerTool:(NSNotification*)note { + if(_embedded||![DYToolTypes()containsObject:note.userInfo[@"type"]])return;NSString *type=note.userInfo[@"type"];ida=[self actionAPI];[a startAction:self];@try{DYInspectorToken *old=nil;[[_manager apiForProtocol:@protocol(FxParameterRetrievalAPI_v6)]getCustomParameterValue:&old fromParameter:DYInspectorParameterID atTime:a.currentTime];DYInspectorToken *token=old?[[old copy]autorelease]:[[[DYInspectorToken alloc]init]autorelease];NSMutableDictionary *folds=[[token.folds mutableCopy]autorelease];folds[[@"visible:" stringByAppendingString:type]]=@YES;token.folds=folds;[[_manager apiForProtocol:@protocol(FxParameterSettingAPI_v6)]setCustomParameterValue:token toParameter:DYInspectorParameterID atTime:a.currentTime]; + NSMutableDictionary *doc=DYMutablePlist(DYReadTools(_manager,a.currentTime).document);if(DYBaseToolRemoved(doc,type)){BOOL existing=NO;for(NSDictionary*n in doc[@"layers"])if([n[@"type"]isEqual:type])existing=YES;if(!existing){idundo=[_manager apiForProtocol:@protocol(FxUndoAPI)];if([undo startUndoGroup:@"添加画布工具"]){DYInsertTool(doc,type,[@"base:" stringByAppendingString:type]);DYWriteTools(_manager,doc,a.currentTime);[undo endUndoGroup];}}} + }@finally{[a endAction:self];}[self refresh];[self setNeedsLayout:YES]; +} - (void)addModule:(NSMenuItem *)sender{ if(_embedded)return;NSString *type=sender.representedObject;for(NSUInteger i=0;i<_cards.count;i++)if([_cards[i][@"section"][@"key"]isEqual:type]){NSButton *source=[[[NSButton alloc]init]autorelease];source.tag=i;[self repeatTool:source];return;} } diff --git a/大鱼调色/Plugin/DYToolRender.inc.h b/大鱼调色/Plugin/DYToolRender.inc.h index fe49c77..b159bfc 100644 --- a/大鱼调色/Plugin/DYToolRender.inc.h +++ b/大鱼调色/Plugin/DYToolRender.inc.h @@ -7,7 +7,7 @@ h->premultiplied=1; for(NSString *type in groups){NSInteger section=[DYToolTypes()indexOfObject:type];if(section==NSNotFound)continue; for(NSDictionary *m in groups[type]){if(![m[@"enabled"]boolValue])continue;DYToolMaskEntry entry{};entry.section=(int)section;entry.combine=[m[@"combine"]intValue];[m[@"parameters"]getBytes:&entry.mask.parameters length:sizeof(DYMaskParameters)];entry.mask.parameters.imageAspect=w/ht;NSData *nodes=m[@"nodes"];entry.mask.path=dyFlattenMask((const DYBezierNode*)nodes.bytes,nodes.length/sizeof(DYBezierNode));entries.push_back(entry);} - }h->count=(unsigned)entries.size();if(entries.empty())entries.push_back({});return [[device newBufferWithBytes:entries.data() length:entries.size()*sizeof(DYToolMaskEntry) options:MTLResourceStorageModeShared]autorelease]; + }if(_faceEntries.length){const DYToolMaskEntry *faces=(const DYToolMaskEntry*)_faceEntries.bytes;entries.insert(entries.end(),faces,faces+_faceEntries.length/sizeof(DYToolMaskEntry));}h->count=(unsigned)entries.size();if(entries.empty())entries.push_back({});return [[device newBufferWithBytes:entries.data() length:entries.size()*sizeof(DYToolMaskEntry) options:MTLResourceStorageModeShared]autorelease]; } - (void)encodeBlend:(id)before after:(id)after output:(id)output masks:(id)masks header:(DYToolMaskHeader)h entry:(NSDictionary*)entry commands:(id)commands { idencoder=[commands computeCommandEncoder];[encoder setComputePipelineState:entry[@"dyToolBlend"]];[encoder setTexture:before atIndex:0];[encoder setTexture:after atIndex:1];[encoder setTexture:output atIndex:2];[encoder setBuffer:masks offset:0 atIndex:0];[encoder setBytes:&h length:sizeof(h) atIndex:1];[encoder dispatchThreads:MTLSizeMake(output.width,output.height,1) threadsPerThreadgroup:MTLSizeMake(16,16,1)];[encoder endEncoding]; @@ -31,21 +31,22 @@ BOOL found=NO;float low=1,high=1;for(NSDictionary *mask in node[@"masks"]){if(![mask[@"enabled"]boolValue])continue;DYMaskParameters p=DYMaskAtTime(mask,kCMTimeInvalid);float a=0,b=p.strength==0?0:1;NSInteger combine=[mask[@"combine"]integerValue];if(!found){low=combine==1?1-b:a;high=combine==1?1-a:b;found=YES;}else if(combine==1){low*=1-b;high*=1-a;}else if(combine==2){low*=a;high*=b;}else{low=1-(1-low)*(1-a);high=1-(1-high)*(1-b);}} if(found&&high==0)return [self copyTile:source to:destination entry:entry error:error]; DYUniforms layer=DYToolUniforms(node);NSString *type=node[@"type"]; + if([type isEqual:@"lens"])return [self renderLens:source destination:destination uniforms:layer masks:node[@"masks"] entry:entry error:error]; if([type isEqual:@"mixer"]||[type isEqual:@"film"]){layer.filmFrameKey=[node[@"filmFrameKey"]unsignedIntValue];return [self renderFilmTool:type source:source destination:destination uniforms:layer masks:node[@"masks"] entry:entry error:error];} if(![type isEqual:@"skin"])return [self renderLegacy:source destination:destination uniforms:layer paths:node[@"paths"] spider:node[@"spider"] masks:@{type:node[@"masks"]} error:error]; idd=entry[@"device"];idbefore=[source metalTextureForDevice:d],input=[original metalTextureForDevice:d],after=[destination metalTextureForDevice:d]; idcb=[entry[@"queue"]commandBuffer];idce=[cb computeCommandEncoder];[ce setComputePipelineState:entry[@"dyToolSkin"]];[ce setTexture:before atIndex:0];[ce setTexture:input atIndex:1];[ce setTexture:after atIndex:2];[ce setBytes:&layer length:sizeof(layer) atIndex:0];[ce dispatchThreads:MTLSizeMake(after.width,after.height,1) threadsPerThreadgroup:MTLSizeMake(16,16,1)];[ce endEncoding];[cb commit];[cb waitUntilCompleted];if(cb.status!=MTLCommandBufferStatusCompleted)return fail(error,cb.error.localizedDescription); - if(![node[@"masks"]count])return YES; + if(![node[@"masks"]count]&&layer.skinFaceOnly<.5)return YES; MTLTextureDescriptor *desc=[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA16Float width:after.width height:after.height mipmapped:NO];desc.storageMode=MTLStorageModePrivate;desc.usage=MTLTextureUsageRenderTarget|MTLTextureUsageShaderRead|MTLTextureUsageShaderWrite;idblend=[d newTextureWithDescriptor:desc];if(!blend)return fail(error,@"无法分配新增工具蒙版缓冲区"); - DYToolMaskHeader h{};h.section=3;idbuffer=[self maskBuffer:@{type:node[@"masks"]} tile:source device:d header:&h];cb=[entry[@"queue"]commandBuffer];[self encodeBlend:before after:after output:blend masks:buffer header:h entry:entry commands:cb];[cb commit];[cb waitUntilCompleted];BOOL ok=cb.status==MTLCommandBufferStatusCompleted; + DYToolMaskHeader h{};h.section=3;h.faceOnly=layer.skinFaceOnly>.5;idbuffer=[self maskBuffer:@{type:node[@"masks"]} tile:source device:d header:&h];cb=[entry[@"queue"]commandBuffer];[self encodeBlend:before after:after output:blend masks:buffer header:h entry:entry commands:cb];[cb commit];[cb waitUntilCompleted];BOOL ok=cb.status==MTLCommandBufferStatusCompleted; DYExportTile *blended=[[DYExportTile alloc]initWithTexture:blend registry:d.registryID];[blended setBounds:source.tilePixelBounds origin:source.imageOrigin];[blended setPixelAspect:source.pixelAspect];[blend release];if(ok)ok=[self copyTile:blended to:destination entry:entry error:error];else fail(error,cb.error.localizedDescription);[blended release];return ok; } -- (BOOL)renderSource:(FxImageTile*)src destination:(FxImageTile*)dst uniforms:(DYUniforms)u paths:(NSDictionary*)paths spider:(NSData*)spider tools:(NSDictionary*)tools error:(NSError**)error {@synchronized(self){return DYRenderWithPool(error,[&]()->BOOL{ +- (BOOL)renderToolsSource:(FxImageTile*)src destination:(FxImageTile*)dst uniforms:(DYUniforms)u paths:(NSDictionary*)paths spider:(NSData*)spider tools:(NSDictionary*)tools error:(NSError**)error {@synchronized(self){return DYRenderWithPool(error,[&]()->BOOL{ if(!tools)tools=@{@"schema":@1,@"layers":@[],@"baseMasks":@{}};if(!DYValidToolDocument(tools))return fail(error,@"工具或蒙版数据损坏,未更改原工程"); DYApplyRemovedBaseTools(&u,tools);paths=DYVisibleBaseToolPaths(paths,tools);if(DYBaseToolRemoved(tools,@"spider"))spider=nil; NSArray *layers=tools[@"layers"];BOOL active=NO,anchored=NO;for(NSDictionary *node in layers)if(!DYToolIsNeutral(node)){active=YES;anchored|=![DYToolRootAnchor(tools,node[@"id"])isEqual:@"tail"];} // No active extra tool keeps the exact historical fused path, including HDR. - if(!active&&!DYChannelMixerActive(u)&&!DYFilmToolActive(u))return [self renderLegacy:src destination:dst uniforms:u paths:paths spider:spider masks:tools[@"baseMasks"] error:error]; + if(!active&&!DYChannelMixerActive(u)&&!DYFilmToolActive(u)&&u.lensSectionEnabled<.5)return [self renderLegacy:src destination:dst uniforms:u paths:paths spider:spider masks:tools[@"baseMasks"] error:error]; NSMutableDictionary *entry=[self device:dst.deviceRegistryID error:error];if(!entry)return NO;idd=entry[@"device"];idinput=[src metalTextureForDevice:d];if(!input)return fail(error,@"宿主图像纹理不可用"); MTLTextureDescriptor *desc=[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA16Float width:input.width height:input.height mipmapped:NO];desc.storageMode=MTLStorageModePrivate;desc.usage=MTLTextureUsageRenderTarget|MTLTextureUsageShaderRead|MTLTextureUsageShaderWrite; DYExportTile *tile=nil,*skinReference=nil,*originalReference=nil;NSArray *order=DYToolDisplayOrder(tools);NSMutableDictionary *groups=[NSMutableDictionary dictionary];for(NSString *ID in order){NSDictionary *node=DYToolWithID(tools,ID);if(!node||DYToolIsNeutral(node))continue;NSString *root=DYToolRootAnchor(tools,ID);if(!groups[root])groups[root]=[NSMutableArray array];[groups[root]addObject:node];} @@ -91,7 +92,7 @@ if(!apply(@"base:spider"))return NO; } // New end-of-chain base tools do not move any historical color stages. - for(NSString *type in @[@"mixer",@"film"]){BOOL enabled=[type isEqual:@"mixer"]?DYChannelMixerActive(u):DYFilmToolActive(u);if(enabled){DYExportTile *next=makeTile();if(!next)return fail(error,@"无法分配胶片工具缓冲区");BOOL ok=[self renderFilmTool:type source:tile destination:next uniforms:u masks:tools[@"baseMasks"][type]?:@[] entry:entry error:error];if(!ok){[next release];return NO;}replace(next);}if(!apply([@"base:" stringByAppendingString:type]))return NO;} + for(NSString *type in @[@"mixer",@"film",@"lens"]){BOOL enabled=[type isEqual:@"lens"]?u.lensSectionEnabled>.5&&(u.lensStrength!=0||u.lensScale!=1):[type isEqual:@"mixer"]?DYChannelMixerActive(u):DYFilmToolActive(u);if(enabled){DYExportTile *next=makeTile();if(!next)return fail(error,@"无法分配胶片工具缓冲区");BOOL ok=[type isEqual:@"lens"]?[self renderLens:tile destination:next uniforms:u masks:tools[@"baseMasks"][type]?:@[] entry:entry error:error]:[self renderFilmTool:type source:tile destination:next uniforms:u masks:tools[@"baseMasks"][type]?:@[] entry:entry error:error];if(!ok){[next release];return NO;}replace(next);}if(!apply([@"base:" stringByAppendingString:type]))return NO;} // Schema 1 extra layers (and children inserted after those layers) retain // their old end-of-chain order. Saving does not silently migrate old looks. if(!apply(@"tail"))return NO;return [self copyTile:tile to:dst entry:entry error:error]; @@ -99,6 +100,7 @@ });}} - (BOOL)exportLUT:(NSURL*)url uniforms:(DYUniforms)u paths:(NSDictionary*)paths spider:(NSData*)spider tools:(NSDictionary*)tools error:(NSError**)error {@synchronized(self){ if(tools&&!DYValidToolDocument(tools))return fail(error,@"工具或蒙版数据损坏,未更改原工程");DYApplyRemovedBaseTools(&u,tools);paths=DYVisibleBaseToolPaths(paths,tools);if(DYBaseToolRemoved(tools,@"spider"))spider=nil; + if((u.lensSectionEnabled>.5&&(u.lensStrength!=0||u.lensScale!=1))||u.skinVisualize>.5)return fail(error,@"镜头修复与肤色区域显示无法保存到 Cube,请保存完整预设。");for(NSDictionary *node in tools[@"layers"]){DYUniforms layer=DYToolUniforms(node);if([node[@"type"]isEqual:@"lens"]&&!DYToolIsNeutral(node))return fail(error,@"镜头畸变属于空间处理,请保存完整预设。");} if(DYFilmToolActive(u)&&DYFilmSpatialActive(u.film))return fail(error,@"当前胶片含晕光、辉光、颗粒或暗角,无法完整保存到静态 Cube。请保存完整预设,或关闭这些处理后再导出。");for(NSDictionary *node in tools[@"layers"]){DYUniforms layer=DYToolUniforms(node);if([node[@"type"]isEqual:@"film"]&&DYFilmToolActive(layer)&&DYFilmSpatialActive(layer.film))return fail(error,@"新增胶片层含空间或时间处理,无法完整保存到静态 Cube。请保存完整预设。");} for(NSArray *masks in [tools[@"baseMasks"]allValues])if(masks.count)return fail(error,@"当前调色含空间蒙版或跟踪,Cube 无法保存这些信息。请先保存完整预设,或移除蒙版后导出。");for(NSDictionary *node in tools[@"layers"])if([node[@"masks"]count])return fail(error,@"新增工具含蒙版,无法完整导出为 Cube。请保存完整预设。"); _toolDocument=tools;BOOL ok=NO;@try{ok=[self exportLUT:url uniforms:u paths:paths spider:spider error:error];}@finally{_toolDocument=nil;}return ok; diff --git a/大鱼调色/Plugin/DYToolState.mm b/大鱼调色/Plugin/DYToolState.mm index 5ee5885..3866fde 100644 --- a/大鱼调色/Plugin/DYToolState.mm +++ b/大鱼调色/Plugin/DYToolState.mm @@ -4,7 +4,7 @@ #include #import -NSArray *DYToolTypes(void){return @[@"primary",@"spider",@"base",@"skin",@"look",@"hsl",@"curve",@"grading",@"primaries",@"levels",@"blackwhite",@"balance",@"mixer",@"film"];} +NSArray *DYToolTypes(void){return @[@"primary",@"spider",@"base",@"skin",@"look",@"hsl",@"curve",@"grading",@"primaries",@"levels",@"blackwhite",@"balance",@"mixer",@"film",@"lens"];} NSDictionary *DYToolSection(NSString *type){for(NSDictionary *s in DYSections())if([s[@"key"]isEqual:type])return s;return nil;} static NSArray *DYBaseToolParts(NSString *type){return [type isEqual:@"primary"]?@[@"input",@"primary",@"output"]:[type isEqual:@"base"]?@[@"base",@"color"]:@[type];} static NSArray *DYBuildBaseToolDescriptors(NSString *type){ diff --git a/大鱼调色/Plugin/DYUniforms.h b/大鱼调色/Plugin/DYUniforms.h index 19f7535..47aa50d 100644 --- a/大鱼调色/Plugin/DYUniforms.h +++ b/大鱼调色/Plugin/DYUniforms.h @@ -132,6 +132,9 @@ typedef struct DYUniforms { DYFilmSettings film; DYUInt filmFrameKey; // frozen render time, never an author parameter DYFloat4 filmPrint; // appended after the complete 1.5.0 prefix: look, strength, reserved, reserved + // Append-only 1.11 extension; every historical offset remains unchanged. + float lensSectionEnabled,lensStrength,lensScale,lensCenterX; + float lensCenterY,skinFaceOnly,skinVisualize,extensionReserved; } DYUniforms; typedef struct DYVertex2D { DYFloat2 position; DYFloat2 textureCoordinate; } DYVertex2D; @@ -152,7 +155,7 @@ DY_ABI_ASSERT(offsetof(DYUniforms, mixerRed) == 1104, "complete 1.4.3 prefix sta DY_ABI_ASSERT(offsetof(DYUniforms, film) == 1168, "1.5.0 film settings stay fixed"); DY_ABI_ASSERT(offsetof(DYUniforms, filmFrameKey) == 1284, "1.5.0 frozen frame key stays fixed"); DY_ABI_ASSERT(offsetof(DYUniforms, filmPrint) == 1296, "complete 1.5.0 prefix stays fixed"); -DY_ABI_ASSERT(sizeof(DYUniforms) == 1312, "1.6.0 uniform size"); +DY_ABI_ASSERT(offsetof(DYUniforms, lensSectionEnabled) == 1312, "complete 1.10 prefix stays fixed"); DY_ABI_ASSERT(offsetof(DYUniforms, exposure) == 0, "exposure offset"); DY_ABI_ASSERT(offsetof(DYUniforms, contrast) == 4, "contrast offset"); DY_ABI_ASSERT(offsetof(DYUniforms, highlights) == 8, "highlights offset"); diff --git a/大鱼调色/Plugin/DYViewerControls.inc.h b/大鱼调色/Plugin/DYViewerControls.inc.h index 39daa27..dd29c88 100644 --- a/大鱼调色/Plugin/DYViewerControls.inc.h +++ b/大鱼调色/Plugin/DYViewerControls.inc.h @@ -31,11 +31,11 @@ static const NSInteger DYViewerPartBase=20000; for(DYViewerParameterPanel*p in [[_panels copy]autorelease]){if(!p.visible){if(p==_capture){[p finishCapture];_capture=nil;}p.bridge=nil;[_panels removeObjectIdenticalTo:p];continue;}[p setViewport:v];[p prepareWithSize:size scale:s atTime:time];} if(_capture&&![_capture capturing])_capture=nil; [_areas removeAllObjects];if(!_bridge||v.size.width<100||v.size.height<80)return; - NSInteger cap=MAX(1,MIN(14,(NSInteger)floor((v.size.height-72*s)/(30*s))));if(cap<14)cap=MAX(1,MIN(13,(NSInteger)floor((v.size.height-96*s)/(30*s))));NSInteger pages=(14+cap-1)/cap;_railPage=MAX(0,_railPage)%pages; + NSInteger toolCount=DYToolTypes().count;NSInteger cap=MAX(1,MIN(toolCount,(NSInteger)floor((v.size.height-72*s)/(30*s))));if(cap1?24:0))*s); - NSArray*titles=@[@"一级",@"蜘蛛",@"基础",@"肤色",@"LUT",@"HSL",@"曲线",@"分级",@"原色",@"色阶",@"黑白",@"平衡",@"通道",@"胶片"]; - for(NSInteger j=0;j1?24:0))*s); + NSArray*titles=@[@"一级",@"蜘蛛",@"基础",@"肤色",@"LUT",@"HSL",@"曲线",@"分级",@"原色",@"色阶",@"黑白",@"平衡",@"通道",@"胶片",@"畸变"]; + for(NSInteger j=0;j1){[_areas addObject:@{@"part":@20003,@"kind":@"railPage",@"title":@"↕",@"rect":[NSValue valueWithRect:NSMakeRect(x+4*s,end-24*s,w-8*s,22*s)]}];} [_areas addObject:@{@"part":@20001,@"kind":@"workspace",@"title":@"◫",@"rect":[NSValue valueWithRect:NSMakeRect(x+4*s,end,w-8*s,26*s)]}]; [_areas addObject:@{@"part":@20002,@"kind":@"hidePanels",@"title":@"收",@"rect":[NSValue valueWithRect:NSMakeRect(x+4*s,end+27*s,w-8*s,18*s)]}]; @@ -59,7 +59,7 @@ static const NSInteger DYViewerPartBase=20000; } - (void)activateTool:(NSString*)type{ for(DYViewerParameterPanel*p in [[_panels copy]autorelease])if([p.toolType isEqual:type]){[p finishCapture];p.bridge=nil;[_panels removeObjectIdenticalTo:p];return;} - DYViewerParameterPanel*p=[[[DYViewerParameterPanel alloc]init]autorelease];p.toolType=type;p.bridge=_bridge; + [_bridge requestTool:type];DYViewerParameterPanel*p=[[[DYViewerParameterPanel alloc]init]autorelease];p.toolType=type;p.bridge=_bridge; CGFloat x=(_rail.size.width+24*_scale)/MAX(1.,_viewport.size.width),offset=(_panels.count%4)*22*_scale; [p setInitialPosition:NSMakePoint(x+offset/MAX(1.,_viewport.size.width),(8*_scale+offset)/MAX(1.,_viewport.size.height))];[_panels addObject:p]; } diff --git a/大鱼调色/Plugin/DYViewerGraphics.inc.h b/大鱼调色/Plugin/DYViewerGraphics.inc.h index fd80156..b3dd3bc 100644 --- a/大鱼调色/Plugin/DYViewerGraphics.inc.h +++ b/大鱼调色/Plugin/DYViewerGraphics.inc.h @@ -1,4 +1,14 @@ // Methods of DYViewerParameterPanel. Geometry is shared by drawing and input. +- (BOOL)graphicKind:(NSString*)kind{return [@[@"curvePlot",@"wheel",@"hslPlot",@"spiderPlot"]containsObject:kind];} +- (NSData*)spiderData {if(_spiderDraft)return _spiderDraft;return [_nodeID hasPrefix:@"base:"]?_snapshot[@"spider"]:[self node][@"layer"][@"spider"];} +- (void)beginSpiderData {[_bridge beginSpider:[self spiderData] node:_nodeID enabled:[self graphicValue:@"spiderEnabled"] atTime:_time];} +- (void)spiderAction:(NSInteger)action { + auto mesh=DYSpiderMesh([self spiderData]);if(action==0){mesh=dy::neutralMesh(mesh.hues,mesh.rings+1);} + else if(action==3||action==4){int count=action==3?mesh.hues:mesh.rings+1;int next=count<12?12:count<24?24:6;mesh=dy::resampleMesh(mesh,action==3?next:mesh.hues,action==4?next:mesh.rings+1);_selectedSpider=-1;} + else if(_selectedSpider>=0&&_selectedSpidersamples){uint32_t peak=1;for(int c=0;c<4;c++)if(_channel==0||c==_channel)for(int b=0;b<256;b++)peak=MAX(peak,hist->bins[c][b]);NSArray *colors=@[ink,NSColor.systemRedColor,NSColor.systemGreenColor,NSColor.systemBlueColor];for(int c=3;c>=0;c--){if(_channel&&c!=_channel)continue;NSBezierPath *area=[NSBezierPath bezierPath];[area moveToPoint:NSMakePoint(NSMinX(r),NSMaxY(r))];for(int b=0;b<256;b++)[area lineToPoint:NSMakePoint(NSMinX(r)+b/255.*r.size.width,NSMaxY(r)-sqrt(hist->bins[c][b]/double(peak))*r.size.height*.86)];[area lineToPoint:NSMakePoint(NSMaxX(r),NSMaxY(r))];[area closePath];[[colors[c]colorWithAlphaComponent:c==0?.08:.2]setFill];[area fill];}} [[ink colorWithAlphaComponent:.16]setStroke];NSBezierPath*grid=[NSBezierPath bezierPath];grid.lineWidth=.5*s; for(int i=0;i<5;i++){CGFloat x=r.origin.x+r.size.width*i/4,y=r.origin.y+r.size.height*i/4;[grid moveToPoint:NSMakePoint(x,NSMinY(r))];[grid lineToPoint:NSMakePoint(x,NSMaxY(r))];[grid moveToPoint:NSMakePoint(NSMinX(r),y)];[grid lineToPoint:NSMakePoint(NSMaxX(r),y)];}[grid stroke]; [[ink colorWithAlphaComponent:.2]setStroke];NSBezierPath*diagonal=[NSBezierPath bezierPath];[diagonal moveToPoint:NSMakePoint(NSMinX(r),NSMaxY(r))];[diagonal lineToPoint:NSMakePoint(NSMaxX(r),NSMinY(r))];[diagonal stroke]; @@ -51,6 +87,8 @@ } - (void)beginGraphicAt:(NSPoint)p{ if(!_snapshot||![self node])return;NSMutableDictionary*c=[[_captured mutableCopy]autorelease];NSRect r=[c[@"rect"]rectValue];NSString*xKey=nil,*yKey=nil; + if([c[@"kind"]isEqual:@"spiderPlot"]){auto mesh=DYSpiderMesh([self spiderData]);double best=12*_scale;NSInteger chosen=-1;for(int i=0;i selected;selected[_selectedSpider]=true;auto moved=dy::moveMesh(mesh,selected,(p.x-_down.x)/r.size.width,(p.y-_down.y)/r.size.height);[_spiderDraft release];_spiderDraft=[[NSData alloc]initWithBytes:&moved length:sizeof(moved)];[_bridge changeSpider:_spiderDraft];return;} + if([_captured[@"kind"]isEqual:@"hslPlot"]){NSString *key=_captured[@"hslKey"];if(!key)return;NSRect r=[_captured[@"rect"]rectValue];double v=MAX(-100.,MIN(100.,(NSMidY(r)-p.y)/r.size.height*200));_draftValues[key]=@(v);[_bridge changeValue:v];return;} NSString*xKey=_captured[@"xKey"],*yKey=_captured[@"yKey"];if(!xKey||!yKey)return;NSRect r=[_captured[@"rect"]rectValue];double x,y; if([_captured[@"kind"]isEqual:@"curvePlot"]){x=MAX(.001,MIN(.999,(p.x-r.origin.x)/MAX(1.,r.size.width)));double output=MAX(0.,MIN(1.,1-(p.y-r.origin.y)/MAX(1.,r.size.height))); for(NSDictionary*point in [self curvePoints])if(![point[@"xKey"]isEqual:xKey]){double other=[point[@"x"]doubleValue];if(fabs(x-other)<.001)x=x)manager { if((self=[super init])){_apiManager=manager;_snapshotTime=kCMTimeInvalid;_writerTime=kCMTimeInvalid;}return self; @@ -71,6 +78,13 @@ static BOOL DYViewerSanitizeValue(NSDictionary *d,double input,double *output) { [_snapshot release];[_sourceDocument release];[_writerHost release];[_writerTarget release]; [_writerDescriptors release];[_writerLastValues release];[_writerCompanions release];[_writerNode release];[_writerType release];[super dealloc]; } +- (void)publishAssets:(DYAssetState*)assets histogram:(NSData*)histogram atTime:(CMTime)time { + @synchronized(self){if(_invalidated||!_snapshot||CMTimeCompare(time,_snapshotTime)!=0)return;NSMutableDictionary *next=[[_snapshot mutableCopy]autorelease];next[@"spider"]=assets.spiderMesh?:[NSData data];if(histogram)next[@"histogram"]=histogram;[_snapshot release];_snapshot=[next copy];} +} +- (void)requestTool:(NSString*)type { + if(![DYToolTypes()containsObject:type])return; + dispatch_async(dispatch_get_main_queue(),^{id manager=nil;@synchronized(self){if(!self->_invalidated)manager=self->_apiManager;}if(manager)[NSNotificationCenter.defaultCenter postNotificationName:@"DYViewerToolRequested" object:manager userInfo:@{@"type":type}];}); +} - (void)requestWorkspace{ dispatch_async(dispatch_get_main_queue(),^{id manager=nil;@synchronized(self){if(!_invalidated)manager=_apiManager;}if(manager)[NSNotificationCenter.defaultCenter postNotificationName:@"DYColorWorkspaceRequested" object:manager];}); } @@ -111,7 +125,7 @@ static BOOL DYViewerSanitizeValue(NSDictionary *d,double input,double *output) { idaction=[_writerHost apiForProtocol:@protocol(FxCustomParameterActionAPI_v4)]; [action startAction:self];@try{[[_writerHost apiForProtocol:@protocol(FxUndoAPI)]endUndoGroup];}@finally{[action endAction:self];} } - _writerUndoOpen=NO;_writerGesture=0;_writerTime=kCMTimeInvalid; + _writerUndoOpen=NO;_writerSpider=NO;[_writerLastMesh release];_writerLastMesh=nil;_writerGesture=0;_writerTime=kCMTimeInvalid; [_writerHost release];_writerHost=nil;[_writerTarget release];_writerTarget=nil; [_writerDescriptors release];_writerDescriptors=nil;[_writerLastValues release];_writerLastValues=nil; [_writerCompanions release];_writerCompanions=nil; @@ -124,6 +138,7 @@ static BOOL DYViewerSanitizeValue(NSDictionary *d,double input,double *output) { } - (BOOL)writerValueMatches { if(![self writerNodeExists])return NO; + if(_writerSpider){NSData *current=DYReadAssets(_writerTarget,_writerTime).spiderMesh?:[NSData data];if(![current isEqual:_writerLastMesh])return NO;} idget=[_writerTarget apiForProtocol:@protocol(FxParameterRetrievalAPI_v6)]; for(NSDictionary *d in _writerDescriptors){double value=NAN; if(![get getFloatValue:&value fromParameter:[d[@"pid"]unsignedIntValue] atTime:_writerTime]||!DYViewerSameValue(value,[_writerLastValues[d[@"key"]]doubleValue]))return NO; @@ -180,6 +195,33 @@ static BOOL DYViewerSanitizeValue(NSDictionary *d,double input,double *output) { }); [node release];[selected release];[initial release]; } +- (void)beginSpider:(NSData*)mesh node:(NSString*)node enabled:(double)enabled atTime:(CMTime)time { + if(mesh.length&&!DYSpiderMeshIsValid(mesh))return;NSDictionary *descriptor=nil;for(NSDictionary*d in DYDescriptors())if([d[@"key"]isEqual:@"spiderEnabled"])descriptor=d; + if(!descriptor)return;[self beginParameter:descriptor node:node value:enabled atTime:time];uint64_t gesture;@synchronized(self){gesture=_requestedGesture;}NSData *original=[mesh copy]?:[NSData new]; + dispatch_async(dispatch_get_main_queue(),^{if(self->_writerGesture==gesture&&[self->_writerType isEqual:@"spider"]){self->_writerSpider=YES;self->_writerLastMesh=[original copy];if(![self writerStillValid])[self closeWriter];}});[original release]; +} +- (void)changeSpider:(NSData*)mesh { + if(!DYSpiderMeshIsValid(mesh))return;NSData *frozen=[mesh copy];uint64_t gesture;@synchronized(self){gesture=_invalidated?0:_requestedGesture;} + if(gesture)dispatch_async(dispatch_get_main_queue(),^{ + if(self->_writerGesture!=gesture||!self->_writerSpider)return; + if(![self writerStillValid]){[self closeWriter];return;} + if([frozen isEqual:self->_writerLastMesh])return; + ida=[self->_writerTarget apiForProtocol:@protocol(FxCustomParameterActionAPI_v4)];BOOL changed=NO,failed=NO; + [a startAction:self];@try{ + if(!CMTIME_IS_NUMERIC(a.currentTime)||CMTimeCompare(a.currentTime,self->_writerTime)!=0||![self writerValueMatches]){failed=YES;} + else{ + if(!self->_writerUndoOpen)self->_writerUndoOpen=[[self->_writerHost apiForProtocol:@protocol(FxUndoAPI)]startUndoGroup:@"画面调整 · 蜘蛛盘"]; + if(self->_writerUndoOpen){DYAssetState *old=DYReadAssets(self->_writerTarget,self->_writerTime);DYAssetState *next=[[old copy]autorelease];next.spiderMesh=frozen; + failed=!DYWriteAssets(self->_writerTarget,next,self->_writerTime); + if(failed)DYWriteAssets(self->_writerTarget,old,self->_writerTime);else changed=YES; + } + } + }@finally{[a endAction:self];} + // Re-read after DYToolManager commits its document at the outer boundary. + if(changed){NSData *actual=DYReadAssets(self->_writerTarget,self->_writerTime).spiderMesh;if(![actual isEqual:frozen])failed=YES;else{[self->_writerLastMesh release];self->_writerLastMesh=[frozen copy];[NSNotificationCenter.defaultCenter postNotificationName:DYModelChanged object:self->_apiManager];}} + if(failed)[self closeWriter]; + });[frozen release]; +} - (void)writeValues:(NSDictionary*)values gesture:(uint64_t)gesture { NSCAssert(NSThread.isMainThread,@"Host writes require the main queue"); if(!_writerGesture||gesture!=_writerGesture||values.count!=_writerDescriptors.count)return; diff --git a/大鱼调色/Plugin/DYViewerParameterPanel.inc.h b/大鱼调色/Plugin/DYViewerParameterPanel.inc.h index fef4b88..7c1f02d 100644 --- a/大鱼调色/Plugin/DYViewerParameterPanel.inc.h +++ b/大鱼调色/Plugin/DYViewerParameterPanel.inc.h @@ -18,17 +18,17 @@ @end @implementation DYViewerParameterPanel { DYViewerParameterBridge *_bridge;NSDictionary *_snapshot;NSArray *_nodes,*_rows;NSMutableArray *_areas; - NSString *_nodeID,*_toolType,*_selectedX;NSMutableDictionary *_draftValues;NSInteger _channel;BOOL _graphMode,_visible;NSSize _size;NSRect _panel,_viewport;BOOL _hasViewport;CGFloat _scale;BOOL _open,_catalog,_dragging,_hasDraft,_positioned,_movingPanel;NSPoint _position,_panelStart; + NSString *_nodeID,*_toolType,*_selectedX;NSMutableDictionary *_draftValues;NSInteger _channel,_hslAxis,_selectedSpider;NSData *_spiderDraft;BOOL _graphMode,_visible;NSSize _size;NSRect _panel,_viewport;BOOL _hasViewport;CGFloat _scale;BOOL _open,_catalog,_dragging,_hasDraft,_positioned,_movingPanel;NSPoint _position,_panelStart; NSInteger _page,_catalogPage,_capacity,_catalogCapacity,_hover,_pressed;NSPoint _down;NSDictionary *_captured; double _draftValue,_downValue;CGFloat _knobOffset;CMTime _time,_downTime; } @synthesize bridge=_bridge,toolType=_toolType,visible=_visible; - (void)setInitialPosition:(NSPoint)p{_position=p;_positioned=YES;} -- (instancetype)init{if((self=[super init])){_areas=[NSMutableArray new];_nodeID=[@"base:base" copy];_scale=1;_open=YES;_visible=YES;_graphMode=YES;_draftValues=[NSMutableDictionary new];_time=_downTime=kCMTimeInvalid;}return self;} -- (void)dealloc{if(_pressed)[_bridge endGesture];[_bridge release];[_snapshot release];[_nodes release];[_rows release];[_areas release];[_nodeID release];[_toolType release];[_selectedX release];[_draftValues release];[_captured release];[super dealloc];} +- (instancetype)init{if((self=[super init])){_areas=[NSMutableArray new];_nodeID=[@"base:base" copy];_scale=1;_open=YES;_visible=YES;_graphMode=YES;_selectedSpider=-1;_draftValues=[NSMutableDictionary new];_time=_downTime=kCMTimeInvalid;}return self;} +- (void)dealloc{if(_pressed)[_bridge endGesture];[_bridge release];[_spiderDraft release];[_snapshot release];[_nodes release];[_rows release];[_areas release];[_nodeID release];[_toolType release];[_selectedX release];[_draftValues release];[_captured release];[super dealloc];} - (void)setBridge:(DYViewerParameterBridge*)bridge{if(bridge==_bridge)return;if(_pressed)[_bridge endGesture];[_bridge release];_bridge=[bridge retain];_pressed=0;_dragging=NO;_movingPanel=NO;[_captured release];_captured=nil;} - (BOOL)capturing{return _pressed!=0;} -- (BOOL)finishCapture{BOOL had=_pressed!=0;if(had)[_bridge endGesture];_pressed=0;_hasDraft=NO;[_draftValues removeAllObjects];_movingPanel=NO;_dragging=NO;[_captured release];_captured=nil;return had;} +- (BOOL)finishCapture{BOOL had=_pressed!=0;if(had)[_bridge endGesture];_pressed=0;_hasDraft=NO;[_spiderDraft release];_spiderDraft=nil;[_draftValues removeAllObjects];_movingPanel=NO;_dragging=NO;[_captured release];_captured=nil;return had;} - (NSDictionary*)descriptorForKey:(NSString*)key{for(NSDictionary*d in DYDescriptors())if([d[@"key"]isEqual:key])return d;return nil;} - (NSDictionary*)node{for(NSDictionary*n in _nodes)if([n[@"id"]isEqual:_nodeID])return n;return nil;} - (double)valueForDescriptor:(NSDictionary*)d{ @@ -62,7 +62,7 @@ CGFloat s=_scale,margin=8*s,w=MIN(300*s,size.width-2*margin);_capacity=MAX(1,MIN(5,(NSInteger)floor((size.height-124*s)/(46*s)))); _catalogCapacity=MAX(1,MIN(7,(NSInteger)floor((size.height-124*s)/(32*s)))); _page=MIN(MAX(0,_page),MAX(0,((NSInteger)_rows.count-1)/_capacity));_catalogPage=MIN(MAX(0,_catalogPage),MAX(0,((NSInteger)_nodes.count-1)/_catalogCapacity)); - BOOL graph=_graphMode&&([type isEqual:@"curve"]||[type isEqual:@"grading"]); + BOOL graph=_graphMode&&([@[@"curve",@"grading",@"hsl",@"spider"]containsObject:type]); CGFloat body=_catalog?32*MIN(_catalogCapacity,(NSInteger)_nodes.count):graph?([type isEqual:@"curve"]?236:278):46*MIN(_capacity,(NSInteger)_rows.count); CGFloat h=_open?(100+body)*s:30*s,panelHeight=MIN(h,size.height-2*margin),x=viewport.origin.x+margin,top=viewport.origin.y+margin; if(_positioned){x=MAX(viewport.origin.x+margin,MIN(NSMaxX(viewport)-margin-w,viewport.origin.x+_position.x*size.width));top=MAX(viewport.origin.y+margin,MIN(NSMaxY(viewport)-margin-panelHeight,viewport.origin.y+_position.y*size.height));} @@ -85,7 +85,7 @@ [self addArea:NSMakeRect(x+10*s,y+i*46*s,w-46*s,40*s) part:21000+i*3 kind:valueKind title:d[@"title"] descriptor:d index:i]; [self addArea:NSMakeRect(NSMaxX(_panel)-31*s,y+i*46*s+5*s,23*s,29*s) part:21001+i*3 kind:@"reset" title:@"↺" descriptor:d index:i];}y+=MIN(_capacity,(NSInteger)_rows.count)*46*s; } - if([type isEqual:@"curve"]||[type isEqual:@"grading"])[self addArea:NSMakeRect(NSMaxX(_panel)-110*s,NSMaxY(_panel)-23*s,66*s,19*s) part:20008 kind:@"graphMode" title:_graphMode?@"参数 ›":@"图形 ›" descriptor:nil index:0]; + if([@[@"curve",@"grading",@"hsl",@"spider"]containsObject:type])[self addArea:NSMakeRect(NSMaxX(_panel)-110*s,NSMaxY(_panel)-23*s,66*s,19*s) part:20008 kind:@"graphMode" title:_graphMode?@"参数 ›":@"图形 ›" descriptor:nil index:0]; NSInteger total=_catalog?_nodes.count:_rows.count,cap=_catalog?_catalogCapacity:_capacity; if(total>cap&&(_catalog||!graph)){[self addArea:NSMakeRect(x+8*s,y,29*s,23*s) part:20004 kind:@"previous" title:@"‹" descriptor:nil index:0];[self addArea:NSMakeRect(NSMaxX(_panel)-37*s,y,29*s,23*s) part:20005 kind:@"next" title:@"›" descriptor:nil index:0];} } @@ -102,16 +102,17 @@ } - (void)draw{ if(!_areas.count)return;[NSGraphicsContext saveGraphicsState];NSRectClip(NSIntersectionRect(_panel,NSMakeRect(0,0,_size.width,_size.height)));CGFloat s=_scale;NSColor*ink=DYThemeColor(@"text")?:NSColor.whiteColor,*accent=DYThemeColor(@"accent")?:NSColor.systemCyanColor; - NSBezierPath*panel=[NSBezierPath bezierPathWithRoundedRect:_panel xRadius:9*s yRadius:9*s];DYDrawThemeSurface(panel,YES); + NSBezierPath*panel=[NSBezierPath bezierPathWithRoundedRect:_panel xRadius:9*s yRadius:9*s];BOOL solid=NSWorkspace.sharedWorkspace.accessibilityDisplayShouldReduceTransparency; + [[DYThemeColor(@"surface")?:DYThemeColor(@"background")?:NSColor.blackColor colorWithAlphaComponent:solid?1:.66]setFill];[panel fill];[[ink colorWithAlphaComponent:.32]setStroke];panel.lineWidth=s;[panel stroke]; for(NSDictionary*a in _areas){NSRect r=[a[@"rect"]rectValue];NSInteger part=[a[@"part"]integerValue];NSString*kind=a[@"kind"];BOOL pressed=_pressed==part,hover=_hover==part;NSDictionary*d=a[@"descriptor"]; - if([kind isEqual:@"curvePlot"]||[kind isEqual:@"wheel"]){[self drawGraphic:a];continue;} + if([self graphicKind:kind]){[self drawGraphic:a];continue;} if([kind isEqual:@"slider"]){double v=[self valueForDescriptor:d],lo=[d[@"min"]doubleValue],hi=[d[@"max"]doubleValue];CGFloat ratio=hi>lo?MAX(0.,MIN(1.,(v-lo)/(hi-lo))):0;NSRect track=[self trackForArea:a]; [self text:a[@"title"] rect:NSMakeRect(r.origin.x,r.origin.y,r.size.width-68*s,18*s) size:11 color:ink alignment:NSTextAlignmentLeft];[self text:[self valueText:d value:v] rect:NSMakeRect(NSMaxX(r)-68*s,r.origin.y,68*s,18*s) size:11 color:hover||pressed?accent:ink alignment:NSTextAlignmentRight]; DYDrawSoftControl(NSInsetRect(track,-2*s,-3*s),5*s,YES,NO,NO);[accent setFill];[[NSBezierPath bezierPathWithRoundedRect:NSMakeRect(track.origin.x,track.origin.y,MAX(2*s,track.size.width*ratio),track.size.height) xRadius:2*s yRadius:2*s]fill]; CGFloat marker=MAX(0.,MIN(1.,([d[@"default"]doubleValue]-lo)/(hi-lo)));[ink setStroke];NSBezierPath*tick=[NSBezierPath bezierPath];[tick moveToPoint:NSMakePoint(track.origin.x+marker*track.size.width,NSMidY(track)-5*s)];[tick lineToPoint:NSMakePoint(track.origin.x+marker*track.size.width,NSMidY(track)+5*s)];tick.lineWidth=.7*s;[tick stroke]; DYDrawSoftControl(NSMakeRect(track.origin.x+ratio*track.size.width-6*s,NSMidY(track)-6*s,12*s,12*s),6*s,NO,hover||pressed,pressed); }else{ - BOOL selected=([kind isEqual:@"channel"]&&[a[@"index"]integerValue]==_channel)||([kind isEqual:@"module"]&&[a[@"nodeID"]isEqual:_nodeID])||([kind isEqual:@"tool"]&&[a[@"toolType"]isEqual:[self node][@"type"]]);BOOL on=([kind isEqual:@"bool"]||[kind isEqual:@"headerBool"])&&[self valueForDescriptor:d]>.5; + BOOL selected=(([kind isEqual:@"channel"]&&[a[@"index"]integerValue]==_channel)||([kind isEqual:@"hslAxis"]&&[a[@"index"]integerValue]==_hslAxis))||([kind isEqual:@"module"]&&[a[@"nodeID"]isEqual:_nodeID])||([kind isEqual:@"tool"]&&[a[@"toolType"]isEqual:[self node][@"type"]]);BOOL on=([kind isEqual:@"bool"]||[kind isEqual:@"headerBool"])&&[self valueForDescriptor:d]>.5; DYDrawSoftControl(r,5*s,NO,hover||selected||on,pressed);NSString*title=a[@"title"]; if(d&&![kind isEqual:@"reset"]){NSString*value=[self valueText:d value:[self valueForDescriptor:d]];title=[kind isEqual:@"headerBool"]?(title.length?title:([self valueForDescriptor:d]>.5?@"●":@"○")):[NSString stringWithFormat:@"%@ %@%@",title,value,[kind isEqual:@"choice"]?@" ›":@""];} [self text:title rect:NSInsetRect(r,5*s,5*s) size:[kind isEqual:@"open"]?12:11 color:[kind isEqual:@"toolUnavailable"]?[ink colorWithAlphaComponent:.35]:ink alignment:NSTextAlignmentCenter]; @@ -126,7 +127,7 @@ NSRect t=[self trackForArea:_captured];NSDictionary*d=_captured[@"descriptor"];double ratio=MAX(0.,MIN(1.,(p.x-_knobOffset-t.origin.x)/MAX(1.,t.size.width)));_draftValue=[d[@"min"]doubleValue]+ratio*([d[@"max"]doubleValue]-[d[@"min"]doubleValue]);[_bridge changeValue:_draftValue]; } - (void)clickArea:(NSDictionary*)a{ - NSString*kind=a[@"kind"];if([kind isEqual:@"close"]){_visible=NO;return;}if([kind isEqual:@"open"]){_open=!_open;_catalog=NO;return;}if([kind isEqual:@"graphMode"]){_graphMode=!_graphMode;return;}if([kind isEqual:@"channel"]){_channel=[a[@"index"]integerValue];[_selectedX release];_selectedX=nil;return;}if([kind isEqual:@"deletePoint"]){[self deleteSelectedPoint];return;}if([kind isEqual:@"catalog"]){_catalog=!_catalog;return;} + NSString*kind=a[@"kind"];if([kind isEqual:@"hslAxis"]){_hslAxis=[a[@"index"]integerValue];return;}if([kind hasPrefix:@"spiderAction"]){[self spiderAction:[a[@"index"]integerValue]];return;}if([kind isEqual:@"close"]){_visible=NO;return;}if([kind isEqual:@"open"]){_open=!_open;_catalog=NO;return;}if([kind isEqual:@"graphMode"]){_graphMode=!_graphMode;return;}if([kind isEqual:@"channel"]){_channel=[a[@"index"]integerValue];[_selectedX release];_selectedX=nil;return;}if([kind isEqual:@"deletePoint"]){[self deleteSelectedPoint];return;}if([kind isEqual:@"catalog"]){_catalog=!_catalog;return;} if([kind isEqual:@"module"]||[kind isEqual:@"tool"]){for(NSDictionary*n in _nodes)if([n[@"id"]isEqual:a[@"nodeID"]]){[_nodeID release];_nodeID=[a[@"nodeID"]copy];_catalog=NO;_page=0;break;}return;} if([kind isEqual:@"previous"]||[kind isEqual:@"next"]){NSInteger total=_catalog?_nodes.count:_rows.count,cap=_catalog?_catalogCapacity:_capacity,count=MAX(1,(total+cap-1)/cap),delta=[kind isEqual:@"next"]?1:-1;if(_catalog)_catalogPage=(_catalogPage+delta+count)%count;else _page=(_page+delta+count)%count;return;} NSDictionary*d=a[@"descriptor"];if(!d||!_snapshot)return;double old=[self valueForDescriptor:d],v=old; @@ -141,14 +142,14 @@ - (BOOL)event:(NSEventType)type point:(NSPoint)p atTime:(CMTime)time{ if(!std::isfinite(p.x)||!std::isfinite(p.y))return NO;[self prepareWithSize:_size scale:_scale atTime:time];NSInteger hit=[self partAtPoint:p]; if(type==NSEventTypeLeftMouseDown){if(!hit)return NO;[_bridge endGesture];_hasDraft=NO;_pressed=hit;_down=p;_panelStart=_panel.origin;_downTime=time;_dragging=NO;_movingPanel=NO;[_captured release];_captured=[[self areaForPart:hit]copy];NSDictionary*d=_captured[@"descriptor"]; - if([_captured[@"kind"]isEqual:@"curvePlot"]||[_captured[@"kind"]isEqual:@"wheel"]){[self beginGraphicAt:p];return YES;} + if([self graphicKind:_captured[@"kind"]]){[self beginGraphicAt:p];return YES;} if([_captured[@"kind"]isEqual:@"slider"]&&_snapshot){NSRect t=[self trackForArea:_captured];if(NSPointInRect(p,NSInsetRect(t,-8*_scale,-8*_scale))){_downValue=[self valueForDescriptor:d];_draftValue=_downValue;_hasDraft=YES;[_bridge beginParameter:d node:_nodeID value:_downValue atTime:time];CGFloat knob=t.origin.x+(_downValue-[d[@"min"]doubleValue])/([d[@"max"]doubleValue]-[d[@"min"]doubleValue])*t.size.width;_knobOffset=fabs(p.x-knob)<=8*_scale?p.x-knob:0;if(fabs(p.x-knob)>8*_scale)[self applySliderPoint:p];}}return YES; } if(!_pressed)return NO; - if(type==NSEventTypeLeftMouseDragged){if(fabs(p.x-_down.x)>2*_scale||fabs(p.y-_down.y)>2*_scale)_dragging=YES;if(_dragging&&[_captured[@"kind"]isEqual:@"open"])[self movePanelToPointer:p];if(_dragging&&([_captured[@"kind"]isEqual:@"curvePlot"]||[_captured[@"kind"]isEqual:@"wheel"]))[self updateGraphicAt:p];if(_dragging&&_hasDraft&&[_captured[@"kind"]isEqual:@"slider"]&&_snapshot)[self applySliderPoint:p];return YES;} - if(type==NSEventTypeLeftMouseUp){if([_captured[@"kind"]isEqual:@"open"]&&(_dragging||fabs(p.x-_down.x)>2*_scale||fabs(p.y-_down.y)>2*_scale))[self movePanelToPointer:p];BOOL moved=_movingPanel;BOOL graphic=[_captured[@"kind"]isEqual:@"curvePlot"]||[_captured[@"kind"]isEqual:@"wheel"];if(graphic){if(_dragging||fabs(p.x-_down.x)>2*_scale||fabs(p.y-_down.y)>2*_scale)[self updateGraphicAt:p];[_bridge endGesture];}BOOL slider=[_captured[@"kind"]isEqual:@"slider"];NSDictionary*a=[_captured retain];NSInteger pressed=_pressed; + if(type==NSEventTypeLeftMouseDragged){if(fabs(p.x-_down.x)>2*_scale||fabs(p.y-_down.y)>2*_scale)_dragging=YES;if(_dragging&&[_captured[@"kind"]isEqual:@"open"])[self movePanelToPointer:p];if(_dragging&&([self graphicKind:_captured[@"kind"]]))[self updateGraphicAt:p];if(_dragging&&_hasDraft&&[_captured[@"kind"]isEqual:@"slider"]&&_snapshot)[self applySliderPoint:p];return YES;} + if(type==NSEventTypeLeftMouseUp){if([_captured[@"kind"]isEqual:@"open"]&&(_dragging||fabs(p.x-_down.x)>2*_scale||fabs(p.y-_down.y)>2*_scale))[self movePanelToPointer:p];BOOL moved=_movingPanel;BOOL graphic=[self graphicKind:_captured[@"kind"]];if(graphic){if(_dragging||fabs(p.x-_down.x)>2*_scale||fabs(p.y-_down.y)>2*_scale)[self updateGraphicAt:p];[_bridge endGesture];}BOOL slider=[_captured[@"kind"]isEqual:@"slider"];NSDictionary*a=[_captured retain];NSInteger pressed=_pressed; if(slider){if(_hasDraft&&(_dragging||fabs(p.x-_down.x)>2*_scale||fabs(p.y-_down.y)>2*_scale))[self applySliderPoint:p];[_bridge endGesture];} - _pressed=0;_dragging=NO;_movingPanel=NO;_hasDraft=NO;[_captured release];_captured=nil;[_draftValues removeAllObjects];if(!moved&&!slider&&!graphic&&hit==pressed&&(!a[@"nodeID"]||[a[@"nodeID"]isEqual:[self areaForPart:hit][@"nodeID"]]))[self clickArea:a];[a release];[self prepareWithSize:_size scale:_scale atTime:time];return YES;} + _pressed=0;_dragging=NO;_movingPanel=NO;_hasDraft=NO;[_captured release];_captured=nil;[_spiderDraft release];_spiderDraft=nil;[_draftValues removeAllObjects];if(!moved&&!slider&&!graphic&&hit==pressed&&(!a[@"nodeID"]||[a[@"nodeID"]isEqual:[self areaForPart:hit][@"nodeID"]]))[self clickArea:a];[a release];[self prepareWithSize:_size scale:_scale atTime:time];return YES;} return NO; } #include "DYViewerGraphics.inc.h"