skia2/gyp
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
..
all.gyp Some final cleanups leading up to The Official Switch to Gyp 2011-06-07 14:48:41 +00:00
android_system.gyp Move the Android sample app into the android repo. 2011-11-04 13:00:18 +00:00
animator.gyp combine target_defaults.gypi into common.gypi 2011-07-01 17:16:26 +00:00
apptype_console.gypi Stop packaging command-line Mac tools as a bundle. 2011-08-15 19:22:39 +00:00
bench.gyp move ports into its own gyp file 2011-12-14 17:12:04 +00:00
bench.gypi add bench for shader+blitMask 2011-11-15 15:29:45 +00:00
common_conditions.gypi posix: Avoid static initializers in static/global mutexes 2012-01-26 21:26:40 +00:00
common_variables.gypi Fix for missing file from previous CL that broke the build. 2011-11-03 13:13:27 +00:00
common.gypi Virtualize SkGLContext with subclasses SkNativeGLContext and SkMesaGLContext, allow both in gm 2011-10-19 20:43:20 +00:00
core.gyp Add ARM optimizations to the build. 2012-01-09 14:38:25 +00:00
effects.gyp Add SkTableColorFilter, as a foundation for several SVG filters 2011-12-28 20:31:00 +00:00
experimental.gyp combine target_defaults.gypi into common.gypi 2011-07-01 17:16:26 +00:00
FileReaderApp.gyp move ports into its own gyp file 2011-12-14 17:12:04 +00:00
freetype.gyp add initial gyp to build freetype lib (problems with cflags not showing up in xcode) 2011-11-10 15:00:52 +00:00
gm.gyp move ports into its own gyp file 2011-12-14 17:12:04 +00:00
gmslides.gypi Add convex path renderer (disabled) 2012-01-17 14:25:10 +00:00
gpu.gyp Add convex path renderer (disabled) 2012-01-17 14:25:10 +00:00
images.gyp Add windowscodecs.lib to images.gyp 2011-11-21 21:04:06 +00:00
iOSSampleApp.gyp move ports into its own gyp file 2011-12-14 17:12:04 +00:00
libtess.gyp Changes to the android gyp system to build without RTTI and exceptions. 2011-12-05 13:55:55 +00:00
opts.gyp Add ARM optimizations to the build. 2012-01-09 14:38:25 +00:00
pdf.gyp [PDF] Refactor SkPDFFont to enable font/cmap subsetting. 2011-07-25 22:34:12 +00:00
ports.gyp Fix android build and cleanup references to SkMMapStream 2011-12-15 16:16:22 +00:00
SampleApp.gyp move ports into its own gyp file 2011-12-14 17:12:04 +00:00
SimpleCocoaApp.gyp Switched Mac SampleApp to use Cocoa, removed the seperate CocoaSampleApp, moved dependencies out of experimental 2011-08-30 14:40:49 +00:00
svg.gyp combine target_defaults.gypi into common.gypi 2011-07-01 17:16:26 +00:00
tests.gyp Subpixel text 3/8 of a pixel too far to the right. 2012-01-13 15:02:58 +00:00
tools.gyp add optional manual global initialization 2011-12-15 14:16:43 +00:00
utils.gyp Adding class SkDeferredCanvas for deferred rendering. 2012-01-18 16:21:08 +00:00
views.gyp Add support for building Android SampleApp. 2011-11-07 15:43:57 +00:00
xml.gyp Adding support to trunk for building Skia using the Android NDK. 2011-11-03 13:08:29 +00:00
xps.gyp Add xps device to skia. 2011-10-10 13:19:10 +00:00
zlib.gyp Add support for building Android SampleApp. 2011-11-07 15:43:57 +00:00