| OLD | NEW | 
|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "third_party/skia/include/core/SkThread.h" | 5 #include "third_party/skia/include/core/SkThread.h" | 
| 6 | 6 | 
| 7 #include <new> | 7 #include <new> | 
| 8 | 8 | 
| 9 #include "base/atomicops.h" | 9 #include "base/atomicops.h" | 
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" | 
| 11 #include "base/lock.h" |  | 
| 12 #include "base/logging.h" | 11 #include "base/logging.h" | 
|  | 12 #include "base/synchronization/lock.h" | 
| 13 | 13 | 
| 14 int32_t sk_atomic_inc(int32_t* addr) { | 14 int32_t sk_atomic_inc(int32_t* addr) { | 
| 15   // sk_atomic_inc is expected to return the old value, Barrier_AtomicIncrement | 15   // sk_atomic_inc is expected to return the old value, Barrier_AtomicIncrement | 
| 16   // returns the new value. | 16   // returns the new value. | 
| 17   return base::subtle::Barrier_AtomicIncrement(addr, 1) - 1; | 17   return base::subtle::Barrier_AtomicIncrement(addr, 1) - 1; | 
| 18 } | 18 } | 
| 19 | 19 | 
| 20 int32_t sk_atomic_dec(int32_t* addr) { | 20 int32_t sk_atomic_dec(int32_t* addr) { | 
| 21   // sk_atomic_dec is expected to return the old value, Barrier_AtomicIncrement | 21   // sk_atomic_dec is expected to return the old value, Barrier_AtomicIncrement | 
| 22   // returns the new value. | 22   // returns the new value. | 
| 23   return base::subtle::Barrier_AtomicIncrement(addr, -1) + 1; | 23   return base::subtle::Barrier_AtomicIncrement(addr, -1) + 1; | 
| 24 } | 24 } | 
| 25 | 25 | 
| 26 SkMutex::SkMutex(bool isGlobal) : fIsGlobal(isGlobal) { | 26 SkMutex::SkMutex(bool isGlobal) : fIsGlobal(isGlobal) { | 
| 27   COMPILE_ASSERT(sizeof(Lock) <= sizeof(fStorage), Lock_is_too_big_for_SkMutex); | 27   COMPILE_ASSERT(sizeof(base::Lock) <= sizeof(fStorage), Lock_is_too_big_for_SkM
    utex); | 
| 28   Lock* lock = reinterpret_cast<Lock*>(fStorage); | 28   base::Lock* lock = reinterpret_cast<base::Lock*>(fStorage); | 
| 29   new(lock) Lock(); | 29   new(lock) base::Lock(); | 
| 30 } | 30 } | 
| 31 | 31 | 
| 32 SkMutex::~SkMutex() { | 32 SkMutex::~SkMutex() { | 
| 33   Lock* lock = reinterpret_cast<Lock*>(fStorage); | 33   base::Lock* lock = reinterpret_cast<base::Lock*>(fStorage); | 
| 34   lock->~Lock(); | 34   lock->~Lock(); | 
| 35 } | 35 } | 
| 36 | 36 | 
| 37 void SkMutex::acquire() { | 37 void SkMutex::acquire() { | 
| 38   Lock* lock = reinterpret_cast<Lock*>(fStorage); | 38   base::Lock* lock = reinterpret_cast<base::Lock*>(fStorage); | 
| 39   lock->Acquire(); | 39   lock->Acquire(); | 
| 40 } | 40 } | 
| 41 | 41 | 
| 42 void SkMutex::release() { | 42 void SkMutex::release() { | 
| 43   Lock* lock = reinterpret_cast<Lock*>(fStorage); | 43   base::Lock* lock = reinterpret_cast<base::Lock*>(fStorage); | 
| 44   lock->Release(); | 44   lock->Release(); | 
| 45 } | 45 } | 
| OLD | NEW | 
|---|