我看GPUImage2的源码
picture = PictureInput(image:UIImage(named:"WID-small.jpg")!)
filter = SaturationAdjustment()
picture --> filter --> renderView
picture.processImage()
-->
是做什么的?
最佳答案
这是一个声明为将目标添加到源的运算符。
infix operator --> : AdditionPrecedence
//precedencegroup ProcessingOperationPrecedence {
// associativity: left
//// higherThan: Multiplicative
//}
@discardableResult public func --><T:ImageConsumer>(source:ImageSource, destination:T) -> T {
source.addTarget(destination)
return destination
}
函数在pipeline.swift
文件中声明
addTarget
函数也非常 self 描述。
public func addTarget(_ target:ImageConsumer, atTargetIndex:UInt? = nil) {
if let targetIndex = atTargetIndex {
target.setSource(self, atIndex:targetIndex)
targets.append(target, indexAtTarget:targetIndex)
transmitPreviousImage(to:target, atIndex:targetIndex)
} else if let indexAtTarget = target.addSource(self) {
targets.append(target, indexAtTarget:indexAtTarget)
transmitPreviousImage(to:target, atIndex:indexAtTarget)
} else {
debugPrint("Warning: tried to add target beyond target's input capacity")
}
}
编辑 正如其他人所说,运算符(operator)是该项目的自定义运算符(operator),截至 2018 年 3 月 29 日,该运算符(operator)并未内置在 swift 语言中
关于swift - --> (dash dash greater than) 运算符在 Swift 中是什么意思,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42478881/