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

Side by Side Diff: tools/get_current_monitor_profile.cpp

Issue 2141573004: Monitor profile tool, now with Windows support, too! (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 5 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 | « gyp/tools.gyp ('k') | 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
(Empty)
1 /*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "SkStream.h"
9
10 #if defined(SK_BUILD_FOR_MAC)
11 #include <ApplicationServices/ApplicationServices.h>
12 #elif defined(SK_BUILD_FOR_WIN)
13 #include <windows.h>
14 #endif
15
16 int main(int argc, char** argv) {
17 #if defined(SK_BUILD_FOR_MAC)
18 CGColorSpaceRef cs = CGDisplayCopyColorSpace(CGMainDisplayID());
19 CFDataRef dataRef = CGColorSpaceCopyICCProfile(cs);
20 const uint8_t* data = CFDataGetBytePtr(dataRef);
21 size_t size = CFDataGetLength(dataRef);
22
23 SkFILEWStream file("monitor.icc");
msarett 2016/07/12 18:56:49 Maybe make this monitor_0.icc for consistency?
24 file.write(data, size);
25
26 CFRelease(cs);
27 CFRelease(dataRef);
28 return 0;
29 #elif defined(SK_BUILD_FOR_WIN)
30 DISPLAY_DEVICE dd = { sizeof(DISPLAY_DEVICE) };
31 SkString outputFilename;
32
33 for (int i = 0; EnumDisplayDevices(NULL, i, &dd, 0); ++i) {
msarett 2016/07/12 18:56:49 I think it's worth adding a comment that this is "
34 if (dd.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) {
35 // There are other helpful things in dd at this point:
36 // dd.DeviceString has a longer name for the adapter
37 // dd.StateFlags indicates primary display, mirroring, etc...
38 HDC dc = CreateDC(NULL, dd.DeviceName, NULL, NULL);
39 if (dc) {
40 char icmPath[MAX_PATH + 1];
41 DWORD pathLength = MAX_PATH;
42 if (GetICMProfile(dc, &pathLength, icmPath)) {
43 // GetICMProfile just returns the path to the installed prof ile (not the data)
44 outputFilename = SkStringPrintf("monitor_%d.icc", i);
45 CopyFile(icmPath, outputFilename.c_str(), FALSE);
46 }
47 DeleteDC(dc);
48 }
49 }
50 }
51
52 return 0;
53 #else
54 SkDebugf("ERROR: Unsupported platform\n")
55 return 1;
56 #endif
57 }
OLDNEW
« no previous file with comments | « gyp/tools.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698