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

Side by Side Diff: ui/base/cocoa/controls/blue_label_button.mm

Issue 1368883002: Mac: restore subpixel AA in the find bar when it doesn't have focus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: respond to comments Created 5 years, 2 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
« no previous file with comments | « ui/base/BUILD.gn ('k') | ui/base/cocoa/scoped_cg_context_smooth_fonts.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ui/base/cocoa/controls/blue_label_button.h" 5 #import "ui/base/cocoa/controls/blue_label_button.h"
6 6
7 #include "base/mac/foundation_util.h" 7 #include "base/mac/foundation_util.h"
8 #include "skia/ext/skia_utils_mac.h" 8 #include "skia/ext/skia_utils_mac.h"
9 #include "third_party/skia/include/core/SkColor.h" 9 #include "third_party/skia/include/core/SkColor.h"
10 #include "ui/base/cocoa/scoped_cg_context_smooth_fonts.h"
10 #include "ui/base/resource/resource_bundle.h" 11 #include "ui/base/resource/resource_bundle.h"
11 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" 12 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
12 13
13 const CGFloat kCornerRadius = 2; 14 const CGFloat kCornerRadius = 2;
14 15
15 const CGFloat kTopBottomTextPadding = 7; 16 const CGFloat kTopBottomTextPadding = 7;
16 const CGFloat kLeftRightTextPadding = 15; 17 const CGFloat kLeftRightTextPadding = 15;
17 const SkColor kTextShadowColor = SkColorSetRGB(0x53, 0x8c, 0xea); 18 const SkColor kTextShadowColor = SkColorSetRGB(0x53, 0x8c, 0xea);
18 19
19 const SkColor kShadowColor = SkColorSetRGB(0xe9, 0xe9, 0xe9); 20 const SkColor kShadowColor = SkColorSetRGB(0xe9, 0xe9, 0xe9);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 textSize.width += 2 * kLeftRightTextPadding; 87 textSize.width += 2 * kLeftRightTextPadding;
87 return textSize; 88 return textSize;
88 } 89 }
89 90
90 - (NSRect)drawTitle:(NSAttributedString*)title 91 - (NSRect)drawTitle:(NSAttributedString*)title
91 withFrame:(NSRect)frame 92 withFrame:(NSRect)frame
92 inView:(NSView*)controlView { 93 inView:(NSView*)controlView {
93 // Fuzz factor to adjust for the drop shadow. Based on visual inspection. 94 // Fuzz factor to adjust for the drop shadow. Based on visual inspection.
94 frame.origin.y -= 1; 95 frame.origin.y -= 1;
95 96
96 // Ensure LCD font smoothing is enabled when layer backed. 97 ui::ScopedCGContextSmoothFonts fontSmoothing;
97 // This is safe to do because we know we are drawing on an opaque background.
98 gfx::ScopedNSGraphicsContextSaveGState scopedGState;
99 NSGraphicsContext* context = [NSGraphicsContext currentContext];
100 CGContextRef cgContext = static_cast<CGContextRef>([context graphicsPort]);
101 CGContextSetShouldSmoothFonts(cgContext, true);
102
103 NSAttributedString* attributedTitle = 98 NSAttributedString* attributedTitle =
104 [[self class] generateAttributedString:[self title]]; 99 [[self class] generateAttributedString:[self title]];
105 [attributedTitle drawInRect:frame]; 100 [attributedTitle drawInRect:frame];
106 return frame; 101 return frame;
107 } 102 }
108 103
109 - (void)drawBezelWithFrame:(NSRect)frame 104 - (void)drawBezelWithFrame:(NSRect)frame
110 inView:(NSView*)controlView { 105 inView:(NSView*)controlView {
111 NSColor* centerColor; 106 NSColor* centerColor;
112 NSColor* innerColor; 107 NSColor* innerColor;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 [[NSBezierPath bezierPathWithRoundedRect:NSInsetRect(frame, 1, 1) 142 [[NSBezierPath bezierPathWithRoundedRect:NSInsetRect(frame, 1, 1)
148 xRadius:kCornerRadius 143 xRadius:kCornerRadius
149 yRadius:kCornerRadius] fill]; 144 yRadius:kCornerRadius] fill];
150 [centerColor set]; 145 [centerColor set];
151 [[NSBezierPath bezierPathWithRoundedRect:NSInsetRect(frame, 2, 2) 146 [[NSBezierPath bezierPathWithRoundedRect:NSInsetRect(frame, 2, 2)
152 xRadius:kCornerRadius 147 xRadius:kCornerRadius
153 yRadius:kCornerRadius] fill]; 148 yRadius:kCornerRadius] fill];
154 } 149 }
155 150
156 @end 151 @end
OLDNEW
« no previous file with comments | « ui/base/BUILD.gn ('k') | ui/base/cocoa/scoped_cg_context_smooth_fonts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698