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

Side by Side Diff: chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm

Issue 23503064: [Mac] Fix some leaks in tab drawing code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" 5 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h"
6 6
7 #import <QuartzCore/QuartzCore.h> 7 #import <QuartzCore/QuartzCore.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 #include <limits> 10 #include <limits>
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 // 1x and 2x scale factors. |drawingHandler| is called once for every scale 159 // 1x and 2x scale factors. |drawingHandler| is called once for every scale
160 // factor. This is similar to -[NSImage imageWithSize:flipped:drawingHandler:], 160 // factor. This is similar to -[NSImage imageWithSize:flipped:drawingHandler:],
161 // but this function always evaluates drawingHandler eagerly, and it works on 161 // but this function always evaluates drawingHandler eagerly, and it works on
162 // 10.6 and 10.7. 162 // 10.6 and 10.7.
163 NSImage* CreateImageWithSize(NSSize size, 163 NSImage* CreateImageWithSize(NSSize size,
164 void (^drawingHandler)(NSSize)) { 164 void (^drawingHandler)(NSSize)) {
165 base::scoped_nsobject<NSImage> result([[NSImage alloc] initWithSize:size]); 165 base::scoped_nsobject<NSImage> result([[NSImage alloc] initWithSize:size]);
166 [NSGraphicsContext saveGraphicsState]; 166 [NSGraphicsContext saveGraphicsState];
167 for (ui::ScaleFactor scale_factor : ui::GetSupportedScaleFactors()) { 167 for (ui::ScaleFactor scale_factor : ui::GetSupportedScaleFactors()) {
168 float scale = GetScaleFactorScale(scale_factor); 168 float scale = GetScaleFactorScale(scale_factor);
169 NSBitmapImageRep *bmpImageRep = [[NSBitmapImageRep alloc] 169 NSBitmapImageRep *bmpImageRep = [[[NSBitmapImageRep alloc]
170 initWithBitmapDataPlanes:NULL 170 initWithBitmapDataPlanes:NULL
171 pixelsWide:size.width * scale 171 pixelsWide:size.width * scale
172 pixelsHigh:size.height * scale 172 pixelsHigh:size.height * scale
173 bitsPerSample:8 173 bitsPerSample:8
174 samplesPerPixel:4 174 samplesPerPixel:4
175 hasAlpha:YES 175 hasAlpha:YES
176 isPlanar:NO 176 isPlanar:NO
177 colorSpaceName:NSDeviceRGBColorSpace 177 colorSpaceName:NSDeviceRGBColorSpace
178 bytesPerRow:0 178 bytesPerRow:0
179 bitsPerPixel:0]; 179 bitsPerPixel:0] autorelease];
Nico 2013/09/16 20:54:21 !!
180 [bmpImageRep setSize:size]; 180 [bmpImageRep setSize:size];
181 [NSGraphicsContext setCurrentContext: 181 [NSGraphicsContext setCurrentContext:
182 [NSGraphicsContext graphicsContextWithBitmapImageRep:bmpImageRep]]; 182 [NSGraphicsContext graphicsContextWithBitmapImageRep:bmpImageRep]];
183 drawingHandler(size); 183 drawingHandler(size);
184 [result addRepresentation:bmpImageRep]; 184 [result addRepresentation:bmpImageRep];
185 } 185 }
186 [NSGraphicsContext restoreGraphicsState]; 186 [NSGraphicsContext restoreGraphicsState];
187 187
188 return result.release(); 188 return result.release();
189 } 189 }
(...skipping 2111 matching lines...) Expand 10 before | Expand all | Expand 10 after
2301 NSView* GetSheetParentViewForWebContents(WebContents* web_contents) { 2301 NSView* GetSheetParentViewForWebContents(WebContents* web_contents) {
2302 // View hierarchy of the contents view: 2302 // View hierarchy of the contents view:
2303 // NSView -- switchView, same for all tabs 2303 // NSView -- switchView, same for all tabs
2304 // +- NSView -- TabContentsController's view 2304 // +- NSView -- TabContentsController's view
2305 // +- TabContentsViewCocoa 2305 // +- TabContentsViewCocoa
2306 // 2306 //
2307 // Changing it? Do not forget to modify 2307 // Changing it? Do not forget to modify
2308 // -[TabStripController swapInTabAtIndex:] too. 2308 // -[TabStripController swapInTabAtIndex:] too.
2309 return [web_contents->GetView()->GetNativeView() superview]; 2309 return [web_contents->GetView()->GetNativeView() superview];
2310 } 2310 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/tabs/tab_view.mm » ('j') | chrome/browser/ui/cocoa/tabs/tab_view.mm » ('J')

Powered by Google App Engine
This is Rietveld 408576698