Skip to content

Commit

Permalink
Fix pod issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
kawoou committed May 15, 2017
1 parent 5b2e8ba commit 0b0e41f
Show file tree
Hide file tree
Showing 8 changed files with 345 additions and 141 deletions.
7 changes: 1 addition & 6 deletions FlexibleImage.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ Pod::Spec.new do |s|
s.source = { :git => 'https://github.com/Kawoou/FlexibleImage.git',
:tag => s.version.to_s }
s.requires_arc = true
s.source_files = 'Sources/*.swift',
'Sources/Abstract/*.swift',
'Sources/Device/*.swift',
'Sources/Filter/*.swift',
'Sources/Filter/*.metal',
'Sources/Type/*.swift'
s.source_files = 'Sources/**/*.{swift,metal}'

s.ios.deployment_target = '8.0'
s.tvos.deployment_target = '9.0'
Expand Down
18 changes: 0 additions & 18 deletions FlexibleImage.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,6 @@
9D8538001EC7A27700A9715A /* ExclusionFilter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D8537491EC7A27700A9715A /* ExclusionFilter.swift */; };
9D8538011EC7A27700A9715A /* ExclusionFilter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D8537491EC7A27700A9715A /* ExclusionFilter.swift */; };
9D8538021EC7A27700A9715A /* ExclusionFilter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D8537491EC7A27700A9715A /* ExclusionFilter.swift */; };
9D8538031EC7A27700A9715A /* FilterMath.h in Headers */ = {isa = PBXBuildFile; fileRef = 9D85374A1EC7A27700A9715A /* FilterMath.h */; };
9D8538041EC7A27700A9715A /* FilterMath.h in Headers */ = {isa = PBXBuildFile; fileRef = 9D85374A1EC7A27700A9715A /* FilterMath.h */; };
9D8538051EC7A27700A9715A /* FilterMath.h in Headers */ = {isa = PBXBuildFile; fileRef = 9D85374A1EC7A27700A9715A /* FilterMath.h */; };
9D8538061EC7A27700A9715A /* FilterMath.h in Headers */ = {isa = PBXBuildFile; fileRef = 9D85374A1EC7A27700A9715A /* FilterMath.h */; };
9D8538071EC7A27700A9715A /* FilterMath.metal in Sources */ = {isa = PBXBuildFile; fileRef = 9D85374B1EC7A27700A9715A /* FilterMath.metal */; };
9D8538081EC7A27700A9715A /* FilterMath.metal in Sources */ = {isa = PBXBuildFile; fileRef = 9D85374B1EC7A27700A9715A /* FilterMath.metal */; };
9D8538091EC7A27700A9715A /* FilterMath.metal in Sources */ = {isa = PBXBuildFile; fileRef = 9D85374B1EC7A27700A9715A /* FilterMath.metal */; };
9D85380B1EC7A27700A9715A /* GammaFilter.metal in Sources */ = {isa = PBXBuildFile; fileRef = 9D85374C1EC7A27700A9715A /* GammaFilter.metal */; };
9D85380C1EC7A27700A9715A /* GammaFilter.metal in Sources */ = {isa = PBXBuildFile; fileRef = 9D85374C1EC7A27700A9715A /* GammaFilter.metal */; };
9D85380D1EC7A27700A9715A /* GammaFilter.metal in Sources */ = {isa = PBXBuildFile; fileRef = 9D85374C1EC7A27700A9715A /* GammaFilter.metal */; };
Expand Down Expand Up @@ -401,8 +394,6 @@
9D8537471EC7A27700A9715A /* DifferenceFilter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = DifferenceFilter.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
9D8537481EC7A27700A9715A /* ExclusionFilter.metal */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.metal; path = ExclusionFilter.metal; sourceTree = "<group>"; };
9D8537491EC7A27700A9715A /* ExclusionFilter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = ExclusionFilter.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
9D85374A1EC7A27700A9715A /* FilterMath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FilterMath.h; sourceTree = "<group>"; };
9D85374B1EC7A27700A9715A /* FilterMath.metal */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.metal; path = FilterMath.metal; sourceTree = "<group>"; };
9D85374C1EC7A27700A9715A /* GammaFilter.metal */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.metal; path = GammaFilter.metal; sourceTree = "<group>"; };
9D85374D1EC7A27700A9715A /* GammaFilter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = GammaFilter.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
9D85374E1EC7A27700A9715A /* GlowFilter.metal */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.metal; path = GlowFilter.metal; sourceTree = "<group>"; };
Expand Down Expand Up @@ -579,8 +570,6 @@
9D8537471EC7A27700A9715A /* DifferenceFilter.swift */,
9D8537481EC7A27700A9715A /* ExclusionFilter.metal */,
9D8537491EC7A27700A9715A /* ExclusionFilter.swift */,
9D85374A1EC7A27700A9715A /* FilterMath.h */,
9D85374B1EC7A27700A9715A /* FilterMath.metal */,
9D85374C1EC7A27700A9715A /* GammaFilter.metal */,
9D85374D1EC7A27700A9715A /* GammaFilter.swift */,
9D85374E1EC7A27700A9715A /* GlowFilter.metal */,
Expand Down Expand Up @@ -740,7 +729,6 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
9D8538031EC7A27700A9715A /* FilterMath.h in Headers */,
9DF90EA11EBA5594002B0CBD /* FlexibleImageIOS.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -749,7 +737,6 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
9D8538041EC7A27700A9715A /* FilterMath.h in Headers */,
9DF90E891EBA50EB002B0CBD /* FlexibleImageTvOS.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -758,7 +745,6 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
9D8538051EC7A27700A9715A /* FilterMath.h in Headers */,
9DF90E971EBA512B002B0CBD /* FlexibleImageMacOS.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -767,7 +753,6 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
9D8538061EC7A27700A9715A /* FilterMath.h in Headers */,
9DF90EAB1EBB52A6002B0CBD /* FlexibleImageWatchOS.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -995,7 +980,6 @@
9D8538231EC7A27700A9715A /* HardLightFilter.metal in Sources */,
9D85383B1EC7A27700A9715A /* InvertFilter.metal in Sources */,
9D8537BB1EC7A27700A9715A /* BrightnessFilter.metal in Sources */,
9D8538071EC7A27700A9715A /* FilterMath.metal in Sources */,
9D8538571EC7A27700A9715A /* LinearLightFilter.metal in Sources */,
9D8538271EC7A27700A9715A /* HardLightFilter.swift in Sources */,
9D85386B1EC7A27700A9715A /* MonochromeFilter.swift in Sources */,
Expand Down Expand Up @@ -1101,7 +1085,6 @@
9D8538241EC7A27700A9715A /* HardLightFilter.metal in Sources */,
9D85383C1EC7A27700A9715A /* InvertFilter.metal in Sources */,
9D8537BC1EC7A27700A9715A /* BrightnessFilter.metal in Sources */,
9D8538081EC7A27700A9715A /* FilterMath.metal in Sources */,
9D8538581EC7A27700A9715A /* LinearLightFilter.metal in Sources */,
9D8538281EC7A27700A9715A /* HardLightFilter.swift in Sources */,
9D85386C1EC7A27700A9715A /* MonochromeFilter.swift in Sources */,
Expand Down Expand Up @@ -1207,7 +1190,6 @@
9D8538251EC7A27700A9715A /* HardLightFilter.metal in Sources */,
9D85383D1EC7A27700A9715A /* InvertFilter.metal in Sources */,
9D8537BD1EC7A27700A9715A /* BrightnessFilter.metal in Sources */,
9D8538091EC7A27700A9715A /* FilterMath.metal in Sources */,
9D8538591EC7A27700A9715A /* LinearLightFilter.metal in Sources */,
9D8538291EC7A27700A9715A /* HardLightFilter.swift in Sources */,
9D85386D1EC7A27700A9715A /* MonochromeFilter.swift in Sources */,
Expand Down
89 changes: 86 additions & 3 deletions Sources/Filter/ColorFilter.metal
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,92 @@
//

