aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-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
12 files changed, 52 insertions, 91 deletions
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,