Skip to content

Commit

Permalink
Fixed forceProcessingAtSize: glitches for the bulge, pinch, pixellate…
Browse files Browse the repository at this point in the history
…, sphere refraction, and centered Gaussian blur filters.
  • Loading branch information
BradLarson committed Jun 4, 2013
1 parent 1f6f130 commit bb90abd
Show file tree
Hide file tree
Showing 8 changed files with 155 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1278,7 +1278,9 @@ - (void)setupFilter;
default: filter = [[GPUImageSepiaFilter alloc] init]; break;
}

if (filterType == GPUIMAGE_FILECONFIG)
[filter forceProcessingAtSize:CGSizeMake(480.0, 640.0)];

if (filterType == GPUIMAGE_FILECONFIG)
{
self.title = @"File Configuration";
pipeline = [[GPUImageFilterPipeline alloc] initWithConfigurationFile:[[NSBundle mainBundle] URLForResource:@"SampleConfiguration" withExtension:@"plist"]
Expand Down
30 changes: 22 additions & 8 deletions framework/Source/GPUImageBulgeDistortionFilter.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ void main()

@interface GPUImageBulgeDistortionFilter ()

- (void)adjustAspectRatio;

@property (readwrite, nonatomic) CGFloat aspectRatio;

@end
Expand Down Expand Up @@ -103,21 +105,32 @@ - (id)init;
#pragma mark -
#pragma mark Accessors

- (void)adjustAspectRatio;
{
if (GPUImageRotationSwapsWidthAndHeight(inputRotation))
{
[self setAspectRatio:(inputTextureSize.width / inputTextureSize.height)];
}
else
{
[self setAspectRatio:(inputTextureSize.height / inputTextureSize.width)];
}
}

- (void)forceProcessingAtSize:(CGSize)frameSize;
{
[super forceProcessingAtSize:frameSize];
[self adjustAspectRatio];
}

- (void)setInputSize:(CGSize)newSize atIndex:(NSInteger)textureIndex;
{
CGSize oldInputSize = inputTextureSize;
[super setInputSize:newSize atIndex:textureIndex];

if ( (!CGSizeEqualToSize(oldInputSize, inputTextureSize)) && (!CGSizeEqualToSize(newSize, CGSizeZero)) )
{
if (GPUImageRotationSwapsWidthAndHeight(inputRotation))
{
[self setAspectRatio:(inputTextureSize.width / inputTextureSize.height)];
}
else
{
[self setAspectRatio:(inputTextureSize.height / inputTextureSize.width)];
}
[self adjustAspectRatio];
}
}

Expand All @@ -132,6 +145,7 @@ - (void)setInputRotation:(GPUImageRotationMode)newInputRotation atIndex:(NSInteg
{
[super setInputRotation:newInputRotation atIndex:textureIndex];
[self setCenter:self.center];
[self adjustAspectRatio];
}

- (void)setRadius:(CGFloat)newValue;
Expand Down
40 changes: 30 additions & 10 deletions framework/Source/GPUImageGaussianBlurPositionFilter.m
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ void main()

@interface GPUImageGaussianBlurPositionFilter ()

- (void)adjustAspectRatio;

@property (readwrite, nonatomic) CGFloat aspectRatio;

@end
Expand Down Expand Up @@ -157,25 +159,43 @@ - (id)init;
secondStageFragmentShaderFromString:nil];
}

- (void)adjustAspectRatio;
{
if (GPUImageRotationSwapsWidthAndHeight(inputRotation))
{
[self setAspectRatio:(inputTextureSize.width / inputTextureSize.height)];
}
else
{
[self setAspectRatio:(inputTextureSize.height / inputTextureSize.width)];
}
}

- (void)forceProcessingAtSize:(CGSize)frameSize;
{
[super forceProcessingAtSize:frameSize];
[self adjustAspectRatio];
}

- (void)setInputSize:(CGSize)newSize atIndex:(NSInteger)textureIndex;
{
CGSize oldInputSize = inputTextureSize;
[super setInputSize:newSize atIndex:textureIndex];

if ( (!CGSizeEqualToSize(oldInputSize, inputTextureSize)) && (!CGSizeEqualToSize(newSize, CGSizeZero)) )
{
if (GPUImageRotationSwapsWidthAndHeight(inputRotation))
{
[self setAspectRatio:(inputTextureSize.width / inputTextureSize.height)];
}
else
{
[self setAspectRatio:(inputTextureSize.height / inputTextureSize.width)];
}
[self adjustAspectRatio];
}
}

#pragma mark Getters and Setters
- (void)setInputRotation:(GPUImageRotationMode)newInputRotation atIndex:(NSInteger)textureIndex;
{
[super setInputRotation:newInputRotation atIndex:textureIndex];
[self adjustAspectRatio];
}

#pragma mark -
#pragma mark Accessors

- (void)setBlurSize:(CGFloat)newValue;
{
Expand Down
30 changes: 22 additions & 8 deletions framework/Source/GPUImagePinchDistortionFilter.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ void main()

@interface GPUImagePinchDistortionFilter ()

- (void)adjustAspectRatio;

@property (readwrite, nonatomic) CGFloat aspectRatio;

@end
Expand Down Expand Up @@ -106,28 +108,40 @@ - (id)init;
#pragma mark -
#pragma mark Accessors

- (void)adjustAspectRatio;
{
if (GPUImageRotationSwapsWidthAndHeight(inputRotation))
{
[self setAspectRatio:(inputTextureSize.width / inputTextureSize.height)];
}
else
{
[self setAspectRatio:(inputTextureSize.height / inputTextureSize.width)];
}
}

- (void)forceProcessingAtSize:(CGSize)frameSize;
{
[super forceProcessingAtSize:frameSize];
[self adjustAspectRatio];
}

- (void)setInputSize:(CGSize)newSize atIndex:(NSInteger)textureIndex;
{
CGSize oldInputSize = inputTextureSize;
[super setInputSize:newSize atIndex:textureIndex];

if ( (!CGSizeEqualToSize(oldInputSize, inputTextureSize)) && (!CGSizeEqualToSize(newSize, CGSizeZero)) )
{
if (GPUImageRotationSwapsWidthAndHeight(inputRotation))
{
[self setAspectRatio:(inputTextureSize.width / inputTextureSize.height)];
}
else
{
[self setAspectRatio:(inputTextureSize.height / inputTextureSize.width)];
}
[self adjustAspectRatio];
}
}

- (void)setInputRotation:(GPUImageRotationMode)newInputRotation atIndex:(NSInteger)textureIndex;
{
[super setInputRotation:newInputRotation atIndex:textureIndex];
[self setCenter:self.center];
[self adjustAspectRatio];
}

- (void)setAspectRatio:(CGFloat)newValue;
Expand Down
1 change: 1 addition & 0 deletions framework/Source/GPUImagePixellateFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
// The fractional width of the image to use as a size for the pixels in the resulting image. Values below one pixel width in the source image are ignored.
@property(readwrite, nonatomic) CGFloat fractionalWidthOfAPixel;


@end
35 changes: 27 additions & 8 deletions framework/Source/GPUImagePixellateFilter.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ @interface GPUImagePixellateFilter ()

@property (readwrite, nonatomic) CGFloat aspectRatio;

- (void)adjustAspectRatio;

@end

@implementation GPUImagePixellateFilter
Expand Down Expand Up @@ -77,21 +79,38 @@ - (id)initWithFragmentShaderFromString:(NSString *)fragmentShaderString;
return self;
}

- (void)adjustAspectRatio;
{
if (GPUImageRotationSwapsWidthAndHeight(inputRotation))
{
[self setAspectRatio:(inputTextureSize.width / inputTextureSize.height)];
}
else
{
[self setAspectRatio:(inputTextureSize.height / inputTextureSize.width)];
}
}

- (void)setInputRotation:(GPUImageRotationMode)newInputRotation atIndex:(NSInteger)textureIndex;
{
[super setInputRotation:newInputRotation atIndex:textureIndex];
[self adjustAspectRatio];
}

- (void)forceProcessingAtSize:(CGSize)frameSize;
{
[super forceProcessingAtSize:frameSize];
[self adjustAspectRatio];
}

- (void)setInputSize:(CGSize)newSize atIndex:(NSInteger)textureIndex;
{
CGSize oldInputSize = inputTextureSize;
[super setInputSize:newSize atIndex:textureIndex];

if ( (!CGSizeEqualToSize(oldInputSize, inputTextureSize)) && (!CGSizeEqualToSize(newSize, CGSizeZero)) )
{
if (GPUImageRotationSwapsWidthAndHeight(inputRotation))
{
[self setAspectRatio:(inputTextureSize.width / inputTextureSize.height)];
}
else
{
[self setAspectRatio:(inputTextureSize.height / inputTextureSize.width)];
}
[self adjustAspectRatio];
}
}

Expand Down
36 changes: 28 additions & 8 deletions framework/Source/GPUImagePixellatePositionFilter.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ void main()

@interface GPUImagePixellatePositionFilter ()

- (void)adjustAspectRatio;

@property (readwrite, nonatomic) CGFloat aspectRatio;

@end
Expand Down Expand Up @@ -112,20 +114,38 @@ - (void)setInputSize:(CGSize)newSize atIndex:(NSInteger)textureIndex;

if ( (!CGSizeEqualToSize(oldInputSize, inputTextureSize)) && (!CGSizeEqualToSize(newSize, CGSizeZero)) )
{
if (GPUImageRotationSwapsWidthAndHeight(inputRotation))
{
[self setAspectRatio:(inputTextureSize.width / inputTextureSize.height)];
}
else
{
[self setAspectRatio:(inputTextureSize.height / inputTextureSize.width)];
}
[self adjustAspectRatio];
}
}

