blob: 84502d6d33be642a348efedb798c3f7315078154 [file] [log] [blame]
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ui/base/cocoa/nscolor_additions.h"
#include "base/mac/foundation_util.h"
#import "base/mac/sdk_forward_declarations.h"
#include "base/macros.h"
@implementation NSColor (ChromeAdditions)
- (CGColorRef)cr_CGColor {
// Redirect to -[NSColor CGColor] if available because it caches.
static BOOL redirect =
[NSColor instancesRespondToSelector:@selector(CGColor)];
if (redirect)
return [self CGColor];
const NSInteger numberOfComponents = [self numberOfComponents];
std::vector<CGFloat> components(numberOfComponents, 0.0);
auto* color =
CGColorCreate([[self colorSpace] CGColorSpace],;
return color;