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

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: Address feedback, fix compile error on other platforms 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_0.icc");
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 // Chrome's code for this currently just gets the primary monitor's profile. This code iterates
34 // over all attached monitors, so it's "better" in that sense. Making intell igent use of this
35 // information (via things like MonitorFromWindow or MonitorFromRect to pick the correct
36 // profile for a particular window or region of a window), is an exercise le ft to the reader.
37 for (int i = 0; EnumDisplayDevices(NULL, i, &dd, 0); ++i) {
38 if (dd.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) {
39 // There are other helpful things in dd at this point:
40 // dd.DeviceString has a longer name for the adapter
41 // dd.StateFlags indicates primary display, mirroring, etc...
42 HDC dc = CreateDC(NULL, dd.DeviceName, NULL, NULL);
43 if (dc) {
44 char icmPath[MAX_PATH + 1];
45 DWORD pathLength = MAX_PATH;
46 if (GetICMProfile(dc, &pathLength, icmPath)) {
47 // GetICMProfile just returns the path to the installed prof ile (not the data)
48 outputFilename = SkStringPrintf("monitor_%d.icc", i);
49 CopyFile(icmPath, outputFilename.c_str(), FALSE);
50 }
51 DeleteDC(dc);
52 }
53 }
54 }
55
56 return 0;
57 #else
58 SkDebugf("ERROR: Unsupported platform\n");
59 return 1;
60 #endif
61 }
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