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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gyp/tools.gyp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/get_current_monitor_profile.cpp
diff --git a/tools/get_current_monitor_profile.cpp b/tools/get_current_monitor_profile.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..048efc2b768497973084f61afdb69f1880cb944f
--- /dev/null
+++ b/tools/get_current_monitor_profile.cpp
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkStream.h"
+
+#if defined(SK_BUILD_FOR_MAC)
+#include <ApplicationServices/ApplicationServices.h>
+#elif defined(SK_BUILD_FOR_WIN)
+#include <windows.h>
+#endif
+
+int main(int argc, char** argv) {
+#if defined(SK_BUILD_FOR_MAC)
+ CGColorSpaceRef cs = CGDisplayCopyColorSpace(CGMainDisplayID());
+ CFDataRef dataRef = CGColorSpaceCopyICCProfile(cs);
+ const uint8_t* data = CFDataGetBytePtr(dataRef);
+ size_t size = CFDataGetLength(dataRef);
+
+ SkFILEWStream file("monitor.icc");
msarett 2016/07/12 18:56:49 Maybe make this monitor_0.icc for consistency?
+ file.write(data, size);
+
+ CFRelease(cs);
+ CFRelease(dataRef);
+ return 0;
+#elif defined(SK_BUILD_FOR_WIN)
+ DISPLAY_DEVICE dd = { sizeof(DISPLAY_DEVICE) };
+ SkString outputFilename;
+
+ 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 "
+ if (dd.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) {
+ // There are other helpful things in dd at this point:
+ // dd.DeviceString has a longer name for the adapter
+ // dd.StateFlags indicates primary display, mirroring, etc...
+ HDC dc = CreateDC(NULL, dd.DeviceName, NULL, NULL);
+ if (dc) {
+ char icmPath[MAX_PATH + 1];
+ DWORD pathLength = MAX_PATH;
+ if (GetICMProfile(dc, &pathLength, icmPath)) {
+ // GetICMProfile just returns the path to the installed profile (not the data)
+ outputFilename = SkStringPrintf("monitor_%d.icc", i);
+ CopyFile(icmPath, outputFilename.c_str(), FALSE);
+ }
+ DeleteDC(dc);
+ }
+ }
+ }
+
+ return 0;
+#else
+ SkDebugf("ERROR: Unsupported platform\n")
+ return 1;
+#endif
+}
« 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