aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--bench/MathBench.cpp1
-rw-r--r--bench/nanobench.cpp1
-rw-r--r--dm/DM.cpp1
-rw-r--r--gm/drawbitmaprect.cpp1
-rw-r--r--gm/drawminibitmaprect.cpp1
-rw-r--r--include/core/SkMath.h53
-rw-r--r--include/core/SkPostConfig.h20
-rw-r--r--include/core/SkPreConfig.h2
-rw-r--r--include/gpu/GrTypes.h14
-rw-r--r--include/ports/SkTypeface_win.h1
-rw-r--r--include/private/SkLeanWindows.h34
-rw-r--r--include/private/SkRecords.h8
-rw-r--r--include/utils/win/SkAutoCoInitialize.h2
-rw-r--r--include/utils/win/SkHRESULT.h2
-rw-r--r--include/utils/win/SkIStream.h3
-rw-r--r--include/utils/win/SkTScopedComPtr.h2
-rw-r--r--include/views/SkEvent.h2
-rw-r--r--src/core/SkEdge.cpp2
-rw-r--r--src/core/SkMathPriv.h66
-rw-r--r--src/core/SkMipMap.cpp2
-rw-r--r--src/core/SkScan_Hairline.cpp1
-rw-r--r--src/core/SkSemaphore.cpp1
-rw-r--r--src/core/SkTSort.h2
-rw-r--r--src/core/SkTaskGroup.cpp1
-rw-r--r--src/core/SkThreadID.cpp2
-rw-r--r--src/core/SkTime.cpp3
-rw-r--r--src/effects/gradients/SkClampRange.cpp2
-rw-r--r--src/gpu/GrGpu.cpp2
-rw-r--r--src/gpu/GrPathUtils.cpp1
-rw-r--r--src/gpu/GrRectanizer_pow2.h1
-rw-r--r--src/gpu/GrResourceProvider.cpp1
-rw-r--r--src/gpu/GrTextureProvider.cpp1
-rw-r--r--src/gpu/batches/GrAtlasTextBatch.cpp1
-rw-r--r--src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp4
-rw-r--r--src/ports/SkDebug_win.cpp8
-rw-r--r--src/ports/SkFontHost_mac.cpp1
-rw-r--r--src/ports/SkOSFile_win.cpp2
-rw-r--r--src/ports/SkOSLibrary_win.cpp2
-rw-r--r--src/ports/SkTLS_win.cpp3
-rw-r--r--src/ports/SkTypeface_win_dw.h2
-rw-r--r--src/utils/SkTextureCompressor.cpp1
-rw-r--r--src/utils/SkTextureCompressor_ASTC.cpp2
-rw-r--r--src/utils/SkThreadUtils_win.h3
-rw-r--r--src/utils/win/SkAutoCoInitialize.cpp7
-rw-r--r--src/utils/win/SkIStream.cpp3
-rw-r--r--src/utils/win/SkWGL.h12
-rw-r--r--src/views/win/SkOSWindow_win.cpp2
-rw-r--r--src/views/win/skia_win.cpp5
-rw-r--r--src/xps/SkXPSDevice.cpp2
-rw-r--r--tests/ClipStackTest.cpp2
-rw-r--r--tests/PathCoverageTest.cpp2
-rw-r--r--tests/PathTest.cpp2
-rw-r--r--tests/SubsetPath.cpp1
-rw-r--r--tools/CrashHandler.cpp2
-rw-r--r--tools/gpu/GrTest.cpp1
55 files changed, 171 insertions, 135 deletions
diff --git a/bench/MathBench.cpp b/bench/MathBench.cpp
index 877d42663c..05a5f8a2d5 100644
--- a/bench/MathBench.cpp
+++ b/bench/MathBench.cpp
@@ -8,6 +8,7 @@
#include "Benchmark.h"
#include "SkColorPriv.h"
#include "SkFixed.h"
+#include "SkMathPriv.h"
#include "SkMatrix.h"
#include "SkPaint.h"
#include "SkRandom.h"
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp
index a7e9ebb855..e5a63a022d 100644
--- a/bench/nanobench.cpp
+++ b/bench/nanobench.cpp
@@ -34,6 +34,7 @@
#include "SkData.h"
#include "SkForceLinking.h"
#include "SkGraphics.h"
+#include "SkLeanWindows.h"
#include "SkOSFile.h"
#include "SkPictureRecorder.h"
#include "SkPictureUtils.h"
diff --git a/dm/DM.cpp b/dm/DM.cpp
index 61a3d2e22e..de99b6b3e2 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -22,6 +22,7 @@
#include "SkFontMgr.h"
#include "SkGraphics.h"
#include "SkHalf.h"
+#include "SkLeanWindows.h"
#include "SkMD5.h"
#include "SkMutex.h"
#include "SkOSFile.h"
diff --git a/gm/drawbitmaprect.cpp b/gm/drawbitmaprect.cpp
index bd6fffec63..4e1af7ef25 100644
--- a/gm/drawbitmaprect.cpp
+++ b/gm/drawbitmaprect.cpp
@@ -12,6 +12,7 @@
#include "SkGradientShader.h"
#include "SkImage.h"
#include "SkImage_Base.h"
+#include "SkMathPriv.h"
#include "SkShader.h"
#include "SkSurface.h"
diff --git a/gm/drawminibitmaprect.cpp b/gm/drawminibitmaprect.cpp
index 073d5a1ce3..d539f26048 100644
--- a/gm/drawminibitmaprect.cpp
+++ b/gm/drawminibitmaprect.cpp
@@ -9,6 +9,7 @@
#include "SkColorPriv.h"
#include "SkGradientShader.h"
#include "SkImage.h"
+#include "SkMathPriv.h"
#include "SkRandom.h"
#include "SkShader.h"
#include "SkSurface.h"
diff --git a/include/core/SkMath.h b/include/core/SkMath.h
index 799939039c..8276c5d04f 100644
--- a/include/core/SkMath.h
+++ b/include/core/SkMath.h
@@ -61,35 +61,6 @@ int32_t SkSqrtBits(int32_t value, int bitBias);
*/
#define SkSqrt32(n) SkSqrtBits(n, 15)
-//! Returns the number of leading zero bits (0...32)
-int SkCLZ_portable(uint32_t);
-
-#ifndef SkCLZ
- #if defined(_MSC_VER)
- #include <intrin.h>
-
- static inline int SkCLZ(uint32_t mask) {
- if (mask) {
- DWORD index;
- _BitScanReverse(&index, mask);
- // Suppress this bogus /analyze warning. The check for non-zero
- // guarantees that _BitScanReverse will succeed.
-#pragma warning(suppress : 6102) // Using 'index' from failed function call
- return index ^ 0x1F;
- } else {
- return 32;
- }
- }
- #elif defined(SK_CPU_ARM32) || defined(__GNUC__) || defined(__clang__)
- static inline int SkCLZ(uint32_t mask) {
- // __builtin_clz(0) is undefined, so we have to detect that case.
- return mask ? __builtin_clz(mask) : 32;
- }
- #else
- #define SkCLZ(x) SkCLZ_portable(x)
- #endif
-#endif
-
/**
* Returns (value < 0 ? 0 : value) efficiently (i.e. no compares or branches)
*/
@@ -116,30 +87,6 @@ static inline int SkClampMax(int value, int max) {
}
/**
- * Returns the smallest power-of-2 that is >= the specified value. If value
- * is already a power of 2, then it is returned unchanged. It is undefined
- * if value is <= 0.
- */
-static inline int SkNextPow2(int value) {
- SkASSERT(value > 0);
- return 1 << (32 - SkCLZ(value - 1));
-}
-
-/**
- * Returns the log2 of the specified value, were that value to be rounded up
- * to the next power of 2. It is undefined to pass 0. Examples:
- * SkNextLog2(1) -> 0
- * SkNextLog2(2) -> 1
- * SkNextLog2(3) -> 2
- * SkNextLog2(4) -> 2
- * SkNextLog2(5) -> 3
- */
-static inline int SkNextLog2(uint32_t value) {
- SkASSERT(value != 0);
- return 32 - SkCLZ(value - 1);
-}
-
-/**
* Returns true if value is a power of 2. Does not explicitly check for
* value <= 0.
*/
diff --git a/include/core/SkPostConfig.h b/include/core/SkPostConfig.h
index c3255b8768..9cae12fdf4 100644
--- a/include/core/SkPostConfig.h
+++ b/include/core/SkPostConfig.h
@@ -107,26 +107,6 @@
///////////////////////////////////////////////////////////////////////////////
#ifdef SK_BUILD_FOR_WIN
-# ifndef WIN32_LEAN_AND_MEAN
-# define WIN32_LEAN_AND_MEAN
-# define WIN32_IS_MEAN_WAS_LOCALLY_DEFINED
-# endif
-# ifndef NOMINMAX
-# define NOMINMAX
-# define NOMINMAX_WAS_LOCALLY_DEFINED
-# endif
-#
-# include <windows.h>
-#
-# ifdef WIN32_IS_MEAN_WAS_LOCALLY_DEFINED
-# undef WIN32_IS_MEAN_WAS_LOCALLY_DEFINED
-# undef WIN32_LEAN_AND_MEAN
-# endif
-# ifdef NOMINMAX_WAS_LOCALLY_DEFINED
-# undef NOMINMAX_WAS_LOCALLY_DEFINED
-# undef NOMINMAX
-# endif
-#
# ifndef SK_A32_SHIFT
# define SK_A32_SHIFT 24
# define SK_R32_SHIFT 16
diff --git a/include/core/SkPreConfig.h b/include/core/SkPreConfig.h
index 928c1bda63..c410c988b5 100644
--- a/include/core/SkPreConfig.h
+++ b/include/core/SkPreConfig.h
@@ -210,7 +210,7 @@
#endif
#if defined(SKIA_DLL)
- #if defined(WIN32)
+ #if defined(SK_BUILD_FOR_WIN32)
#if SKIA_IMPLEMENTATION
#define SK_API __declspec(dllexport)
#else
diff --git a/include/gpu/GrTypes.h b/include/gpu/GrTypes.h
index 902594522d..979afb3b2f 100644
--- a/include/gpu/GrTypes.h
+++ b/include/gpu/GrTypes.h
@@ -108,20 +108,6 @@ static inline size_t GrSizeAlignDown(size_t x, uint32_t alignment) {
///////////////////////////////////////////////////////////////////////////////
/**
- * Return the next power of 2 >= n.
- */
-static inline uint32_t GrNextPow2(uint32_t n) {
- return n ? (1 << (32 - SkCLZ(n - 1))) : 1;
-}
-
-static inline int GrNextPow2(int n) {
- SkASSERT(n >= 0); // this impl only works for non-neg.
- return n ? (1 << (32 - SkCLZ(n - 1))) : 1;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-/**
* Possible 3D APIs that may be used by Ganesh.
*/
enum GrBackend {
diff --git a/include/ports/SkTypeface_win.h b/include/ports/SkTypeface_win.h
index e18ed93341..1945b755e7 100644
--- a/include/ports/SkTypeface_win.h
+++ b/include/ports/SkTypeface_win.h
@@ -8,6 +8,7 @@
#ifndef SkTypeface_win_DEFINED
#define SkTypeface_win_DEFINED
+#include "../private/SkLeanWindows.h"
#include "SkTypeface.h"
#ifdef SK_BUILD_FOR_WIN
diff --git a/include/private/SkLeanWindows.h b/include/private/SkLeanWindows.h
new file mode 100644
index 0000000000..2bdddbba39
--- /dev/null
+++ b/include/private/SkLeanWindows.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#ifndef SkLeanWindows_DEFINED
+#define SkLeanWindows_DEFINED
+
+#include "SkTypes.h"
+
+#ifdef SK_BUILD_FOR_WIN
+# ifndef WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN
+# define WIN32_IS_MEAN_WAS_LOCALLY_DEFINED
+# endif
+# ifndef NOMINMAX
+# define NOMINMAX
+# define NOMINMAX_WAS_LOCALLY_DEFINED
+# endif
+#
+# include <windows.h>
+#
+# ifdef WIN32_IS_MEAN_WAS_LOCALLY_DEFINED
+# undef WIN32_IS_MEAN_WAS_LOCALLY_DEFINED
+# undef WIN32_LEAN_AND_MEAN
+# endif
+# ifdef NOMINMAX_WAS_LOCALLY_DEFINED
+# undef NOMINMAX_WAS_LOCALLY_DEFINED
+# undef NOMINMAX
+# endif
+#endif
+
+#endif // SkLeanWindows_DEFINED
diff --git a/include/private/SkRecords.h b/include/private/SkRecords.h
index 1e274e9f46..d6ef12fe6c 100644
--- a/include/private/SkRecords.h
+++ b/include/private/SkRecords.h
@@ -21,6 +21,14 @@
#include "SkString.h"
#include "SkTextBlob.h"
+// Windows.h, will pull in all of the GDI defines. GDI #defines
+// DrawText to DrawTextA or DrawTextW, but SkRecord has a struct
+// called DrawText. Since this file does not use GDI, undefing
+// DrawText makes things less confusing.
+#ifdef DrawText
+#undef DrawText
+#endif
+
namespace SkRecords {
// A list of all the types of canvas calls we can record.
diff --git a/include/utils/win/SkAutoCoInitialize.h b/include/utils/win/SkAutoCoInitialize.h
index 35fcce5b13..04709782ee 100644
--- a/include/utils/win/SkAutoCoInitialize.h
+++ b/include/utils/win/SkAutoCoInitialize.h
@@ -12,6 +12,8 @@
#ifdef SK_BUILD_FOR_WIN
+#include "../../private/SkLeanWindows.h"
+
/**
* An instance of this class initializes COM on creation
* and closes the COM library on destruction.
diff --git a/include/utils/win/SkHRESULT.h b/include/utils/win/SkHRESULT.h
index a0ffd5935c..69a7118940 100644
--- a/include/utils/win/SkHRESULT.h
+++ b/include/utils/win/SkHRESULT.h
@@ -11,6 +11,8 @@
#include "SkTypes.h"
#ifdef SK_BUILD_FOR_WIN
+#include "../../private/SkLeanWindows.h"
+
void SkTraceHR(const char* file, unsigned long line,
HRESULT hr, const char* msg);
diff --git a/include/utils/win/SkIStream.h b/include/utils/win/SkIStream.h
index 4a72f5b729..28a59f9a02 100644
--- a/include/utils/win/SkIStream.h
+++ b/include/utils/win/SkIStream.h
@@ -14,8 +14,7 @@
#ifdef SK_BUILD_FOR_WIN
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
+#include "../../private/SkLeanWindows.h"
#include <ole2.h>
class SkStream;
diff --git a/include/utils/win/SkTScopedComPtr.h b/include/utils/win/SkTScopedComPtr.h
index d2d925c56f..6fb6143adc 100644
--- a/include/utils/win/SkTScopedComPtr.h
+++ b/include/utils/win/SkTScopedComPtr.h
@@ -8,7 +8,7 @@
#ifndef SkTScopedComPtr_DEFINED
#define SkTScopedComPtr_DEFINED
-#include "SkTypes.h"
+#include "../../private/SkLeanWindows.h"
#ifdef SK_BUILD_FOR_WIN
diff --git a/include/views/SkEvent.h b/include/views/SkEvent.h
index b8fc00ef51..6495530006 100644
--- a/include/views/SkEvent.h
+++ b/include/views/SkEvent.h
@@ -12,6 +12,8 @@
#include "SkMetaData.h"
#include "SkString.h"
+#include "../private/SkLeanWindows.h"
+
/** Unique 32bit id used to identify an instance of SkEventSink. When events are
posted, they are posted to a specific sinkID. When it is time to dispatch the
event, the sinkID is used to find the specific SkEventSink object. If it is found,
diff --git a/src/core/SkEdge.cpp b/src/core/SkEdge.cpp
index 49df95b568..d91c3e6bce 100644
--- a/src/core/SkEdge.cpp
+++ b/src/core/SkEdge.cpp
@@ -8,7 +8,7 @@
#include "SkEdge.h"
#include "SkFDot6.h"
-#include "SkMath.h"
+#include "SkMathPriv.h"
/*
In setLine, setQuadratic, setCubic, the first thing we do is to convert
diff --git a/src/core/SkMathPriv.h b/src/core/SkMathPriv.h
index 1b64a6cd33..fca09f3ffc 100644
--- a/src/core/SkMathPriv.h
+++ b/src/core/SkMathPriv.h
@@ -92,4 +92,70 @@ static inline float SkPinToUnitFloat(float x) {
static inline uint32_t SkBSwap32(uint32_t v) { return __builtin_bswap32(v); }
#endif
+//! Returns the number of leading zero bits (0...32)
+int SkCLZ_portable(uint32_t);
+
+#ifndef SkCLZ
+ #if defined(SK_BUILD_FOR_WIN32)
+ #include <intrin.h>
+
+ static inline int SkCLZ(uint32_t mask) {
+ if (mask) {
+ unsigned long index;
+ _BitScanReverse(&index, mask);
+ // Suppress this bogus /analyze warning. The check for non-zero
+ // guarantees that _BitScanReverse will succeed.
+#pragma warning(suppress : 6102) // Using 'index' from failed function call
+ return index ^ 0x1F;
+ } else {
+ return 32;
+ }
+ }
+ #elif defined(SK_CPU_ARM32) || defined(__GNUC__) || defined(__clang__)
+ static inline int SkCLZ(uint32_t mask) {
+ // __builtin_clz(0) is undefined, so we have to detect that case.
+ return mask ? __builtin_clz(mask) : 32;
+ }
+ #else
+ #define SkCLZ(x) SkCLZ_portable(x)
+ #endif
+#endif
+
+/**
+ * Returns the smallest power-of-2 that is >= the specified value. If value
+ * is already a power of 2, then it is returned unchanged. It is undefined
+ * if value is <= 0.
+ */
+static inline int SkNextPow2(int value) {
+ SkASSERT(value > 0);
+ return 1 << (32 - SkCLZ(value - 1));
+}
+
+/**
+ * Returns the log2 of the specified value, were that value to be rounded up
+ * to the next power of 2. It is undefined to pass 0. Examples:
+ * SkNextLog2(1) -> 0
+ * SkNextLog2(2) -> 1
+ * SkNextLog2(3) -> 2
+ * SkNextLog2(4) -> 2
+ * SkNextLog2(5) -> 3
+ */
+static inline int SkNextLog2(uint32_t value) {
+ SkASSERT(value != 0);
+ return 32 - SkCLZ(value - 1);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Return the next power of 2 >= n.
+ */
+static inline uint32_t GrNextPow2(uint32_t n) {
+ return n ? (1 << (32 - SkCLZ(n - 1))) : 1;
+}
+
+static inline int GrNextPow2(int n) {
+ SkASSERT(n >= 0); // this impl only works for non-neg.
+ return n ? (1 << (32 - SkCLZ(n - 1))) : 1;
+}
#endif
diff --git a/src/core/SkMipMap.cpp b/src/core/SkMipMap.cpp
index 76f1718e7f..e6f4bad6d2 100644
--- a/src/core/SkMipMap.cpp
+++ b/src/core/SkMipMap.cpp
@@ -9,7 +9,7 @@
#include "SkBitmap.h"
#include "SkColorPriv.h"
#include "SkHalf.h"
-#include "SkMath.h"
+#include "SkMathPriv.h"
#include "SkNx.h"
#include "SkTypes.h"
diff --git a/src/core/SkScan_Hairline.cpp b/src/core/SkScan_Hairline.cpp
index a023ca1f24..fc9e82818d 100644
--- a/src/core/SkScan_Hairline.cpp
+++ b/src/core/SkScan_Hairline.cpp
@@ -7,6 +7,7 @@
#include "SkScan.h"
#include "SkBlitter.h"
+#include "SkMathPriv.h"
#include "SkRasterClip.h"
#include "SkFDot6.h"
#include "SkLineClipper.h"
diff --git a/src/core/SkSemaphore.cpp b/src/core/SkSemaphore.cpp
index 2286c0b2bb..1ebe51b15c 100644
--- a/src/core/SkSemaphore.cpp
+++ b/src/core/SkSemaphore.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
+#include "../private/SkLeanWindows.h"
#include "../private/SkSemaphore.h"
#if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
diff --git a/src/core/SkTSort.h b/src/core/SkTSort.h
index 51b103cb5d..7101bab9ba 100644
--- a/src/core/SkTSort.h
+++ b/src/core/SkTSort.h
@@ -10,7 +10,7 @@
#define SkTSort_DEFINED
#include "SkTypes.h"
-#include "SkMath.h"
+#include "SkMathPriv.h"
/* A comparison functor which performs the comparison 'a < b'. */
template <typename T> struct SkTCompareLT {
diff --git a/src/core/SkTaskGroup.cpp b/src/core/SkTaskGroup.cpp
index 7a58c865a7..d151510cfa 100644
--- a/src/core/SkTaskGroup.cpp
+++ b/src/core/SkTaskGroup.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
+#include "SkLeanWindows.h"
#include "SkOnce.h"
#include "SkSemaphore.h"
#include "SkSpinlock.h"
diff --git a/src/core/SkThreadID.cpp b/src/core/SkThreadID.cpp
index 589b4da05a..948884d0ce 100644
--- a/src/core/SkThreadID.cpp
+++ b/src/core/SkThreadID.cpp
@@ -5,10 +5,10 @@
* found in the LICENSE file.
*/
+#include "SkLeanWindows.h"
#include "SkThreadID.h"
#ifdef SK_BUILD_FOR_WIN
- #include <windows.h>
SkThreadID SkGetThreadID() { return GetCurrentThreadId(); }
#else
#include <pthread.h>
diff --git a/src/core/SkTime.cpp b/src/core/SkTime.cpp
index e89d5b9b3a..4ed08928ba 100644
--- a/src/core/SkTime.cpp
+++ b/src/core/SkTime.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
+#include "SkLeanWindows.h"
#include "SkString.h"
#include "SkTime.h"
#include "SkTypes.h"
@@ -25,10 +26,8 @@ void SkTime::DateTime::toISO8601(SkString* dst) const {
}
}
-
#ifdef SK_BUILD_FOR_WIN32
-#include "windows.h"
void SkTime::GetDateTime(DateTime* dt) {
if (dt) {
SYSTEMTIME st;
diff --git a/src/effects/gradients/SkClampRange.cpp b/src/effects/gradients/SkClampRange.cpp
index 0bf30f14ea..5fd1c0369e 100644
--- a/src/effects/gradients/SkClampRange.cpp
+++ b/src/effects/gradients/SkClampRange.cpp
@@ -6,7 +6,7 @@
*/
#include "SkClampRange.h"
-#include "SkMath.h"
+#include "SkMathPriv.h"
static int SkCLZ64(uint64_t value) {
int count = 0;
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index 691c0ab83a..a381f311aa 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -21,7 +21,7 @@
#include "GrStencilAttachment.h"
#include "GrSurfacePriv.h"
#include "GrTexturePriv.h"
-#include "SkTypes.h"
+#include "SkMathPriv.h"
GrMesh& GrMesh::operator =(const GrMesh& di) {
fPrimitiveType = di.fPrimitiveType;
diff --git a/src/gpu/GrPathUtils.cpp b/src/gpu/GrPathUtils.cpp
index fcb32cbd9a..aa55dade96 100644
--- a/src/gpu/GrPathUtils.cpp
+++ b/src/gpu/GrPathUtils.cpp
@@ -9,6 +9,7 @@
#include "GrTypes.h"
#include "SkGeometry.h"
+#include "SkMathPriv.h"
SkScalar GrPathUtils::scaleToleranceToSrc(SkScalar devTol,
const SkMatrix& viewM,
diff --git a/src/gpu/GrRectanizer_pow2.h b/src/gpu/GrRectanizer_pow2.h
index 451589db0a..296e0520bf 100644
--- a/src/gpu/GrRectanizer_pow2.h
+++ b/src/gpu/GrRectanizer_pow2.h
@@ -9,6 +9,7 @@
#define GrRectanizer_pow2_DEFINED
#include "GrRectanizer.h"
+#include "SkMathPriv.h"
#include "SkPoint.h"
// This Rectanizer quantizes the incoming rects to powers of 2. Each power
diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp
index 9fa202af6c..efbcdba248 100644
--- a/src/gpu/GrResourceProvider.cpp
+++ b/src/gpu/GrResourceProvider.cpp
@@ -15,6 +15,7 @@
#include "GrResourceCache.h"
#include "GrResourceKey.h"
#include "GrStencilAttachment.h"
+#include "SkMathPriv.h"
GR_DECLARE_STATIC_UNIQUE_KEY(gQuadIndexBufferKey);
diff --git a/src/gpu/GrTextureProvider.cpp b/src/gpu/GrTextureProvider.cpp
index 1053ab272b..69792ede81 100644
--- a/src/gpu/GrTextureProvider.cpp
+++ b/src/gpu/GrTextureProvider.cpp
@@ -10,6 +10,7 @@
#include "GrResourceCache.h"
#include "GrGpu.h"
#include "../private/GrSingleOwner.h"
+#include "SkMathPriv.h"
#include "SkTArray.h"
#define ASSERT_SINGLE_OWNER \
diff --git a/src/gpu/batches/GrAtlasTextBatch.cpp b/src/gpu/batches/GrAtlasTextBatch.cpp
index 5a41457c58..32a64c3b17 100644
--- a/src/gpu/batches/GrAtlasTextBatch.cpp
+++ b/src/gpu/batches/GrAtlasTextBatch.cpp
@@ -11,6 +11,7 @@
#include "GrResourceProvider.h"
#include "SkGlyphCache.h"
+#include "SkMathPriv.h"
#include "effects/GrBitmapTextGeoProc.h"
#include "effects/GrDistanceFieldGeoProc.h"
diff --git a/src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp b/src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp
index 1eae5d7502..5f26fdde34 100644
--- a/src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp
+++ b/src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp
@@ -7,11 +7,11 @@
#include "SkTypes.h"
#if defined(SK_BUILD_FOR_WIN32)
+#include "SkLeanWindows.h"
+
#include "gl/GrGLInterface.h"
#include "gl/GrGLAssembleInterface.h"
#include "gl/GrGLUtil.h"
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
class AutoLibraryUnload {
public:
diff --git a/src/ports/SkDebug_win.cpp b/src/ports/SkDebug_win.cpp
index b0c5725a79..da1e2b573f 100644
--- a/src/ports/SkDebug_win.cpp
+++ b/src/ports/SkDebug_win.cpp
@@ -5,16 +5,16 @@
* found in the LICENSE file.
*/
-
-
#include "SkTypes.h"
+
#if defined(SK_BUILD_FOR_WIN32)
-static const size_t kBufferSize = 2048;
+#include "SkLeanWindows.h"
#include <stdarg.h>
#include <stdio.h>
-#include <windows.h>
+
+static const size_t kBufferSize = 2048;
void SkDebugf(const char format[], ...) {
char buffer[kBufferSize + 1];
diff --git a/src/ports/SkFontHost_mac.cpp b/src/ports/SkFontHost_mac.cpp
index 0cc436f7c3..c129a6b24b 100644
--- a/src/ports/SkFontHost_mac.cpp
+++ b/src/ports/SkFontHost_mac.cpp
@@ -29,6 +29,7 @@
#include "SkFontMgr.h"
#include "SkGlyph.h"
#include "SkMaskGamma.h"
+#include "SkMathPriv.h"
#include "SkMutex.h"
#include "SkOTTable_glyf.h"
#include "SkOTTable_head.h"
diff --git a/src/ports/SkOSFile_win.cpp b/src/ports/SkOSFile_win.cpp
index 6bdf9ab163..cf46cea985 100644
--- a/src/ports/SkOSFile_win.cpp
+++ b/src/ports/SkOSFile_win.cpp
@@ -8,8 +8,8 @@
#include "SkTypes.h"
#if defined(SK_BUILD_FOR_WIN32)
+#include "SkLeanWindows.h"
#include "SkOSFile.h"
-
#include "SkTFitsIn.h"
#include <io.h>
diff --git a/src/ports/SkOSLibrary_win.cpp b/src/ports/SkOSLibrary_win.cpp
index 63d8d2d383..b6d8dd3183 100644
--- a/src/ports/SkOSLibrary_win.cpp
+++ b/src/ports/SkOSLibrary_win.cpp
@@ -8,7 +8,7 @@
#if defined(SK_BUILD_FOR_WIN32)
#include "SkOSLibrary.h"
-#include <windows.h>
+#include "SkLeanWindows.h"
void* DynamicLoadLibrary(const char* libraryName) {
return LoadLibraryA(libraryName);
diff --git a/src/ports/SkTLS_win.cpp b/src/ports/SkTLS_win.cpp
index 8bc55a0f2c..c349ad99c2 100644
--- a/src/ports/SkTLS_win.cpp
+++ b/src/ports/SkTLS_win.cpp
@@ -7,8 +7,9 @@
#include "SkTypes.h"
#if defined(SK_BUILD_FOR_WIN32)
-#include "SkTLS.h"
+#include "SkLeanWindows.h"
#include "SkMutex.h"
+#include "SkTLS.h"
static bool gOnce = false;
static DWORD gTlsIndex;
diff --git a/src/ports/SkTypeface_win_dw.h b/src/ports/SkTypeface_win_dw.h
index 3e429f47cb..11b3fb5ffc 100644
--- a/src/ports/SkTypeface_win_dw.h
+++ b/src/ports/SkTypeface_win_dw.h
@@ -11,10 +11,10 @@
#include "SkAdvancedTypefaceMetrics.h"
#include "SkDWrite.h"
#include "SkHRESULT.h"
+#include "SkLeanWindows.h"
#include "SkTScopedComPtr.h"
#include "SkTypeface.h"
#include "SkTypefaceCache.h"
-#include "SkTypes.h"
#include <dwrite.h>
#if SK_HAS_DWRITE_1_H
diff --git a/src/utils/SkTextureCompressor.cpp b/src/utils/SkTextureCompressor.cpp
index e308f6e480..086214ec59 100644
--- a/src/utils/SkTextureCompressor.cpp
+++ b/src/utils/SkTextureCompressor.cpp
@@ -14,6 +14,7 @@
#include "SkBitmapProcShader.h"
#include "SkData.h"
#include "SkEndian.h"
+#include "SkMathPriv.h"
#include "SkOpts.h"
#ifndef SK_IGNORE_ETC1_SUPPORT
diff --git a/src/utils/SkTextureCompressor_ASTC.cpp b/src/utils/SkTextureCompressor_ASTC.cpp
index 02f4f17144..8a96b911ea 100644
--- a/src/utils/SkTextureCompressor_ASTC.cpp
+++ b/src/utils/SkTextureCompressor_ASTC.cpp
@@ -10,7 +10,7 @@
#include "SkBlitter.h"
#include "SkEndian.h"
-#include "SkMath.h"
+#include "SkMathPriv.h"
// This table contains the weight values for each texel. This is used in determining
// how to convert a 12x12 grid of alpha values into a 6x5 grid of index values. Since
diff --git a/src/utils/SkThreadUtils_win.h b/src/utils/SkThreadUtils_win.h
index 51b32fad6f..b1de4816cf 100644
--- a/src/utils/SkThreadUtils_win.h
+++ b/src/utils/SkThreadUtils_win.h
@@ -8,8 +8,7 @@
#ifndef SkThreadUtils_WinData_DEFINED
#define SkThreadUtils_WinData_DEFINED
-#include "SkTypes.h"
-
+#include "SkLeanWindows.h"
#include "SkThreadUtils.h"
class SkThread_WinData : SkNoncopyable {
diff --git a/src/utils/win/SkAutoCoInitialize.cpp b/src/utils/win/SkAutoCoInitialize.cpp
index 3b7b42b74f..f6da67dcae 100644
--- a/src/utils/win/SkAutoCoInitialize.cpp
+++ b/src/utils/win/SkAutoCoInitialize.cpp
@@ -8,12 +8,11 @@
#include "SkTypes.h"
#if defined(SK_BUILD_FOR_WIN32)
-
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#include <ole2.h>
#include "SkAutoCoInitialize.h"
+#include <objbase.h>
+#include <winerror.h>
+
SkAutoCoInitialize::SkAutoCoInitialize() :
fHR(
CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE)
diff --git a/src/utils/win/SkIStream.cpp b/src/utils/win/SkIStream.cpp
index ad9bf05076..560a947fcf 100644
--- a/src/utils/win/SkIStream.cpp
+++ b/src/utils/win/SkIStream.cpp
@@ -8,9 +8,6 @@
#include "SkTypes.h"
#if defined(SK_BUILD_FOR_WIN32)
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#include <ole2.h>
#include "SkIStream.h"
#include "SkStream.h"
diff --git a/src/utils/win/SkWGL.h b/src/utils/win/SkWGL.h
index ebd95e7a83..3799377cc3 100644
--- a/src/utils/win/SkWGL.h
+++ b/src/utils/win/SkWGL.h
@@ -10,6 +10,8 @@
#ifndef SkWGL_DEFINED
#define SkWGL_DEFINED
+#include "SkLeanWindows.h"
+
/**
* Working with WGL extensions can be a pain. Among the reasons is that You must
* have a GL context to get the proc addresses, but you want to use the procs to
@@ -22,16 +24,6 @@
* an extension.
*/
-#if !defined(WIN32_LEAN_AND_MEAN)
- #define WIN32_LEAN_AND_MEAN
- #define SK_LOCAL_LEAN_AND_MEAN
-#endif
-#include <windows.h>
-#if defined(SK_LOCAL_LEAN_AND_MEAN)
- #undef WIN32_LEAN_AND_MEAN
- #undef SK_LOCAL_LEAN_AND_MEAN
-#endif
-
#define SK_WGL_DRAW_TO_WINDOW 0x2001
#define SK_WGL_ACCELERATION 0x2003
#define SK_WGL_SUPPORT_OPENGL 0x2010
diff --git a/src/views/win/SkOSWindow_win.cpp b/src/views/win/SkOSWindow_win.cpp
index a5aafd05d1..c93d60b2d6 100644
--- a/src/views/win/SkOSWindow_win.cpp
+++ b/src/views/win/SkOSWindow_win.cpp
@@ -8,6 +8,8 @@
#if defined(SK_BUILD_FOR_WIN)
+#include "SkLeanWindows.h"
+
#include <GL/gl.h>
#include <WindowsX.h>
#include "win/SkWGL.h"
diff --git a/src/views/win/skia_win.cpp b/src/views/win/skia_win.cpp
index 8996ddac4d..fc07bd46da 100644
--- a/src/views/win/skia_win.cpp
+++ b/src/views/win/skia_win.cpp
@@ -4,10 +4,11 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include <windows.h>
-#include <tchar.h>
#include "SkTypes.h"
+
+#include <tchar.h>
+
#include "SkApplication.h"
#include "SkOSWindow_Win.h"
diff --git a/src/xps/SkXPSDevice.cpp b/src/xps/SkXPSDevice.cpp
index eb983fc0d7..ca0ee04add 100644
--- a/src/xps/SkXPSDevice.cpp
+++ b/src/xps/SkXPSDevice.cpp
@@ -8,6 +8,8 @@
#include "SkTypes.h"
#if defined(SK_BUILD_FOR_WIN32)
+#include "SkLeanWindows.h"
+
#ifndef UNICODE
#define UNICODE
#endif
diff --git a/tests/ClipStackTest.cpp b/tests/ClipStackTest.cpp
index a18d1efe06..c2ad21b24d 100644
--- a/tests/ClipStackTest.cpp
+++ b/tests/ClipStackTest.cpp
@@ -1011,7 +1011,7 @@ static void test_reduced_clip_stack(skiatest::Reporter* reporter) {
}
}
-#if defined(WIN32)
+#ifdef SK_BUILD_FOR_WIN
#define SUPPRESS_VISIBILITY_WARNING
#else
#define SUPPRESS_VISIBILITY_WARNING __attribute__((visibility("hidden")))
diff --git a/tests/PathCoverageTest.cpp b/tests/PathCoverageTest.cpp
index 303ddcc4cb..255156394a 100644
--- a/tests/PathCoverageTest.cpp
+++ b/tests/PathCoverageTest.cpp
@@ -5,7 +5,7 @@
* found in the LICENSE file.
*/
-#include "SkMath.h"
+#include "SkMathPriv.h"
#include "SkPoint.h"
#include "SkScalar.h"
#include "Test.h"
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp
index 9de5f81661..5bc3d95b6f 100644
--- a/tests/PathTest.cpp
+++ b/tests/PathTest.cpp
@@ -180,7 +180,7 @@ static void test_path_to_region(skiatest::Reporter* reporter) {
}
}
-#if defined(WIN32)
+#ifdef SK_BUILD_FOR_WIN
#define SUPPRESS_VISIBILITY_WARNING
#else
#define SUPPRESS_VISIBILITY_WARNING __attribute__((visibility("hidden")))
diff --git a/tests/SubsetPath.cpp b/tests/SubsetPath.cpp
index e67df1210b..6a7660e527 100644
--- a/tests/SubsetPath.cpp
+++ b/tests/SubsetPath.cpp
@@ -6,6 +6,7 @@
*/
#include "SubsetPath.h"
+#include "SkMathPriv.h"
SubsetPath::SubsetPath(const SkPath& path)
: fPath(path)
diff --git a/tools/CrashHandler.cpp b/tools/CrashHandler.cpp
index 5428116741..f141e55407 100644
--- a/tools/CrashHandler.cpp
+++ b/tools/CrashHandler.cpp
@@ -7,7 +7,7 @@
#include "CrashHandler.h"
-#include "SkTypes.h"
+#include "../private/SkLeanWindows.h"
#include <stdlib.h>
diff --git a/tools/gpu/GrTest.cpp b/tools/gpu/GrTest.cpp
index 8fdab2e716..c797dc011a 100644
--- a/tools/gpu/GrTest.cpp
+++ b/tools/gpu/GrTest.cpp
@@ -16,6 +16,7 @@
#include "SkGpuDevice.h"
#include "SkGrPriv.h"
+#include "SkMathPriv.h"
#include "SkString.h"
#include "text/GrBatchFontCache.h"