Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2534)

Unified Diff: chrome/browser/cocoa/throbber_view.mm

Issue 115643: Rewriting to use CIImage in hopes of better performance. Still playing with p... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/cocoa/throbber_view.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/throbber_view.mm
===================================================================
--- chrome/browser/cocoa/throbber_view.mm (revision 16615)
+++ chrome/browser/cocoa/throbber_view.mm (working copy)
@@ -48,8 +48,19 @@
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]);
timer_ =
@@ -78,18 +89,19 @@
// 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
« no previous file with comments | « chrome/browser/cocoa/throbber_view.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698