| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 // | |
| 5 // This is a simple helper app that disables Cleartype and does whatever | |
| 6 // else it can to get the system into the configuration the layout tests | |
| 7 // expect. | |
| 8 | |
| 9 #include <signal.h> | |
| 10 #include <stdio.h> | |
| 11 #include <stdlib.h> | |
| 12 #include <windows.h> | |
| 13 | |
| 14 BOOL g_font_smoothing_enabled = FALSE; | |
| 15 | |
| 16 static void SaveInitialSettings(void) { | |
| 17 BOOL ret; | |
| 18 ret = SystemParametersInfo(SPI_GETFONTSMOOTHING, 0, | |
| 19 (PVOID)&g_font_smoothing_enabled, 0); | |
| 20 } | |
| 21 | |
| 22 // Technically, all we need to do is disable ClearType. However, | |
| 23 // for some reason, the call to SPI_SETFONTSMOOTHINGTYPE doesn't | |
| 24 // seem to work, so we just disable font smoothing all together | |
| 25 // (which works reliably) | |
| 26 static void InstallLayoutTestSettings(void) { | |
| 27 BOOL ret; | |
| 28 ret = SystemParametersInfo(SPI_SETFONTSMOOTHING, (UINT)FALSE, (PVOID)0, 0); | |
| 29 } | |
| 30 | |
| 31 static void RestoreInitialSettings(void) { | |
| 32 BOOL ret; | |
| 33 ret = SystemParametersInfo(SPI_SETFONTSMOOTHING, | |
| 34 (UINT)g_font_smoothing_enabled, (PVOID)0, 0); | |
| 35 } | |
| 36 | |
| 37 static void SimpleSignalHandler(int sig) { | |
| 38 // Try to restore the settings and then go down cleanly | |
| 39 RestoreInitialSettings(); | |
| 40 exit(128 + sig); | |
| 41 } | |
| 42 | |
| 43 int main(int argc, char *argv[]) { | |
| 44 // Hooks the ways we might get told to clean up... | |
| 45 signal(SIGINT, SimpleSignalHandler); | |
| 46 signal(SIGTERM, SimpleSignalHandler); | |
| 47 | |
| 48 SaveInitialSettings(); | |
| 49 | |
| 50 InstallLayoutTestSettings(); | |
| 51 | |
| 52 // Let the script know we're ready | |
| 53 printf("ready\n"); | |
| 54 fflush(stdout); | |
| 55 | |
| 56 // Wait for any key (or signal) | |
| 57 getchar(); | |
| 58 | |
| 59 RestoreInitialSettings(); | |
| 60 | |
| 61 return 0; | |
| 62 } | |
| OLD | NEW |