Index: chrome/browser/cocoa/throbber_view.mm |
=================================================================== |
--- chrome/browser/cocoa/throbber_view.mm (revision 16989) |
+++ chrome/browser/cocoa/throbber_view.mm (working copy) |
@@ -39,28 +39,8 @@ |
- (id)initWithFrame:(NSRect)frame image:(NSImage*)image { |
if ((self = [super initWithFrame:frame])) { |
- // Ensure that the height divides evenly into the width. Cache the |
- // number of frames in the animation for later. |
- NSSize imageSize = [image size]; |
- DCHECK(imageSize.height && imageSize.width); |
- if (!imageSize.height) |
- return nil; |
- DCHECK((int)imageSize.width % (int)imageSize.height == 0); |
- numFrames_ = (int)imageSize.width / (int)imageSize.height; |
- DCHECK(numFrames_); |
+ [self setImage:image]; |
- // First check if we have a bitmap image rep and use it, otherwise fall |
- // back to creating one. |
- NSBitmapImageRep* rep = [[image representations] objectAtIndex:0]; |
- if (![rep isKindOfClass:[NSBitmapImageRep class]]) { |
- [image lockFocus]; |
- NSRect imageRect = NSMakeRect(0, 0, imageSize.width, imageSize.height); |
- rep = [[[NSBitmapImageRep alloc] initWithFocusedViewRect:imageRect] |
- autorelease]; |
- [image unlockFocus]; |
- } |
- image_.reset([[CIImage alloc] initWithBitmapImageRep:rep]); |
- |
#if 0 |
// TODO(pinkerton): The invalidation of the view to trigger re-draw causes |
TVL
2009/05/29 13:05:19
this should also move into the setImage call with
pink (ping after 24hrs)
2009/05/29 13:19:11
Done.
|
// the entire title-bar to redraw (you can see it with QuartzDebug). For some |
@@ -116,4 +96,34 @@ |
fraction:1.0]; |
} |
+// Stores the internal representation of the image from |image|. We use |
+// CoreImage for speed (though this doesn't seem to help perf issues). We |
+// validate that the image is of the appropriate ratio. |
+- (void)setImage:(NSImage*)image { |
+ // Reset the animation counter so there's no chance we are off the end. |
+ animationFrame_ = 0; |
+ |
+ // Ensure that the height divides evenly into the width. Cache the |
+ // number of frames in the animation for later. |
+ NSSize imageSize = [image size]; |
+ DCHECK(imageSize.height && imageSize.width); |
+ if (!imageSize.height) |
+ return; |
+ DCHECK((int)imageSize.width % (int)imageSize.height == 0); |
+ numFrames_ = (int)imageSize.width / (int)imageSize.height; |
+ DCHECK(numFrames_); |
+ |
+ // First check if we have a bitmap image rep and use it, otherwise fall |
+ // back to creating one. |
+ NSBitmapImageRep* rep = [[image representations] objectAtIndex:0]; |
+ if (![rep isKindOfClass:[NSBitmapImageRep class]]) { |
+ [image lockFocus]; |
+ NSRect imageRect = NSMakeRect(0, 0, imageSize.width, imageSize.height); |
+ rep = [[[NSBitmapImageRep alloc] initWithFocusedViewRect:imageRect] |
+ autorelease]; |
+ [image unlockFocus]; |
+ } |
+ image_.reset([[CIImage alloc] initWithBitmapImageRep:rep]); |
+} |
+ |
@end |