56c69773ae
This CL also removes any unecessary references to the ANDROID definition. Review URL: http://codereview.appspot.com/5354049 git-svn-id: http://skia.googlecode.com/svn/trunk@2629 2bbb7eff-a529-9590-31e7-b0007b416f81
65 lines
1.5 KiB
C++
65 lines
1.5 KiB
C++
|
|
/*
|
|
* Copyright 2006 The Android Open Source Project
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
|
|
#ifndef SkThread_platform_DEFINED
|
|
#define SkThread_platform_DEFINED
|
|
|
|
#if defined(SK_BUILD_FOR_ANDROID) && !defined(SK_BUILD_FOR_ANDROID_NDK)
|
|
|
|
#include <utils/threads.h>
|
|
#include <utils/Atomic.h>
|
|
|
|
#define sk_atomic_inc(addr) android_atomic_inc(addr)
|
|
#define sk_atomic_dec(addr) android_atomic_dec(addr)
|
|
|
|
class SkMutex : android::Mutex {
|
|
public:
|
|
// if isGlobal is true, then ignore any errors in the platform-specific
|
|
// destructor
|
|
SkMutex(bool isGlobal = true) {}
|
|
~SkMutex() {}
|
|
|
|
void acquire() { this->lock(); }
|
|
void release() { this->unlock(); }
|
|
};
|
|
|
|
#else
|
|
|
|
/** Implemented by the porting layer, this function adds 1 to the int specified
|
|
by the address (in a thread-safe manner), and returns the previous value.
|
|
*/
|
|
SK_API int32_t sk_atomic_inc(int32_t* addr);
|
|
/** Implemented by the porting layer, this function subtracts 1 to the int
|
|
specified by the address (in a thread-safe manner), and returns the previous
|
|
value.
|
|
*/
|
|
SK_API int32_t sk_atomic_dec(int32_t* addr);
|
|
|
|
class SkMutex {
|
|
public:
|
|
// if isGlobal is true, then ignore any errors in the platform-specific
|
|
// destructor
|
|
SkMutex(bool isGlobal = true);
|
|
~SkMutex();
|
|
|
|
void acquire();
|
|
void release();
|
|
|
|
private:
|
|
bool fIsGlobal;
|
|
enum {
|
|
kStorageIntCount = 64
|
|
};
|
|
uint32_t fStorage[kStorageIntCount];
|
|
};
|
|
|
|
#endif
|
|
|
|
#endif
|