OLD | NEW |
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 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 | 664 |
665 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 665 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
666 NSImage* leftMask = rb.GetNativeImageNamed(IDR_TAB_ALPHA_LEFT).ToNSImage(); | 666 NSImage* leftMask = rb.GetNativeImageNamed(IDR_TAB_ALPHA_LEFT).ToNSImage(); |
667 NSImage* rightMask = rb.GetNativeImageNamed(IDR_TAB_ALPHA_RIGHT).ToNSImage(); | 667 NSImage* rightMask = rb.GetNativeImageNamed(IDR_TAB_ALPHA_RIGHT).ToNSImage(); |
668 | 668 |
669 CGFloat leftWidth = leftMask.size.width; | 669 CGFloat leftWidth = leftMask.size.width; |
670 CGFloat rightWidth = rightMask.size.width; | 670 CGFloat rightWidth = rightMask.size.width; |
671 | 671 |
672 // Image masks must be in the DeviceGray colorspace. Create a context and | 672 // Image masks must be in the DeviceGray colorspace. Create a context and |
673 // draw the mask into it. | 673 // draw the mask into it. |
674 base::mac::ScopedCFTypeRef<CGColorSpaceRef> colorspace( | 674 base::ScopedCFTypeRef<CGColorSpaceRef> colorspace( |
675 CGColorSpaceCreateDeviceGray()); | 675 CGColorSpaceCreateDeviceGray()); |
676 CGContextRef maskContext = | 676 CGContextRef maskContext = |
677 CGBitmapContextCreate(NULL, tabWidth * scale, kMaskHeight * scale, | 677 CGBitmapContextCreate(NULL, tabWidth * scale, kMaskHeight * scale, |
678 8, tabWidth * scale, colorspace, 0); | 678 8, tabWidth * scale, colorspace, 0); |
679 CGContextScaleCTM(maskContext, scale, scale); | 679 CGContextScaleCTM(maskContext, scale, scale); |
680 NSGraphicsContext* maskGraphicsContext = | 680 NSGraphicsContext* maskGraphicsContext = |
681 [NSGraphicsContext graphicsContextWithGraphicsPort:maskContext | 681 [NSGraphicsContext graphicsContextWithGraphicsPort:maskContext |
682 flipped:NO]; | 682 flipped:NO]; |
683 | 683 |
684 gfx::ScopedNSGraphicsContextSaveGState scopedGState; | 684 gfx::ScopedNSGraphicsContextSaveGState scopedGState; |
(...skipping 10 matching lines...) Expand all Loading... |
695 CGFloat middleWidth = tabWidth - leftWidth - rightWidth; | 695 CGFloat middleWidth = tabWidth - leftWidth - rightWidth; |
696 NSRect middleRect = NSMakeRect(leftWidth, 0, middleWidth, kFillHeight); | 696 NSRect middleRect = NSMakeRect(leftWidth, 0, middleWidth, kFillHeight); |
697 [[NSColor whiteColor] setFill]; | 697 [[NSColor whiteColor] setFill]; |
698 NSRectFill(middleRect); | 698 NSRectFill(middleRect); |
699 | 699 |
700 maskCache_.reset(CGBitmapContextCreateImage(maskContext)); | 700 maskCache_.reset(CGBitmapContextCreateImage(maskContext)); |
701 return maskCache_; | 701 return maskCache_; |
702 } | 702 } |
703 | 703 |
704 @end // @implementation TabView(Private) | 704 @end // @implementation TabView(Private) |
OLD | NEW |