2016-07-12 22:06:24 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2016 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkStream.h"
|
2016-07-12 22:06:24 +00:00
|
|
|
|
|
|
|
#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);
|
2017-10-09 19:45:33 +00:00
|
|
|
|
2016-07-12 22:06:24 +00:00
|
|
|
SkFILEWStream file("monitor_0.icc");
|
|
|
|
file.write(data, size);
|
2017-10-09 19:45:33 +00:00
|
|
|
|
2016-07-12 22:06:24 +00:00
|
|
|
CFRelease(cs);
|
|
|
|
CFRelease(dataRef);
|
|
|
|
return 0;
|
|
|
|
#elif defined(SK_BUILD_FOR_WIN)
|
|
|
|
DISPLAY_DEVICE dd = { sizeof(DISPLAY_DEVICE) };
|
|
|
|
SkString outputFilename;
|
|
|
|
|
|
|
|
// Chrome's code for this currently just gets the primary monitor's profile. This code iterates
|
|
|
|
// over all attached monitors, so it's "better" in that sense. Making intelligent use of this
|
|
|
|
// information (via things like MonitorFromWindow or MonitorFromRect to pick the correct
|
|
|
|
// profile for a particular window or region of a window), is an exercise left to the reader.
|
2022-02-08 23:03:48 +00:00
|
|
|
for (int i = 0; EnumDisplayDevices(nullptr, i, &dd, 0); ++i) {
|
2016-07-12 22:06:24 +00:00
|
|
|
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...
|
2022-02-08 23:03:48 +00:00
|
|
|
HDC dc = CreateDC(nullptr, dd.DeviceName, nullptr, nullptr);
|
2016-07-12 22:06:24 +00:00
|
|
|
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
|
|
|
|
}
|