aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2015-11-02 10:20:27 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-11-02 10:20:27 -0800
commit1ee76510f5dbf632d30975fc3509ef4f609156d2 (patch)
treea2d6b772ec69a735bd37ebdbdc6864cfe823a7cc /src/utils
parent3f0424ff57f93666df7347d4787816b210233eb0 (diff)
Start making all .cpp files compile-able on all platforms.
I sometimes dream to hone our build process down to something as simple as $ find src -name '*.cpp' | xargs c++ <some cflags> -c -o skia.o To start, it helps if we can compile all files on all platforms. Each non-portable file guards itself with defines provided by SkTypes.h. This does not convert all non-portable code, but it's a good representative chunk. E.g. instead of having to remember which SkDebug_*.cpp to compile on which platform we can just compile all three and let the code itself sort it out. This has the nice side effect of making non-portable code declare the conditions under which it can compile explicitly. I've been testing mostly with the CMake build as it's easiest, but this should apply equally to BUILD, Gyp, and GN files... to any build system really. BUG=skia:4269 CQ_EXTRA_TRYBOTS=client.skia.compile:Build-Ubuntu-GCC-x86_64-Release-CMake-Trybot,Build-Mac10.9-Clang-x86_64-Release-CMake-Trybot Review URL: https://codereview.chromium.org/1411283005
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/SkThreadUtils_win.cpp3
-rw-r--r--src/utils/mac/SkCreateCGImageRef.cpp6
-rw-r--r--src/utils/mac/SkStream_mac.cpp5
-rw-r--r--src/utils/win/SkAutoCoInitialize.cpp5
-rw-r--r--src/utils/win/SkDWrite.cpp4
-rw-r--r--src/utils/win/SkDWriteFontFileStream.cpp4
-rw-r--r--src/utils/win/SkDWriteGeometrySink.cpp3
-rw-r--r--src/utils/win/SkHRESULT.cpp3
-rw-r--r--src/utils/win/SkIStream.cpp3
-rw-r--r--src/utils/win/SkWGL_win.cpp5
10 files changed, 41 insertions, 0 deletions
diff --git a/src/utils/SkThreadUtils_win.cpp b/src/utils/SkThreadUtils_win.cpp
index 07cceee142..0da339aa84 100644
--- a/src/utils/SkThreadUtils_win.cpp
+++ b/src/utils/SkThreadUtils_win.cpp
@@ -6,6 +6,7 @@
*/
#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_WIN32)
#include "SkThreadUtils.h"
#include "SkThreadUtils_win.h"
@@ -96,3 +97,5 @@ void SkThread::join() {
WaitForSingleObject(winData->fHandle, INFINITE);
}
+
+#endif//defined(SK_BUILD_FOR_WIN32)
diff --git a/src/utils/mac/SkCreateCGImageRef.cpp b/src/utils/mac/SkCreateCGImageRef.cpp
index 0cbf704a41..3fd9057c35 100644
--- a/src/utils/mac/SkCreateCGImageRef.cpp
+++ b/src/utils/mac/SkCreateCGImageRef.cpp
@@ -5,6 +5,10 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+
+#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
+
#include "SkCGUtils.h"
#include "SkBitmap.h"
#include "SkColorPriv.h"
@@ -306,3 +310,5 @@ bool SkCreateBitmapFromCGImage(SkBitmap* dst, CGImageRef image, SkISize* scaleTo
*dst = tmp;
return true;
}
+
+#endif//defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
diff --git a/src/utils/mac/SkStream_mac.cpp b/src/utils/mac/SkStream_mac.cpp
index e62ced220f..36e5194a19 100644
--- a/src/utils/mac/SkStream_mac.cpp
+++ b/src/utils/mac/SkStream_mac.cpp
@@ -5,6 +5,9 @@
* found in the LICENSE file.
*/
+#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
+
#include "SkCGUtils.h"
#include "SkStream.h"
@@ -74,3 +77,5 @@ CGDataProviderRef SkCreateDataProviderFromData(SkData* data) {
return CGDataProviderCreateWithData(data, data->data(), data->size(),
unref_proc);
}
+
+#endif//defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
diff --git a/src/utils/win/SkAutoCoInitialize.cpp b/src/utils/win/SkAutoCoInitialize.cpp
index 78326a5608..83f23bda0b 100644
--- a/src/utils/win/SkAutoCoInitialize.cpp
+++ b/src/utils/win/SkAutoCoInitialize.cpp
@@ -6,6 +6,9 @@
* found in the LICENSE file.
*/
+#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_WIN32)
+
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@@ -27,3 +30,5 @@ SkAutoCoInitialize::~SkAutoCoInitialize() {
bool SkAutoCoInitialize::succeeded() {
return SUCCEEDED(this->fHR) || RPC_E_CHANGED_MODE == this->fHR;
}
+
+#endif//defined(SK_BUILD_FOR_WIN32)
diff --git a/src/utils/win/SkDWrite.cpp b/src/utils/win/SkDWrite.cpp
index 2254961d14..2fdd6115b0 100644
--- a/src/utils/win/SkDWrite.cpp
+++ b/src/utils/win/SkDWrite.cpp
@@ -4,6 +4,8 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_WIN32)
#include "SkDWrite.h"
#include "SkHRESULT.h"
@@ -122,3 +124,5 @@ HRESULT SkGetGetUserDefaultLocaleNameProc(SkGetUserDefaultLocaleNameProc* proc)
}
return S_OK;
}
+
+#endif//defined(SK_BUILD_FOR_WIN32)
diff --git a/src/utils/win/SkDWriteFontFileStream.cpp b/src/utils/win/SkDWriteFontFileStream.cpp
index 0e3d4fc202..d4bf8a2023 100644
--- a/src/utils/win/SkDWriteFontFileStream.cpp
+++ b/src/utils/win/SkDWriteFontFileStream.cpp
@@ -4,6 +4,8 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_WIN32)
#include "SkTypes.h"
#include "SkDWriteFontFileStream.h"
@@ -229,3 +231,5 @@ HRESULT STDMETHODCALLTYPE SkDWriteFontFileStreamWrapper::GetLastWriteTime(UINT64
*lastWriteTime = 0;
return E_NOTIMPL;
}
+
+#endif//defined(SK_BUILD_FOR_WIN32)
diff --git a/src/utils/win/SkDWriteGeometrySink.cpp b/src/utils/win/SkDWriteGeometrySink.cpp
index 066d4a4674..9f6a97caf1 100644
--- a/src/utils/win/SkDWriteGeometrySink.cpp
+++ b/src/utils/win/SkDWriteGeometrySink.cpp
@@ -6,6 +6,7 @@
*/
#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_WIN32)
#include "SkDWriteGeometrySink.h"
#include "SkFloatUtils.h"
@@ -144,3 +145,5 @@ HRESULT SkDWriteGeometrySink::Create(SkPath* path, IDWriteGeometrySink** geometr
*geometryToPath = new SkDWriteGeometrySink(path);
return S_OK;
}
+
+#endif//defined(SK_BUILD_FOR_WIN32)
diff --git a/src/utils/win/SkHRESULT.cpp b/src/utils/win/SkHRESULT.cpp
index d565986d10..d95629961b 100644
--- a/src/utils/win/SkHRESULT.cpp
+++ b/src/utils/win/SkHRESULT.cpp
@@ -6,6 +6,7 @@
*/
#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_WIN32)
#include "SkHRESULT.h"
@@ -35,3 +36,5 @@ void SkTraceHR(const char* file, unsigned long line, HRESULT hr, const char* msg
errorText = nullptr;
}
}
+
+#endif//defined(SK_BUILD_FOR_WIN32)
diff --git a/src/utils/win/SkIStream.cpp b/src/utils/win/SkIStream.cpp
index f1dbcb274c..fdb6ce6eff 100644
--- a/src/utils/win/SkIStream.cpp
+++ b/src/utils/win/SkIStream.cpp
@@ -6,6 +6,8 @@
* found in the LICENSE file.
*/
+#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_WIN32)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@@ -275,3 +277,4 @@ HRESULT STDMETHODCALLTYPE SkWIStream::Stat(STATSTG* pStatstg
pStatstg->grfMode = STGM_WRITE;
return S_OK;
}
+#endif//defined(SK_BUILD_FOR_WIN32)
diff --git a/src/utils/win/SkWGL_win.cpp b/src/utils/win/SkWGL_win.cpp
index ef07bea61e..bc22795e2f 100644
--- a/src/utils/win/SkWGL_win.cpp
+++ b/src/utils/win/SkWGL_win.cpp
@@ -6,6 +6,9 @@
* found in the LICENSE file.
*/
+#include "SkTypes.h"
+#if defined(SK_BUILD_FOR_WIN32)
+
#include "SkWGL.h"
#include "SkTDArray.h"
@@ -455,3 +458,5 @@ SkWGLPbufferContext::SkWGLPbufferContext(HPBUFFER pbuffer, HDC dc, HGLRC glrc)
, fDC(dc)
, fGLRC(glrc) {
}
+
+#endif//defined(SK_BUILD_FOR_WIN32)