Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
get_current_monitor_profile.cpp File Reference
#include "include/core/SkStream.h"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 16 of file get_current_monitor_profile.cpp.

16 {
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 intelligent 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 left to the reader.
37 for (int i = 0; EnumDisplayDevices(nullptr, 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(nullptr, dd.DeviceName, nullptr, nullptr);
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 profile (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}
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
SK_API SkString static SkString SkStringPrintf()
Definition SkString.h:287
const char * c_str() const
Definition SkString.h:133
return FALSE
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition switches.h:259
#define CopyFile
#define MAX_PATH
unsigned long DWORD