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

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

Issue 112065: Implement Clear Browser Data for Mac as an app modal dialog. Uses the profile... (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 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
« 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