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

Side by Side Diff: base/mac_util.mm

Issue 194096: For the purposes of the "system color space," use the main display's color space (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008 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 "base/mac_util.h" 5 #include "base/mac_util.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 if (!library_dir_path) 101 if (!library_dir_path)
102 return FilePath(); 102 return FilePath();
103 103
104 return FilePath(library_dir_path); 104 return FilePath(library_dir_path);
105 } 105 }
106 106
107 CGColorSpaceRef GetSRGBColorSpace() { 107 CGColorSpaceRef GetSRGBColorSpace() {
108 // Leaked. That's OK, it's scoped to the lifetime of the application. 108 // Leaked. That's OK, it's scoped to the lifetime of the application.
109 static CGColorSpaceRef g_color_space_sRGB = 109 static CGColorSpaceRef g_color_space_sRGB =
110 CGColorSpaceCreateWithName(kCGColorSpaceSRGB); 110 CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
111 LOG_IF(ERROR, !g_color_space_sRGB) << "Couldn't get the sRGB color space";
111 return g_color_space_sRGB; 112 return g_color_space_sRGB;
112 } 113 }
113 114
114 CGColorSpaceRef GetSystemColorSpace() { 115 CGColorSpaceRef GetSystemColorSpace() {
115 // Leaked. That's OK, it's scoped to the lifetime of the application. 116 // Leaked. That's OK, it's scoped to the lifetime of the application.
116 static CGColorSpaceRef g_system_color_space = NULL; 117 // Try to get the main display's color space.
118 static CGColorSpaceRef g_system_color_space =
119 CGDisplayCopyColorSpace(CGMainDisplayID());
117 120
118 if (!g_system_color_space) { 121 if (!g_system_color_space) {
119 // Get the System Profile for the main display 122 // Use a generic RGB color space. This is better than nothing.
120 CMProfileRef system_profile = NULL; 123 g_system_color_space = CGColorSpaceCreateDeviceRGB();
121 if (CMGetSystemProfile(&system_profile) == noErr) { 124
122 // Create a colorspace with the system profile 125 if (g_system_color_space) {
123 g_system_color_space = 126 LOG(WARNING) <<
124 CGColorSpaceCreateWithPlatformColorSpace(system_profile); 127 "Couldn't get the main display's color space, using generic";
125 // Close the profile 128 } else {
126 CMCloseProfile(system_profile); 129 LOG(ERROR) << "Couldn't get any color space";
127 } 130 }
128 } 131 }
132
129 return g_system_color_space; 133 return g_system_color_space;
130 } 134 }
131 135
132 } // namespace mac_util 136 } // namespace mac_util
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698