Skip to content

Commit

Permalink
ARC: SwiffSparseArray and SwiffRenderer are now Obj-C classes, use CF…
Browse files Browse the repository at this point in the history
… in C structs
  • Loading branch information
iccir committed Jan 29, 2012
1 parent ea132ab commit 7dbde74
Show file tree
Hide file tree
Showing 21 changed files with 464 additions and 451 deletions.
55 changes: 26 additions & 29 deletions Source/SwiffDynamicTextAttributes.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,46 +75,43 @@ static void sGetMapTypeAndName(NSString *inName, NSString **outName, SwiffFontMa
SwiffFontMapType mapType = SwiffFontMapTypeDirect;
NSString *name = nil;

@autoreleasepool {
NSCharacterSet *whitespace = [NSCharacterSet whitespaceAndNewlineCharacterSet];
NSArray *components = [inName componentsSeparatedByString:@","];

for (NSString *component in components) {
component = [component stringByTrimmingCharactersInSet:whitespace];
NSCharacterSet *whitespace = [NSCharacterSet whitespaceAndNewlineCharacterSet];
NSArray *components = [inName componentsSeparatedByString:@","];

for (NSString *component in components) {
component = [component stringByTrimmingCharactersInSet:whitespace];

if ([inName hasPrefix:@"_"]) {
if ([inName isEqualToString:@"_sans"]) {
mapType = SwiffFontMapTypeIndirectSans;
name = @"Helvetica";
if ([inName hasPrefix:@"_"]) {
if ([inName isEqualToString:@"_sans"]) {
mapType = SwiffFontMapTypeIndirectSans;
name = @"Helvetica";

} else if ([inName isEqualToString:@"_serif"]) {
mapType = SwiffFontMapTypeIndirectSerif;
name = @"Times";
} else if ([inName isEqualToString:@"_serif"]) {
mapType = SwiffFontMapTypeIndirectSerif;
name = @"Times";

} else if ([inName isEqualToString:@"_typewriter"]) {
mapType = SwiffFontMapTypeIndirectTypewriter;
name = @"Courier";
} else if ([inName isEqualToString:@"_typewriter"]) {
mapType = SwiffFontMapTypeIndirectTypewriter;
name = @"Courier";

} else {
mapType = SwiffFontMapTypeIndirectUnknown;
}
} else {
mapType = SwiffFontMapTypeIndirectUnknown;
}

if (mapType == SwiffFontMapTypeDirect) {
CTFontRef font = CTFontCreateWithName((__bridge CFStringRef)component, 12.0, NULL);
}

if (mapType == SwiffFontMapTypeDirect) {
CTFontRef font = CTFontCreateWithName((__bridge CFStringRef)component, 12.0, NULL);

if (font) {
name = [component retain];
CFRelease(font);
}
if (font) {
name = [[component retain] autorelease];
CFRelease(font);
}

if (name) break;
}

if (name) break;
}

if (!name) name = @"Helvetica";
[name autorelease];

if (outName) *outName = name;
if (outMapType) *outMapType = mapType;
Expand Down
3 changes: 2 additions & 1 deletion Source/SwiffDynamicTextDefinition.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@

@interface SwiffDynamicTextDefinition : NSObject <SwiffDefinition> {
@private
SwiffMovie *m_movie;
SwiffUnretained SwiffMovie *m_movie;

UInt16 m_libraryID;
CGRect m_bounds;

Expand Down
2 changes: 1 addition & 1 deletion Source/SwiffFillStyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ typedef NSInteger SwiffFillStyleType;
SwiffColor color;
};
struct {
SwiffGradient *gradient;
CFTypeRef gradient;
CGAffineTransform gradientTransform;
};
struct {
Expand Down
13 changes: 8 additions & 5 deletions Source/SwiffFillStyle.m
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ - (id) initWithParser:(SwiffParser *)parser
} else if (IS_GRADIENT_TYPE) {
SwiffParserReadMatrix(parser, &m_content.gradientTransform);
BOOL isFocalGradient = (m_type == SwiffFillStyleTypeFocalRadialGradient);
m_content.gradient = [[SwiffGradient alloc] initWithParser:parser isFocalGradient:isFocalGradient];

SwiffGradient *gradient = [[SwiffGradient alloc] initWithParser:parser isFocalGradient:isFocalGradient];
m_content.gradient = CFBridgingRetain(gradient);
[gradient release];

} else if (IS_BITMAP_TYPE) {
UInt16 bitmapID;
Expand Down Expand Up @@ -120,9 +123,9 @@ - (id) initWithParser:(SwiffParser *)parser

- (void) dealloc
{
if (IS_GRADIENT_TYPE) {
[m_content.gradient release];
m_content.gradient = nil;
if (IS_GRADIENT_TYPE && m_content.gradient) {
CFRelease(m_content.gradient);
m_content.gradient = NULL;
}

[super dealloc];
Expand Down Expand Up @@ -189,7 +192,7 @@ - (SwiffColor) color
- (SwiffGradient *) gradient
{
if (IS_GRADIENT_TYPE) {
return m_content.gradient;
return (__bridge SwiffGradient *)m_content.gradient;
} else {
return nil;
}
Expand Down
8 changes: 4 additions & 4 deletions Source/SwiffLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,22 @@
#import <SwiffImport.h>
#import <QuartzCore/QuartzCore.h>
#import <SwiffPlayhead.h>
#import <SwiffRenderer.h>

@class SwiffMovie, SwiffFrame, SwiffPlacedObject, SwiffPlayhead;

@class SwiffMovie, SwiffFrame, SwiffPlacedObject, SwiffPlayhead, SwiffRenderer, SwiffSparseArray;
@protocol SwiffLayerDelegate;


@interface SwiffLayer : CALayer <SwiffPlayheadDelegate> {
id<SwiffLayerDelegate> m_delegate;

SwiffMovie *m_movie;
SwiffRenderer *m_renderer;
SwiffFrame *m_currentFrame;
SwiffPlayhead *m_playhead;
SwiffRenderer *m_renderer;
SwiffSparseArray *m_sublayers;
CALayer *m_contentLayer;
NSUInteger m_sublayerCount;
SwiffSparseArray m_sublayers;

CGFloat m_scaleFactor;
CGAffineTransform m_baseAffineTransform;
Expand Down
Loading

0 comments on commit 7dbde74

Please sign in to comment.