From 297c3c8e85bdb7ed79aaa6a596f52874d79e7a25 Mon Sep 17 00:00:00 2001 From: Ben Wagner Date: Thu, 19 Jul 2018 08:55:10 -0400 Subject: Ignore NTDDI_VERSION with DirectWrite. Some builds set NTDDI_VERSION to a very old version of Windows to ensure they run on those older versions of Windows. The dwrite_3.h header uses NTDDI_VERSION in an odd manner, hiding immutable declarations of enums, structs, and interfaces. NTDDI_VERSION was indended to hide functions and extensions to structs. DWrite has one function (to create the factory) and no structs which will be extended. Skia is already tested to run on the oldest supported Windows platform (Windows 7), so an external build building Skia with NTDDI_VERSION as a build define should have no issues at runtime if Skia ignores it. If Skia doesn't ignore NTDDI_VERSION in this case the DWrite backend will be runtime limited to interfaces in very old versions of Windows, instead of using newer interfaces which become available at runtime. Change-Id: I3e9ac2c4116d75588bfff391928d3cd446d6363a Reviewed-on: https://skia-review.googlesource.com/142324 Commit-Queue: Ben Wagner Reviewed-by: Brian Osman Reviewed-by: Herb Derby --- src/utils/win/SkDWriteNTDDI_VERSION.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/utils/win/SkDWriteNTDDI_VERSION.h (limited to 'src/utils') diff --git a/src/utils/win/SkDWriteNTDDI_VERSION.h b/src/utils/win/SkDWriteNTDDI_VERSION.h new file mode 100644 index 0000000000..7196639b97 --- /dev/null +++ b/src/utils/win/SkDWriteNTDDI_VERSION.h @@ -0,0 +1,31 @@ +/* + * Copyright 2018 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef SkDWriteNTDDI_VERSION_DEFINED +#define SkDWriteNTDDI_VERSION_DEFINED + +// More strictly, this header should be the first thing in a translation unit, +// since it is effectively negating build flags. +#if defined(_WINDOWS_) || defined(DWRITE_3_H_INCLUDED) +#error Must include SkDWriteNTDDI_VERSION.h before any Windows or DWrite headers. +#endif + +// If the build defines NTDDI_VERSION, pretend it didn't. +// This also requires resetting _WIN32_WINNT and WINVER. +// dwrite_3.h guards enum, macro, and interface declarations behind NTDDI_VERSION, +// but it is not clear this is correct since these are all immutable. +#if defined(NTDDI_VERSION) +# undef NTDDI_VERSION +# if defined(_WIN32_WINNT) +# undef _WIN32_WINNT_WIN10 +# endif +# if defined(WINVER) +# undef WINVER +# endif +#endif + +#endif -- cgit v1.2.3