Skip to content

Commit 8d7d53d

Browse files
author
Mallory Paine
committed
64-byte alignment is an even more robust choice for all of the various GPUs. Bump the metadata version
so that image tables created with the previous 32-byte alignment can be tossed.
1 parent 8b6800c commit 8d7d53d

File tree

4 files changed

+6
-8
lines changed

4 files changed

+6
-8
lines changed

FastImageCache/FICImageTable.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ - (instancetype)initWithFormat:(FICImageFormat *)imageFormat {
133133
_screenScale = [[UIScreen mainScreen] scale];
134134

135135
int bytesPerPixel = 4;
136-
_imageRowLength = FICByteAlignForCoreAnimation([_imageFormat pixelSize].width * bytesPerPixel, bytesPerPixel);
136+
_imageRowLength = FICByteAlignForCoreAnimation([_imageFormat pixelSize].width * bytesPerPixel);
137137
_imageLength = _imageRowLength * (NSInteger)[_imageFormat pixelSize].height;
138138

139139
_chunkDictionary = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, NULL, NULL); // Non-retained keys and values

FastImageCache/FICImageTableEntry.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ - (void)dealloc {
7777
#pragma mark - Other Accessors
7878

7979
+ (NSInteger)metadataVersion {
80-
return 7;
80+
return 8;
8181
}
8282

8383
- (FICImageTableEntryMetadata *)_metadata {

FastImageCache/FICUtilities.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#import "FICImports.h"
1010

1111
size_t FICByteAlign(size_t bytesPerRow, size_t alignment);
12-
size_t FICByteAlignForCoreAnimation(size_t bytesPerRow, size_t bytesPerPixel);
12+
size_t FICByteAlignForCoreAnimation(size_t bytesPerRow);
1313

1414
NSString * FICStringWithUUIDBytes(CFUUIDBytes UUIDBytes);
1515
CFUUIDBytes FICUUIDBytesWithString(NSString *string);

FastImageCache/FICUtilities.m

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,18 @@
1212

1313
#pragma mark Internal Definitions
1414

15-
#define FIC_CA_BACKING_STORE_ALIGNMENT_PIXELS 8
1615
// Core Animation will make a copy of any image that a client application provides whose backing store isn't properly byte-aligned.
1716
// This copy operation can be prohibitively expensive, so we want to avoid this by properly aligning any UIImages we're working with.
18-
// To produce a UIImage that is properly aligned, we need to ensure that the backing store's bytes per row is a multiple of
19-
// (bytes per pixel * FIC_CA_BACKING_STORE_ALIGNMENT_PIXELS).
17+
// To produce a UIImage that is properly aligned, we need to ensure that the backing store's bytes per row is a multiple of 64.
2018

2119
#pragma mark - Byte Alignment
2220

2321
inline size_t FICByteAlign(size_t width, size_t alignment) {
2422
return ((width + (alignment - 1)) / alignment) * alignment;
2523
}
2624

27-
inline size_t FICByteAlignForCoreAnimation(size_t bytesPerRow, size_t bytesPerPixel) {
28-
return FICByteAlign(bytesPerRow, (bytesPerPixel * FIC_CA_BACKING_STORE_ALIGNMENT_PIXELS));
25+
inline size_t FICByteAlignForCoreAnimation(size_t bytesPerRow) {
26+
return FICByteAlign(bytesPerRow, 64);
2927
}
3028

3129
#pragma mark - Strings and UUIDs

0 commit comments

Comments
 (0)