Skip to content

Commit

Permalink
Disabled CoreImage filters on iOS 8.x due to runtime mapping issue wi…
Browse files Browse the repository at this point in the history
…th CIContext.

See the following Stack Overflow thread for more info:

- http://tinyurl.com/jh26j6m
  • Loading branch information
cnoon committed Nov 20, 2016
1 parent d315b34 commit e0c2cf1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Source/ImageFilter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ public struct CircleFilter: ImageFilter {
#if os(iOS) || os(tvOS)

/// The `CoreImageFilter` protocol defines `parameters`, `filterName` properties used by CoreImage.
@available(iOS 9.0, *)
public protocol CoreImageFilter: ImageFilter {
/// The filter name of the CoreImage filter.
var filterName: String { get }
Expand All @@ -297,6 +298,7 @@ public protocol CoreImageFilter: ImageFilter {
var parameters: [String: Any] { get }
}

@available(iOS 9.0, *)
public extension ImageFilter where Self: CoreImageFilter {
/// The filter closure used to create the modified representation of the given image.
public var filter: (Image) -> Image {
Expand All @@ -310,6 +312,7 @@ public extension ImageFilter where Self: CoreImageFilter {
}

/// Blurs an image using a `CIGaussianBlur` filter with the specified blur radius.
@available(iOS 9.0, *)
public struct BlurFilter: ImageFilter, CoreImageFilter {
/// The filter name.
public let filterName = "CIGaussianBlur"
Expand Down
1 change: 1 addition & 0 deletions Source/UIImage+AlamofireImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ import CoreImage

// MARK: - Core Image Filters

@available(iOS 9.0, *)
extension UIImage {
/// Returns a new version of the image using a CoreImage filter with the specified name and parameters.
///
Expand Down
2 changes: 2 additions & 0 deletions Tests/ImageFilterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ class ImageFilterTestCase: BaseTestCase {
}

func testThatBlurFilterReturnsCorrectFilteredImage() {
guard #available(iOS 9.0, *) else { return }

// Given
let image = self.image(forResource: "unicorn", withExtension: "png")
let filter = BlurFilter(blurRadius: 8)
Expand Down
6 changes: 6 additions & 0 deletions Tests/UIImageTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,8 @@ class UIImageTestCase: BaseTestCase {
// MARK: - Core Image Filters

func testThatImageWithAppliedGaussianBlurFilterReturnsBlurredImage() {
guard #available(iOS 9.0, *) else { return }

// Given
let parameters: [String: Any] = ["inputRadius": 8]

Expand All @@ -358,6 +360,8 @@ class UIImageTestCase: BaseTestCase {
}

func testThatImageWithAppliedSepiaToneFilterReturnsSepiaImage() {
guard #available(iOS 9.0, *) else { return }

// Given, When
let sepiaImage = unicornImage.af_imageFiltered(withCoreImageFilter: "CISepiaTone")

Expand All @@ -371,6 +375,8 @@ class UIImageTestCase: BaseTestCase {
}

func testThatInvalidCoreImageFilterReturnsNil() {
guard #available(iOS 9.0, *) else { return }

// Given
let filterName = "SomeFilterThatDoesNotExist"

Expand Down

0 comments on commit e0c2cf1

Please # to comment.