Skip to content

Commit

Permalink
Stop recreating the CIContext for every frame.
Browse files Browse the repository at this point in the history
  • Loading branch information
Omer Karisman committed Sep 4, 2017
1 parent d0de14e commit 63996b0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion SceneKitVideoRecorder.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
#

s.name = "SceneKitVideoRecorder"
s.version = "1.0.0"
s.version = "1.0.1"
s.summary = "Record videos of SceneKit and ARKit"

# This description is used to generate tags and improve search results.
Expand Down
4 changes: 3 additions & 1 deletion SceneKitVideoRecorder/Classes/PixelBufferFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
import UIKit

struct PixelBufferFactory {

static let context = CIContext(options: nil)

static func make(with metalLayer: CAMetalLayer, usingBuffer pool: CVPixelBufferPool) -> (CVPixelBuffer?, UIImage) {

let currentDrawable = metalLayer.nextDrawable()
Expand All @@ -38,7 +41,6 @@ struct PixelBufferFactory {
static func imageFromCVPixelBuffer(buffer: CVPixelBuffer) -> UIImage {

let ciimage = CIImage(cvPixelBuffer: buffer)
let context = CIContext(options: nil)
let cgimgage = context.createCGImage(ciimage, from: CGRect(x: 0, y: 0, width: CVPixelBufferGetWidth(buffer), height: CVPixelBufferGetHeight(buffer)))

let uiimage = UIImage(cgImage: cgimgage!)
Expand Down

0 comments on commit 63996b0

Please sign in to comment.