#include <metal_stdlib>
#include "FilterMath.h"
using namespace metal;

float ColorFilter_HueToRGB(float f1, float f2, float hue);
float3 ColorFilter_HSLToRGB(float3 hsl);
float3 ColorFilter_RGBToHSL(float3 color);

float ColorFilter_HueToRGB(float f1, float f2, float hue) {
if (hue < 0.0)
hue += 1.0;
else if (hue > 1.0)
hue -= 1.0;

float res;
if ((6.0 * hue) < 1.0)
res = f1 + (f2 - f1) * 6.0 * hue;
else if ((2.0 * hue) < 1.0)
res = f2;
else if ((3.0 * hue) < 2.0)
res = f1 + (f2 - f1) * ((2.0 / 3.0) - hue) * 6.0;
else
res = f1;

return res;
}

float3 ColorFilter_HSLToRGB(float3 hsl) {
float3 rgb;

if (hsl.y == 0.0) {
rgb = float3(hsl.z);
} else {
float f2;

if (hsl.z < 0.5)
f2 = hsl.z * (1.0 + hsl.y);
else
f2 = (hsl.z + hsl.y) - (hsl.y * hsl.z);

float f1 = 2.0 * hsl.z - f2;

rgb.r = ColorFilter_HueToRGB(f1, f2, hsl.x + (1.0/3.0));
rgb.g = ColorFilter_HueToRGB(f1, f2, hsl.x);
rgb.b = ColorFilter_HueToRGB(f1, f2, hsl.x - (1.0/3.0));
}

return rgb;
}

