From 7f960d20838130ee0786574621507db86ffc336a Mon Sep 17 00:00:00 2001 From: Mike Klein Date: Thu, 11 Apr 2019 09:37:51 -0500 Subject: [PATCH] simplify and centralize SK_API Attempt two, this time not setting visibility("default") unless SKIA_IMPLEMENTATION is defined. Bug: skia:8975 Change-Id: I8d4e2071f1a8ee8a5702ac62ffc4000379d4fc43 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/207854 Reviewed-by: Mike Klein Commit-Queue: Mike Klein --- include/c/sk_types.h | 17 +---------------- include/core/SkApi.h | 21 +++++++++++++++++++++ include/core/SkPreConfig.h | 24 ++---------------------- 3 files changed, 24 insertions(+), 38 deletions(-) create mode 100644 include/core/SkApi.h diff --git a/include/c/sk_types.h b/include/c/sk_types.h index 852526f2b6..5c87588d35 100644 --- a/include/c/sk_types.h +++ b/include/c/sk_types.h @@ -13,6 +13,7 @@ #include #include +#include "SkApi.h" #ifdef __cplusplus #define SK_C_PLUS_PLUS_BEGIN_GUARD extern "C" { @@ -23,22 +24,6 @@ #define SK_C_PLUS_PLUS_END_GUARD #endif -#if !defined(SK_API) - #if defined(SKIA_DLL) - #if defined(_MSC_VER) - #if SKIA_IMPLEMENTATION - #define SK_API __declspec(dllexport) - #else - #define SK_API __declspec(dllimport) - #endif - #else - #define SK_API __attribute__((visibility("default"))) - #endif - #else - #define SK_API - #endif -#endif - /////////////////////////////////////////////////////////////////////////////////////// SK_C_PLUS_PLUS_BEGIN_GUARD diff --git a/include/core/SkApi.h b/include/core/SkApi.h new file mode 100644 index 0000000000..012aa2acf5 --- /dev/null +++ b/include/core/SkApi.h @@ -0,0 +1,21 @@ +/* + * Copyright 2019 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef SkApi_DEFINED +#define SkApi_DEFINED + +#if defined(SKIA_IMPLEMENTATION) + #if defined(_MSC_VER) + #define SK_API __declspec(dllexport) + #else + #define SK_API __attribute__((visibility("default"))) + #endif +#else + #define SK_API +#endif + +#endif//SkApi_DEFINED diff --git a/include/core/SkPreConfig.h b/include/core/SkPreConfig.h index 923d9650de..bf08f9c796 100644 --- a/include/core/SkPreConfig.h +++ b/include/core/SkPreConfig.h @@ -10,6 +10,8 @@ #ifndef SkPreConfig_DEFINED #define SkPreConfig_DEFINED +#include "SkApi.h" + // Allows embedders that want to disable macros that take arguments to just // define that symbol to be one of these #define SK_NOTHING_ARG1(arg1) @@ -175,26 +177,4 @@ #define SK_ARM_HAS_CRC32 #endif -////////////////////////////////////////////////////////////////////// - -#if !defined(SKIA_IMPLEMENTATION) - #define SKIA_IMPLEMENTATION 0 -#endif - -#if !defined(SK_API) - #if defined(SKIA_DLL) - #if defined(_MSC_VER) - #if SKIA_IMPLEMENTATION - #define SK_API __declspec(dllexport) - #else - #define SK_API __declspec(dllimport) - #endif - #else - #define SK_API __attribute__((visibility("default"))) - #endif - #else - #define SK_API - #endif -#endif - #endif