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

Side by Side Diff: ui/native_theme/native_theme_mac.mm

Issue 1508893003: Use proper namespace in skia/ext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #include "ui/native_theme/native_theme_mac.h" 5 #include "ui/native_theme/native_theme_mac.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/mac/mac_util.h" 10 #include "base/mac/mac_util.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 // list is just populated with class methods on NSColor. 89 // list is just populated with class methods on NSColor.
90 SkColor NSSystemColorToSkColor(NSColor* color) { 90 SkColor NSSystemColorToSkColor(NSColor* color) {
91 if (base::mac::IsOSMountainLionOrEarlier()) 91 if (base::mac::IsOSMountainLionOrEarlier())
92 return GetSystemColorUsingSwatch(color); 92 return GetSystemColorUsingSwatch(color);
93 93
94 // System colors use the an NSNamedColorSpace called "System", so first step 94 // System colors use the an NSNamedColorSpace called "System", so first step
95 // is to convert the color into something that can be worked with. 95 // is to convert the color into something that can be worked with.
96 NSColor* device_color = 96 NSColor* device_color =
97 [color colorUsingColorSpace:[NSColorSpace deviceRGBColorSpace]]; 97 [color colorUsingColorSpace:[NSColorSpace deviceRGBColorSpace]];
98 if (device_color) 98 if (device_color)
99 return gfx::NSDeviceColorToSkColor(device_color); 99 return skia::NSDeviceColorToSkColor(device_color);
100 100
101 // Sometimes the conversion is not possible, but we can get an approximation 101 // Sometimes the conversion is not possible, but we can get an approximation
102 // by going through a CGColorRef. Note that simply using NSColor methods for 102 // by going through a CGColorRef. Note that simply using NSColor methods for
103 // accessing components for system colors results in exceptions like 103 // accessing components for system colors results in exceptions like
104 // "-numberOfComponents not valid for the NSColor NSNamedColorSpace System 104 // "-numberOfComponents not valid for the NSColor NSNamedColorSpace System
105 // windowBackgroundColor; need to first convert colorspace." Hence the 105 // windowBackgroundColor; need to first convert colorspace." Hence the
106 // conversion first to CGColor. 106 // conversion first to CGColor.
107 CGColorRef cg_color = [color CGColor]; 107 CGColorRef cg_color = [color CGColor];
108 const size_t component_count = CGColorGetNumberOfComponents(cg_color); 108 const size_t component_count = CGColorGetNumberOfComponents(cg_color);
109 if (component_count == 4) 109 if (component_count == 4)
110 return gfx::CGColorRefToSkColor(cg_color); 110 return skia::CGColorRefToSkColor(cg_color);
111 111
112 CHECK(component_count == 1 || component_count == 2); 112 CHECK(component_count == 1 || component_count == 2);
113 // 1-2 components means a grayscale channel and maybe an alpha channel, which 113 // 1-2 components means a grayscale channel and maybe an alpha channel, which
114 // CGColorRefToSkColor will not like. But RGB is additive, so the conversion 114 // CGColorRefToSkColor will not like. But RGB is additive, so the conversion
115 // is easy (RGB to grayscale is less easy). 115 // is easy (RGB to grayscale is less easy).
116 const CGFloat* components = CGColorGetComponents(cg_color); 116 const CGFloat* components = CGColorGetComponents(cg_color);
117 CGFloat alpha = component_count == 2 ? components[1] : 1.0; 117 CGFloat alpha = component_count == 2 ? components[1] : 1.0;
118 return SkColorSetARGB(SkScalarRoundToInt(255.0 * alpha), 118 return SkColorSetARGB(SkScalarRoundToInt(255.0 * alpha),
119 SkScalarRoundToInt(255.0 * components[0]), 119 SkScalarRoundToInt(255.0 * components[0]),
120 SkScalarRoundToInt(255.0 * components[0]), 120 SkScalarRoundToInt(255.0 * components[0]),
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 set_scrollbar_button_length(0); 408 set_scrollbar_button_length(0);
409 SetScrollbarColors(kScrollerThumbColor, 409 SetScrollbarColors(kScrollerThumbColor,
410 kScrollerThumbHoverColor, 410 kScrollerThumbHoverColor,
411 kScrollerTrackGradientColors[0]); 411 kScrollerTrackGradientColors[0]);
412 } 412 }
413 413
414 NativeThemeMac::~NativeThemeMac() { 414 NativeThemeMac::~NativeThemeMac() {
415 } 415 }
416 416
417 } // namespace ui 417 } // namespace ui
OLDNEW
« no previous file with comments | « ui/message_center/cocoa/notification_controller.mm ('k') | ui/views/cocoa/bridged_content_view.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698