diff --git a/research/UnifiedPipeline1.17.0.md b/research/UnifiedPipeline1.17.0.md index 1982f45..dfc582c 100644 --- a/research/UnifiedPipeline1.17.0.md +++ b/research/UnifiedPipeline1.17.0.md @@ -5,3 +5,10 @@ 本轮范围:16 个功能缩略图;检视器移除内部纵向滚动并按内容高度伸缩;新增显式 V4 全链路颜色管理和可移动输出边界;人脸/共享蒙版局部马赛克。旧 nil/V2/V3 流程保持,新流程必须显式区分,既有工程不静默迁移。 验证要求:真实节点顺序;输出前负值、超白及宽色域不被通用工具无故裁切;LUT 和胶片的有限域明确;蒙版、混合和 Cube 导出一致;马赛克空选区不影响全画面,包含眼睛和嘴部,复用既有轨迹;展开/收起实窗高度和模板缩略图。阶段状态以之后的验证与交付记录为准。 + +## 实现检查点(尚未交付) + +- 16 套原生矢量缩略图(两种尺寸)与独立打包路径;34 个预览哈希互异(含整合版),模板静态检查通过。 +- 检视器已移除内部纵向 ScrollView、取消高度上限;实际宿主自适应仍待正式版验收。 +- 新 V4 状态/顺序、独立输出卡片与移动写回、局部马赛克逐帧人脸和共享蒙版实现。V4 使用工作域码值模块,Rec.709 创意 LUT/胶片使用明确局部参考域;有界兼容算法以边界增量延拓并保留 float32 超范围残差。此实现不等同所有旧算法均已改写成场景线性算法。 +- Release 编译通过;新增生产渲染检查正在补齐。版本、公证、安装、宿主与 Release 尚未开始,正式安装仍 1.16.0。 diff --git a/template/CST 色彩空间转换/large.png b/template/CST 色彩空间转换/large.png new file mode 100644 index 0000000..d6ce359 Binary files /dev/null and b/template/CST 色彩空间转换/large.png differ diff --git a/template/CST 色彩空间转换/small.png b/template/CST 色彩空间转换/small.png new file mode 100644 index 0000000..d735a04 Binary files /dev/null and b/template/CST 色彩空间转换/small.png differ diff --git a/template/HSL/large.png b/template/HSL/large.png new file mode 100644 index 0000000..707b1f0 Binary files /dev/null and b/template/HSL/large.png differ diff --git a/template/HSL/small.png b/template/HSL/small.png new file mode 100644 index 0000000..3536d5e Binary files /dev/null and b/template/HSL/small.png differ diff --git a/template/sources/RegisteredParameters.json b/template/sources/RegisteredParameters.json index f49d453..eee9b83 100644 --- a/template/sources/RegisteredParameters.json +++ b/template/sources/RegisteredParameters.json @@ -3715,13 +3715,13 @@ "大鱼调色/Plugin/DYColorManagement.h": "b0a4cd1b8c45dbce90a7b4f30f72ebf95ecd382895e74e3bfeda0f7cdb185157", "大鱼调色/Plugin/DYFilmMath.h": "945b7036c6aa6d27941a3bf96c4d70dec65a14b1747fba618e650738fa7108f0", "大鱼调色/Plugin/DYFilmTypes.h": "c35a43b5b93988e8517e5db8f281da0dfd1e02f5b0e7bfb62e7345cec444a36d", - "大鱼调色/Plugin/DYManagedColor.h": "d5901d6ac11d93f3f4438dd8d48bb3a123d06d9b79ed39e8dca38db4261bc87a", - "大鱼调色/Plugin/DYManagedColor.mm": "d9d2688f26a51d1131ee63b415e0c09989616312d31eb3b636fd299f475ece08", + "大鱼调色/Plugin/DYManagedColor.h": "1f435e32ee8b6f74fbc6c588f3564cc794ce100d1aae821075c115b33bb24412", + "大鱼调色/Plugin/DYManagedColor.mm": "0d2527b18589f63d63d16fd64c47a70c5973994fb3841a3246631c7e836ea8e8", "大鱼调色/Plugin/DYModel.h": "a28652bd53aa9e1d085af1108c344b5d673c5e1b3731531e1bb2982efeb8708c", "大鱼调色/Plugin/DYModel.mm": "e5bdf3177e164c0b97e535be7e6d14ea56d49f3f74c3622078374e7a9597d2c1", "大鱼调色/Plugin/DYSpiderState.h": "0c80747e41e8fc97762e301b011bd08c18865a825eaafde086ed79ace37b22f9", - "大鱼调色/Plugin/DYToolState.h": "83e54959fe6161dee7a3a9c3afec7ca0872b52ad9c0fa286e7497a4a759f8e2f", - "大鱼调色/Plugin/DYToolState.mm": "e84646669d14a992b66fbfbf3c0ea1a9be9c7ffdc85529cd34ab44f78d107074", + "大鱼调色/Plugin/DYToolState.h": "96eff1bd54be127e527595da7cbf38e58f4dfd4a16c9491d8630f7b1d1045c84", + "大鱼调色/Plugin/DYToolState.mm": "cb51ebe02f836434b3dda43999625cc82cee7726574e19e7273f1644c68554f0", "大鱼调色/Plugin/DYUniforms.h": "4901446fa6b2a6987a6a137baa458df70f5e25a1e64fdb5c502f765b20edc0c0", "大鱼调色/Plugin/MaskCore/DYMask.h": "5b9aa44390d4a1fca1baf5e34cb9eefc8483c939a65cc2a0412b7b41fc85bc16", "大鱼调色/Plugin/MaskCore/DYMaskOperator.h": "43fa701ad574f38ce0ab4f4d3900bb034edaaa1adc09821d2f4443ee2b687ba2", diff --git a/template/verification/ModulePreviews.json b/template/verification/ModulePreviews.json new file mode 100644 index 0000000..7343733 --- /dev/null +++ b/template/verification/ModulePreviews.json @@ -0,0 +1,244 @@ +{ + "passed": true, + "generator": "tools/build_module_previews.swift", + "files": [ + { + "source": "large.png", + "bundle": "large.png", + "installed": "大鱼调色/large.png", + "bytes": 261628, + "sha256": "ab12611e8801cff86332ccc505a4cffa0c1120541c2efb9bb9908be2c9fe631a" + }, + { + "source": "small.png", + "bundle": "small.png", + "installed": "大鱼调色/small.png", + "bytes": 42791, + "sha256": "41fec3138aee904fc39d6982e6fde809243ffec55298dbfe966f4f48d89caf8a" + }, + { + "source": "一级调色/large.png", + "bundle": "一级调色/large.png", + "installed": "一级调色/large.png", + "bytes": 31953, + "sha256": "b9b990a46f3fd9b6974a1aba1a3e9bff11a287fd1615d4cd0f9e7393c302631b" + }, + { + "source": "一级调色/small.png", + "bundle": "一级调色/small.png", + "installed": "一级调色/small.png", + "bytes": 8051, + "sha256": "77b36c042fb82219651e5bd22c1057b644c06a528a8962d4afecdcb8cab52635" + }, + { + "source": "蜘蛛盘校色仪/large.png", + "bundle": "蜘蛛盘校色仪/large.png", + "installed": "蜘蛛盘校色仪/large.png", + "bytes": 29077, + "sha256": "52de21d5fc598fda331cd472b937cf4aaf69a09c80d49e7b168ac7804e9cd040" + }, + { + "source": "蜘蛛盘校色仪/small.png", + "bundle": "蜘蛛盘校色仪/small.png", + "installed": "蜘蛛盘校色仪/small.png", + "bytes": 8606, + "sha256": "ea9b69d12948c5cd5f6acd9d000822d9fff6df3beec9dd278077a8ab66d455cd" + }, + { + "source": "基础调整/large.png", + "bundle": "基础调整/large.png", + "installed": "基础调整/large.png", + "bytes": 14561, + "sha256": "a25e2b5ed50628ebe77220719528d14f21c25b5eecf37a5d60f211d2179ece43" + }, + { + "source": "基础调整/small.png", + "bundle": "基础调整/small.png", + "installed": "基础调整/small.png", + "bytes": 4537, + "sha256": "3da91ae3461b882f5e1a557b4191d9aedaa6d329da70999eb7f26cbfb63a057f" + }, + { + "source": "肤色保护/large.png", + "bundle": "肤色保护/large.png", + "installed": "肤色保护/large.png", + "bytes": 15279, + "sha256": "f124e8f3d93c2be76ba26ba06d8b9c0b42e2c10dcb6300ae6ee7b7d7c7eb3025" + }, + { + "source": "肤色保护/small.png", + "bundle": "肤色保护/small.png", + "installed": "肤色保护/small.png", + "bytes": 5144, + "sha256": "51fe525e67903101920a994d3540f368780d3aa9c0e54ebdb847871c82d81562" + }, + { + "source": "风格 LUT/large.png", + "bundle": "风格 LUT/large.png", + "installed": "风格 LUT/large.png", + "bytes": 15637, + "sha256": "a9a4b48885752282535ec3ec2ffbe19bcd27af7132337e4a4ad3d104a2082692" + }, + { + "source": "风格 LUT/small.png", + "bundle": "风格 LUT/small.png", + "installed": "风格 LUT/small.png", + "bytes": 5877, + "sha256": "9ae76ba957b1e94a5a03a600140f59e98861917d13da9124082810c509400e36" + }, + { + "source": "HSL/large.png", + "bundle": "HSL/large.png", + "installed": "HSL/large.png", + "bytes": 36559, + "sha256": "eaa2e7b025dc59416fddb8de8b9c56f0a7d34ba70facd7aa45cfb84660f7da78" + }, + { + "source": "HSL/small.png", + "bundle": "HSL/small.png", + "installed": "HSL/small.png", + "bytes": 9811, + "sha256": "3a54428bc6821e75935aa1be0f149aac6e6ce05fcc059b7f0e90ceef9a41981e" + }, + { + "source": "曲线/large.png", + "bundle": "曲线/large.png", + "installed": "曲线/large.png", + "bytes": 14887, + "sha256": "273899eb6aa60fc0f7c8d41cc0e1f5a15b4c88a8803c00020a085ea874160870" + }, + { + "source": "曲线/small.png", + "bundle": "曲线/small.png", + "installed": "曲线/small.png", + "bytes": 4513, + "sha256": "c17a2343b076650344b1c53ce92acf32f7696d66e32bda2d156996d4e3b834f5" + }, + { + "source": "颜色分级/large.png", + "bundle": "颜色分级/large.png", + "installed": "颜色分级/large.png", + "bytes": 30645, + "sha256": "f9afe6c3a76080a2a7c7ea98f24e62a74ab2e6fd8b4ad16ba9eb6065fef5d2ed" + }, + { + "source": "颜色分级/small.png", + "bundle": "颜色分级/small.png", + "installed": "颜色分级/small.png", + "bytes": 9702, + "sha256": "9e9d7759f829d25a01a77422c989949b02ad34de81013f6b91505c4a3d1397e9" + }, + { + "source": "三原色/large.png", + "bundle": "三原色/large.png", + "installed": "三原色/large.png", + "bytes": 19743, + "sha256": "bf7bfc893e294fc38c0f97e5594b6ba6e5c7126b9aae643754c89647e8bd5a1f" + }, + { + "source": "三原色/small.png", + "bundle": "三原色/small.png", + "installed": "三原色/small.png", + "bytes": 6228, + "sha256": "2e28988e6bae0503edadef22cf7793ce51a1b8e5930623b2eff3c01212e57ee8" + }, + { + "source": "色阶/large.png", + "bundle": "色阶/large.png", + "installed": "色阶/large.png", + "bytes": 13205, + "sha256": "fcea12f4367039ea1512d2e23d51b9ca5198172dc5b10a1ff94a828fe94f4802" + }, + { + "source": "色阶/small.png", + "bundle": "色阶/small.png", + "installed": "色阶/small.png", + "bytes": 4767, + "sha256": "41cd1a9c4d3b68972181534abe0e91bdb9e01ef5559b6b1f7ef6bf305f450a76" + }, + { + "source": "黑白混色/large.png", + "bundle": "黑白混色/large.png", + "installed": "黑白混色/large.png", + "bytes": 12899, + "sha256": "6df07fb223ab43b2b5b6115bef4a1a97eed5cbeb6afab84e005c3a2bdfe01979" + }, + { + "source": "黑白混色/small.png", + "bundle": "黑白混色/small.png", + "installed": "黑白混色/small.png", + "bytes": 3958, + "sha256": "5382be0d29b4a195b8639b3c325f80e9b8cecaa9c12837ab5cf57b6ea877ecbc" + }, + { + "source": "色彩平衡/large.png", + "bundle": "色彩平衡/large.png", + "installed": "色彩平衡/large.png", + "bytes": 14637, + "sha256": "fa2ce9071dee52d7ab9dc7cf6020f8679df3af707663c9a57a28fcde73e6801e" + }, + { + "source": "色彩平衡/small.png", + "bundle": "色彩平衡/small.png", + "installed": "色彩平衡/small.png", + "bytes": 6069, + "sha256": "12a72a9f26e6ee41613b16ed2402f94a04837e55895addc8f5c25137ad7feaa6" + }, + { + "source": "通道混合器/large.png", + "bundle": "通道混合器/large.png", + "installed": "通道混合器/large.png", + "bytes": 27134, + "sha256": "5ae9d2683450a3a515822520911885a774e202aa924465602f7369a1e67c0c4c" + }, + { + "source": "通道混合器/small.png", + "bundle": "通道混合器/small.png", + "installed": "通道混合器/small.png", + "bytes": 7731, + "sha256": "23bfafb79287855e037f98f0ab5cee10914384824b1a65f0247cad2dd239ef1c" + }, + { + "source": "胶片模拟/large.png", + "bundle": "胶片模拟/large.png", + "installed": "胶片模拟/large.png", + "bytes": 13409, + "sha256": "d36a794f9640874f6ad7f3523b9eac92ba7c6ef8fa7b63c4594fc68e87c2eee7" + }, + { + "source": "胶片模拟/small.png", + "bundle": "胶片模拟/small.png", + "installed": "胶片模拟/small.png", + "bytes": 4357, + "sha256": "f125deaf0c8d55ecc04e555cfb133c40ff3703f34a663548c6b38b3196780eb1" + }, + { + "source": "镜头畸变修复/large.png", + "bundle": "镜头畸变修复/large.png", + "installed": "镜头畸变修复/large.png", + "bytes": 32470, + "sha256": "a00136fb9276c41518ba6096314fb6772ad1dc9be4f4d766409239fa923cfcd1" + }, + { + "source": "镜头畸变修复/small.png", + "bundle": "镜头畸变修复/small.png", + "installed": "镜头畸变修复/small.png", + "bytes": 10171, + "sha256": "1b2480cfa33e1ab54a1ffcd81d9496aac1354b0d2974d6616fe7128965c2ede3" + }, + { + "source": "CST 色彩空间转换/large.png", + "bundle": "CST 色彩空间转换/large.png", + "installed": "CST 色彩空间转换/large.png", + "bytes": 27622, + "sha256": "816db272970491181aca4b872f09ca1900ebf0e7f21fee5bd6e2b4daedea5306" + }, + { + "source": "CST 色彩空间转换/small.png", + "bundle": "CST 色彩空间转换/small.png", + "installed": "CST 色彩空间转换/small.png", + "bytes": 8498, + "sha256": "677353684eeaa1986bd21580eb0f2dcf4486f8cfba3985686c2ecb67afed5dbc" + } + ] +} diff --git a/template/一级调色/large.png b/template/一级调色/large.png new file mode 100644 index 0000000..4dbd52f Binary files /dev/null and b/template/一级调色/large.png differ diff --git a/template/一级调色/small.png b/template/一级调色/small.png new file mode 100644 index 0000000..fa3e121 Binary files /dev/null and b/template/一级调色/small.png differ diff --git a/template/三原色/large.png b/template/三原色/large.png new file mode 100644 index 0000000..b2b12ee Binary files /dev/null and b/template/三原色/large.png differ diff --git a/template/三原色/small.png b/template/三原色/small.png new file mode 100644 index 0000000..4584259 Binary files /dev/null and b/template/三原色/small.png differ diff --git a/template/基础调整/large.png b/template/基础调整/large.png new file mode 100644 index 0000000..9d41b25 Binary files /dev/null and b/template/基础调整/large.png differ diff --git a/template/基础调整/small.png b/template/基础调整/small.png new file mode 100644 index 0000000..5d89c23 Binary files /dev/null and b/template/基础调整/small.png differ diff --git a/template/曲线/large.png b/template/曲线/large.png new file mode 100644 index 0000000..9533c65 Binary files /dev/null and b/template/曲线/large.png differ diff --git a/template/曲线/small.png b/template/曲线/small.png new file mode 100644 index 0000000..9d1d748 Binary files /dev/null and b/template/曲线/small.png differ diff --git a/template/肤色保护/large.png b/template/肤色保护/large.png new file mode 100644 index 0000000..52ab85e Binary files /dev/null and b/template/肤色保护/large.png differ diff --git a/template/肤色保护/small.png b/template/肤色保护/small.png new file mode 100644 index 0000000..fb527d2 Binary files /dev/null and b/template/肤色保护/small.png differ diff --git a/template/胶片模拟/large.png b/template/胶片模拟/large.png new file mode 100644 index 0000000..c40a20a Binary files /dev/null and b/template/胶片模拟/large.png differ diff --git a/template/胶片模拟/small.png b/template/胶片模拟/small.png new file mode 100644 index 0000000..e045f66 Binary files /dev/null and b/template/胶片模拟/small.png differ diff --git a/template/色彩平衡/large.png b/template/色彩平衡/large.png new file mode 100644 index 0000000..dd9affa Binary files /dev/null and b/template/色彩平衡/large.png differ diff --git a/template/色彩平衡/small.png b/template/色彩平衡/small.png new file mode 100644 index 0000000..1509de0 Binary files /dev/null and b/template/色彩平衡/small.png differ diff --git a/template/色阶/large.png b/template/色阶/large.png new file mode 100644 index 0000000..3ea562f Binary files /dev/null and b/template/色阶/large.png differ diff --git a/template/色阶/small.png b/template/色阶/small.png new file mode 100644 index 0000000..77b1d6b Binary files /dev/null and b/template/色阶/small.png differ diff --git a/template/蜘蛛盘校色仪/large.png b/template/蜘蛛盘校色仪/large.png new file mode 100644 index 0000000..c2c43e1 Binary files /dev/null and b/template/蜘蛛盘校色仪/large.png differ diff --git a/template/蜘蛛盘校色仪/small.png b/template/蜘蛛盘校色仪/small.png new file mode 100644 index 0000000..11c8c96 Binary files /dev/null and b/template/蜘蛛盘校色仪/small.png differ diff --git a/template/通道混合器/large.png b/template/通道混合器/large.png new file mode 100644 index 0000000..bcbc3bd Binary files /dev/null and b/template/通道混合器/large.png differ diff --git a/template/通道混合器/small.png b/template/通道混合器/small.png new file mode 100644 index 0000000..8ef1cf3 Binary files /dev/null and b/template/通道混合器/small.png differ diff --git a/template/镜头畸变修复/large.png b/template/镜头畸变修复/large.png new file mode 100644 index 0000000..64554c0 Binary files /dev/null and b/template/镜头畸变修复/large.png differ diff --git a/template/镜头畸变修复/small.png b/template/镜头畸变修复/small.png new file mode 100644 index 0000000..8537568 Binary files /dev/null and b/template/镜头畸变修复/small.png differ diff --git a/template/颜色分级/large.png b/template/颜色分级/large.png new file mode 100644 index 0000000..d33c993 Binary files /dev/null and b/template/颜色分级/large.png differ diff --git a/template/颜色分级/small.png b/template/颜色分级/small.png new file mode 100644 index 0000000..ec4ffe3 Binary files /dev/null and b/template/颜色分级/small.png differ diff --git a/template/风格 LUT/large.png b/template/风格 LUT/large.png new file mode 100644 index 0000000..b71b8ee Binary files /dev/null and b/template/风格 LUT/large.png differ diff --git a/template/风格 LUT/small.png b/template/风格 LUT/small.png new file mode 100644 index 0000000..82a3086 Binary files /dev/null and b/template/风格 LUT/small.png differ diff --git a/template/黑白混色/large.png b/template/黑白混色/large.png new file mode 100644 index 0000000..6455632 Binary files /dev/null and b/template/黑白混色/large.png differ diff --git a/template/黑白混色/small.png b/template/黑白混色/small.png new file mode 100644 index 0000000..fff6d80 Binary files /dev/null and b/template/黑白混色/small.png differ diff --git a/tools/build_module_previews.swift b/tools/build_module_previews.swift new file mode 100644 index 0000000..864e1ce --- /dev/null +++ b/tools/build_module_previews.swift @@ -0,0 +1,63 @@ +// Native vector artwork, rendered directly at both Motion browser sizes. +import AppKit + +let root = URL(fileURLWithPath: CommandLine.arguments[1]) +let names = ["一级调色", "蜘蛛盘校色仪", "基础调整", "肤色保护", "风格 LUT", "HSL", "曲线", "颜色分级", "三原色", "色阶", "黑白混色", "色彩平衡", "通道混合器", "胶片模拟", "镜头畸变修复", "CST 色彩空间转换"] +let accents: [NSColor] = [.systemOrange,.systemCyan,.systemYellow,.systemPink,.systemPurple,.systemGreen,.systemCyan,.systemPurple,.systemRed,.systemOrange,.white,.systemTeal,.systemGreen,.systemOrange,.systemCyan,.systemBlue] +func color(_ h: CGFloat) -> NSColor { NSColor(calibratedHue: h, saturation: 0.8, brightness: 1, alpha: 1) } +func line(_ points: [NSPoint], _ c: NSColor, _ width: CGFloat = 6) { + let p = NSBezierPath(); p.move(to: points[0]); for v in points.dropFirst() { p.line(to: v) } + p.lineWidth=width; p.lineCapStyle = .round; p.lineJoinStyle = .round; c.setStroke();p.stroke() +} +func box(_ r: NSRect, _ c: NSColor, _ radius: CGFloat=12) {c.setFill();NSBezierPath(roundedRect:r,xRadius:radius,yRadius:radius).fill()} +func circle(_ x: CGFloat, _ y: CGFloat, _ r: CGFloat, _ c: NSColor){c.setFill();NSBezierPath(ovalIn:NSRect(x:x-r,y:y-r,width:r*2,height:r*2)).fill()} +func text(_ s: String, _ r: NSRect, _ size: CGFloat, _ c: NSColor, _ weight:NSFont.Weight = .semibold) { + let p=NSMutableParagraphStyle();p.alignment = .center + (s as NSString).draw(in:r,withAttributes:[.font:NSFont.systemFont(ofSize:size,weight:weight),.foregroundColor:c,.paragraphStyle:p]) +} +func wheel(_ x:CGFloat,_ y:CGFloat,_ r:CGFloat) { + for i in 0..<120 { let a=CGFloat(i)*2 * .pi/120,b=CGFloat(i+1)*2 * .pi/120 + let p=NSBezierPath();p.move(to:NSPoint(x:x,y:y));p.line(to:NSPoint(x:x+cos(a)*r,y:y+sin(a)*r));p.line(to:NSPoint(x:x+cos(b)*r,y:y+sin(b)*r));p.close();color(CGFloat(i)/120).setFill();p.fill() + };circle(x,y,r*0.69,NSColor(calibratedWhite:0.09,alpha:1));circle(x,y,5,.white) +} +func art(_ n:Int) { + let a=accents[n],muted=NSColor(calibratedWhite:0.30,alpha:1),ink=NSColor(calibratedWhite:0.94,alpha:1) + switch n { + case 0: wheel(215,205,64);for i in 0..<3 {let x=CGFloat(335+i*47);line([.init(x:x,y:140),.init(x:x,y:270)],muted,8);circle(x,CGFloat(170+i*30),10,[NSColor.systemOrange,.systemCyan,.systemPurple][i])} + case 1: + let center=NSPoint(x:320,y:208) + for r in [CGFloat(40),70,100] {let p=(0...6).map { i in NSPoint(x:center.x+cos(CGFloat(i) * .pi/3)*r,y:center.y+sin(CGFloat(i) * .pi/3)*r)};line(p,muted,2)} + let p=(0...6).map { i -> NSPoint in let r:CGFloat=[82,64,90,73,92,56,82][i]; return NSPoint(x:center.x+cos(CGFloat(i) * .pi/3)*r,y:center.y+sin(CGFloat(i) * .pi/3)*r)};line(p,a,5);for (i,q) in p.dropLast().enumerated(){circle(q.x,q.y,8,color(CGFloat(i)/6))} + case 2:for i in 0..<4{let y=CGFloat(145+i*42);line([.init(x:180,y:y),.init(x:460,y:y)],muted,8);let x=CGFloat([260,382,302,418][i]);line([.init(x:180,y:y),.init(x:x,y:y)],a,8);circle(x,y,13,ink)} + case 3: + box(.init(x:258,y:133,width:124,height:154),NSColor(calibratedRed:0.8,green:0.51,blue:0.36,alpha:1),58) + circle(296,222,6,ink);circle(344,222,6,ink);line([.init(x:301,y:177),.init(x:320,y:170),.init(x:339,y:177)],ink,4) + for s:CGFloat in [-1,1]{let x:CGFloat=320+s*94;line([.init(x:x-s*22,y:293),.init(x:x,y:293),.init(x:x,y:270)],a,5);line([.init(x:x-s*22,y:125),.init(x:x,y:125),.init(x:x,y:148)],a,5)} + case 4:for y in 0..<4{for x in 0..<8{box(.init(x:174+CGFloat(x)*37,y:137+CGFloat(y)*37,width:32,height:32),color(CGFloat(x)/8).blended(withFraction:CGFloat(y)*0.14,of:.black)!,4)}} + case 5:wheel(320,207,87);text("H · S · L",.init(x:255,y:192,width:130,height:30),26,ink) + case 6:for i in 0...4{let p=CGFloat(i)*38;line([.init(x:237+p,y:128),.init(x:237+p,y:280)],muted,1);line([.init(x:237,y:128+p),.init(x:389,y:128+p)],muted,1)} + let p=NSBezierPath();p.move(to:.init(x:237,y:128));p.curve(to:.init(x:389,y:280),controlPoint1:.init(x:340,y:140),controlPoint2:.init(x:288,y:267));p.lineWidth=6;a.setStroke();p.stroke();for q in [NSPoint(x:237,y:128),.init(x:313,y:207),.init(x:389,y:280)]{circle(q.x,q.y,8,ink)} + case 7:for i in 0..<3{wheel(CGFloat(196+i*124),210,50);text(["暗部","中间调","亮部"][i],.init(x:CGFloat(146+i*124),y:135,width:100,height:25),20,ink)} + case 8:for (i,c) in [NSColor.systemRed,.systemGreen,.systemBlue].enumerated(){let x=CGFloat(240+i*80);circle(x,210,58,c.withAlphaComponent(0.8));text(["R","G","B"][i],.init(x:x-30,y:189,width:60,height:45),34,ink)} + case 9:for i in 0..<48{let x=CGFloat(i)/47;let height=CGFloat(15+90*exp(-pow((Double(x)-0.32)/0.14,2))+120*exp(-pow((Double(x)-0.70)/0.18,2)));box(.init(x:171+CGFloat(i)*6.3,y:155,width:4.8,height:height),a,1)} + for i in 0..<64{box(.init(x:171+CGFloat(i)*4.7,y:121,width:5,height:17),NSColor(calibratedWhite:CGFloat(i)/63,alpha:1),0)} + case 10:for i in 0..<7{box(.init(x:181+CGFloat(i)*40,y:135,width:36,height:144),NSColor(calibratedWhite:CGFloat(i)/6,alpha:1),5)} + case 11:for i in 0..<3{let y=CGFloat(155+i*51),c1:[NSColor]=[.systemCyan,.systemPurple,.systemYellow],c2:[NSColor]=[.systemRed,.systemGreen,.systemBlue];for k in 0..<50{box(.init(x:184+CGFloat(k)*5.4,y:y,width:6,height:12),c1[i].blended(withFraction:CGFloat(k)/49,of:c2[i])!,0)};circle(CGFloat([295,354,318][i]),y+6,12,ink)} + case 12:for i in 0..<3{for j in 0..<3{line([.init(x:218,y:CGFloat(150+i*57)),.init(x:422,y:CGFloat(150+j*57))],color(CGFloat(i)/3).withAlphaComponent(i==j ? 0.9:0.45),i==j ? 5:2)}};for i in 0..<3{for x:CGFloat in [218,422]{circle(x,CGFloat(150+i*57),16,color(CGFloat(i)/3))}} + case 13:box(.init(x:170,y:126,width:300,height:163),muted,10);for x in stride(from:CGFloat(180),to:460,by:28){box(.init(x:x,y:135,width:15,height:13),.black,2);box(.init(x:x,y:268,width:15,height:13),.black,2)};for i in 0..<3{box(.init(x:184+CGFloat(i)*92,y:157,width:84,height:100),[NSColor.systemOrange,.systemTeal,.systemPurple][i].withAlphaComponent(0.65),3)} + case 14:for i in 0...6{let v=CGFloat(i)/6;let p=(0...32).map{k -> NSPoint in let t=CGFloat(k)/32;return .init(x:210+v*220+(v-0.5)*35*sin(t * .pi),y:125+t*165)};line(p,a,2);let q=(0...32).map{k -> NSPoint in let t=CGFloat(k)/32;return .init(x:210+t*220,y:125+v*165+(v-0.5)*35*sin(t * .pi))};line(q,a,2)} + default:let c1=[NSPoint(x:184,y:142),.init(x:214,y:282),.init(x:296,y:175),.init(x:184,y:142)];line(c1,.systemPurple,6);let c2=[NSPoint(x:366,y:148),.init(x:409,y:269),.init(x:465,y:176),.init(x:366,y:148)];line(c2,.systemCyan,6);line([.init(x:302,y:211),.init(x:351,y:211),.init(x:339,y:221)],ink,5);line([.init(x:351,y:211),.init(x:339,y:201)],ink,5);text("LOG",.init(x:191,y:110,width:90,height:25),19,ink);text("709",.init(x:371,y:110,width:90,height:25),19,ink) + } +} +func render(_ n:Int,_ width:Int,_ height:Int) -> Data { + let b=NSBitmapImageRep(bitmapDataPlanes:nil,pixelsWide:width,pixelsHigh:height,bitsPerSample:8,samplesPerPixel:4,hasAlpha:true,isPlanar:false,colorSpaceName:.deviceRGB,bytesPerRow:0,bitsPerPixel:0)! + NSGraphicsContext.saveGraphicsState();NSGraphicsContext.current=NSGraphicsContext(bitmapImageRep:b) + let transform=NSAffineTransform();transform.scale(by:CGFloat(width)/640);transform.concat() + box(.init(x:0,y:0,width:640,height:360),NSColor(calibratedWhite:0.065,alpha:1),0) + box(.init(x:0,y:0,width:640,height:7),accents[n],0) + text("大鱼调色",.init(x:20,y:316,width:110,height:24),18,NSColor(calibratedWhite:0.65,alpha:1),.medium) + art(n);text(names[n],.init(x:16,y:35,width:608,height:50),names[n].count>10 ? 31:37,.white) + NSGraphicsContext.restoreGraphicsState();return b.representation(using:.png,properties:[:])! +} +for (i,name) in names.enumerated(){let dir=root.appendingPathComponent("template").appendingPathComponent(name);try FileManager.default.createDirectory(at:dir,withIntermediateDirectories:true);for (file,w,h) in [("large.png",640,360),("small.png",240,135)]{try render(i,w,h).write(to:dir.appendingPathComponent(file))}} +print("Rendered 16 distinct module previews at 640×360 and 240×135") diff --git a/tools/template_payload.py b/tools/template_payload.py index 1775d00..cf1a3b1 100644 --- a/tools/template_payload.py +++ b/tools/template_payload.py @@ -12,5 +12,5 @@ def template_files(): installed = Path(effect) / name # Preserve the full effect's original flat bundle layout and artwork. bundled = Path(name) if effect == EFFECTS[0] else installed - source = Path(name) if name in PREVIEWS else bundled + source = bundled yield source, bundled, installed diff --git a/大鱼调色/Plugin/DYCanvasToolsDiagnostics.inc.h b/大鱼调色/Plugin/DYCanvasToolsDiagnostics.inc.h index 5d32b1b..9dbc2ea 100644 --- a/大鱼调色/Plugin/DYCanvasToolsDiagnostics.inc.h +++ b/大鱼调色/Plugin/DYCanvasToolsDiagnostics.inc.h @@ -56,6 +56,11 @@ if(faceFixture.length){ NSMutableDictionary *masked=DYMutablePlist([[[DYToolDocument alloc]init]autorelease].document);NSMutableDictionary *zero=DYMutablePlist(DYNewMask(DYMaskRectangle));DYMaskParameters zeroP=DYMaskAtTime(zero,kCMTimeZero);zeroP.strength=0;zero[@"parameters"]=[NSData dataWithBytes:&zeroP length:sizeof(zeroP)];masked[@"baseMasks"][@"skin"]=[NSMutableArray arrayWithObject:zero];u.skinVisualize=1;NSError *maskError=nil;BOOL maskOK=[face renderSource:src destination:dst uniforms:u paths:@{}spider:nil tools:masked error:&maskError];Pixels empty=read(dst,gpu);double emptyMax=0;for(NSUInteger i=0;i.01&&layerBackground<.001); DYDiagnosticTile *twoSource=[[[DYDiagnosticTile alloc]initWithDevice:gpu width:1024 height:512]autorelease],*twoDest=[[[DYDiagnosticTile alloc]initWithDevice:gpu width:1024 height:512]autorelease];Pixels two(1024*512*4);for(NSUInteger y=0;y<512;y++)for(NSUInteger x=0;x<1024;x++)memcpy(two.data()+(y*1024+x)*4,portrait.data()+(y*512+x%512)*4,8);[[twoSource metalTextureForDevice:gpu]replaceRegion:MTLRegionMake2D(0,0,1024,512)mipmapLevel:0 withBytes:two.data()bytesPerRow:1024*8];u.skinProtection.x=1;BOOL twoOK=[face renderSource:twoSource destination:twoDest uniforms:u paths:@{}error:&maskError];NSData *twoEntries=[face valueForKey:@"faceEntries"];const DYToolMaskEntry *twoMasks=(const DYToolMaskEntry*)twoEntries.bytes;NSInteger faceCount=0;for(NSUInteger i=0;i.05&&privateOutside==0,@{@"faceChange":@(privateInside),@"backgroundChange":@(privateOutside)}); Pixels noFace(w*h*4);for(NSUInteger i=0;i_values copy]autorelease],*custom=[[host->_custom copy]autorelease];int starts=host->_undoStarts,ends=host->_undoEnds; [settings performClick:nil];[view layoutSubtreeIfNeeded];run.record(@"compact-color-settings-button-expands-panel",!panel.hidden&&first.frame.origin.y>=NSMaxY(panel.frame)+12&&settings.state==NSControlStateValueOn); - run.record(@"inspector-preferred-height-follows-content-with-a-scroll-cap",foldedHeight<780&&view.intrinsicContentSize.height>foldedHeight&&view.intrinsicContentSize.height<=780); + run.record(@"inspector-preferred-height-follows-complete-content",view.intrinsicContentSize.height>foldedHeight); double layoutDeadline=NSProcessInfo.processInfo.systemUptime+.02; while(NSProcessInfo.processInfo.systemUptimecardsScroll.contentSize.height); + run.record(@"inspector-grows-with-content-and-has-no-inner-scroll-view",view.frame.size.height==view.intrinsicContentSize.height&&NSContainsRect(view.bounds,brandLabel.frame)&&cardsScroll==nil); for(int i=0;i<9;i++){[settings performClick:nil];[view layoutSubtreeIfNeeded];} run.record(@"compact-color-settings-repeated-toggle-does-not-edit-grade",panel.hidden&&first.frame.origin.y==8&&[values isEqual:host->_values]&&[custom isEqual:host->_custom]&&starts==host->_undoStarts&&ends==host->_undoEnds); diff --git a/大鱼调色/Plugin/DYDiagnostics.mm b/大鱼调色/Plugin/DYDiagnostics.mm index 5275cde..07abfea 100644 --- a/大鱼调色/Plugin/DYDiagnostics.mm +++ b/大鱼调色/Plugin/DYDiagnostics.mm @@ -528,6 +528,7 @@ extern "C" int DYRunDiagnostics(void) { @autoreleasepool { #include "DYMaskPanelDiagnostics.inc.h" #include "DYManagedDiagnostics.inc.h" #include "DYPrimaryDiagnostics.inc.h" + #include "DYUnifiedDiagnostics.inc.h" #include "DYCompactUIDiagnostics.inc.h" #include "DYViewerParameterDiagnostics.inc.h" #include "DYViewerControlsDiagnostics.inc.h" diff --git a/大鱼调色/Plugin/DYFaceRender.inc.h b/大鱼调色/Plugin/DYFaceRender.inc.h index d174e9e..746b33a 100644 --- a/大鱼调色/Plugin/DYFaceRender.inc.h +++ b/大鱼调色/Plugin/DYFaceRender.inc.h @@ -17,6 +17,11 @@ 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; + // Privacy coverage includes eyes, brows and mouth. Skin's feature holes must + // never punch through the mosaic. A padded rectangle covers the full face. + DYToolMaskEntry privacy{};privacy.section=-102;privacy.mask.parameters=dyDefaultMaskParameters(); + privacy.mask.parameters.kind=DYMaskRectangle;privacy.mask.parameters.centerX=CGRectGetMidX(box);privacy.mask.parameters.centerY=1-CGRectGetMidY(box); + privacy.mask.parameters.width=box.size.width*1.2;privacy.mask.parameters.height=box.size.height*1.25;privacy.mask.parameters.feather=0;entries.push_back(privacy); 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;i input [[texture(0)]], } output.write(color,gid); } + +// Block-centre sampling is stable in image coordinates and never feeds back. +kernel void dyLocalMosaic(texture2d input [[texture(0)]],texture2d output [[texture(1)]],device const DYToolMaskEntry* masks [[buffer(0)]],constant DYToolMaskHeader& h [[buffer(1)]],constant uint& block [[buffer(2)]],uint2 p [[thread_position_in_grid]]) { + uint2 size=uint2(output.get_width(),output.get_height());if(any(p>=size))return; + float4 original=input.read(p);float2 uv=(float2(p)+.5f)/float2(size);float3 code=dyToolEncode(original.a>0?original.rgb/original.a:float3(0));float coverage=0; + if(h.section==-102){float x=h.offsetX+uv.x*h.scaleX,y=h.offsetY+uv.y*h.scaleY;for(uint i=0;i0?sample.rgb/sample.a*original.a:original.rgb; + output.write(float4(mix(original.rgb,rgb,coverage),original.a),p); +} + +// Extend bounded creative operators by their boundary delta. The float32 +// residual carries negative / above-one values around the historical bounded +// kernels. Neutral tools skip this adapter entirely. This is a declared code +// domain extension, not a tone map and not an intermediate output transform. +kernel void dyUnifiedBridgeIn(texture2d a [[texture(0)]],texture2d b [[texture(1)]],uint2 p [[thread_position_in_grid]]){ + if(any(p>=uint2(b.get_width(),b.get_height())))return;float4 c=a.read(p);if(c.a>0)c.rgb=dyToolDecode(clamp(c.rgb/c.a,0.f,1.f))*c.a;b.write(c,p); +} +kernel void dyUnifiedBridgeOut(texture2d raw [[texture(0)]],texture2d changed [[texture(1)]],texture2d out [[texture(2)]],uint2 p [[thread_position_in_grid]]){ + if(any(p>=uint2(out.get_width(),out.get_height())))return;float4 a=raw.read(p),b=changed.read(p);if(a.a>0&&b.a>0){float3 c=a.rgb/a.a;float3 delta=dyToolEncode(b.rgb/b.a)-clamp(c,0.f,1.f);a.rgb=(c+delta)*a.a;}out.write(a,p); +} diff --git a/大鱼调色/Plugin/DYInspector.mm b/大鱼调色/Plugin/DYInspector.mm index cdacacd..b56919f 100644 --- a/大鱼调色/Plugin/DYInspector.mm +++ b/大鱼调色/Plugin/DYInspector.mm @@ -211,12 +211,12 @@ static NSArray *DYAccessibleSubviews(NSView *view, BOOL visibleOnly) { } @end -static NSArray *DYPresentationSections(BOOL cstOnly) { +static NSArray *DYPresentationSections(BOOL cstOnly,BOOL splitOutput) { NSMutableDictionary *bySection=[NSMutableDictionary dictionary],*byKey=[NSMutableDictionary dictionary]; for(NSDictionary *s in DYSections())bySection[s[@"key"]]=s; for(NSDictionary *d in DYDescriptors())byKey[d[@"key"]]=d; NSMutableDictionary *primary=[[bySection[@"primary"]mutableCopy]autorelease];NSMutableArray *cmRows=[NSMutableArray array]; - for(NSString *part in (cstOnly?@[@"input",@"output"]:@[@"input",@"primary",@"output"])){ + for(NSString *part in (splitOutput?(cstOnly?@[@"input"]:@[@"input",@"primary"]):(cstOnly?@[@"input",@"output"]:@[@"input",@"primary",@"output"]))){ [cmRows addObject:@{@"key":[@"heading:" stringByAppendingString:part],@"title":[part isEqual:@"input"]?@"输入与工作空间":[part isEqual:@"output"]?@"输出转换":@"一级调色"}]; for(NSDictionary *d in bySection[part][@"rows"]){NSString *key=d[@"key"];if([key hasPrefix:@"cmbypass"]||[key isEqual:@"cmbalanceStrength"])continue; if([key isEqual:@"cmbalanceAngle"])[cmRows addObject:@{@"key":@"primaryBalance",@"kind":@"balanceWheel",@"title":@"一级白平衡色轮"}];else[cmRows addObject:d];} @@ -227,7 +227,7 @@ static NSArray *DYPresentationSections(BOOL cstOnly) { 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"],bySection[@"lens"]]; + NSMutableArray *presentation=[NSMutableArray arrayWithArray:@[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"]]];if(splitOutput)[presentation addObject:bySection[@"output"]];return presentation; } @@ -488,7 +488,7 @@ NSView *DYCreateWorkspaceMaskEditor(id NSInteger _visibleLooks; NSButton *_colorSettings;BOOL _colorSettingsExpanded; BOOL _refreshing,_graphicUndoOpen,_graphicCancelled;CMTime _graphicTime;NSMutableDictionary *_graphicExpected; - BOOL _embedded,_workspaceEditor;NSMutableDictionary *_stackViews;NSArray *_stackOrder;NSDictionary *_stackRoots;CGFloat _stackHeight,_preferredHeight; + BOOL _embedded,_workspaceEditor,_unified;NSArray *_renderOrder;NSMutableDictionary *_stackViews;NSArray *_stackOrder;NSDictionary *_stackRoots;CGFloat _stackHeight,_preferredHeight; DYSpiderPanel *_spiderPanel; NSMutableDictionary *_assetLoads,*_assetLoadIDs; NSUInteger _nextAssetLoadID; @@ -516,7 +516,7 @@ NSView *DYCreateWorkspaceMaskEditor(id _preferredHeight=(_embedded||_workspaceEditor)?780:406; BOOL cstOnly=NO; if(!_embedded){idaction=[manager apiForProtocol:@protocol(FxCustomParameterActionAPI_v4)];if(action){[action startAction:self];@try{cstOnly=[DYReadTools(manager,action.currentTime).document[@"starterTool"]isEqual:@"cst"];}@finally{[action endAction:self];}}} - NSArray *presentation=DYPresentationSections(cstOnly);if(_embedded||_workspaceEditor){NSMutableArray *filtered=[NSMutableArray array];for(NSDictionary *s in presentation)if([s[@"key"]isEqual:_workspaceEditor?workspaceType:[(DYToolManager*)manager type]])[filtered addObject:s];presentation=filtered;} + NSArray *presentation=DYPresentationSections(cstOnly,!_embedded&&!_workspaceEditor);if(_embedded||_workspaceEditor){NSMutableArray *filtered=[NSMutableArray array];for(NSDictionary *s in presentation)if([s[@"key"]isEqual:_workspaceEditor?workspaceType:[(DYToolManager*)manager type]])[filtered addObject:s];presentation=filtered;} _sections=[presentation copy];_stackViews=[NSMutableDictionary new];_stackOrder=[@[]copy]; _cards=[[NSMutableArray alloc] init]; _controls=[[NSMutableDictionary alloc] init]; _assetButtons=[[NSMutableDictionary alloc] init]; _graphics=[[NSMutableArray alloc] init]; @@ -538,14 +538,14 @@ NSView *DYCreateWorkspaceMaskEditor(id _save.identifier=@"primaryAction"; _workspaceButton=[DYButton(@"控制面板",self,@selector(openWorkspace:))retain];_workspaceButton.accessibilityLabel=@"打开调色控制面板"; _addModule=[[DYThemePopUpButton alloc]initWithFrame:NSZeroRect pullsDown:YES];_addModule.font=[NSFont systemFontOfSize:11];_addModule.accessibilityLabel=@"添加模块";[_addModule addItemWithTitle:@"+ 添加模块"]; - for(NSDictionary *section in DYPresentationSections(NO)){NSMenuItem *item=[[[NSMenuItem alloc]initWithTitle:section[@"title"] action:@selector(addModule:) keyEquivalent:@""]autorelease];item.target=self;item.representedObject=section[@"key"];[_addModule.menu addItem:item];} + for(NSDictionary *section in DYPresentationSections(NO,NO)){NSMenuItem *item=[[[NSMenuItem alloc]initWithTitle:section[@"title"] action:@selector(addModule:) keyEquivalent:@""]autorelease];item.target=self;item.representedObject=section[@"key"];[_addModule.menu addItem:item];} for(NSView *v in @[_brand,_subtitle,_websiteLink,_resetAll,_save,_load,_export,_colorSettings,_addModule,_workspaceButton]){[self addSubview:v];v.hidden=_embedded||_workspaceEditor;} NSMutableArray *themes=[NSMutableArray array];for(NSInteger i=0;i *DYCreateWorkspaceMaskEditor(id _scroll.accessibilityLabel=@"调色参数滚动区"; _document=[[DYFlippedView alloc] initWithFrame:NSMakeRect(0,0,360,1000)]; _document.accessibilityLabel=@"调色参数";_document.identifier=@"inspectorBackground"; - _scroll.documentView=_document; [self addSubview:_scroll]; + if(_scroll){_scroll.documentView=_document;[self addSubview:_scroll];} + else [self addSubview:_document]; if(!_embedded&&!_workspaceEditor){_managedPanel=[[DYManagedColorPanel alloc]initWithManager:_manager renderer:_renderer assetTarget:self];_managedPanel.hidden=YES;[_document addSubview:_managedPanel];} [self buildCards]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(modelChanged:) name:@"DYModelChanged" object:_manager]; @@ -577,7 +578,7 @@ NSView *DYCreateWorkspaceMaskEditor(id for(id graphic in _graphics)if([graphic isKindOfClass:DYPrimaryBalanceWheel.class])[(DYPrimaryBalanceWheel*)graphic setDelegate:nil]; for(NSProgress *p in _assetLoads.allValues)[p cancel];[_assetLoads release];[_assetLoadIDs release];[_menuScan cancel];[_menuScan release];[_pendingAssetMenuCommand release]; [[NSNotificationCenter defaultCenter] removeObserver:self];[NSWorkspace.sharedWorkspace.notificationCenter removeObserver:self]; - if(_embedded)[(id)_manager release];[_stackViews release];[_stackOrder release];[_stackRoots release]; + if(_embedded)[(id)_manager release];[_stackViews release];[_stackOrder release];[_stackRoots release];[_renderOrder release]; [_brand release]; [_subtitle release]; [_websiteLink release]; [_resetAll release]; [_save release]; [_load release]; [_export release];[_colorSettings release];[_addModule release]; [_managedPanel release];[_scroll release]; [_document release]; [_sections release]; [_cards release]; [_controls release]; [_assetButtons release]; [_graphics release]; [_sampler release]; [_recentBrowser close];[_recentBrowser release];[_recentHost release]; @@ -605,6 +606,19 @@ NSView *DYCreateWorkspaceMaskEditor(id if([NSThread isMainThread]) {[self refresh];NSString *ID=n.userInfo[@"scrollToTool"];if(!_embedded&&ID.length&&_stackViews[ID]){[self layoutSubtreeIfNeeded];NSView *child=_stackViews[ID];[_document scrollPoint:NSMakePoint(0,MAX(0,child.frame.origin.y-8))];}} else dispatch_async(dispatch_get_main_queue(),^{ [self refresh]; }); } +- (void)moveOutput:(NSButton*)button { + ida=[self actionAPI];[a startAction:self]; + @try{NSMutableDictionary *doc=DYMutablePlist(DYReadTools(_manager,a.currentTime).document);NSMutableArray *visible=[NSMutableArray array]; + for(NSString *ID in DYUnifiedRenderOrder(doc)){BOOL shown=[ID isEqual:@"output"]||_stackViews[ID]!=nil;if([ID hasPrefix:@"base:"])for(NSDictionary *card in _cards)if([card[@"section"][@"key"]isEqual:[ID substringFromIndex:5]])shown=![card[@"removed"]boolValue];if(shown)[visible addObject:ID];} + NSInteger index=[visible indexOfObject:@"output"],target=index+button.tag;if(index==NSNotFound||target<0||target>=visible.count)return; + [visible exchangeObjectAtIndex:index withObjectAtIndex:target]; + // Input interpretation remains at the front. Output may follow the first + // grading node, but it cannot precede the declared input conversion. + if(target==0)return; + doc[@"outputAfter"]=target==visible.count-1?@"tail":visible[target-1]; + idundo=[_manager apiForProtocol:@protocol(FxUndoAPI)];if([undo startUndoGroup:@"移动输出转换层"]){DYWriteTools(_manager,doc,a.currentTime);[undo endUndoGroup];} + }@finally{[a endAction:self];}[self postChanged]; +} - (void)selectTheme:(NSButton *)button {DYSetThemeIndex(button.tag);} - (void)toggleColorSettings:(id)sender { _colorSettingsExpanded=!_colorSettingsExpanded;_managedPanel.hidden=!_colorSettingsExpanded;_colorSettings.state=_colorSettingsExpanded?NSControlStateValueOn:NSControlStateValueOff; @@ -824,7 +838,7 @@ NSView *DYCreateWorkspaceMaskEditor(id NSArray *actions=@[_save,_load,_export,_colorSettings];for(NSUInteger i=0;i *DYCreateWorkspaceMaskEditor(id [r[@"choose"]setFrame:NSMakeRect(97,3,MAX(65,rw-152),26)];[r[@"folder"]setFrame:NSMakeRect(rw-51,4,24,24)];[r[@"remove"]setFrame:NSMakeRect(rw-23,4,22,24)]; } y=[self layoutRepeatedToolsAfter:@"tail" y:y width:w]; - _stackHeight=y;CGFloat documentWidth=_scroll.contentSize.width;if(_workspaceEditor)for(NSDictionary *card in _cards)documentWidth=MAX(documentWidth,[card[@"view"]frame].size.width);[_document setFrameSize:NSMakeSize(documentWidth,_workspaceEditor?_scroll.contentSize.height:MAX(y,_scroll.contentSize.height))]; + if(_unified&&!_embedded&&!_workspaceEditor){ + NSMutableDictionary *views=[NSMutableDictionary dictionary]; + for(NSDictionary *card in _cards){NSString *key=card[@"section"][@"key"];NSView *view=card[@"view"];if(!view.hidden)views[[key isEqual:@"output"]?@"output":[@"base:" stringByAppendingString:key]]=view;} + [views addEntriesFromDictionary:_stackViews];y=(_managedPanel&&!_managedPanel.hidden)?NSMaxY(_managedPanel.frame)+12:8; + for(NSString *ID in _renderOrder){NSView *view=views[ID];if(!view||view.hidden)continue;NSRect frame=view.frame;frame.origin.y=y;view.frame=frame;y+=frame.size.height+([ID hasPrefix:@"base:"]||[ID isEqual:@"output"]?12:0);} + } + for(NSDictionary *card in _cards)if([card[@"section"][@"key"]isEqual:@"output"]){ + [card[@"maskButton"]setHidden:YES];[card[@"maskBadge"]setHidden:YES]; + NSButton *up=card[@"repeatButton"],*down=card[@"removeButton"];up.image=down.image=nil;up.title=@"↑";down.title=@"↓";up.tag=-1;down.tag=1;up.action=down.action=@selector(moveOutput:);up.toolTip=@"输出转换上移一层";down.toolTip=@"输出转换下移一层";up.accessibilityLabel=up.toolTip;down.accessibilityLabel=down.toolTip; + } + + _stackHeight=y;CGFloat documentWidth=_scroll?_scroll.contentSize.width:w;if(_workspaceEditor)for(NSDictionary *card in _cards)documentWidth=MAX(documentWidth,[card[@"view"]frame].size.width); + _document.frame=NSMakeRect(0,(_embedded||_workspaceEditor)?0:top,documentWidth,_workspaceEditor?_scroll.contentSize.height:y); if(!_embedded&&!_workspaceEditor){ - CGFloat preferred=MIN(780,ceil(top+MAX(12,y))); + CGFloat preferred=ceil(top+MAX(12,y)); if(preferred!=_preferredHeight){ _preferredHeight=preferred; - // FCP owns the attached custom parameter's slot. Resizing the - // remote child there bottom-aligns it and clips the fixed header. + // Notify ViewBridge after the parameter action has unwound. The + // entire document has one natural height; only the host scrolls. dispatch_async(dispatch_get_main_queue(),^{ if(preferred!=self->_preferredHeight)return; [self invalidateIntrinsicContentSize]; - if(!self.superview&&!self.window&&self.frame.size.height!=preferred) + if(self.frame.size.height!=preferred) [self setFrameSize:NSMakeSize(self.frame.size.width,preferred)]; + [self.superview setNeedsLayout:YES]; + NSAccessibilityPostNotification(self,NSAccessibilityLayoutChangedNotification); }); } } @@ -933,6 +961,14 @@ NSView *DYCreateWorkspaceMaskEditor(id @try { CMTime t=action.currentTime; id get=[_manager apiForProtocol:@protocol(FxParameterRetrievalAPI_v6)]; + if(!_embedded&&!_workspaceEditor){ + _unified=DYUnifiedColorState(DYReadAssets(_manager,t).colorManagement); + [_renderOrder release];_renderOrder=[DYUnifiedRenderOrder(DYReadTools(_manager,t).document)copy]; + NSMutableDictionary *primary=nil,*output=nil;for(NSMutableDictionary *card in _cards){if([card[@"section"][@"key"]isEqual:@"primary"])primary=card;if([card[@"section"][@"key"]isEqual:@"output"])output=card;} + NSMutableArray *body=[NSMutableArray arrayWithArray:primary[@"body"]]; + for(NSView *row in output[@"body"]){if([row.identifier isEqual:@"toolMasks"])continue;[body removeObjectIdenticalTo:row];[(_unified?output:primary)[@"view"]addSubview:row];if(!_unified)[body addObject:row];} + primary[@"body"]=body; + } NSMutableDictionary *graphicValues=[NSMutableDictionary dictionary]; for(NSNumber *pid in _controls) { NSDictionary *r=_controls[pid],*d=r[@"descriptor"]; double v=[d[@"default"] doubleValue]; @@ -968,7 +1004,7 @@ NSView *DYCreateWorkspaceMaskEditor(id if(!_embedded){DYInspectorToken *token=nil;[get getCustomParameterValue:&token fromParameter:DYInspectorParameterID atTime:t];visible=[tools[@"starterTool"]isEqual:type]||[@[@"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"])for(NSString *assetKey in DYReadAssets(_manager,t).paths)if([assetKey hasPrefix:@"look"])visible=YES;} } - BOOL removed=!_embedded&&(DYBaseToolRemoved(tools,type)||(!_workspaceEditor&&!visible));groupingChanged|=[card[@"removed"]boolValue]!=removed;((NSMutableDictionary *)card)[@"removed"]=@(removed); + BOOL removed=[type isEqual:@"output"]?!_unified:!_embedded&&(DYBaseToolRemoved(tools,type)||(!_workspaceEditor&&!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]:@"添加本工具的独立蒙版"; @@ -1075,7 +1111,7 @@ NSView *DYCreateWorkspaceMaskEditor(id id set=[_manager apiForProtocol:@protocol(FxParameterSettingAPI_v6)]; [set setFloatValue:enabled?1:0 toParameter:pid.unsignedIntValue atTime:action.currentTime]; NSNumber *extra=section[@"extraEnabled"];if(extra)[set setFloatValue:enabled?1:0 toParameter:extra.unsignedIntValue atTime:action.currentTime]; - for(NSNumber *linked in section[@"enableParameters"])[set setFloatValue:enabled?1:0 toParameter:linked.unsignedIntValue atTime:action.currentTime]; + if(!(_unified&&[section[@"key"]isEqual:@"primary"]))for(NSNumber *linked in section[@"enableParameters"])[set setFloatValue:enabled?1:0 toParameter:linked.unsignedIntValue atTime:action.currentTime]; } @finally {[action endAction:self];} diff --git a/大鱼调色/Plugin/DYManagedColor.h b/大鱼调色/Plugin/DYManagedColor.h index 39f8d67..b63df7a 100644 --- a/大鱼调色/Plugin/DYManagedColor.h +++ b/大鱼调色/Plugin/DYManagedColor.h @@ -4,6 +4,8 @@ // Separate authoring state; absent state always selects the unchanged v1 renderer. FOUNDATION_EXPORT NSDictionary *DYManagedColorDefaults(void); FOUNDATION_EXPORT NSDictionary *DYPrimaryColorDefaults(void); +FOUNDATION_EXPORT NSDictionary *DYUnifiedColorDefaults(void); +FOUNDATION_EXPORT BOOL DYUnifiedColorState(NSDictionary *state); FOUNDATION_EXPORT BOOL DYPrimaryColorState(NSDictionary *state); FOUNDATION_EXPORT void DYSeedPrimaryWorkingSpace(NSMutableDictionary *node,float transfer,float gamut); FOUNDATION_EXPORT BOOL DYManagedColorValid(id state,NSError **error); diff --git a/大鱼调色/Plugin/DYManagedColor.mm b/大鱼调色/Plugin/DYManagedColor.mm index 473a28a..2e18c9a 100644 --- a/大鱼调色/Plugin/DYManagedColor.mm +++ b/大鱼调色/Plugin/DYManagedColor.mm @@ -5,7 +5,9 @@ #include NSDictionary *DYManagedColorDefaults(void){return @{@"version":@2,@"mode":@1,@"input":@109,@"output":@1,@"gamutCompression":@YES,@"engine":@"OpenColorIO-2.5.2",@"config":@"studio-config-v2.2.0_aces-v1.3_ocio-v2.4"};} NSDictionary *DYPrimaryColorDefaults(void){return @{@"version":@3,@"mode":@4,@"engine":@"Dayu-CST-f32",@"config":@"primary-parameters-v1"};} -BOOL DYPrimaryColorState(NSDictionary *s){return [s isKindOfClass:NSDictionary.class]&&[s[@"version"]isEqual:@3]&&[s[@"mode"]isEqual:@4];} +NSDictionary *DYUnifiedColorDefaults(void){return @{@"version":@4,@"mode":@5,@"engine":@"Dayu-CST-f32",@"config":@"ordered-working-domain-v1"};} +BOOL DYUnifiedColorState(NSDictionary *s){return [s isKindOfClass:NSDictionary.class]&&[s[@"version"]isEqual:@4]&&[s[@"mode"]isEqual:@5];} +BOOL DYPrimaryColorState(NSDictionary *s){return DYUnifiedColorState(s)||([s isKindOfClass:NSDictionary.class]&&[s[@"version"]isEqual:@3]&&[s[@"mode"]isEqual:@4]);} void DYSeedPrimaryWorkingSpace(NSMutableDictionary *node,float transfer,float gamut){ if(![node[@"type"]isEqual:@"primary"])return;NSMutableDictionary*v=node[@"values"];NSUInteger follow=[node[@"primaryFollow"]unsignedIntegerValue],bit=1; for(NSString *part in @[@"input",@"working",@"output"]){NSString*t=[NSString stringWithFormat:@"cm%@Transfer",part],*g=[NSString stringWithFormat:@"cm%@Gamut",part];if(!v[t]&&!v[g])follow|=bit;if(!v[t])v[t]=@(transfer);if(!v[g])v[g]=@(gamut);bit<<=1;}node[@"primaryFollow"]=@(follow); @@ -19,6 +21,7 @@ void DYPrimaryControlChanged(id manager,CMTime time,NSString *k NSArray *DYManagedInputSpaces(void){NSMutableArray *a=[NSMutableArray array];for(const auto&s:dycm::spaces())[a addObject:@{@"id":@(unsigned(s.id)),@"name":@(s.label)}];return a;} NSArray *DYManagedOutputSpaces(void){NSMutableArray *a=[NSMutableArray array];for(const auto&s:dycm::outputs())[a addObject:@{@"id":@(unsigned(s.id)),@"name":@(s.label)}];return a;} BOOL DYManagedColorValid(id state,NSError **error){ + if(DYUnifiedColorState(state))return [state isEqual:DYUnifiedColorDefaults()]; if(DYPrimaryColorState(state)){BOOL valid=[state isEqual:DYPrimaryColorDefaults()];if(!valid&&error)*error=[NSError errorWithDomain:@"com.dayu.color.cms" code:1 userInfo:@{NSLocalizedDescriptionKey:@"一级 CST 设置版本不匹配。"}];return valid;} BOOL valid=[state isKindOfClass:NSDictionary.class]&&[state count]==7&&[state[@"version"]isEqual:@2]&&[state[@"engine"]isEqual:@"OpenColorIO-2.5.2"]&&[state[@"config"]isEqual:@"studio-config-v2.2.0_aces-v1.3_ocio-v2.4"]; for(NSString *key in @[@"mode",@"input",@"output",@"gamutCompression"]){id v=[state isKindOfClass:NSDictionary.class]?state[key]:nil;double n=[v isKindOfClass:NSNumber.class]?[v doubleValue]:NAN;valid&=std::isfinite(n)&&n==floor(n);} diff --git a/大鱼调色/Plugin/DYManagedColorPanel.mm b/大鱼调色/Plugin/DYManagedColorPanel.mm index 9962d6b..aa480ab 100644 --- a/大鱼调色/Plugin/DYManagedColorPanel.mm +++ b/大鱼调色/Plugin/DYManagedColorPanel.mm @@ -13,11 +13,11 @@ NSDictionary *_state;NSString *_inputLUTPath;NSUInteger _selectionGeneration;BOOL _refreshing; } - (BOOL)isFlipped{return YES;} -- (CGFloat)contentHeight{NSInteger m=[_state[@"mode"]integerValue];return m==0?82:(m==1||m==4)?110:238;} +- (CGFloat)contentHeight{NSInteger m=[_state[@"mode"]integerValue];return m==0?82:(m==1||m>=4)?110:238;} static NSTextField *cmsLabel(NSString*s){NSTextField*l=[DYThemeLabel wrappingLabelWithString:s];l.font=[NSFont systemFontOfSize:11];l.textColor=DYThemeColor(@"text");return l;} - (instancetype)initWithManager:(id)m renderer:(DYRenderer*)r assetTarget:(id)target { if((self=[super initWithFrame:NSZeroRect])){_manager=m;_renderer=[r retain];_assetTarget=target;self.identifier=@"managedColor"; - _mode=[[DYThemePopUpButton alloc]initWithFrame:NSZeroRect];[_mode addItemsWithTitles:@[@"原有流程(默认)",@"1.8 兼容 · 跟随 FCP",@"1.8 兼容 · 相机 → ACES",@"1.8 兼容 · LUT → ACES",@"一级 CST · 延后输出"]];_mode.target=self;_mode.action=@selector(modeChanged:);_mode.accessibilityLabel=@"色彩管理方式"; + _mode=[[DYThemePopUpButton alloc]initWithFrame:NSZeroRect];[_mode addItemsWithTitles:@[@"原有流程(默认)",@"1.8 兼容 · 跟随 FCP",@"1.8 兼容 · 相机 → ACES",@"1.8 兼容 · LUT → ACES",@"1.9 兼容 · 一级与印片后输出",@"全链路 · 输出转换层"]];_mode.target=self;_mode.action=@selector(modeChanged:);_mode.accessibilityLabel=@"色彩管理方式"; _inputLabel=[cmsLabel(@"输入空间")retain];_outputLabel=[cmsLabel(@"输出目标")retain]; _input=[[DYThemePopUpButton alloc]initWithFrame:NSZeroRect];for(NSDictionary*s in DYManagedInputSpaces()){[_input addItemWithTitle:s[@"name"]];_input.lastItem.representedObject=s[@"id"];} _input.target=self;_input.action=@selector(settingsChanged:);_input.accessibilityLabel=@"新版输入空间"; _output=[[DYThemePopUpButton alloc]initWithFrame:NSZeroRect];for(NSDictionary*s in DYManagedOutputSpaces()){[_output addItemWithTitle:s[@"name"]];_output.lastItem.representedObject=s[@"id"];} _output.target=self;_output.action=@selector(settingsChanged:);_output.accessibilityLabel=@"新版输出目标"; @@ -32,17 +32,17 @@ static NSTextField *cmsLabel(NSString*s){NSTextField*l=[DYThemeLabel wrappingLab - (void)refreshWithState:(NSDictionary*)s context:(NSDictionary*)context { _refreshing=YES;NSDictionary *saved=[s copy];[_state release];_state=saved;NSInteger mode=s.count?[s[@"mode"]integerValue]:0;[_mode selectItemAtIndex:mode]; NSDictionary *values=s.count&&!DYPrimaryColorState(s)?s:DYManagedColorDefaults();for(NSMenuItem*i in _input.itemArray)if([i.representedObject isEqual:values[@"input"]])[_input selectItem:i];for(NSMenuItem*i in _output.itemArray)if([i.representedObject isEqual:values[@"output"]])[_output selectItem:i]; - _input.hidden=_inputLabel.hidden=_output.hidden=_outputLabel.hidden=_gamut.hidden=mode<2||mode==4;_context.hidden=mode==0;_input.enabled=mode==2||mode==3;_output.enabled=mode==2||mode==3;_gamut.enabled=mode==2||mode==3;_gamut.state=[values[@"gamutCompression"]boolValue];_lut.hidden=mode!=3;_inputLabel.stringValue=mode==3?@"LUT 输出":@"输入空间";_outputLabel.stringValue=mode==1?@"跟随宿主":@"输出目标"; + _input.hidden=_inputLabel.hidden=_output.hidden=_outputLabel.hidden=_gamut.hidden=mode<2||mode>=4;_context.hidden=mode==0;_input.enabled=mode==2||mode==3;_output.enabled=mode==2||mode==3;_gamut.enabled=mode==2||mode==3;_gamut.state=[values[@"gamutCompression"]boolValue];_lut.hidden=mode!=3;_inputLabel.stringValue=mode==3?@"LUT 输出":@"输入空间";_outputLabel.stringValue=mode==1?@"跟随宿主":@"输出目标"; _help.toolTip=mode==4?@"输入、工作空间及输出均使用下面的一级 CST 设置。一级与印片完成后才执行主输出;其余工具为输出后的 SDR 修饰。请核对上游相机 LUT 与颜色符合,插件无法恢复上游已裁切的信息。":mode==0?@"保留原有处理顺序。选择“延后输出”后,使用一级 CST 的输入和工作空间,在一级与印片之后执行主输出。":mode==1?@"保留 1.8.0 的固定 ACEScct 流程,一级 CST 转换由全局管理接管。宿主已还原的画面无法重新获得原始 Log 信息。":mode==2?@"按所选相机编码解释兼容码值。请确认上游未还原、未自动符合;选择准确输入与输出目标。PQ/HLG 仅支持一级与印片,其他工具用于 SDR。":@"使用输入 LUT,并按“LUT 输出”解释其结果;再进入 ACEScct 和所选输出变换。"; - _help.stringValue=mode==0?@"保留原有调色顺序。高级流程按需选择。":mode==4?@"使用一级 CST 设置,在一级与印片之后输出。":mode==1?@"保留 1.8 兼容流程,输入跟随 FCP。":mode==2?@"按所选相机编码解释输入;请核对上游转换。":@"按所选编码解释输入 LUT 的输出。"; - _context.stringValue=mode==4?@"输入 CST → 工作域调色与印片 → 输出 CST":context.count?[NSString stringWithFormat:@"%@ → ACEScct → %@",context[@"source"]?:@"未知",context[@"destination"]?:@"未知"]:@"宿主颜色信息将在渲染后显示。";_context.toolTip=mode==4?@"素材编码 → 一级输入 CST → 所选工作域调色与印片 → 一级输出 CST → 宿主。请核对上游相机 LUT 与颜色符合;已裁切信息无法恢复。":_context.stringValue;_refreshing=NO;[self setNeedsLayout:YES]; + _help.stringValue=mode==5?@"按模块顺序调色,输出层默认最后,可上下移动。":mode==0?@"保留原有调色顺序。高级流程按需选择。":mode==4?@"使用一级 CST 设置,在一级与印片之后输出。":mode==1?@"保留 1.8 兼容流程,输入跟随 FCP。":mode==2?@"按所选相机编码解释输入;请核对上游转换。":@"按所选编码解释输入 LUT 的输出。"; + _context.stringValue=mode==5?@"输入 → 工作域节点 → 输出转换层 → 宿主":mode==4?@"输入 CST → 工作域调色与印片 → 输出 CST":context.count?[NSString stringWithFormat:@"%@ → ACEScct → %@",context[@"source"]?:@"未知",context[@"destination"]?:@"未知"]:@"宿主颜色信息将在渲染后显示。";_context.toolTip=mode==4?@"素材编码 → 一级输入 CST → 所选工作域调色与印片 → 一级输出 CST → 宿主。请核对上游相机 LUT 与颜色符合;已裁切信息无法恢复。":_context.stringValue;_refreshing=NO;[self setNeedsLayout:YES]; } - (void)setInputLUTPath:(NSString*)path{NSString *saved=[path copy];[_inputLUTPath release];_inputLUTPath=saved;_lut.title=path.length?path.lastPathComponent:@"选择输入 LUT…";_lut.toolTip=path.length?path:@"选择 LUT,并准确指定其输出编码";_lut.accessibilityLabel=path.length?[@"输入 LUT:" stringByAppendingString:path.lastPathComponent]:@"选择输入 LUT";} - (void)refreshContext{[self refreshWithState:_state context:[_renderer colorContext]];} - (void)writeState:(NSDictionary*)state { if(state&&!DYManagedColorValid(state,nil))return;ida=[_manager apiForProtocol:@protocol(FxCustomParameterActionAPI_v4)];if(!a)return;[a startAction:self];@try{idundo=[_manager apiForProtocol:@protocol(FxUndoAPI)];[undo startUndoGroup:@"更改色彩管理方式"];DYAssetState*assets=[[DYReadAssets(_manager,a.currentTime)copy]autorelease];assets.colorManagement=state;DYWriteAssets(_manager,assets,a.currentTime);if(DYPrimaryColorState(state)&&!DYPrimaryColorState(_state)){DYUniforms u;DYReadUniforms(_manager,a.currentTime,&u);NSMutableDictionary*doc=DYMutablePlist(DYReadTools(_manager,a.currentTime).document);for(NSMutableDictionary*node in doc[@"layers"])DYSeedPrimaryWorkingSpace(node,u.cm.workingTransfer,u.cm.workingGamut);DYFollowPrimaryWorkingSpace(doc,u.cm.workingTransfer,u.cm.workingGamut);DYWriteTools(_manager,doc,a.currentTime);}[undo endUndoGroup];}@finally{[a endAction:self];}[_renderer invalidatePreview];[NSNotificationCenter.defaultCenter postNotificationName:DYModelChanged object:_manager]; } -- (void)modeChanged:(id)sender {if(_refreshing)return;NSInteger mode=_mode.indexOfSelectedItem;_selectionGeneration++;if(mode==3&&(!_inputLUTPath.length||![NSFileManager.defaultManager fileExistsAtPath:_inputLUTPath])){[self refreshWithState:_state context:[_renderer colorContext]];[self selectInputLUTAndEnable:YES];return;}if(!mode){[self writeState:nil];return;}if(mode==4){[self writeState:DYPrimaryColorDefaults()];return;}NSMutableDictionary *s=[[(_state&&!DYPrimaryColorState(_state)?_state:DYManagedColorDefaults())mutableCopy]autorelease];s[@"mode"]=@(mode);[self writeState:s];} +- (void)modeChanged:(id)sender {if(_refreshing)return;NSInteger mode=_mode.indexOfSelectedItem;_selectionGeneration++;if(mode==3&&(!_inputLUTPath.length||![NSFileManager.defaultManager fileExistsAtPath:_inputLUTPath])){[self refreshWithState:_state context:[_renderer colorContext]];[self selectInputLUTAndEnable:YES];return;}if(!mode){[self writeState:nil];return;}if(mode==5){[self writeState:DYUnifiedColorDefaults()];return;}if(mode==4){[self writeState:DYPrimaryColorDefaults()];return;}NSMutableDictionary *s=[[(_state&&!DYPrimaryColorState(_state)?_state:DYManagedColorDefaults())mutableCopy]autorelease];s[@"mode"]=@(mode);[self writeState:s];} - (void)settingsChanged:(id)sender {if(_refreshing||!_state)return;NSMutableDictionary*s=[[_state mutableCopy]autorelease];s[@"input"]=_input.selectedItem.representedObject;s[@"output"]=_output.selectedItem.representedObject;s[@"gamutCompression"]=@(_gamut.state==NSControlStateValueOn);[self writeState:s];} - (void)selectInputLUTAndEnable:(BOOL)enable { NSUInteger generation=_selectionGeneration;NSOpenPanel *panel=[NSOpenPanel openPanel];panel.allowedFileTypes=@[@"cube"];panel.allowsMultipleSelection=NO;panel.canChooseDirectories=NO;panel.message=@"选择输入 LUT,再指定 LUT 的输出编码"; diff --git a/大鱼调色/Plugin/DYManagedRender.inc.h b/大鱼调色/Plugin/DYManagedRender.inc.h index 35c37e2..8447750 100644 --- a/大鱼调色/Plugin/DYManagedRender.inc.h +++ b/大鱼调色/Plugin/DYManagedRender.inc.h @@ -95,6 +95,12 @@ - (BOOL)renderColorSource:(FxImageTile*)src destination:(FxImageTile*)dst uniforms:(DYUniforms)u paths:(NSDictionary*)paths spider:(NSData*)spider tools:(NSDictionary*)tools colorManagement:(NSDictionary*)state hostPrimaries:(NSInteger)primaries error:(NSError**)error {@synchronized(self){return DYRenderWithPool(error,[&]()->BOOL{ if(state&&![state isKindOfClass:NSDictionary.class])return fail(error,@"色彩管理状态无效。"); NSDictionary*context=DYHostColorContext(src,dst,primaries);@synchronized(_previewLock){[_colorContext release];_colorContext=[context copy];} + if([tools[@"mosaic"][@"enabled"]boolValue]){ + if(!DYValidToolDocument(tools))return fail(error,@"局部马赛克设置无效。"); + FxImageTile *mosaic=[self sourceByApplyingMosaic:tools source:src registry:dst.deviceRegistryID error:error];if(!mosaic)return NO; + NSMutableDictionary *remaining=[[tools mutableCopy]autorelease];[remaining removeObjectForKey:@"mosaic"];[remaining removeObjectForKey:@"mosaicRenderMask"]; + return [self renderColorSource:mosaic destination:dst uniforms:u paths:paths spider:spider tools:remaining colorManagement:state hostPrimaries:primaries error:error]; + } if(tools[@"sharedMasks"]){ if(!DYValidToolDocument(tools))return fail(error,@"调色层或蒙版数据无效。"); FxImageTile *stamped=[self sourceByApplyingStamps:DYSharedMasks(tools) source:src registry:dst.deviceRegistryID error:error];if(!stamped)return NO; @@ -103,6 +109,7 @@ if(!state.count)return [self renderSource:src destination:dst uniforms:u paths:paths spider:spider tools:tools error:error]; if(!DYManagedColorValid(state,error))return NO;if(!tools)tools=@{@"schema":@2,@"layers":@[],@"baseMasks":@{}};if(!DYValidToolDocument(tools))return fail(error,@"调色层或蒙版数据无效。"); if(tools[@"sharedMasks"])tools=DYResolvedToolDocument(tools); + if(DYUnifiedColorState(state))return [self renderUnifiedSource:src destination:dst uniforms:u paths:paths spider:spider tools:tools hostPrimaries:primaries error:error]; if(DYPrimaryColorState(state))return [self renderPrimarySource:src destination:dst uniforms:u paths:paths spider:spider tools:tools hostPrimaries:primaries error:error]; NSMutableDictionary*entry=[self device:dst.deviceRegistryID error:error];if(!entry)return NO;idd=entry[@"device"];idsource=[src metalTextureForDevice:d];if(!source)return fail(error,@"色彩管理输入纹理不可用。"); uint64_t pixels=uint64_t(source.width)*source.height;if(!pixels||pixels>64ull*1024*1024||pixels*16*8>MAX(768ull*1024*1024,MIN(2ull*1024*1024*1024,d.recommendedMaxWorkingSetSize/2)))return fail(error,@"当前画面超过色彩管理内存预算。"); diff --git a/大鱼调色/Plugin/DYMosaicRender.inc.h b/大鱼调色/Plugin/DYMosaicRender.inc.h new file mode 100644 index 0000000..4024e4b --- /dev/null +++ b/大鱼调色/Plugin/DYMosaicRender.inc.h @@ -0,0 +1,26 @@ +// Runs on the original frame before grading, then follows the same spatial +// transforms as the picture. Geometry has already been evaluated at render time. +- (FxImageTile*)sourceByApplyingMosaic:(NSDictionary*)tools source:(FxImageTile*)src registry:(uint64_t)registry error:(NSError**)error { + NSDictionary *settings=tools[@"mosaic"];if(![settings[@"enabled"]boolValue])return src; + FxRect image=src.imagePixelBounds,bounds=src.tilePixelBounds; + if(memcmp(&image,&bounds,sizeof(FxRect))!=0){fail(error,@"局部马赛克需要完整源画面。");return nil;} + BOOL face=[settings[@"source"]isEqual:@"face"]; + NSDictionary *mask=tools[@"mosaicRenderMask"]?:DYSharedMaskWithID(tools,settings[@"maskID"]); + if(!face&&(!mask||mask[@"stampSource"]||![mask[@"enabled"]boolValue]))return src; + NSMutableDictionary *entry=[self device:registry error:error];if(!entry)return nil; + if(face)[self prepareFaceSupport:src];else{[_faceEntries release];_faceEntries=nil;} + DYToolMaskHeader header{};header.section=face?-102:0; + iddevice=entry[@"device"];idinput=[src metalTextureForDevice:device]; + idbuffer=[self maskBuffer:face?@{}:@{@"primary":@[mask]} tile:src device:device header:&header]; + MTLTextureDescriptor *desc=[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA32Float width:input.width height:input.height mipmapped:NO];desc.storageMode=MTLStorageModePrivate;desc.usage=MTLTextureUsageShaderRead|MTLTextureUsageShaderWrite; + idoutput=[[device newTextureWithDescriptor:desc]autorelease]; + idpipeline=[self managedKernel:@"dyLocalMosaic" entry:entry error:error]; + if(!input||!buffer||!output||!pipeline){fail(error,@"局部马赛克缓冲区不可用。");return nil;} + // Size is in 1080-line reference pixels, stable under proxy/viewer scaling. + uint32_t block=(uint32_t)MAX(2,round([settings[@"size"]doubleValue]*input.height/1080.)); + idcb=[entry[@"queue"]commandBuffer];idce=[cb computeCommandEncoder]; + [ce setComputePipelineState:pipeline];[ce setTexture:input atIndex:0];[ce setTexture:output atIndex:1];[ce setBuffer:buffer offset:0 atIndex:0];[ce setBytes:&header length:sizeof(header) atIndex:1];[ce setBytes:&block length:sizeof(block) atIndex:2]; + [ce dispatchThreads:MTLSizeMake(input.width,input.height,1)threadsPerThreadgroup:MTLSizeMake(16,16,1)];[ce endEncoding];[cb commit];[cb waitUntilCompleted]; + if(cb.status!=MTLCommandBufferStatusCompleted){fail(error,cb.error.localizedDescription);return nil;} + DYExportTile *tile=[[[DYExportTile alloc]initWithTexture:output registry:registry]autorelease];[tile setBounds:bounds origin:src.imageOrigin];[tile setPixelAspect:src.pixelAspect];[tile inheritColorSpace:src.colorSpace];return tile; +} diff --git a/大鱼调色/Plugin/DYRenderer.mm b/大鱼调色/Plugin/DYRenderer.mm index ef7806e..8bfa6fe 100644 --- a/大鱼调色/Plugin/DYRenderer.mm +++ b/大鱼调色/Plugin/DYRenderer.mm @@ -133,6 +133,8 @@ static NSArray *DYPrimaryActiveFinishing(DYUniforms u,NSDictionary *paths,NSData #include "DYScopeCapture.inc.h" #include "DYFilmRender.inc.h" #include "DYPrimaryRender.inc.h" +#include "DYUnifiedRender.inc.h" +#include "DYMosaicRender.inc.h" #include "DYManagedRender.inc.h" #include "DYFaceRender.inc.h" #include "DYToolRender.inc.h" diff --git a/大鱼调色/Plugin/DYToolRender.inc.h b/大鱼调色/Plugin/DYToolRender.inc.h index 8c261e5..d7f814a 100644 --- a/大鱼调色/Plugin/DYToolRender.inc.h +++ b/大鱼调色/Plugin/DYToolRender.inc.h @@ -115,6 +115,7 @@ }@finally{[originalReference release];[skinReference release];[tile release];} });}} - (BOOL)exportLUT:(NSURL*)url uniforms:(DYUniforms)u paths:(NSDictionary*)paths spider:(NSData*)spider tools:(NSDictionary*)tools error:(NSError**)error {@synchronized(self){ + if([tools[@"mosaic"][@"enabled"]boolValue])return fail(error,@"局部马赛克属于空间处理,请保存完整预设。"); if(tools&&!DYValidToolDocument(tools))return fail(error,@"工具或蒙版数据损坏,未更改原工程");DYApplyRemovedBaseTools(&u,tools);paths=DYVisibleBaseToolPaths(paths,tools);if(DYBaseToolRemoved(tools,@"spider"))spider=nil; if(![tools[@"levelMeasureOnly"]boolValue]&&[tools[@"levelRotation"]doubleValue]!=0)return fail(error,@"水平校正属于空间处理,请保存完整预设。"); for(NSDictionary *mask in DYSharedMasks(tools))if(mask[@"stampSource"]&&[mask[@"enabled"]boolValue])return fail(error,@"仿制图章属于空间处理,请保存完整预设。"); diff --git a/大鱼调色/Plugin/DYToolState.h b/大鱼调色/Plugin/DYToolState.h index 09a4985..e02d059 100644 --- a/大鱼调色/Plugin/DYToolState.h +++ b/大鱼调色/Plugin/DYToolState.h @@ -21,6 +21,7 @@ NSDictionary *DYNewTool(NSString *type); NSDictionary *DYInsertTool(NSMutableDictionary *document,NSString *type,NSString *afterID); BOOL DYRemoveTool(NSMutableDictionary *document,NSString *nodeID); NSArray *DYToolDisplayOrder(NSDictionary *document); +NSArray *DYUnifiedRenderOrder(NSDictionary *document); NSString *DYToolRootAnchor(NSDictionary *document,NSString *nodeID); NSDictionary *DYNewMask(NSInteger kind); BOOL DYValidToolDocument(NSDictionary *document); diff --git a/大鱼调色/Plugin/DYToolState.mm b/大鱼调色/Plugin/DYToolState.mm index 3e9de95..b6fed50 100644 --- a/大鱼调色/Plugin/DYToolState.mm +++ b/大鱼调色/Plugin/DYToolState.mm @@ -112,6 +112,12 @@ static NSData *DYValidatedToolData(NSDictionary *doc){ if(![NSPropertyListSerialization propertyList:doc isValidForFormat:NSPropertyListBinaryFormat_v1_0])return nil; if(![doc isKindOfClass:NSDictionary.class]||(![doc[@"schema"]isEqual:@1]&&![doc[@"schema"]isEqual:@2]&&![doc[@"schema"]isEqual:@3])||![doc[@"layers"]isKindOfClass:NSArray.class]||[doc[@"layers"]count]>DYToolLimit||![doc[@"baseMasks"]isKindOfClass:NSDictionary.class]||[doc[@"baseMasks"]count]>DYToolTypes().count)return nil; id starter=doc[@"starterTool"],level=doc[@"levelRotation"]; + id mosaic=doc[@"mosaic"]; + if(mosaic){ + if(![mosaic isKindOfClass:NSDictionary.class]||!finiteNumber(mosaic[@"enabled"])||![@[@0,@1]containsObject:mosaic[@"enabled"]]||![@[@"face",@"mask"]containsObject:mosaic[@"source"]]||!finiteNumber(mosaic[@"size"])||[mosaic[@"size"]doubleValue]<4||[mosaic[@"size"]doubleValue]>128)return nil; + if(mosaic[@"maskID"]&&!validID(mosaic[@"maskID"]))return nil; + } + if(doc[@"mosaicRenderMask"]&&!DYValidToolMask(doc[@"mosaicRenderMask"]))return nil; if(starter&&![DYToolTypes() containsObject:starter]&&![starter isEqual:@"cst"])return nil; if(level&&(!finiteNumber(level)||fabs([level doubleValue])>M_PI))return nil; id measured=doc[@"levelMeasureOnly"],reference=doc[@"levelReference"]; @@ -132,6 +138,7 @@ static NSData *DYValidatedToolData(NSDictionary *doc){ // Anchors are stable identities, never an array index or a translated title. // Reject unknown anchors/cycles so layout, rendering and undo share one order. for(NSDictionary *node in doc[@"layers"]){id after=node[@"after"];if(!after)continue;if([doc[@"schema"]isEqual:@1]||![after isKindOfClass:NSString.class])return nil;NSMutableSet *seen=[NSMutableSet setWithObject:node[@"id"]];while(after){if([after hasPrefix:@"base:"]){if(![DYToolTypes()containsObject:[after substringFromIndex:5]])return nil;break;}if([seen containsObject:after])return nil;[seen addObject:after];NSDictionary *parent=DYToolWithID(doc,after);if(!parent)return nil;after=parent[@"after"];}} + id outputAfter=doc[@"outputAfter"];if(outputAfter&&(![outputAfter isKindOfClass:NSString.class]||(![outputAfter isEqual:@"tail"]&&![DYToolDisplayOrder(doc)containsObject:outputAfter])))return nil; NSUInteger totalKeys=0;for(NSDictionary *mask in shared)totalKeys+=[mask[@"keys"]count];for(NSArray *masks in [doc[@"baseMasks"]allValues])for(NSDictionary *mask in masks)totalKeys+=[mask[@"keys"]count];for(NSDictionary *node in doc[@"layers"])for(NSDictionary *mask in node[@"masks"])totalKeys+=[mask[@"keys"]count];if(totalKeys>65536)return nil;NSData *bounded=[NSPropertyListSerialization dataWithPropertyList:doc format:NSPropertyListBinaryFormat_v1_0 options:0 error:nil];return bounded.length<=24*1024*1024?bounded:nil; } BOOL DYValidToolDocument(NSDictionary *doc){return DYValidatedToolData(doc)!=nil;} @@ -154,8 +161,9 @@ NSDictionary *DYToolWithID(NSDictionary *doc,NSString *ID){for(NSDictionary *n i static void DYAppendToolChildren(NSDictionary *doc,NSString *parent,NSMutableArray *order,NSMutableSet *seen){for(NSDictionary *node in doc[@"layers"])if([node[@"after"]isEqual:parent]&&![seen containsObject:node[@"id"]]){[seen addObject:node[@"id"]];[order addObject:node[@"id"]];DYAppendToolChildren(doc,node[@"id"],order,seen);}} NSArray *DYToolDisplayOrder(NSDictionary *doc){NSMutableArray *order=[NSMutableArray array];NSMutableSet *seen=[NSMutableSet set];for(NSString *type in DYToolTypes()){NSString *base=[@"base:" stringByAppendingString:type];[order addObject:base];DYAppendToolChildren(doc,base,order,seen);}for(NSDictionary *node in doc[@"layers"])if(!node[@"after"]&&![seen containsObject:node[@"id"]]){[seen addObject:node[@"id"]];[order addObject:node[@"id"]];DYAppendToolChildren(doc,node[@"id"],order,seen);}return order;} NSString *DYToolRootAnchor(NSDictionary *doc,NSString *ID){NSMutableSet *seen=[NSMutableSet set];NSDictionary *node=DYToolWithID(doc,ID);while(node[@"after"]){NSString *after=node[@"after"];if([after hasPrefix:@"base:"])return after;if([seen containsObject:after])return nil;[seen addObject:after];node=DYToolWithID(doc,after);}return @"tail";} +NSArray *DYUnifiedRenderOrder(NSDictionary *doc){NSMutableArray *order=[NSMutableArray arrayWithArray:DYToolDisplayOrder(doc)];NSString *after=doc[@"outputAfter"]?:@"tail";NSUInteger index=[order indexOfObject:after];[order insertObject:@"output" atIndex:index==NSNotFound?order.count:index+1];return order;} NSDictionary *DYInsertTool(NSMutableDictionary *doc,NSString *type,NSString *after){if(!DYValidToolDocument(doc)||[doc[@"layers"]count]>=DYToolLimit)return nil;if(!([after hasPrefix:@"base:"]&&[DYToolTypes()containsObject:[after substringFromIndex:5]])&&!DYToolWithID(doc,after))return nil;NSDictionary *fresh=DYNewTool(type);if(!fresh)return nil;NSMutableDictionary *node=DYMutablePlist(fresh);node[@"after"]=after;NSMutableArray *layers=doc[@"layers"];for(NSMutableDictionary *old in layers)if([old[@"after"]isEqual:after])old[@"after"]=node[@"id"];NSUInteger index=0;NSDictionary *parent=DYToolWithID(doc,after);if(parent)index=[layers indexOfObjectIdenticalTo:parent]+1;[layers insertObject:node atIndex:MIN(index,layers.count)];if(![doc[@"schema"]isEqual:@3])doc[@"schema"]=@2;return node;} -BOOL DYRemoveTool(NSMutableDictionary *doc,NSString *ID){NSMutableDictionary *node=(id)DYToolWithID(doc,ID);if(!node)return NO;NSString *after=node[@"after"];for(NSMutableDictionary *child in doc[@"layers"])if([child[@"after"]isEqual:ID]){if(after)child[@"after"]=after;else[child removeObjectForKey:@"after"];}[doc[@"layers"]removeObject:node];return YES;} +BOOL DYRemoveTool(NSMutableDictionary *doc,NSString *ID){NSMutableDictionary *node=(id)DYToolWithID(doc,ID);if(!node)return NO;NSString *after=node[@"after"];if([doc[@"outputAfter"]isEqual:ID])doc[@"outputAfter"]=after?:@"tail";for(NSMutableDictionary *child in doc[@"layers"])if([child[@"after"]isEqual:ID]){if(after)child[@"after"]=after;else[child removeObjectForKey:@"after"];}[doc[@"layers"]removeObject:node];return YES;} NSArray *DYSharedMasks(NSDictionary *doc){return [doc[@"sharedMasks"]isKindOfClass:NSArray.class]?doc[@"sharedMasks"]:@[];} NSDictionary *DYSharedMaskWithID(NSDictionary *doc,NSString *ID){for(NSDictionary *mask in DYSharedMasks(doc))if([mask[@"id"]isEqual:ID])return mask;return nil;} static NSArray *DYRawMasksForTool(NSDictionary *doc,NSString *ID){return [ID hasPrefix:@"base:"]?doc[@"baseMasks"][[ID substringFromIndex:5]]?:@[]:DYToolWithID(doc,ID)[@"masks"]?:@[];} @@ -362,6 +370,8 @@ NSDictionary *DYToolRenderSnapshot(NSDictionary *doc,CMTime t){ return result; }; NSMutableDictionary *out=[[doc mutableCopy]autorelease],*base=[NSMutableDictionary dictionary]; + NSString *mosaicID=doc[@"mosaic"][@"maskID"]; + for(NSDictionary *mask in shared)if(!mask[@"stampSource"]&&[mask[@"id"]isEqual:mosaicID])out[@"mosaicRenderMask"]=resolve(@[mask]).firstObject; for(NSString *type in doc[@"baseMasks"])base[type]=resolve(doc[@"baseMasks"][type]);out[@"baseMasks"]=base; NSMutableArray *layers=[NSMutableArray array]; for(NSDictionary *node in doc[@"layers"]){NSMutableDictionary *layer=[[node mutableCopy]autorelease];layer[@"masks"]=resolve(node[@"masks"]);[layers addObject:layer];} diff --git a/大鱼调色/Plugin/DYUnifiedDiagnostics.inc.h b/大鱼调色/Plugin/DYUnifiedDiagnostics.inc.h new file mode 100644 index 0000000..955f8bc --- /dev/null +++ b/大鱼调色/Plugin/DYUnifiedDiagnostics.inc.h @@ -0,0 +1,41 @@ +// Production render tests for the ordered chain and spatial privacy operator. +{ + NSDictionary *v4=DYUnifiedColorDefaults();run.need(@"unified-v4-valid-and-distinct-from-v3",DYManagedColorValid(v4,nil)&&DYUnifiedColorState(v4)&&![v4 isEqual:DYPrimaryColorDefaults()]); + NSMutableDictionary *doc=DYMutablePlist(DYInitialToolDocument(nil));run.record(@"unified-default-output-is-last",[DYUnifiedRenderOrder(doc).lastObject isEqual:@"output"]); + NSDictionary *node=DYInsertTool(doc,@"curve",@"base:hsl");doc[@"outputAfter"]=node[@"id"]; + NSArray *order=DYUnifiedRenderOrder(doc);run.record(@"unified-output-follows-stable-uuid",[order indexOfObject:@"output"]==[order indexOfObject:node[@"id"]]+1&&DYValidToolDocument(doc)); + DYRemoveTool(doc,node[@"id"]);run.record(@"unified-deleting-anchor-keeps-valid-output-order",DYValidToolDocument(doc)&&[doc[@"outputAfter"]isEqual:@"base:hsl"]); + doc[@"outputAfter"]=@"unknown";run.record(@"unified-rejects-unknown-output-anchor",!DYValidToolDocument(doc));doc=DYMutablePlist(DYInitialToolDocument(nil)); + const NSUInteger w=64,h=48;DYDiagnosticTile *src=[[[DYDiagnosticTile alloc]initWithDevice:gpu width:w height:h]autorelease],*dst=[[[DYDiagnosticTile alloc]initWithDevice:gpu width:w height:h]autorelease]; + auto decode=[](float x){return x<=.04045f?x/12.92f:powf((x+.055f)/1.055f,2.4f);}; + Pixels chart(w*h*4);for(NSUInteger i=0;i2.9&&difference(plain,modified).nonfinite==0); + NSMutableDictionary *zero=DYMutablePlist(DYNewMask(DYMaskRectangle));DYMaskParameters p=DYMaskAtTime(zero,kCMTimeZero);p.strength=0;zero[@"parameters"]=[NSData dataWithBytes:&p length:sizeof(p)];doc[@"baseMasks"][@"hsl"]=@[zero]; + Pixels masked=frame(changed,doc,@"unified-zero-mask");run.record(@"unified-zero-mask-is-exact-neutral",difference(masked,plain).maximum==0);[doc[@"baseMasks"]removeObjectForKey:@"hsl"]; + changed.cm.outputTransfer=1002;changed.cm.toneMapping=1;changed.hslSatA.x=40;Pixels last=frame(changed,doc,@"unified-last-output");doc[@"outputAfter"]=@"base:primary";Pixels middle=frame(changed,doc,@"unified-middle-output");run.record(@"unified-moving-output-changes-actual-domain-order",difference(last,middle).maximum>.001,@{@"difference":@(difference(last,middle).maximum)}); + DYDiagnosticManager *host=[[[DYDiagnosticManager alloc]init]autorelease];DYCreateParameters(host,nil);DYAssetState *assets=[[[DYAssetState alloc]init]autorelease];assets.colorManagement=v4;DYWriteAssets(host,assets,kCMTimeZero); + DYInspector *view=[[[DYInspector alloc]initWithAPIManager:host]autorelease];[view refresh];[view setFrameSize:NSMakeSize(400,400)];[view layoutSubtreeIfNeeded];NSDictionary *output=nil;for(NSDictionary *card in [view valueForKey:@"cards"])if([card[@"section"][@"key"]isEqual:@"output"])output=card; + run.record(@"unified-inspector-output-visible-at-chain-tail",output&&![output[@"view"]isHidden]&&NSMaxY([output[@"view"]frame])>NSMaxY([[[view valueForKey:@"cards"]firstObject][@"view"]frame])); + [(NSButton*)output[@"repeatButton"]performClick:nil];run.record(@"unified-output-arrow-persists-and-creates-one-undo",[DYReadTools(host,kCMTimeZero).document[@"outputAfter"]isEqual:@"base:base"]&&host->_undoStarts==1&&host->_undoEnds==1); +} +{ + const NSUInteger w=128,h=96;DYDiagnosticTile *src=[[[DYDiagnosticTile alloc]initWithDevice:gpu width:w height:h]autorelease],*dst=[[[DYDiagnosticTile alloc]initWithDevice:gpu width:w height:h]autorelease];Pixels chart(w*h*4); + for(NSUInteger y=0;y15&&x<48&&y>35&&y<60)inside=MAX(inside,delta);if(x>75)outside=MAX(outside,delta);} + run.record(@"mosaic-changes-selection-and-preserves-outside",inside>.05&&outside==0,@{@"inside":@(inside),@"outside":@(outside)}); + DYMaskParameters moved=p;moved.centerX=.75;mask[@"keys"]=@[DYMaskKey(kCMTimeZero,p,YES,1),DYMaskKey(CMTimeMake(1,1),moved,YES,1)]; + Pixels tracked=frame(DYToolRenderSnapshot(doc,CMTimeMake(1,1)),@"mosaic-follow-existing-tracking");run.record(@"mosaic-tracked-selection-vacates-previous-region",tracked[(48*w+31)*4+2]==baseline[(48*w+31)*4+2]&&tracked[(48*w+95)*4+2]!=baseline[(48*w+95)*4+2]); + doc[@"mosaic"]=@{@"source":@"mask",@"maskID":NSUUID.UUID.UUIDString,@"enabled":@YES,@"size":@96};Pixels missing=frame(DYToolRenderSnapshot(doc,kCMTimeZero),@"mosaic-missing-mask");run.record(@"mosaic-missing-mask-does-not-cover-whole-frame",difference(missing,baseline).maximum==0); + NSURL *cube=[NSURL fileURLWithPath:[runtime stringByAppendingPathComponent:@"mosaic-refused.cube"]];run.record(@"mosaic-refuses-incomplete-cube-export",![renderer exportLUT:cube uniforms:u paths:@{} spider:nil tools:doc colorManagement:nil error:&e]&&e); + NSMutableDictionary *bad=DYMutablePlist(doc);bad[@"mosaic"][@"size"]=@0;run.record(@"mosaic-invalid-block-size-rejected",!DYValidToolDocument(bad)); +} diff --git a/大鱼调色/Plugin/DYUnifiedRender.inc.h b/大鱼调色/Plugin/DYUnifiedRender.inc.h new file mode 100644 index 0000000..62766c0 --- /dev/null +++ b/大鱼调色/Plugin/DYUnifiedRender.inc.h @@ -0,0 +1,80 @@ +// V4: stable author order, one movable output boundary, explicit node domains. +- (BOOL)renderUnifiedSource:(FxImageTile*)src destination:(FxImageTile*)dst uniforms:(DYUniforms)u paths:(NSDictionary*)paths spider:(NSData*)spider tools:(NSDictionary*)tools hostPrimaries:(NSInteger)primaries error:(NSError**)error { + if(tools[@"sharedMasks"])tools=DYResolvedToolDocument(tools); + NSMutableDictionary*entry=[self device:dst.deviceRegistryID error:error];if(!entry)return NO;idd=entry[@"device"];idsource=[src metalTextureForDevice:d];if(!source)return fail(error,@"一级 CST 输入纹理不可用。"); + uint64_t pixels=uint64_t(source.width)*source.height;if(!pixels||pixels>64ull*1024*1024||pixels*16*8>MAX(768ull*1024*1024,MIN(2ull*1024*1024*1024,d.recommendedMaxWorkingSetSize/2)))return fail(error,@"当前画面超过一级 CST 内存预算。"); + BOOL inputEnabled=u.inputSectionEnabled>.5;DYCMSettings global=u.cm;BOOL root=u.primarySectionEnabled>.5&&!DYBaseToolRemoved(tools,@"primary");DYApplyRemovedBaseTools(&u,tools);u.cm=global;int wt=lroundf(u.cm.workingTransfer),wg=lroundf(u.cm.workingGamut); + NSMutableArray*pool=[NSMutableArray array];NSCountedSet*pinned=[NSCountedSet set];idcurrent=nil; + auto next=[&]()->id{for(idt in pool)if(t!=current&&![pinned containsObject:t])return t;MTLTextureDescriptor*td=[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA32Float width:source.width height:source.height mipmapped:NO];td.storageMode=MTLStorageModePrivate;td.usage=MTLTextureUsageShaderRead|MTLTextureUsageShaderWrite|MTLTextureUsageRenderTarget;idt=[d newTextureWithDescriptor:td];if(t){[pool addObject:t];[t release];}return t;}; + auto dispatch=[&](NSString*name,const void*params,NSUInteger length,const void*extra=nullptr,NSUInteger extraLength=0){idout=next();if(!out)return fail(error,@"无法分配一级 CST 缓冲区。");BOOL ok=[self managedDispatch:name textures:@[current,out] data:params length:length extra:extra extraLength:extraLength entry:entry error:error];if(ok)current=out;return ok;}; + auto transform=[&](CSTParams p){if(p.inputTransfer==p.outputTransfer&&p.inputGamut==p.outputGamut&&!p.toneMapping)return YES;return dispatch(@"dyPrimaryCST",&p,sizeof(p));}; + auto tile=[&](idt){DYExportTile*v=[[[DYExportTile alloc]initWithTexture:t registry:d.registryID]autorelease];[v setBounds:src.tilePixelBounds origin:src.imageOrigin];[v setPixelAspect:src.pixelAspect];return v;}; + auto blend=[&](idbefore,NSArray*masks,float amount,NSString*type){if(!masks.count&&amount>=1)return YES;idout=next();if(!out)return fail(error,@"无法分配一级混合缓冲区。");DYToolMaskHeader h{};idmb=[self maskBuffer:@{type:masks?:@[]} tile:src device:d header:&h];h.section=(int)[DYToolTypes()indexOfObject:type];DYCSTMixParams p={{wg,wt,2,20,0},{2,20,wg,wt,0},amount};idpipeline=[self managedKernel:@"dyPrimaryBlend" entry:entry error:error];if(!pipeline||!mb)return NO;idcb=[entry[@"queue"]commandBuffer];idce=[cb computeCommandEncoder];[ce setComputePipelineState:pipeline];[ce setTexture:before atIndex:0];[ce setTexture:current atIndex:1];[ce setTexture:out atIndex:2];[ce setBuffer:mb offset:0 atIndex:0];[ce setBytes:&h length:sizeof(h) atIndex:1];[ce setBytes:&p length:sizeof(p) atIndex:2];[ce dispatchThreads:MTLSizeMake(source.width,source.height,1) threadsPerThreadgroup:MTLSizeMake(16,16,1)];[ce endEncoding];[cb commit];[cb waitUntilCompleted];if(cb.status!=MTLCommandBufferStatusCompleted)return fail(error,cb.error.localizedDescription);current=out;return YES;}; + auto grade=[&](DYUniforms values,NSArray*masks,BOOL local){if(values.primarySectionEnabled<.5||values.cm.mix<=0)return YES;DYUniforms neutral=values;neutral.inputSectionEnabled=neutral.cm.outputEnabled=0;BOOL gradeNeutral=identityCM(neutral);if(!local&&gradeNeutral)return YES;if(local&&identityCM(values))return YES; + DayuRenderParams p=DYCMRender(values.cm);p.input.toneMapping=0;if((int)lroundf(values.cm.workingTransfer)==20){p.reserved|=8;p.basis.colorspace=10;p.basisInput={(int)lroundf(values.cm.workingGamut),20,(int)lroundf(values.cm.workingGamut),10,0};p.basisOutput={(int)lroundf(values.cm.workingGamut),10,(int)lroundf(values.cm.workingGamut),20,0};}CSTParams back={wg,wt,wg,wt,0}; + if(local){p.stages=(values.inputSectionEnabled>.5?1:0)|(gradeNeutral?0:2)|(values.cm.outputEnabled>.5?4:0);back={values.cm.outputEnabled>.5?(int)lroundf(values.cm.outputGamut):(int)lroundf(values.cm.workingGamut),values.cm.outputEnabled>.5?(int)lroundf(values.cm.outputTransfer):(int)lroundf(values.cm.workingTransfer),wg,wt,0};} + else{p.stages=2;} + idbefore=current;[pinned addObject:before];BOOL ok=dispatch(@"dyPrimaryGrade",&p,sizeof(p),&back,sizeof(back));if(ok)ok=blend(before,masks,values.cm.mix,@"primary");[pinned removeObject:before];return ok; + }; + auto print=[&](DYUniforms values,NSArray*masks){if(!DYFilmPrintActive(values))return YES;NSArray*names=@[@"",@"kodak_2383",@"kodak_2393",@"kodak_2302_bw",@"fuji_3510",@"fuji_3513",@"fuji_3519",@"fuji_3521",@"agfa_cp30"];NSString*path=[[NSBundle bundleForClass:self.class]pathForResource:names[(int)values.filmPrint.x] ofType:@"dylut" inDirectory:@"PrintLooks"];idcube=path?[self lut:path entry:entry error:error]:nil;if(!cube)return fail(error,@"印片资源不可用。");idbefore=current;[pinned addObject:before];BOOL ok=transform({wg,wt,2,1,0});float amount=values.filmPrint.y*values.film.mix;if(ok){idout=next();ok=out&&[self managedDispatch:@"dyManagedPrint" textures:@[current,cube,out] data:&amount length:4 extra:nullptr extraLength:0 entry:entry error:error];if(ok)current=out;}if(ok)ok=transform({2,1,wg,wt,0});if(ok)ok=blend(before,masks,1,@"film");[pinned removeObject:before];return ok;}; + // Recover only the pre-existing explicit code-value carrier. No display + // transform or host-profile-to-709 conversion precedes the declared input. + current=source;idcarrier=next();uint32_t noLUT=0;if(!carrier||![self managedDispatch:@"dyManagedCarrier" textures:@[current,carrier,entry[@"identity"]] data:&noLUT length:4 extra:nullptr extraLength:0 entry:entry error:error])return NO;current=carrier; + if(inputEnabled&&!transform({(int)lroundf(u.cm.inputGamut),(int)lroundf(u.cm.inputTransfer),wg,wt,0}))return NO; + // Preserve the original working image for source-referenced operations. + idoriginalWorking=current;[pinned addObject:originalWorking];int initialGamut=wg,initialTransfer=wt; + auto isolated=[&](NSString *type,DYUniforms values,NSDictionary *nodePaths,NSData *mesh,NSArray *masks){ + NSMutableDictionary *node=[NSMutableDictionary dictionaryWithDictionary:DYNewTool(type)];NSMutableDictionary *v=[NSMutableDictionary dictionary]; + for(NSDictionary *descriptor in DYBaseToolDescriptors(type))if([descriptor[@"offset"]integerValue]>=0)v[descriptor[@"key"]]=@(*(float*)((uint8_t*)&values+[descriptor[@"offset"]unsignedIntegerValue])); + node[@"values"]=v;node[@"paths"]=nodePaths?:@{};node[@"masks"]=@[];if(mesh)node[@"spider"]=mesh; + node[@"filmFrameKey"]=@(values.filmFrameKey); + if(DYToolIsNeutral(node))return YES; + idbefore=current;[pinned addObject:before];BOOL ok=YES; + if([type isEqual:@"lens"]){idout=next();ok=out&&[self renderLens:tile(current) destination:tile(out) uniforms:values masks:@[] entry:entry error:error];if(ok)current=out;} + else { + // Creative Rec.709 LUT/film and skin models declare a local reference domain. + // All other legacy controls operate on the current working RGB code values. + BOOL reference=[@[@"look",@"film",@"skin"]containsObject:type]; + int domainGamut=reference?22:wg,domainTransfer=reference?1001:wt; + if(reference)ok=transform({wg,wt,domainGamut,domainTransfer,0}); + idraw=current;[pinned addObject:raw]; + if(ok)ok=dispatch(@"dyUnifiedBridgeIn",nullptr,0); + idbounded=current;[pinned addObject:bounded]; + // A source-referenced skin node compares to the original image in this same + // domain, never to a previous frame or an unrelated cached display image. + idreferenceTexture=bounded; + if(ok&&[type isEqual:@"skin"]){current=originalWorking;ok=transform({initialGamut,initialTransfer,domainGamut,domainTransfer,0})&&dispatch(@"dyUnifiedBridgeIn",nullptr,0);referenceTexture=current;[pinned addObject:referenceTexture];current=bounded;} + if(ok){idout=next();_managedFinishing=YES;@try{ok=out&&[self renderExtraTool:node source:tile(bounded) original:tile(referenceTexture) destination:tile(out) entry:entry error:error];}@finally{_managedFinishing=NO;}if(ok)current=out;} + if(referenceTexture!=bounded)[pinned removeObject:referenceTexture];[pinned removeObject:bounded]; + if(ok){idout=next();ok=out&&[self managedDispatch:@"dyUnifiedBridgeOut" textures:@[raw,current,out] data:nullptr length:0 extra:nullptr extraLength:0 entry:entry error:error];if(ok)current=out;} + [pinned removeObject:raw]; + if(ok&&reference)ok=transform({domainGamut,domainTransfer,wg,wt,0}); + } + if(ok)ok=blend(before,masks,1,type);[pinned removeObject:before];return ok; + }; + for(NSString *ID in DYUnifiedRenderOrder(tools)){ + if([ID isEqual:@"output"]){ + if(u.cm.outputEnabled>.5){CSTParams output={wg,wt,(int)lroundf(u.cm.outputGamut),(int)lroundf(u.cm.outputTransfer),0}; + if(u.cm.toneMapping>.5)output.toneMapping=(wt>1000?2:0)+(output.outputTransfer>1000?1:0); + if(!transform(output))return NO;wg=output.outputGamut;wt=output.outputTransfer; + }continue; + } + BOOL base=[ID hasPrefix:@"base:"];NSDictionary *node=base?nil:DYToolWithID(tools,ID);NSString *type=base?[ID substringFromIndex:5]:node[@"type"]; + if(base&&DYBaseToolRemoved(tools,type))continue; + DYUniforms values=base?u:DYToolUniforms(node);NSArray *masks=base?tools[@"baseMasks"][type]:node[@"masks"]; + if([type isEqual:@"primary"]){values.inputSectionEnabled=values.cm.outputEnabled=0;values.cm.workingTransfer=wt;values.cm.workingGamut=wg;if(!grade(values,masks,NO))return NO;continue;} + if([type isEqual:@"film"]){if(!print(values,masks))return NO;values.filmPrint.x=0;} + if(!isolated(type,values,base?DYVisibleBaseToolPaths(paths,tools):node[@"paths"],base?spider:node[@"spider"],masks))return NO; + } + [pinned removeObject:originalWorking]; + // Final host adaptation is separate from the movable output node. Cube uses + // the exact current code domain after the same ordered operations. + if(_exporting){if(!dispatch(@"dyPrimaryCodeOutput",nullptr,0))return NO;} + else { + if(!transform({wg,wt,22,20,0}))return NO;[self managedPreview:current origin:src.imageOrigin entry:entry]; + CGColorSpaceRef from=CGColorSpaceCreateWithName(kCGColorSpaceExtendedLinearSRGB),to=DYManagedTileSpace(dst,primaries); + DYColorProfile *profile=to?[[[DYColorProfile alloc]initWithSource:from target:to error:error]autorelease]:nil;CGColorSpaceRelease(from);if(to)CGColorSpaceRelease(to); + if(!profile)return fail(error,@"宿主未提供明确的目标颜色空间。");idout=next();if(!out||![self managedProfile:profile input:current output:out entry:entry error:error])return NO;current=out; + } + _managedFinishing=YES;@try{return [self copyTile:tile(current) to:dst entry:entry error:error];}@finally{_managedFinishing=NO;} +} diff --git a/大鱼调色/Plugin/DYViewerControls.inc.h b/大鱼调色/Plugin/DYViewerControls.inc.h index d5889da..f205edd 100644 --- a/大鱼调色/Plugin/DYViewerControls.inc.h +++ b/大鱼调色/Plugin/DYViewerControls.inc.h @@ -79,10 +79,10 @@ NSRect bounds=NSMakeRect(0,0,size.width,size.height),v=_hasViewport?NSIntersecti if(_capture&&![_capture capturing])_capture=nil; [_areas removeAllObjects];if(!_bridge||v.size.width<100||v.size.height<80)return; // Only tools that benefit from direct image interaction belong on the canvas. - NSArray *types=@[@"curve",@"lens",@"skin",@"look",@"whiteBalance",@"cloneStamp",@"level"],*titles=@[@"曲线",@"畸变修复",@"肤色",@"LUT",@"白平衡吸管",@"仿制图章",@"水平校正"],*symbols=@[@"point.topleft.down.to.point.bottomright.curvepath",@"pincushion-grid",@"person.crop.circle",@"square.stack.3d.up",@"eyedropper",@"clone-stamp",@"level"]; - CGFloat railScale=MIN(s,v.size.width/520.),y=NSMaxY(v)-33*railScale,w=36*railScale; - CGFloat x=NSMaxX(v)-516*railScale; - _rail=NSMakeRect(x,y,396*railScale,25*railScale); + NSArray *types=@[@"curve",@"lens",@"skin",@"look",@"whiteBalance",@"cloneStamp",@"level",@"mosaic"],*titles=@[@"曲线",@"畸变修复",@"肤色",@"LUT",@"白平衡吸管",@"仿制图章",@"水平校正",@"局部马赛克"],*symbols=@[@"point.topleft.down.to.point.bottomright.curvepath",@"pincushion-grid",@"person.crop.circle",@"square.stack.3d.up",@"eyedropper",@"clone-stamp",@"level",@"square.grid.3x3.fill"]; + CGFloat railScale=MIN(s,v.size.width/560.),y=NSMaxY(v)-33*railScale,w=36*railScale; + CGFloat x=NSMaxX(v)-556*railScale; + _rail=NSMakeRect(x,y,436*railScale,25*railScale); if(_levelMode){ NSArray *labels=@[@"水平",@"垂直",@"重置",@"仅测量"]; for(NSInteger i=0;i<4;i++){ @@ -157,6 +157,7 @@ NSRect bounds=NSMakeRect(0,0,size.width,size.height),v=_hasViewport?NSIntersecti [NSGraphicsContext restoreGraphicsState]; } - (void)activateTool:(NSString*)type{ + if([type isEqual:@"mosaic"]){[self finishCapture];_stampArmed=NO;_levelMode=0;[_bridge requestMosaicMenu];return;} if([type isEqual:@"level"]){[self finishCapture];_stampArmed=NO;_levelMode=_levelMode?0:1;return;} BOOL returningFromLevel=_levelMode!=0;_levelMode=0; if([type isEqual:@"cloneStamp"]){_stampArmed=!_stampArmed;return;} diff --git a/大鱼调色/Plugin/DYViewerControlsDiagnostics.inc.h b/大鱼调色/Plugin/DYViewerControlsDiagnostics.inc.h index 2fa3d1d..7a222dc 100644 --- a/大鱼调色/Plugin/DYViewerControlsDiagnostics.inc.h +++ b/大鱼调色/Plugin/DYViewerControlsDiagnostics.inc.h @@ -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-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); + run.record(@"viewer-lower-right-rail-has-eight-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",@"mosaic"]]]&&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); diff --git a/大鱼调色/Plugin/DYViewerParameterBridge.inc.h b/大鱼调色/Plugin/DYViewerParameterBridge.inc.h index c8c42c5..8a7ef54 100644 --- a/大鱼调色/Plugin/DYViewerParameterBridge.inc.h +++ b/大鱼调色/Plugin/DYViewerParameterBridge.inc.h @@ -20,6 +20,7 @@ // Call before the owning plug-in releases this object during teardown. - (void)invalidate; - (void)requestWorkspace; +- (void)requestMosaicMenu; - (void)requestWorkspacePage:(NSString *)page; - (void)requestMask:(NSInteger)kind; - (void)requestTool:(NSString*)type; @@ -104,6 +105,38 @@ static BOOL DYViewerSanitizeValue(NSDictionary *d,double input,double *output) { 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)applyMosaicMenu:(NSMenuItem*)item { + id manager=nil;@synchronized(self){if(!_invalidated)manager=_apiManager;}if(!manager)return; + ida=[manager apiForProtocol:@protocol(FxCustomParameterActionAPI_v4)];[a startAction:self]; + @try{ + NSMutableDictionary *doc=DYMutablePlist(DYReadTools(manager,a.currentTime).document); + NSMutableDictionary *settings=[NSMutableDictionary dictionaryWithDictionary:doc[@"mosaic"]?:@{@"enabled":@NO,@"source":@"face",@"size":@32}]; + [settings addEntriesFromDictionary:item.representedObject]; + if([settings[@"source"]isEqual:@"mask"]&&!DYSharedMaskWithID(doc,settings[@"maskID"]))return; + doc[@"mosaic"]=settings;idundo=[manager apiForProtocol:@protocol(FxUndoAPI)]; + if([undo startUndoGroup:@"局部马赛克"]){DYWriteTools(manager,doc,a.currentTime);[undo endUndoGroup];} + }@finally{[a endAction:self];} + [_renderer invalidatePreview];[NSNotificationCenter.defaultCenter postNotificationName:DYModelChanged object:manager]; +} +- (void)requestMosaicMenu { + dispatch_async(dispatch_get_main_queue(),^{ + id manager=nil;@synchronized(self){if(!self->_invalidated)manager=self->_apiManager;}if(!manager)return; + ida=[manager apiForProtocol:@protocol(FxCustomParameterActionAPI_v4)];[a startAction:self];NSDictionary *doc=nil; + @try{doc=[DYReadTools(manager,a.currentTime).document retain];}@finally{[a endAction:self];} + NSMenu *menu=[[[NSMenu alloc]initWithTitle:@"局部马赛克"]autorelease];NSDictionary *settings=doc[@"mosaic"]; + auto add=[&](NSString *title,NSDictionary *value,BOOL checked){NSMenuItem *item=[menu addItemWithTitle:title action:@selector(applyMosaicMenu:) keyEquivalent:@""];item.target=self;item.representedObject=value;item.state=checked?NSControlStateValueOn:NSControlStateValueOff;}; + add(@"应用到人脸(逐帧识别)",@{@"source":@"face",@"enabled":@YES},[settings[@"enabled"]boolValue]&&[settings[@"source"]isEqual:@"face"]); + NSInteger count=0; + for(NSDictionary *mask in DYSharedMasks(doc)){if(mask[@"stampSource"])continue;count++;DYMaskParameters p=DYMaskAtTime(mask,kCMTimeInvalid);NSString *shape=@[@"椭圆",@"矩形",@"钢笔",@"渐变",@"HSL",@"亮度"][p.kind]; + add([NSString stringWithFormat:@"应用到蒙版 %ld · %@%@",(long)count,shape,[mask[@"keys"]count]?@" · 已跟踪":@""],@{@"source":@"mask",@"maskID":mask[@"id"],@"enabled":@YES},[settings[@"enabled"]boolValue]&&[settings[@"source"]isEqual:@"mask"]&&[settings[@"maskID"]isEqual:mask[@"id"]]); + } + if(!count){NSMenuItem *hint=[menu addItemWithTitle:@"先用矩形、椭圆或钢笔绘制蒙版" action:nil keyEquivalent:@""];hint.enabled=NO;} + [menu addItem:NSMenuItem.separatorItem]; + for(NSNumber *size in @[@8,@16,@32,@64,@96,@128])add([NSString stringWithFormat:@"方块大小:%@",size],@{@"size":size},[settings[@"size"]isEqual:size]); + [menu addItem:NSMenuItem.separatorItem];add(@"关闭局部马赛克",@{@"enabled":@NO},![settings[@"enabled"]boolValue]); + [doc release];[menu popUpMenuPositioningItem:nil atLocation:NSEvent.mouseLocation inView:nil]; + }); +} - (void)requestWorkspace{ [self requestWorkspacePage:@"tools"]; }