#pragma mark -
#pragma mark Accessors

- (void)setInputRotation:(GPUImageRotationMode)newInputRotation atIndex:(NSInteger)textureIndex;
{
[super setInputRotation:newInputRotation atIndex:textureIndex];
[self setCenter:self.center];
[self adjustAspectRatio];
}

- (void)adjustAspectRatio;
{
if (GPUImageRotationSwapsWidthAndHeight(inputRotation))
{
[self setAspectRatio:(inputTextureSize.width / inputTextureSize.height)];
}
else
{
[self setAspectRatio:(inputTextureSize.height / inputTextureSize.width)];
}
}

- (void)forceProcessingAtSize:(CGSize)frameSize;
{
[super forceProcessingAtSize:frameSize];
[self adjustAspectRatio];
}

- (void)setFractionalWidthOfAPixel:(CGFloat)newValue;
{
CGFloat singlePixelSpacing;
Expand Down
30 changes: 22 additions & 8 deletions framework/Source/GPUImageSphereRefractionFilter.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ void main()

@interface GPUImageSphereRefractionFilter ()

- (void)adjustAspectRatio;

@property (readwrite, nonatomic) CGFloat aspectRatio;

@end
Expand Down Expand Up @@ -113,24 +115,36 @@ - (void)setInputSize:(CGSize)newSize atIndex:(NSInteger)textureIndex;

if (!CGSizeEqualToSize(oldInputSize, inputTextureSize) && (!CGSizeEqualToSize(newSize, CGSizeZero)) )
{
if (GPUImageRotationSwapsWidthAndHeight(inputRotation))
{
[self setAspectRatio:(inputTextureSize.width / inputTextureSize.height)];
}
else
{
[self setAspectRatio:(inputTextureSize.height / inputTextureSize.width)];
}
[self adjustAspectRatio];
}
}

#pragma mark -
#pragma mark Accessors

- (void)adjustAspectRatio;
{
if (GPUImageRotationSwapsWidthAndHeight(inputRotation))
{
[self setAspectRatio:(inputTextureSize.width / inputTextureSize.height)];
}
else
{
[self setAspectRatio:(inputTextureSize.height / inputTextureSize.width)];
}
}

- (void)setInputRotation:(GPUImageRotationMode)newInputRotation atIndex:(NSInteger)textureIndex;
{
[super setInputRotation:newInputRotation atIndex:textureIndex];
[self setCenter:self.center];
[self adjustAspectRatio];
}

- (void)forceProcessingAtSize:(CGSize)frameSize;
{
[super forceProcessingAtSize:frameSize];
[self adjustAspectRatio];
}

- (void)setRadius:(CGFloat)newValue;
Expand Down

0 comments on commit bb90abd

Please sign in to comment.