]> git.saurik.com Git - winterboard.git/commitdiff
Attempting to deal with memory footprint.
authorJay Freeman (saurik) <saurik@saurik.com>
Mon, 16 Mar 2009 20:46:22 +0000 (20:46 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Mon, 16 Mar 2009 20:46:22 +0000 (20:46 +0000)
Library.mm
control

index 2a4483a42e548240f3e2377ed76c5918ff073cc0..796ffb95a6c939267b5124650eb5f7a18c1ff9eb 100644 (file)
@@ -62,6 +62,7 @@
 #import <SpringBoard/SBIconLabel.h>
 #import <SpringBoard/SBIconList.h>
 #import <SpringBoard/SBIconModel.h>
 #import <SpringBoard/SBIconLabel.h>
 #import <SpringBoard/SBIconList.h>
 #import <SpringBoard/SBIconModel.h>
+#import <SpringBoard/SBImageCache.h>
 #import <SpringBoard/SBStatusBarContentsView.h>
 #import <SpringBoard/SBStatusBarController.h>
 #import <SpringBoard/SBStatusBarOperatorNameView.h>
 #import <SpringBoard/SBStatusBarContentsView.h>
 #import <SpringBoard/SBStatusBarController.h>
 #import <SpringBoard/SBStatusBarOperatorNameView.h>
@@ -105,6 +106,7 @@ Class $SBIconController;
 Class $SBIconLabel;
 Class $SBIconList;
 Class $SBIconModel;
 Class $SBIconLabel;
 Class $SBIconList;
 Class $SBIconModel;
+//Class $SBImageCache;
 Class $SBStatusBarContentsView;
 Class $SBStatusBarController;
 Class $SBStatusBarOperatorNameView;
 Class $SBStatusBarContentsView;
 Class $SBStatusBarController;
 Class $SBStatusBarOperatorNameView;
@@ -305,27 +307,42 @@ static NSString *$pathForIcon$(SBApplication *self) {
 
 @end
 
 
 @end
 
-MSHook(void, SBIconModel$cacheImageForIcon$, SBIconModel *self, SEL sel, SBIcon *icon) {
-    _SBIconModel$cacheImageForIcon$(self, sel, icon);
-    NSString *key([icon displayIdentifier]);
+UIImage *$cacheForImage$(UIImage *image) {
+    CGColorSpaceRef space(CGColorSpaceCreateDeviceRGB());
+    CGRect rect = {CGPointMake(1, 1), [image size]};
+    CGSize size = {rect.size.width + 2, rect.size.height + 2};
 
 
-    if (UIImage *image = [icon icon]) {
-        CGColorSpaceRef space(CGColorSpaceCreateDeviceRGB());
-        CGRect rect = {CGPointMake(1, 1), [image size]};
-        CGSize size = {rect.size.width + 2, rect.size.height + 2};
+    CGContextRef context(CGBitmapContextCreate(NULL, size.width, size.height, 8, 4 * size.width, space, kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst));
+    CGColorSpaceRelease(space);
 
 
-        CGContextRef context(CGBitmapContextCreate(NULL, size.width, size.height, 8, 4 * size.width, space, kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst));
-        CGColorSpaceRelease(space);
+    CGContextDrawImage(context, rect, [image CGImage]);
+    CGImageRef ref(CGBitmapContextCreateImage(context));
+    CGContextRelease(context);
 
 
-        CGContextDrawImage(context, rect, [image CGImage]);
-        CGImageRef ref(CGBitmapContextCreateImage(context));
-        CGContextRelease(context);
+    UIImage *cache([UIImage imageWithCGImage:ref]);
+    CGImageRelease(ref);
 
 
-        UIImage *image([UIImage imageWithCGImage:ref]);
-        CGImageRelease(ref);
+    return cache;
+}
+
+/*MSHook(id, SBImageCache$initWithName$forImageWidth$imageHeight$initialCapacity$, SBImageCache *self, SEL sel, NSString *name, unsigned width, unsigned height, unsigned capacity) {
+    //if ([name isEqualToString:@"icons"]) return nil;
+    return _SBImageCache$initWithName$forImageWidth$imageHeight$initialCapacity$(self, sel, name, width, height, capacity);
+}*/
+
+MSHook(void, SBIconModel$cacheImageForIcon$, SBIconModel *self, SEL sel, SBIcon *icon) {
+    NSString *key([icon displayIdentifier]);
 
 
-        [Cache_ setObject:image forKey:key];
+    if (UIImage *image = [icon icon]) {
+        CGSize size = [image size];
+        if (size.width > 59 || size.height > 60) {
+            UIImage *cache($cacheForImage$(image));
+            [Cache_ setObject:cache forKey:key];
+            return;
+        }
     }
     }
+
+    _SBIconModel$cacheImageForIcon$(self, sel, icon);
 }
 
 MSHook(UIImage *, SBIconModel$getCachedImagedForIcon$, SBIconModel *self, SEL sel, SBIcon *icon) {
 }
 
 MSHook(UIImage *, SBIconModel$getCachedImagedForIcon$, SBIconModel *self, SEL sel, SBIcon *icon) {
@@ -1105,7 +1122,6 @@ MSHook(bool, _Z24GetFileNameForThisActionmPcRb, unsigned long a0, char *a1, bool
         NSString *path = [NSString stringWithUTF8String:a1];
         if ([path hasPrefix:@"/System/Library/Audio/UISounds/"]) {
             NSString *file = [path substringFromIndex:31];
         NSString *path = [NSString stringWithUTF8String:a1];
         if ([path hasPrefix:@"/System/Library/Audio/UISounds/"]) {
             NSString *file = [path substringFromIndex:31];
-            NSLog(@"%@", file);
             for (NSString *theme in themes_) {
                 NSString *path([NSString stringWithFormat:@"%@/UISounds/%@", theme, file]);
                 if ([Manager_ fileExistsAtPath:path]) {
             for (NSString *theme in themes_) {
                 NSString *path([NSString stringWithFormat:@"%@/UISounds/%@", theme, file]);
                 if ([Manager_ fileExistsAtPath:path]) {
@@ -1262,10 +1278,12 @@ extern "C" void WBInitialize() {
     Info_ = [[NSMutableDictionary dictionaryWithCapacity:16] retain];
 
     for (NSString *theme in themes_)
     Info_ = [[NSMutableDictionary dictionaryWithCapacity:16] retain];
 
     for (NSString *theme in themes_)
-        if (NSDictionary *info = [[NSDictionary alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/Info.plist", theme]])
+        if (NSDictionary *info = [[NSDictionary alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/Info.plist", theme]]) {
+            [info autorelease];
             for (NSString *key in [info allKeys])
                 if ([Info_ objectForKey:key] == nil)
                     [Info_ setObject:[info objectForKey:key] forKey:key];
             for (NSString *key in [info allKeys])
                 if ([Info_ objectForKey:key] == nil)
                     [Info_ setObject:[info objectForKey:key] forKey:key];
+        }
 
     if ([identifier isEqualToString:@"com.apple.MobileSMS"]) {
         Class mSMSMessageTranscriptController = objc_getClass("mSMSMessageTranscriptController");
 
     if ([identifier isEqualToString:@"com.apple.MobileSMS"]) {
         Class mSMSMessageTranscriptController = objc_getClass("mSMSMessageTranscriptController");
@@ -1296,6 +1314,7 @@ extern "C" void WBInitialize() {
         $SBIconLabel = objc_getClass("SBIconLabel");
         $SBIconList = objc_getClass("SBIconList");
         $SBIconModel = objc_getClass("SBIconModel");
         $SBIconLabel = objc_getClass("SBIconLabel");
         $SBIconList = objc_getClass("SBIconList");
         $SBIconModel = objc_getClass("SBIconModel");
+        //$SBImageCache = objc_getClass("SBImageCache");
         $SBStatusBarContentsView = objc_getClass("SBStatusBarContentsView");
         $SBStatusBarController = objc_getClass("SBStatusBarController");
         $SBStatusBarOperatorNameView = objc_getClass("SBStatusBarOperatorNameView");
         $SBStatusBarContentsView = objc_getClass("SBStatusBarContentsView");
         $SBStatusBarController = objc_getClass("SBStatusBarController");
         $SBStatusBarOperatorNameView = objc_getClass("SBStatusBarOperatorNameView");
@@ -1323,6 +1342,8 @@ extern "C" void WBInitialize() {
         WBRename(SBIconModel, cacheImageForIcon:, cacheImageForIcon$);
         WBRename(SBIconModel, getCachedImagedForIcon:, getCachedImagedForIcon$);
 
         WBRename(SBIconModel, cacheImageForIcon:, cacheImageForIcon$);
         WBRename(SBIconModel, getCachedImagedForIcon:, getCachedImagedForIcon$);
 
+        //WBRename(SBImageCache, initWithName:forImageWidth:imageHeight:initialCapacity:, initWithName$forImageWidth$imageHeight$initialCapacity$);
+
         WBRename(SBAwayView, updateDesktopImage:, updateDesktopImage$);
         WBRename(SBStatusBarContentsView, didMoveToSuperview, didMoveToSuperview);
         WBRename(SBStatusBarContentsView, initWithStatusBar:mode:, initWithStatusBar$mode$);
         WBRename(SBAwayView, updateDesktopImage:, updateDesktopImage$);
         WBRename(SBStatusBarContentsView, didMoveToSuperview, didMoveToSuperview);
         WBRename(SBStatusBarContentsView, initWithStatusBar:mode:, initWithStatusBar$mode$);
@@ -1332,12 +1353,12 @@ extern "C" void WBInitialize() {
         WBRename(SBStatusBarTimeView, drawRect:, drawRect$);
 
         English_ = [[NSDictionary alloc] initWithContentsOfFile:@"/System/Library/CoreServices/SpringBoard.app/English.lproj/LocalizedApplicationNames.strings"];
         WBRename(SBStatusBarTimeView, drawRect:, drawRect$);
 
         English_ = [[NSDictionary alloc] initWithContentsOfFile:@"/System/Library/CoreServices/SpringBoard.app/English.lproj/LocalizedApplicationNames.strings"];
-        if (English_ != nil)
-            English_ = [English_ retain];
-
         Cache_ = [[NSMutableDictionary alloc] initWithCapacity:64];
     }
 
         Cache_ = [[NSMutableDictionary alloc] initWithCapacity:64];
     }
 
+        [pool release];
+        return;
+
     Wallpapers_ = [[NSArray arrayWithObjects:@"Wallpaper.mp4", @"Wallpaper.png", @"Wallpaper.jpg", @"Wallpaper.html", nil] retain];
 
     if ([Info_ objectForKey:@"UndockedIconLabels"] == nil)
     Wallpapers_ = [[NSArray arrayWithObjects:@"Wallpaper.mp4", @"Wallpaper.png", @"Wallpaper.jpg", @"Wallpaper.html", nil] retain];
 
     if ([Info_ objectForKey:@"UndockedIconLabels"] == nil)
diff --git a/control b/control
index 47766a94f80a711f70bcf9fe29d25be7c4421c64..ec52d6c5895cd36939716c260d405c1a3c2fedfa 100644 (file)
--- a/control
+++ b/control
@@ -3,7 +3,7 @@ Priority: optional
 Section: System
 Maintainer: Jay Freeman (saurik) <saurik@saurik.com>
 Architecture: iphoneos-arm
 Section: System
 Maintainer: Jay Freeman (saurik) <saurik@saurik.com>
 Architecture: iphoneos-arm
-Version: 0.9.2696-1
+Version: 0.9.2794-1
 Description: more powerful, open-source SummerBoard
 Name: WinterBoard
 Depends: mobilesubstrate (>= 0.9.2660-1)
 Description: more powerful, open-source SummerBoard
 Name: WinterBoard
 Depends: mobilesubstrate (>= 0.9.2660-1)