     
     var image:UIImage!
     var delegate:SNTrimControllerDelegate!
+    
+    // Metal
+    static let device = MTLCreateSystemDefaultDevice()
+    let function = SNTrimController.device?.newDefaultLibrary()?.newFunctionWithName("maskImage")
 
     private let borderView:UIView = {
         let borderView = UIView()

            encoder.setBytes(&uz0, length: sizeofValue(uz0), atIndex: 5)
            encoder.setBytes(&inv, length: sizeofValue(inv), atIndex: 6)

            let function = device.newDefaultLibrary()!.newFunctionWithName("maskImage")!
            let pipeline = try! device.newComputePipelineStateWithFunction(function)
            encoder.setComputePipelineState(pipeline)
            let threadExeWidth = pipeline.threadExecutionWidth

            let cmdBuffer = queue.commandBuffer()
            let encoder = cmdBuffer.computeCommandEncoder(); defer { encoder.endEncoding() }
            
            var intWidth = CUnsignedInt(size.width)
            var intHeight = CUnsignedInt(size.height)
            var (ux0, uy0, uz0) = (CFloat(x0), CFloat(y0), CFloat(z0))