float3 ColorFilter_RGBToHSL(float3 color) {
float3 hsl;

float fmin = min(min(color.r, color.g), color.b);
float fmax = max(max(color.r, color.g), color.b);
float delta = fmax - fmin;

hsl.z = (fmax + fmin) / 2.0;

if (delta == 0.0) {
hsl.x = 0.0;
hsl.y = 0.0;
} else {
if (hsl.z < 0.5)
hsl.y = delta / (fmax + fmin);
else
hsl.y = delta / (2.0 - fmax - fmin);

float deltaR = (((fmax - color.r) / 6.0) + (delta / 2.0)) / delta;
float deltaG = (((fmax - color.g) / 6.0) + (delta / 2.0)) / delta;
float deltaB = (((fmax - color.b) / 6.0) + (delta / 2.0)) / delta;

if (color.r == fmax)
hsl.x = deltaB - deltaG;
else if (color.g == fmax)
hsl.x = (1.0 / 3.0) + deltaR - deltaB;
else if (color.b == fmax)
hsl.x = (2.0 / 3.0) + deltaG - deltaR;

if (hsl.x < 0.0)
hsl.x += 1.0;
else if (hsl.x > 1.0)
hsl.x -= 1.0;
}

return hsl;
}

kernel void ColorFilter(
texture2d<float, access::write> outTexture [[texture(0)]],
texture2d<float, access::read> inTexture [[texture(1)]],
Expand All @@ -22,7 +105,7 @@ kernel void ColorFilter(
const float4 inColor = inTexture.read(gid);
const float4 adjustColor = float4(*colorRed, *colorGreen, *colorBlue, *colorAlpha);

const float3 blendHSL = RGBToHSL(adjustColor.rgb);
const float4 outColor = float4(HSLToRGB(float3(blendHSL.r, blendHSL.g, RGBToHSL(inColor.rgb).b)), inColor.a);
const float3 blendHSL = ColorFilter_RGBToHSL(adjustColor.rgb);
const float4 outColor = float4(ColorFilter_HSLToRGB(float3(blendHSL.r, blendHSL.g, ColorFilter_RGBToHSL(inColor.rgb).b)), inColor.a);
outTexture.write(outColor, gid);
}
14 changes: 0 additions & 14 deletions Sources/Filter/FilterMath.h

This file was deleted.

91 changes: 0 additions & 91 deletions Sources/Filter/FilterMath.metal

This file was deleted.

Loading

0 comments on commit 0b0e41f

Please sign in to comment.