This repository was archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathYUCIReflectedTile.m
executable file
·64 lines (55 loc) · 2.26 KB
/
YUCIReflectedTile.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//
// YUCIReflectTile.m
// Pods
//
// Created by YuAo on 2/16/16.
//
//
#import "YUCIReflectedTile.h"
#import "YUCIFilterConstructor.h"
#import "YUCIReflectedTileROICalculator.h"
@implementation YUCIReflectedTile
+ (void)load {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
@autoreleasepool {
if ([CIFilter respondsToSelector:@selector(registerFilterName:constructor:classAttributes:)]) {
[CIFilter registerFilterName:NSStringFromClass([YUCIReflectedTile class])
constructor:[YUCIFilterConstructor constructor]
classAttributes:@{kCIAttributeFilterCategories: @[kCICategoryStillImage,kCICategoryVideo,kCICategoryTileEffect],
kCIAttributeFilterDisplayName: @"Reflected Tile"}];
}
}
});
}
+ (CIWarpKernel *)filterKernel {
static CIWarpKernel *kernel;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
NSString *kernelString = [[NSString alloc] initWithContentsOfURL:[[NSBundle bundleForClass:self] URLForResource:NSStringFromClass([YUCIReflectedTile class]) withExtension:@"cikernel"] encoding:NSUTF8StringEncoding error:nil];
kernel = [CIWarpKernel kernelWithString:kernelString];
});
return kernel;
}
- (NSNumber *)inputMode {
if (!_inputMode) {
_inputMode = @(YUCIReflectedTileModeReflectWithoutBorder);
}
return _inputMode;
}
- (void)setDefaults {
self.inputMode = nil;
}
- (CIImage *)outputImage {
if (!self.inputImage) {
return nil;
}
CGRect inputExtent = self.inputImage.extent;
return [[YUCIReflectedTile filterKernel] applyWithExtent:CGRectInfinite
roiCallback:^CGRect(int index, CGRect destRect) {
return [YUCIReflectedTileROICalculator ROIForDestinationRect:destRect inputImageExtent:inputExtent mode:self.inputMode.integerValue];
}
inputImage:self.inputImage
arguments:@[self.inputMode,[CIVector vectorWithCGRect:self.inputImage.extent]]];
}
@end