diff options
author | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-21 18:56:08 +0000 |
---|---|---|
committer | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-21 18:56:08 +0000 |
commit | 92ecb839397040d8ddd2342a72532fd83d375535 (patch) | |
tree | cc8cf15e00d107e7d348cce4b71e4c235c8a9688 /chrome/browser/cocoa | |
parent | 1c58a5c5098144cb4d281301aa79408d21998239 (diff) | |
download | chromium_src-92ecb839397040d8ddd2342a72532fd83d375535.zip chromium_src-92ecb839397040d8ddd2342a72532fd83d375535.tar.gz chromium_src-92ecb839397040d8ddd2342a72532fd83d375535.tar.bz2 |
Rewriting to use CIImage in hopes of better performance. Still playing with perf bot.
Review URL: http://codereview.chromium.org/115643
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16636 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r-- | chrome/browser/cocoa/throbber_view.h | 2 | ||||
-rw-r--r-- | chrome/browser/cocoa/throbber_view.mm | 24 |
2 files changed, 19 insertions, 7 deletions
diff --git a/chrome/browser/cocoa/throbber_view.h b/chrome/browser/cocoa/throbber_view.h index 5403371..00f83ed 100644 --- a/chrome/browser/cocoa/throbber_view.h +++ b/chrome/browser/cocoa/throbber_view.h @@ -19,7 +19,7 @@ @interface ThrobberView : NSView { @private - scoped_nsobject<NSImage> image_; + scoped_nsobject<CIImage> image_; scoped_nsobject<TimerTarget> target_; // Target of animation timer. NSTimer* timer_; // Animation timer. Weak, owned by runloop. unsigned int numFrames_; // Number of frames in this animation. diff --git a/chrome/browser/cocoa/throbber_view.mm b/chrome/browser/cocoa/throbber_view.mm index 7f68c03..cafdcf8 100644 --- a/chrome/browser/cocoa/throbber_view.mm +++ b/chrome/browser/cocoa/throbber_view.mm @@ -48,7 +48,18 @@ const float kAnimationIntervalSeconds = 0.03; // 30ms, same as windows DCHECK((int)imageSize.width % (int)imageSize.height == 0); numFrames_ = (int)imageSize.width / (int)imageSize.height; DCHECK(numFrames_); - image_.reset([image retain]); + + // 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]); // Start a timer for the animation frames. target_.reset([[TimerTarget alloc] initWithThrobber:self]); @@ -78,18 +89,19 @@ const float kAnimationIntervalSeconds = 0.03; // 30ms, same as windows // counter and mark as needing display. - (void)animate { animationFrame_ = ++animationFrame_ % numFrames_; - //[self setNeedsDisplay:YES]; + [self setNeedsDisplay:YES]; } // Overridden to draw the appropriate frame in the image strip. - (void)drawRect:(NSRect)rect { - float imageDimension = [image_ size].height; + float imageDimension = [image_ extent].size.height; float xOffset = animationFrame_ * imageDimension; NSRect sourceImageRect = NSMakeRect(xOffset, 0, imageDimension, imageDimension); - [image_ compositeToPoint:NSMakePoint(0, 0) - fromRect:sourceImageRect - operation:NSCompositeSourceOver]; + [image_ drawInRect:[self bounds] + fromRect:sourceImageRect + operation:NSCompositeSourceOver + fraction:1.0]; } @end |