skia2/include/core
digit@google.com 1771cbf43d posix: Avoid static initializers in static/global mutexes
This patch removes static initializers related to static and
global mutexes from the final library's machine code when
building on a pthread-capable system.

We use PTHREAD_MUTEX_INITIALIZER to perform POD-style
initialization. You need a line like the following to declare
a global mutex with it:

    SkBaseMutex gMutex = { PTHREAD_MUTEX_INITIALIZER };

We introduce the SK_DECLARE_STATIC_MUTEX and SK_DECLARE_GLOBAL_MUTEX
macros to be able to declare static/global mutexes in the source tree
uniformly.

SkMutex is now defined as a sub-class of SkBaseMutex, with standard
construction/destruction semantics. This is useful if the mutex
object is a member of another C++ class, or allocated dynamically.

We also modify a few places to refer to SkBaseMutex instead of a
SkMutex, where it makes sense. Generally speaking, client code
should hold and use pointers to SkBaseMutex whenever they can
now.

We defined a new built-time macro named SK_USE_POSIX_THREADS
to indicate that we're using a pthread-based SkThread.h
interface. The macro will also be used in future patches
to implement other helper thread synchronization classes.

Finally, we inline the acquire() and release() functions in the
case of Posix to improve performance a bit.

Running: 'bench -repeat 10 -match mutex' on an Android device or
a 2.4GHz Xeon Linux desktop shows the following improvements:

                      Before     After

        Galaxy Nexus    1.64      1.45
        Nexus S         1.47      1.16
        Xoom            1.86      1.66
        Xeon            0.36      0.31

This removes 5 static mutex initializers from the library
Review URL: https://codereview.appspot.com/5501066

