Skip to content

Commit

Permalink
Some API renaming to bring things in line with Swift 3.
Browse files Browse the repository at this point in the history
  • Loading branch information
BradLarson committed Jul 11, 2016
1 parent f478f48 commit f9fc518
Show file tree
Hide file tree
Showing 61 changed files with 155 additions and 157 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ let filterOperations: Array<FilterOperationInterface> = [
let circleGenerator = CircleGenerator(size:Size(width:1280, height:720))
#endif
castFilter.mask = circleGenerator
circleGenerator.renderCircleOfRadius(0.25, center:Position.Center, circleColor:Color.White, backgroundColor:Color.Transparent)
circleGenerator.renderCircleOfRadius(0.25, center:Position.center, circleColor:Color.white, backgroundColor:Color.transparent)
camera --> castFilter --> outputView
return nil
})
Expand Down
2 changes: 1 addition & 1 deletion framework/GPUImage-Mac.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@
BCFF46BD1CB8ACDA00A0C521 /* TiltShift_GL.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = TiltShift_GL.fsh; path = Source/Operations/Shaders/TiltShift_GL.fsh; sourceTree = "<group>"; };
BCFF46BF1CB9556B00A0C521 /* WhiteBalance.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = WhiteBalance.swift; path = Source/Operations/WhiteBalance.swift; sourceTree = "<group>"; };
BCFF46C11CB9560700A0C521 /* WhiteBalance_GL.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = WhiteBalance_GL.fsh; path = Source/Operations/Shaders/WhiteBalance_GL.fsh; sourceTree = "<group>"; };
BCFF46C31CB9565F00A0C521 /* MotionBlur.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; name = MotionBlur.swift; path = Source/Operations/MotionBlur.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
BCFF46C31CB9565F00A0C521 /* MotionBlur.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; name = MotionBlur.swift; path = Source/Operations/MotionBlur.swift; sourceTree = "<group>"; };
BCFF46C51CB968DE00A0C521 /* ImageBuffer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ImageBuffer.swift; path = Source/Operations/ImageBuffer.swift; sourceTree = "<group>"; };
BCFF46C71CB96AB100A0C521 /* LowPassFilter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = LowPassFilter.swift; path = Source/Operations/LowPassFilter.swift; sourceTree = "<group>"; };
BCFF46C91CB96BD700A0C521 /* HighPassFilter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = HighPassFilter.swift; path = Source/Operations/HighPassFilter.swift; sourceTree = "<group>"; };
Expand Down
4 changes: 2 additions & 2 deletions framework/Source/BasicOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class BasicOperation: ImageProcessingOperation {
public let maximumInputs:UInt
public var overriddenOutputSize:Size?
public var overriddenOutputRotation:Rotation?
public var backgroundColor = Color.Black
public var backgroundColor = Color.black
public var drawUnmodifiedImageOutsideOfMask:Bool = true
public var mask:ImageSource? {
didSet {
Expand Down Expand Up @@ -182,7 +182,7 @@ public class BasicOperation: ImageProcessingOperation {
}
}

public func transmitPreviousImageToTarget(_ target:ImageConsumer, atIndex:UInt) {
public func transmitPreviousImage(to target:ImageConsumer, atIndex:UInt) {
sharedImageProcessingContext.runOperationAsynchronously{
guard let renderFramebuffer = self.renderFramebuffer where (!renderFramebuffer.timingStyle.isTransient()) else { return }

Expand Down
2 changes: 1 addition & 1 deletion framework/Source/CameraConversion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public func convertYUVToRGB(shader:ShaderProgram, luminanceFramebuffer:Framebuff
textureProperties = [luminanceFramebuffer.texturePropertiesForTargetOrientation(resultFramebuffer.orientation), chrominanceFramebuffer.texturePropertiesForTargetOrientation(resultFramebuffer.orientation)]
}
resultFramebuffer.activateFramebufferForRendering()
clearFramebufferWithColor(Color.Black)
clearFramebufferWithColor(Color.black)
var uniformSettings = ShaderUniformSettings()
uniformSettings["colorConversionMatrix"] = colorConversionMatrix
renderQuadWithShader(shader, uniformSettings:uniformSettings, vertices:standardImageVertices, inputTextures:textureProperties)
Expand Down
30 changes: 15 additions & 15 deletions framework/Source/Color.swift
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
public struct Color {
public let red:Float
public let green:Float
public let blue:Float
public let alpha:Float
public let redComponent:Float
public let greenComponent:Float
public let blueComponent:Float
public let alphaComponent:Float

public init(red:Float, green:Float, blue:Float, alpha:Float = 1.0) {
self.red = red
self.green = green
self.blue = blue
self.alpha = alpha
self.redComponent = red
self.greenComponent = green
self.blueComponent = blue
self.alphaComponent = alpha
}

public static let Black = Color(red:0.0, green:0.0, blue:0.0, alpha:1.0)
public static let White = Color(red:1.0, green:1.0, blue:1.0, alpha:1.0)
public static let Red = Color(red:1.0, green:0.0, blue:0.0, alpha:1.0)
public static let Green = Color(red:0.0, green:1.0, blue:0.0, alpha:1.0)
public static let Blue = Color(red:0.0, green:0.0, blue:1.0, alpha:1.0)
public static let Transparent = Color(red:0.0, green:0.0, blue:0.0, alpha:0.0)
}
public static let black = Color(red:0.0, green:0.0, blue:0.0, alpha:1.0)
public static let white = Color(red:1.0, green:1.0, blue:1.0, alpha:1.0)
public static let red = Color(red:1.0, green:0.0, blue:0.0, alpha:1.0)
public static let green = Color(red:0.0, green:1.0, blue:0.0, alpha:1.0)
public static let blue = Color(red:0.0, green:0.0, blue:1.0, alpha:1.0)
public static let transparent = Color(red:0.0, green:0.0, blue:0.0, alpha:0.0)
}
6 changes: 3 additions & 3 deletions framework/Source/Framebuffer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,15 @@ public class Framebuffer {
}
}

func texelSizeForRotation(_ rotation:Rotation) -> Size {
func texelSize(for rotation:Rotation) -> Size {
if rotation.flipsDimensions() {
return Size(width:1.0 / Float(size.height), height:1.0 / Float(size.width))
} else {
return Size(width:1.0 / Float(size.width), height:1.0 / Float(size.height))
}
}

func initialStageTexelSizeForRotation(_ rotation:Rotation) -> Size {
func initialStageTexelSize(for rotation:Rotation) -> Size {
if rotation.flipsDimensions() {
return Size(width:1.0 / Float(size.height), height:0.0)
} else {
Expand Down Expand Up @@ -174,7 +174,7 @@ public class Framebuffer {
print("WARNING: Tried to overrelease a framebuffer")
}
framebufferRetainCount = 0
cache?.returnFramebufferToCache(self)
cache?.returnToCache(self)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion framework/Source/FramebufferCache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class FramebufferCache {
framebufferCache.removeAll()
}

func returnFramebufferToCache(_ framebuffer:Framebuffer) {
func returnToCache(_ framebuffer:Framebuffer) {
// print("Returning to cache: \(framebuffer)")
context.runOperationSynchronously{
if (self.framebufferCache[framebuffer.hash] != nil) {
Expand Down
2 changes: 1 addition & 1 deletion framework/Source/ImageGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class ImageGenerator: ImageSource {
}
}

public func transmitPreviousImageToTarget(_ target:ImageConsumer, atIndex:UInt) {
public func transmitPreviousImage(to target:ImageConsumer, atIndex:UInt) {
imageFramebuffer.lock()
target.newFramebufferAvailable(imageFramebuffer, fromSourceIndex:atIndex)
}
Expand Down
2 changes: 1 addition & 1 deletion framework/Source/Mac/Camera.swift
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public class Camera: NSObject, ImageSource, AVCaptureVideoDataOutputSampleBuffer
}
}

public func transmitPreviousImageToTarget(_ target:ImageConsumer, atIndex:UInt) {
public func transmitPreviousImage(to target:ImageConsumer, atIndex:UInt) {
// Not needed for camera inputs
}

Expand Down
14 changes: 7 additions & 7 deletions framework/Source/Mac/MovieInput.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class MovieInput: ImageSource {
}

while (self.assetReader.status == .reading) {
self.readNextVideoFrameFromOutput(readerVideoTrackOutput!)
self.readNextVideoFrame(from:readerVideoTrackOutput!)
}

if (self.assetReader.status == .completed) {
Expand Down Expand Up @@ -89,7 +89,7 @@ public class MovieInput: ImageSource {
// MARK: -
// MARK: Internal processing functions

func readNextVideoFrameFromOutput(_ videoTrackOutput:AVAssetReaderOutput) {
func readNextVideoFrame(from videoTrackOutput:AVAssetReaderOutput) {
if ((assetReader.status == .reading) && !videoEncodingIsFinished) {
if let sampleBuffer = videoTrackOutput.copyNextSampleBuffer() {
if (playAtActualSpeed) {
Expand All @@ -110,7 +110,7 @@ public class MovieInput: ImageSource {
}

sharedImageProcessingContext.runOperationSynchronously{
self.processMovieFrame(sampleBuffer)
self.process(movieFrame:sampleBuffer)
CMSampleBufferInvalidate(sampleBuffer)
}
} else {
Expand All @@ -130,15 +130,15 @@ public class MovieInput: ImageSource {

}

func processMovieFrame(_ frame:CMSampleBuffer) {
func process(movieFrame frame:CMSampleBuffer) {
let currentSampleTime = CMSampleBufferGetOutputPresentationTimeStamp(frame)
let movieFrame = CMSampleBufferGetImageBuffer(frame)!

// processingFrameTime = currentSampleTime
self.processMovieFrame(movieFrame, withSampleTime:currentSampleTime)
self.process(movieFrame:movieFrame, withSampleTime:currentSampleTime)
}

func processMovieFrame(_ movieFrame:CVPixelBuffer, withSampleTime:CMTime) {
func process(movieFrame:CVPixelBuffer, withSampleTime:CMTime) {
let bufferHeight = CVPixelBufferGetHeight(movieFrame)
let bufferWidth = CVPixelBufferGetWidth(movieFrame)
CVPixelBufferLockBaseAddress(movieFrame, CVPixelBufferLockFlags(rawValue: CVOptionFlags(0)))
Expand Down Expand Up @@ -186,7 +186,7 @@ public class MovieInput: ImageSource {
}
}

public func transmitPreviousImageToTarget(_ target:ImageConsumer, atIndex:UInt) {
public func transmitPreviousImage(to target:ImageConsumer, atIndex:UInt) {
// Not needed for movie inputs
}
}
2 changes: 1 addition & 1 deletion framework/Source/Mac/MovieOutput.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public class MovieOutput: ImageConsumer, AudioEncodingTarget {
renderFramebuffer.lock()

renderFramebuffer.activateFramebufferForRendering()
clearFramebufferWithColor(Color.Black)
clearFramebufferWithColor(Color.black)

renderQuadWithShader(sharedImageProcessingContext.passthroughShader, uniformSettings:ShaderUniformSettings(), vertices:standardImageVertices, inputTextures:[framebuffer.texturePropertiesForOutputRotation(.noRotation)])

Expand Down
2 changes: 1 addition & 1 deletion framework/Source/Mac/PictureInput.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public class PictureInput: ImageSource {
}
}

public func transmitPreviousImageToTarget(_ target:ImageConsumer, atIndex:UInt) {
public func transmitPreviousImage(to target:ImageConsumer, atIndex:UInt) {
if hasProcessedImage {
imageFramebuffer.lock()
target.newFramebufferAvailable(imageFramebuffer, fromSourceIndex:atIndex)
Expand Down
2 changes: 1 addition & 1 deletion framework/Source/Mac/PictureOutput.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class PictureOutput: ImageConsumer {
let renderFramebuffer = sharedImageProcessingContext.framebufferCache.requestFramebufferWithProperties(orientation:framebuffer.orientation, size:framebuffer.size)
renderFramebuffer.lock()
renderFramebuffer.activateFramebufferForRendering()
clearFramebufferWithColor(Color.Red)
clearFramebufferWithColor(Color.red)
renderQuadWithShader(sharedImageProcessingContext.passthroughShader, uniformSettings:ShaderUniformSettings(), vertices:standardImageVertices, inputTextures:[framebuffer.texturePropertiesForOutputRotation(.noRotation)])
framebuffer.unlock()

Expand Down
2 changes: 1 addition & 1 deletion framework/Source/Mac/RenderView.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Cocoa

public class RenderView:NSOpenGLView, ImageConsumer {
public var backgroundColor = Color.Black
public var backgroundColor = Color.black
public var fillMode = FillMode.preserveAspectRatio
public var sizeInPixels:Size { get { return Size(width:Float(self.frame.size.width), height:Float(self.frame.size.width)) } }

Expand Down
6 changes: 3 additions & 3 deletions framework/Source/Matrix.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public struct Matrix4x4 {
self.m44 = rowMajorValues[15]
}

public static let Identity = Matrix4x4(rowMajorValues:[1.0, 0.0, 0.0, 0.0,
public static let identity = Matrix4x4(rowMajorValues:[1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0])
Expand All @@ -59,11 +59,11 @@ public struct Matrix3x3 {
self.m33 = rowMajorValues[8]
}

public static let Identity = Matrix3x3(rowMajorValues:[1.0, 0.0, 0.0,
public static let identity = Matrix3x3(rowMajorValues:[1.0, 0.0, 0.0,
0.0, 1.0, 0.0,
0.0, 0.0, 1.0])

public static let CenterOnly = Matrix3x3(rowMajorValues:[0.0, 0.0, 0.0,
public static let centerOnly = Matrix3x3(rowMajorValues:[0.0, 0.0, 0.0,
0.0, 1.0, 0.0,
0.0, 0.0, 0.0])
}
Expand Down
2 changes: 1 addition & 1 deletion framework/Source/OpenGLRendering.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func renderQuadWithShader(_ shader:ShaderProgram, uniformSettings:ShaderUniformS
}

public func clearFramebufferWithColor(_ color:Color) {
glClearColor(GLfloat(color.red), GLfloat(color.green), GLfloat(color.blue), GLfloat(color.alpha))
glClearColor(GLfloat(color.redComponent), GLfloat(color.greenComponent), GLfloat(color.blueComponent), GLfloat(color.alphaComponent))
glClear(GLenum(GL_COLOR_BUFFER_BIT))
}

Expand Down
4 changes: 2 additions & 2 deletions framework/Source/OperationGroup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class OperationGroup: ImageProcessingOperation {
configurationOperation(input:inputImageRelay, output:outputImageRelay)
}

public func transmitPreviousImageToTarget(_ target:ImageConsumer, atIndex:UInt) {
outputImageRelay.transmitPreviousImageToTarget(target, atIndex:atIndex)
public func transmitPreviousImage(to target:ImageConsumer, atIndex:UInt) {
outputImageRelay.transmitPreviousImage(to:target, atIndex:atIndex)
}
}
6 changes: 3 additions & 3 deletions framework/Source/Operations/BulgeDistortion.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
public class BulgeDistortion: BasicOperation {
public var radius:Float = 0.25 { didSet { uniformSettings["radius"] = radius } }
public var scale:Float = 0.5 { didSet { uniformSettings["scale"] = scale } }
public var center:Position = Position.Center { didSet { uniformSettings["center"] = center } }
public var center:Position = Position.center { didSet { uniformSettings["center"] = center } }

public init() {
super.init(fragmentShader:BulgeDistortionFragmentShader, numberOfInputs:1)

({radius = 0.25})()
({scale = 0.5})()
({center = Position.Center})()
({center = Position.center})()
}
}
}
6 changes: 3 additions & 3 deletions framework/Source/Operations/ChromaKeyBlend.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
public class ChromaKeyBlend: BasicOperation {
public var thresholdSensitivity:Float = 0.4 { didSet { uniformSettings["thresholdSensitivity"] = thresholdSensitivity } }
public var smoothing:Float = 0.1 { didSet { uniformSettings["smoothing"] = smoothing } }
public var colorToReplace:Color = Color.Green { didSet { uniformSettings["colorToReplace"] = colorToReplace } }
public var colorToReplace:Color = Color.green { didSet { uniformSettings["colorToReplace"] = colorToReplace } }

public init() {
super.init(fragmentShader:ChromaKeyBlendFragmentShader, numberOfInputs:2)

({thresholdSensitivity = 0.4})()
({smoothing = 0.1})()
({colorToReplace = Color.Green})()
({colorToReplace = Color.green})()
}
}
}
6 changes: 3 additions & 3 deletions framework/Source/Operations/ChromaKeying.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
public class ChromaKeying: BasicOperation {
public var thresholdSensitivity:Float = 0.4 { didSet { uniformSettings["thresholdSensitivity"] = thresholdSensitivity } }
public var smoothing:Float = 0.1 { didSet { uniformSettings["smoothing"] = smoothing } }
public var colorToReplace:Color = Color.Green { didSet { uniformSettings["colorToReplace"] = colorToReplace } }
public var colorToReplace:Color = Color.green { didSet { uniformSettings["colorToReplace"] = colorToReplace } }

public init() {
super.init(fragmentShader:ChromaKeyFragmentShader, numberOfInputs:1)

({thresholdSensitivity = 0.4})()
({smoothing = 0.1})()
({colorToReplace = Color.Green})()
({colorToReplace = Color.green})()
}
}
}
2 changes: 1 addition & 1 deletion framework/Source/Operations/CircleGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class CircleGenerator: ImageGenerator {
super.init(size:size)
}

public func renderCircleOfRadius(_ radius:Float, center:Position, circleColor:Color = Color.White, backgroundColor:Color = Color.Black) {
public func renderCircleOfRadius(_ radius:Float, center:Position, circleColor:Color = Color.white, backgroundColor:Color = Color.black) {
let scaledRadius = radius * 2.0
imageFramebuffer.activateFramebufferForRendering()
var uniformSettings = ShaderUniformSettings()
Expand Down
6 changes: 3 additions & 3 deletions framework/Source/Operations/ColorMatrixFilter.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
public class ColorMatrixFilter: BasicOperation {
public var intensity:Float = 1.0 { didSet { uniformSettings["intensity"] = intensity } }
public var colorMatrix:Matrix4x4 = Matrix4x4.Identity { didSet { uniformSettings["colorMatrix"] = colorMatrix } }
public var colorMatrix:Matrix4x4 = Matrix4x4.identity { didSet { uniformSettings["colorMatrix"] = colorMatrix } }

public init() {

super.init(fragmentShader:ColorMatrixFragmentShader, numberOfInputs:1)

({intensity = 1.0})()
({colorMatrix = Matrix4x4.Identity})()
({colorMatrix = Matrix4x4.identity})()
}
}
}
6 changes: 3 additions & 3 deletions framework/Source/Operations/Convolution3x3.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
public class Convolution3x3: TextureSamplingOperation {
public var convolutionKernel:Matrix3x3 = Matrix3x3.CenterOnly { didSet { uniformSettings["convolutionMatrix"] = convolutionKernel } }
public var convolutionKernel:Matrix3x3 = Matrix3x3.centerOnly { didSet { uniformSettings["convolutionMatrix"] = convolutionKernel } }

public init() {
super.init(fragmentShader:Convolution3x3FragmentShader)

({convolutionKernel = Matrix3x3.CenterOnly})()
({convolutionKernel = Matrix3x3.centerOnly})()
}
}
}
2 changes: 1 addition & 1 deletion framework/Source/Operations/Crop.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class Crop: BasicOperation {
normalizedOffsetFromOrigin = Position(Float(inputSize.width / 2 - finalCropSize.width / 2) / Float(inputSize.width), Float(inputSize.height / 2 - finalCropSize.height / 2) / Float(inputSize.height))
} else {
finalCropSize = inputSize
normalizedOffsetFromOrigin = Position.Zero
normalizedOffsetFromOrigin = Position.zero
}
let normalizedCropSize = Size(width:Float(finalCropSize.width) / Float(inputSize.width), height:Float(finalCropSize.height) / Float(inputSize.height))

Expand Down
Loading

0 comments on commit f9fc518

Please sign in to comment.