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

Side by Side Diff: chrome/browser/ui/cocoa/tabs/tab_view.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_view.h" 5 #import "chrome/browser/ui/cocoa/tabs/tab_view.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/mac/sdk_forward_declarations.h" 8 #include "base/mac/sdk_forward_declarations.h"
9 #include "chrome/browser/themes/theme_service.h" 9 #include "chrome/browser/themes/theme_service.h"
10 #import "chrome/browser/ui/cocoa/nsview_additions.h" 10 #import "chrome/browser/ui/cocoa/nsview_additions.h"
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 NSImage* leftMask = rb.GetNativeImageNamed(IDR_TAB_ALPHA_LEFT).ToNSImage(); 676 NSImage* leftMask = rb.GetNativeImageNamed(IDR_TAB_ALPHA_LEFT).ToNSImage();
677 NSImage* rightMask = rb.GetNativeImageNamed(IDR_TAB_ALPHA_RIGHT).ToNSImage(); 677 NSImage* rightMask = rb.GetNativeImageNamed(IDR_TAB_ALPHA_RIGHT).ToNSImage();
678 678
679 CGFloat leftWidth = leftMask.size.width; 679 CGFloat leftWidth = leftMask.size.width;
680 CGFloat rightWidth = rightMask.size.width; 680 CGFloat rightWidth = rightMask.size.width;
681 681
682 // Image masks must be in the DeviceGray colorspace. Create a context and 682 // Image masks must be in the DeviceGray colorspace. Create a context and
683 // draw the mask into it. 683 // draw the mask into it.
684 base::ScopedCFTypeRef<CGColorSpaceRef> colorspace( 684 base::ScopedCFTypeRef<CGColorSpaceRef> colorspace(
685 CGColorSpaceCreateDeviceGray()); 685 CGColorSpaceCreateDeviceGray());
686 CGContextRef maskContext = 686 base::ScopedCFTypeRef<CGContextRef> maskContext(
Nico 2013/09/16 20:54:21 !!
687 CGBitmapContextCreate(NULL, tabWidth * scale, kMaskHeight * scale, 687 CGBitmapContextCreate(NULL, tabWidth * scale, kMaskHeight * scale,
688 8, tabWidth * scale, colorspace, 0); 688 8, tabWidth * scale, colorspace, 0));
689 CGContextScaleCTM(maskContext, scale, scale); 689 CGContextScaleCTM(maskContext, scale, scale);
690 NSGraphicsContext* maskGraphicsContext = 690 NSGraphicsContext* maskGraphicsContext =
691 [NSGraphicsContext graphicsContextWithGraphicsPort:maskContext 691 [NSGraphicsContext graphicsContextWithGraphicsPort:maskContext
692 flipped:NO]; 692 flipped:NO];
693 693
694 gfx::ScopedNSGraphicsContextSaveGState scopedGState; 694 gfx::ScopedNSGraphicsContextSaveGState scopedGState;
695 [NSGraphicsContext setCurrentContext:maskGraphicsContext]; 695 [NSGraphicsContext setCurrentContext:maskGraphicsContext];
696 696
697 // Draw mask image. 697 // Draw mask image.
698 [[NSColor blackColor] setFill]; 698 [[NSColor blackColor] setFill];
699 CGContextFillRect(maskContext, CGRectMake(0, 0, tabWidth, kMaskHeight)); 699 CGContextFillRect(maskContext, CGRectMake(0, 0, tabWidth, kMaskHeight));
700 700
701 NSDrawThreePartImage(NSMakeRect(0, 0, tabWidth, kMaskHeight), 701 NSDrawThreePartImage(NSMakeRect(0, 0, tabWidth, kMaskHeight),
702 leftMask, nil, rightMask, /*vertical=*/NO, NSCompositeSourceOver, 1.0, 702 leftMask, nil, rightMask, /*vertical=*/NO, NSCompositeSourceOver, 1.0,
703 /*flipped=*/NO); 703 /*flipped=*/NO);
704 704
705 CGFloat middleWidth = tabWidth - leftWidth - rightWidth; 705 CGFloat middleWidth = tabWidth - leftWidth - rightWidth;
706 NSRect middleRect = NSMakeRect(leftWidth, 0, middleWidth, kFillHeight); 706 NSRect middleRect = NSMakeRect(leftWidth, 0, middleWidth, kFillHeight);
707 [[NSColor whiteColor] setFill]; 707 [[NSColor whiteColor] setFill];
708 NSRectFill(middleRect); 708 NSRectFill(middleRect);
709 709
710 maskCache_.reset(CGBitmapContextCreateImage(maskContext)); 710 maskCache_.reset(CGBitmapContextCreateImage(maskContext));
711 return maskCache_; 711 return maskCache_;
712 } 712 }
713 713
714 @end // @implementation TabView(Private) 714 @end // @implementation TabView(Private)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698