Skip to content

Commit

Permalink
Merge pull request #116 from JanGorman/tuning
Browse files Browse the repository at this point in the history
Tuning
  • Loading branch information
JanGorman authored Mar 15, 2020
2 parents 7fbb324 + 64a63ed commit 5f41882
Show file tree
Hide file tree
Showing 33 changed files with 1,006 additions and 193 deletions.
12 changes: 10 additions & 2 deletions Example/MapleBacon Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
F2CB22EE240A6953009FB183 /* images.plist in Resources */ = {isa = PBXBuildFile; fileRef = F2CB22ED240A6953009FB183 /* images.plist */; };
F2CB22F5240BB864009FB183 /* DownsamplingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F2CB22F4240BB864009FB183 /* DownsamplingViewController.swift */; };
F2CB22F7240BB8DC009FB183 /* ImageCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = F2CB22F6240BB8DC009FB183 /* ImageCollectionViewCell.swift */; };
F2D870D62416C63200946A0B /* PrefetchViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F2D870D52416C63200946A0B /* PrefetchViewController.swift */; };
F2D870D92416C6AB00946A0B /* EntryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F2D870D82416C6AB00946A0B /* EntryViewController.swift */; };
F2EEE58F240BCDA60002C9CA /* ImageTransformerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F2EEE58E240BCDA60002C9CA /* ImageTransformerViewController.swift */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -58,6 +60,8 @@
F2CB22ED240A6953009FB183 /* images.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = images.plist; sourceTree = "<group>"; };
F2CB22F4240BB864009FB183 /* DownsamplingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DownsamplingViewController.swift; sourceTree = "<group>"; };
F2CB22F6240BB8DC009FB183 /* ImageCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageCollectionViewCell.swift; sourceTree = "<group>"; };
F2D870D52416C63200946A0B /* PrefetchViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrefetchViewController.swift; sourceTree = "<group>"; };
F2D870D82416C6AB00946A0B /* EntryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EntryViewController.swift; sourceTree = "<group>"; };
F2EEE58E240BCDA60002C9CA /* ImageTransformerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageTransformerViewController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -122,6 +126,8 @@
F29D6184240595BA00E85F11 /* CollectionViewController.swift */,
F2CB22F4240BB864009FB183 /* DownsamplingViewController.swift */,
F2EEE58E240BCDA60002C9CA /* ImageTransformerViewController.swift */,
F2D870D52416C63200946A0B /* PrefetchViewController.swift */,
F2D870D82416C6AB00946A0B /* EntryViewController.swift */,
);
path = Controllers;
sourceTree = "<group>";
Expand Down Expand Up @@ -236,8 +242,10 @@
F29D6185240595BA00E85F11 /* CollectionViewController.swift in Sources */,
F29D6181240595BA00E85F11 /* AppDelegate.swift in Sources */,
F2CB22EC240A68D1009FB183 /* UICollectionView+MapleBacon.swift in Sources */,
F2D870D92416C6AB00946A0B /* EntryViewController.swift in Sources */,
F2EEE58F240BCDA60002C9CA /* ImageTransformerViewController.swift in Sources */,
F29D6183240595BA00E85F11 /* SceneDelegate.swift in Sources */,
F2D870D62416C63200946A0B /* PrefetchViewController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -321,7 +329,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.4;
IPHONEOS_DEPLOYMENT_TARGET = 13.2;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -375,7 +383,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.4;
IPHONEOS_DEPLOYMENT_TARGET = 13.2;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1130"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F29D617C240595BA00E85F11"
BuildableName = "MapleBacon Example.app"
BlueprintName = "MapleBacon Example"
ReferencedContainer = "container:MapleBacon Example.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
enableThreadSanitizer = "YES"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F29D617C240595BA00E85F11"
BuildableName = "MapleBacon Example.app"
BlueprintName = "MapleBacon Example"
ReferencedContainer = "container:MapleBacon Example.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F29D617C240595BA00E85F11"
BuildableName = "MapleBacon Example.app"
BlueprintName = "MapleBacon Example"
ReferencedContainer = "container:MapleBacon Example.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
87 changes: 81 additions & 6 deletions Example/MapleBacon Example/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16092.1" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="tol-lZ-wfF">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15705" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="tol-lZ-wfF">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16082.1"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15706"/>
<capability name="collection view cell content view" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--MapleBacon-->
<scene sceneID="ERe-tq-LRA">
<objects>
<tableViewController id="Tv8-2v-TBh" sceneMemberID="viewController">
<tableViewController id="Tv8-2v-TBh" customClass="EntryViewController" customModule="MapleBacon_Example" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" id="0dD-bh-HG2">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
Expand Down Expand Up @@ -75,7 +75,27 @@
</subviews>
</tableViewCellContentView>
<connections>
<segue destination="5mB-Cq-mPN" kind="show" id="u6x-o3-rTo"/>
<segue destination="5mB-Cq-mPN" kind="show" id="wXK-3h-eQk"/>
</connections>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" textLabel="DtW-oE-0UA" style="IBUITableViewCellStyleDefault" id="IMk-Fu-Lnk">
<rect key="frame" x="0.0" y="158.5" width="414" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="IMk-Fu-Lnk" id="dDc-tO-ejx">
<rect key="frame" x="0.0" y="0.0" width="383" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Prefetching CollectionView" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="DtW-oE-0UA">
<rect key="frame" x="20" y="0.0" width="355" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
<connections>
<segue destination="jbV-WY-lKN" kind="show" id="jKQ-my-qiv"/>
</connections>
</tableViewCell>
</cells>
Expand All @@ -86,7 +106,13 @@
<outlet property="delegate" destination="Tv8-2v-TBh" id="BtS-ve-rPW"/>
</connections>
</tableView>
<navigationItem key="navigationItem" title="MapleBacon" id="wMu-Yc-AgB"/>
<navigationItem key="navigationItem" title="MapleBacon" id="wMu-Yc-AgB">
<barButtonItem key="rightBarButtonItem" title="Clear Cache" id="lJj-QS-MZu">
<connections>
<action selector="clearCache:" destination="Tv8-2v-TBh" id="uMg-63-S60"/>
</connections>
</barButtonItem>
</navigationItem>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="1na-DO-bzg" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
Expand Down Expand Up @@ -255,7 +281,56 @@
</collectionViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="NGq-Bx-LpA" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1135" y="423"/>
<point key="canvasLocation" x="1135" y="457"/>
</scene>
<!--Prefetch View Controller-->
<scene sceneID="iJy-dZ-dQD">
<objects>
<collectionViewController id="jbV-WY-lKN" customClass="PrefetchViewController" customModule="MapleBacon_Example" customModuleProvider="target" sceneMemberID="viewController">
<collectionView key="view" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" id="JZP-aJ-JdG">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="aHD-Xt-1Nn">
<size key="itemSize" width="128" height="128"/>
<size key="headerReferenceSize" width="0.0" height="0.0"/>
<size key="footerReferenceSize" width="0.0" height="0.0"/>
<inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
</collectionViewFlowLayout>
<cells>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="ImageCollectionViewCell" id="IWy-Ly-vXY" customClass="ImageCollectionViewCell" customModule="MapleBacon_Example" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="128" height="128"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<collectionViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" id="kyB-He-yzm">
<rect key="frame" x="0.0" y="0.0" width="128" height="128"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="6Dt-JI-B5S">
<rect key="frame" x="0.0" y="0.0" width="128" height="128"/>
</imageView>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="6Dt-JI-B5S" secondAttribute="trailing" id="WMZ-hx-0Q3"/>
<constraint firstItem="6Dt-JI-B5S" firstAttribute="leading" secondItem="kyB-He-yzm" secondAttribute="leading" id="jXd-99-wQa"/>
<constraint firstAttribute="bottom" secondItem="6Dt-JI-B5S" secondAttribute="bottom" id="yBz-bV-7fH"/>
<constraint firstItem="6Dt-JI-B5S" firstAttribute="top" secondItem="kyB-He-yzm" secondAttribute="top" id="yKy-2q-2No"/>
</constraints>
</collectionViewCellContentView>
<connections>
<outlet property="imageView" destination="6Dt-JI-B5S" id="YlC-ks-CaH"/>
</connections>
</collectionViewCell>
</cells>
<connections>
<outlet property="dataSource" destination="jbV-WY-lKN" id="Lnc-9B-CzO"/>
<outlet property="delegate" destination="jbV-WY-lKN" id="Zuj-hl-3c6"/>
</connections>
</collectionView>
<navigationItem key="navigationItem" id="8Rs-pJ-NBg"/>
</collectionViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Tn3-No-4QF" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1135" y="1104"/>
</scene>
</scenes>
</document>
14 changes: 14 additions & 0 deletions Example/MapleBacon Example/Controllers/EntryViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// Copyright © 2020 Schnaub. All rights reserved.
//

import MapleBacon
import UIKit

final class EntryViewController: UITableViewController {

@IBAction private func clearCache(_ sender: Any) {
MapleBacon.shared.clearCache(.all)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import UIKit
final class ImageTransformerViewController: UICollectionViewController {

private var imageURLs: [URL] = []
private var imageTransformer = SepiaImageTransformer() >>> VignetteImageTransformer()
private var imageTransformer = SepiaImageTransformer()

override func viewDidLoad() {
super.viewDidLoad()
Expand Down Expand Up @@ -57,25 +57,3 @@ private class SepiaImageTransformer: ImageTransforming {
}

}

private class VignetteImageTransformer: ImageTransforming {

let identifier = "com.schnaub.VignetteImageTransformer"

func transform(image: UIImage) -> UIImage? {
let filter = CIFilter(name: "CIVignette")!

let ciImage = CIImage(image: image)
filter.setValue(ciImage, forKey: kCIInputImageKey)

let context = CIContext()
guard let outputImage = filter.outputImage,
let cgImage = context.createCGImage(outputImage, from: outputImage.extent) else {
return image
}

return UIImage(cgImage: cgImage)
}

}

Loading

0 comments on commit 5f41882

Please sign in to comment.