Move sync code to include/, switch from using platform define to a proxy header in core/

This fixes two problems:
  1)  #include SK_SOME_DEFINE doesn't work well for all our clients.
  2)  Things in include/ are #including things in src/, which we don't like.

TBR=reed@google.com

BUG=skia:

Review URL: https://codereview.chromium.org/862983002
This commit is contained in:
mtklein 2015-01-21 13:13:31 -08:00 committed by Commit bot
parent e6ea244717
commit a64c48f4f9
16 changed files with 56 additions and 69 deletions

View File

@ -22,10 +22,6 @@
'../src/utils',
],
'sources': [
'../src/ports/SkAtomics_sync.h',
'../src/ports/SkAtomics_win.h',
'../src/ports/SkMutex_pthread.h',
'../src/ports/SkMutex_win.h',
'../src/ports/SkDebug_nacl.cpp',
'../src/ports/SkDebug_stdio.cpp',
'../src/ports/SkDebug_win.cpp',
@ -44,8 +40,6 @@
'../src/ports/SkGlobalInitialization_default.cpp',
'../src/ports/SkMemory_malloc.cpp',
'../src/ports/SkMutex_pthread.h',
'../src/ports/SkMutex_win.h',
'../src/ports/SkOSFile_posix.cpp',
'../src/ports/SkOSFile_stdio.cpp',
'../src/ports/SkOSFile_win.cpp',

View File

@ -607,6 +607,13 @@
],
'paths_to_ignore': [
'<(skia_include_path)/gpu/gl/GrGLConfig_chrome.h',
'<(skia_include_path)/ports/SkAtomics_sync.h',
'<(skia_include_path)/ports/SkAtomics_win.h',
'<(skia_include_path)/ports/SkBarriers_arm.h',
'<(skia_include_path)/ports/SkBarriers_tsan.h',
'<(skia_include_path)/ports/SkBarriers_x86.h',
'<(skia_include_path)/ports/SkMutex_pthread.h',
'<(skia_include_path)/ports/SkMutex_win.h',
'<(skia_include_path)/ports/SkTypeface_mac.h',
'<(skia_include_path)/ports/SkTypeface_win.h',
'<(skia_include_path)/utils/ios',

View File

@ -168,14 +168,4 @@
*/
//#define SK_PDF_USE_PATHOPS
/* Skia uses these defines as the target of include preprocessor directives.
* The header files pointed to by these defines provide declarations and
* possibly inline implementations of threading primitives.
*
* See SkThread.h for documentation on what these includes must contain.
*/
//#define SK_ATOMICS_PLATFORM_H "SkAtomics_xxx.h"
//#define SK_MUTEX_PLATFORM_H "SkMutex_xxx.h"
//#define SK_BARRIERS_PLATFORM_H "SkBarriers_xxx.h"
#endif

13
include/core/SkAtomics.h Normal file
View File

@ -0,0 +1,13 @@
#ifndef SkAtomics_DEFINED
#define SkAtomics_DEFINED
// This file is not part of the public Skia API.
#include "SkTypes.h"
#if defined(_MSC_VER)
#include "../ports/SkAtomics_win.h"
#else
#include "../ports/SkAtomics_sync.h"
#endif
#endif//SkAtomics_DEFINED

15
include/core/SkBarriers.h Normal file
View File

@ -0,0 +1,15 @@
#ifndef SkBarriers_DEFINED
#define SkBarriers_DEFINED
// This file is not part of the public Skia API.
#include "SkTypes.h"
#if SK_HAS_COMPILER_FEATURE(thread_sanitizer)
#include "../ports/SkBarriers_tsan.h"
#elif defined(SK_CPU_ARM32) || defined(SK_CPU_ARM64)
#include "../ports/SkBarriers_arm.h"
#else
#include "../ports/SkBarriers_x86.h"
#endif
#endif//SkBarriers_DEFINED

13
include/core/SkMutex.h Normal file
View File

@ -0,0 +1,13 @@
#ifndef SkMutex_DEFINED
#define SkMutex_DEFINED
// This file is not part of the public Skia API.
#include "SkTypes.h"
#if defined(SK_BUILD_FOR_WIN)
#include "../ports/SkMutex_win.h"
#else
#include "../ports/SkMutex_pthread.h"
#endif
#endif//SkMutex_DEFINED

View File

@ -385,34 +385,6 @@
//////////////////////////////////////////////////////////////////////
#ifndef SK_ATOMICS_PLATFORM_H
# if defined(_MSC_VER)
# define SK_ATOMICS_PLATFORM_H "../../src/ports/SkAtomics_win.h"
# else
# define SK_ATOMICS_PLATFORM_H "../../src/ports/SkAtomics_sync.h"
# endif
#endif
#ifndef SK_MUTEX_PLATFORM_H
# if defined(SK_BUILD_FOR_WIN)
# define SK_MUTEX_PLATFORM_H "../../src/ports/SkMutex_win.h"
# else
# define SK_MUTEX_PLATFORM_H "../../src/ports/SkMutex_pthread.h"
# endif
#endif
#ifndef SK_BARRIERS_PLATFORM_H
# if SK_HAS_COMPILER_FEATURE(thread_sanitizer)
# define SK_BARRIERS_PLATFORM_H "../../src/ports/SkBarriers_tsan.h"
# elif defined(SK_CPU_ARM32) || defined(SK_CPU_ARM64)
# define SK_BARRIERS_PLATFORM_H "../../src/ports/SkBarriers_arm.h"
# else
# define SK_BARRIERS_PLATFORM_H "../../src/ports/SkBarriers_x86.h"
# endif
#endif
//////////////////////////////////////////////////////////////////////
#ifndef SK_EGL
# if defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_NACL)
# define SK_EGL 1

View File

@ -10,7 +10,7 @@
#include "SkTypes.h"
// SK_ATOMICS_PLATFORM_H must provide inline implementations for the following declarations.
// SkAtomics.h must provide inline implementations for the following declarations.
/** Atomically adds one to the int referenced by addr and returns the previous value.
* No additional memory barrier is required; this must act as a compiler barrier.
@ -44,11 +44,7 @@ static void sk_membar_acquire__after_atomic_dec();
*/
static void sk_membar_acquire__after_atomic_conditional_inc();
#ifdef GOOGLE3
#include "SkAtomics_sync.h"
#else
#include SK_ATOMICS_PLATFORM_H
#endif
#include "SkAtomics.h"
/** Atomically adds one to the int referenced by addr iff the referenced int was not 0
* and returns the previous value.
@ -65,7 +61,7 @@ template<typename INT_TYPE> static inline INT_TYPE sk_atomic_conditional_inc(INT
return prev;
}
// SK_BARRIERS_PLATFORM_H must provide implementations for the following declarations:
// SkBarriers.h must provide implementations for the following declarations:
/** Prevent the compiler from reordering across this barrier. */
static void sk_compiler_barrier();
@ -82,13 +78,9 @@ template <typename T> T sk_acquire_load(T*);
*/
template <typename T> void sk_release_store(T*, T);
#ifdef GOOGLE3
#include "SkBarriers_x86.h"
#else
#include SK_BARRIERS_PLATFORM_H
#endif
#include "SkBarriers.h"
/** SK_MUTEX_PLATFORM_H must provide the following (or equivalent) declarations.
/** SkMutex.h must provide the following (or equivalent) declarations.
class SkBaseMutex {
public:
@ -106,12 +98,7 @@ public:
#define SK_DECLARE_STATIC_MUTEX(name) static SkBaseMutex name = ...
*/
#ifdef GOOGLE3
#include "SkMutex_pthread.h"
#else
#include SK_MUTEX_PLATFORM_H
#endif
#include "SkMutex.h"
class SkAutoMutexAcquire : SkNoncopyable {
public:

View File

@ -10,7 +10,7 @@
#include "SkTypes.h"
// SK_ATOMICS_PLATFORM_H must provide inline implementations for the following declarations.
// SkAtomics.h must provide inline implementations for the following declarations.
/** Atomic compare and set, for pointers.
* If *addr == before, set *addr to after. Always returns previous value of *addr.
@ -18,10 +18,6 @@
*/
static void* sk_atomic_cas(void** addr, void* before, void* after);
#ifdef GOOGLE3
#include "SkAtomics_sync.h"
#else
#include SK_ATOMICS_PLATFORM_H
#endif
#include "SkAtomics.h"
#endif//SkThreadPriv_DEFINED