git-svn-id: http://skia.googlecode.com/svn/trunk@3091 2bbb7eff-a529-9590-31e7-b0007b416f81
2012-01-26 21:26:40 +00:00
..
Sk64.h Make SkMath.h less visible in public header files. 2011-09-27 17:38:17 +00:00
SkAdvancedTypefaceMetrics.h [PDF] Subset font advance data (W array). 2011-08-18 02:38:50 +00:00
SkAutoKern.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkBitmap.h Exposing the isImmutable/setImmutable API of SkPixelRef in SkBitmap 2011-12-15 20:14:06 +00:00
SkBlitRow.h separate SkBlitMask decl into its own header 2011-10-12 13:43:52 +00:00
SkBlitter.h Tighten up restrictions on blit width: some shaders assert that they 2011-12-29 16:09:31 +00:00
SkBounder.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkBuffer.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkCanvas.h Adding class SkDeferredCanvas for deferred rendering. 2012-01-18 16:21:08 +00:00
SkChunkAlloc.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkClampRange.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkClipStack.h use SkRasterClip inside canvas (check-point for soft clipping) 2011-10-12 14:34:30 +00:00
SkColor.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkColorFilter.h add asComponentTable() query (will impl in SkTableColorFilter next) 2012-01-05 17:24:35 +00:00
SkColorPriv.h Interpolate vertical linear gradients for improved quality. 2012-01-18 21:28:01 +00:00
SkColorShader.h Adding isOpaque method to skia shader classes 2011-12-09 15:48:03 +00:00
SkComposeShader.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkData.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkDeque.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkDescriptor.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkDevice.h add allowImageFilter() so a device can allow/disallow filters 2012-01-06 14:43:09 +00:00
SkDither.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkDraw.h have paint's measure calls respect vertical 2011-11-10 20:04:47 +00:00
SkDrawFilter.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkDrawLooper.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkEdgeClipper.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkEmptyShader.h add more SK_OVERRIDEs 2011-12-07 14:59:50 +00:00
SkEndian.h Unroll loops in SkBlurMask for speedup on Windows (benchmarks should see 2011-11-28 18:22:01 +00:00
SkFDot6.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkFixed.h Make SkMath.h less visible in public header files. 2011-09-27 17:38:17 +00:00
SkFlate.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkFlattenable.h fix 'no static globals' for chromium 2011-12-20 20:26:56 +00:00
SkFloatBits.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkFloatingPoint.h rename sk_float_isNaN to sk_float_isnan to match related functions 2011-12-06 20:18:05 +00:00
SkFontHost.h remove GetGammaFlag from SkFontHost 2011-11-22 14:20:55 +00:00
SkGeometry.h Add perspective support to the gpu aa hairline renderer. 2011-09-12 14:59:34 +00:00
SkGraphics.h cleanup font purging functions 2011-12-16 17:11:17 +00:00
SkImageFilter.h add filterImage() entry-point to SkDevice, to allow it to specialize on subclasses 2012-01-05 21:15:07 +00:00
SkLineClipper.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkMallocPixelRef.h add optional manual global initialization 2011-12-15 14:16:43 +00:00
SkMask.h move SkAutoMaskFreeImage from SkMaskFilter.h to SkMask.h 2011-10-18 17:35:26 +00:00
SkMaskFilter.h enable soft clipping (yikes) 2011-10-24 12:19:46 +00:00
SkMath.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkMatrix.h Setting perspective in fixed point. 2011-10-07 21:55:56 +00:00
SkMetaData.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkMMapStream.h Closing fd for mmap after mapping succeeds. 2011-12-09 21:19:38 +00:00
SkOSFile.h Adding support to trunk for building Skia using the Android NDK. 2011-11-03 13:08:29 +00:00
SkPackBits.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkPaint.h add GenA8FromLCD as a hack to force GDI to create the A8 mask from the LCD 2012-01-18 17:06:35 +00:00
SkPath.h Fixing the behavior of SkPathMeasure to reflect changes in SkPath::Iter. 2012-01-18 18:02:10 +00:00
SkPathEffect.h add optional manual global initialization 2011-12-15 14:16:43 +00:00
SkPathMeasure.h Somehow this change was missing from the previous commit. 2012-01-18 18:06:10 +00:00
SkPerspIter.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkPicture.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkPixelRef.h posix: Avoid static initializers in static/global mutexes 2012-01-26 21:26:40 +00:00
SkPoint.h Modifying SkPath to store all verbs provided by the user, and to give 2011-12-20 15:14:18 +00:00
SkPostConfig.h add optional manual global initialization 2011-12-15 14:16:43 +00:00
SkPreConfig.h add 2nd _ to __OpenBSD_ 2011-11-30 20:44:25 +00:00
SkPtrRecorder.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkRandom.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkRasterizer.h Use SK_OVERRIDE to add a little extra robustness against name changes. 2011-10-03 16:01:10 +00:00
SkReader32.h use templated skipT() for skipping structs within a reader 2011-09-07 13:52:17 +00:00
SkRect.h rename hasValidCoordinates to isFinite (on SkRect) and reimplement for speed 2011-12-06 18:56:37 +00:00
SkRefCnt.h write 0 to our refcnt in the destructor, in the off-chance of it helping us 2011-09-12 19:54:12 +00:00
SkRefDict.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkRegion.h Make SkRegion::operator== a member function, rather than a privately-declared 2012-01-25 21:53:53 +00:00
SkRelay.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkScalar.h Add SkDEBUGFAIL to clean up use of SkASSERT(!"text"); 2011-12-28 14:59:50 +00:00
SkScalarCompare.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkScalerContext.h add GenA8FromLCD as a hack to force GDI to create the A8 mask from the LCD 2012-01-18 17:06:35 +00:00
SkScan.h fix scalar=fixed by implementing SkRegion form of AntiFillRect 2011-10-24 12:56:20 +00:00
SkShader.h Adding isOpaque method to skia shader classes 2011-12-09 15:48:03 +00:00
SkShape.h add optional manual global initialization 2011-12-15 14:16:43 +00:00
SkSize.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkStream.h Use SK_OVERRIDE to add a little extra robustness against name changes. 2011-10-03 16:01:10 +00:00
SkString.h make string's reference counting thread-safe 2011-09-14 16:13:58 +00:00
SkStroke.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkTArray.h replacing Gr* with Sk* in SkTArray.h 2011-11-30 18:35:19 +00:00
SkTDArray.h add bytes() to SkTDArray, which returns the number of bytes in the array, 2011-11-28 19:54:12 +00:00
SkTDict.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkTDStack.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkTemplates.h GrTArray->SkTArray & docs 2011-09-14 13:54:05 +00:00
SkThread_platform.h posix: Avoid static initializers in static/global mutexes 2012-01-26 21:26:40 +00:00
SkThread.h posix: Avoid static initializers in static/global mutexes 2012-01-26 21:26:40 +00:00
SkTime.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkTLazy.h Shutup strict aliasing warnings in SkTLazy 2011-09-14 12:44:13 +00:00
SkTrace.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkTRegistry.h Update files to use SK_BUILD_FOR_ANDROID. 2011-11-08 19:00:26 +00:00
SkTScopedPtr.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkTSearch.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkTypeface.h [PDF] Subset font advance data (W array). 2011-08-18 02:38:50 +00:00
SkTypes.h Add SkDEBUGFAIL to clean up use of SkASSERT(!"text"); 2011-12-28 14:59:50 +00:00
SkUnitMapper.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkUnPreMultiply.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkUtils.h Add ARM optimizations to the build. 2012-01-09 14:38:25 +00:00
SkWriter32.h Automatic update of all copyright notices to reflect new license terms. 2011-07-28 14:26:00 +00:00
SkXfermode.h add optional manual global initialization 2011-12-15 14:16:43 +00:00