Add code needed to build skia as a windows dll within the chromium project.
- Export/import skia APIs if SKIA_DLL is defined.
- This change has no effect on skia.

Review URL: http://codereview.appspot.com/4282042

git-svn-id: http://skia.googlecode.com/svn/trunk@944 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h
index 1d21a2f..349489e 100644
--- a/include/core/SkBitmap.h
+++ b/include/core/SkBitmap.h
@@ -40,7 +40,7 @@
     Bitmaps can be drawn into a SkCanvas, but they are also used to specify the target
     of a SkCanvas' drawing operations.
 */
-class SkBitmap {
+class SK_API SkBitmap {
 public:
     class Allocator;
 
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index 5aecacb..0a1b393 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -51,7 +51,7 @@
     color, typeface, textSize, strokeWidth, shader (e.g. gradients, patterns),
     etc.
 */
-class SkCanvas : public SkRefCnt {
+class SK_API SkCanvas : public SkRefCnt {
 public:
     /** Construct a canvas with the given device factory.
         @param factory  Specify the factory for generating additional devices.
@@ -758,7 +758,7 @@
         call made on the canvas. Ownership of all pointers in the iterator stays
         with the canvas, so none of them should be modified or deleted.
     */
-    class LayerIter /*: SkNoncopyable*/ {
+    class SK_API LayerIter /*: SkNoncopyable*/ {
     public:
         /** Initialize iterator with canvas, and set values for 1st device */
         LayerIter(SkCanvas*, bool skipEmptyClips);
diff --git a/include/core/SkClipStack.h b/include/core/SkClipStack.h
index db42e4d..850a3f0 100644
--- a/include/core/SkClipStack.h
+++ b/include/core/SkClipStack.h
@@ -7,7 +7,7 @@
 struct SkRect;
 class SkPath;
 
-class SkClipStack {
+class SK_API SkClipStack {
 public:
     SkClipStack();
     ~SkClipStack() {}
diff --git a/include/core/SkColor.h b/include/core/SkColor.h
index c17068f..6b86e7e 100644
--- a/include/core/SkColor.h
+++ b/include/core/SkColor.h
@@ -152,12 +152,12 @@
 
 /** Return a SkPMColor value from unpremultiplied 8 bit component values
 */
-SkPMColor SkPreMultiplyARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b);
+SK_API SkPMColor SkPreMultiplyARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b);
 /** Return a SkPMColor value from a SkColor value. This is done by multiplying the color
     components by the color's alpha, and by arranging the bytes in a configuration
     dependent order, to match the format of kARGB32 bitmaps.
 */
-SkPMColor SkPreMultiplyColor(SkColor c);
+SK_API SkPMColor SkPreMultiplyColor(SkColor c);
 
 /** Define a function pointer type for combining two premultiplied colors
 */
diff --git a/include/core/SkColorPriv.h b/include/core/SkColorPriv.h
index bd407da..f9e02a2 100644
--- a/include/core/SkColorPriv.h
+++ b/include/core/SkColorPriv.h
@@ -234,7 +234,7 @@
            (g << SK_G32_SHIFT) | (b << SK_B32_SHIFT);
 }
 
-extern const uint32_t gMask_00FF00FF;
+SK_API extern const uint32_t gMask_00FF00FF;
 
 static inline uint32_t SkAlphaMulQ(uint32_t c, unsigned scale) {
     uint32_t mask = gMask_00FF00FF;
diff --git a/include/core/SkColorShader.h b/include/core/SkColorShader.h
index f7251ff..b7537e1 100644
--- a/include/core/SkColorShader.h
+++ b/include/core/SkColorShader.h
@@ -24,7 +24,7 @@
     accomplished by just using the color field on the paint, but if an
     actual shader object is needed, this provides that feature.
 */
-class SkColorShader : public SkShader {
+class SK_API SkColorShader : public SkShader {
 public:
     /** Create a ColorShader that will inherit its color from the Paint
         at draw time.
diff --git a/include/core/SkDeque.h b/include/core/SkDeque.h
index 92d5153..8bf8b5b 100644
--- a/include/core/SkDeque.h
+++ b/include/core/SkDeque.h
@@ -19,7 +19,7 @@
 
 #include "SkTypes.h"
 
-class SkDeque : SkNoncopyable {
+class SK_API SkDeque : SkNoncopyable {
 public:
     explicit SkDeque(size_t elemSize);
     SkDeque(size_t elemSize, void* storage, size_t storageSize);
diff --git a/include/core/SkDevice.h b/include/core/SkDevice.h
index 7332ba7..2f95015 100644
--- a/include/core/SkDevice.h
+++ b/include/core/SkDevice.h
@@ -49,7 +49,7 @@
                                 int height, bool isOpaque, bool isLayer);
 };
 
-class SkDevice : public SkRefCnt {
+class SK_API SkDevice : public SkRefCnt {
 public:
     SkDevice(SkCanvas*);
     /** Construct a new device, extracting the width/height/config/isOpaque values from
diff --git a/include/core/SkDrawLooper.h b/include/core/SkDrawLooper.h
index 333fb41..87eb5cb 100644
--- a/include/core/SkDrawLooper.h
+++ b/include/core/SkDrawLooper.h
@@ -32,7 +32,7 @@
     invoked multiple times (hence the name loop-er), allow it to perform effects
     like shadows or frame/fills, that require more than one pass.
 */
-class SkDrawLooper : public SkFlattenable {
+class SK_API SkDrawLooper : public SkFlattenable {
 public:
     /** Called right before something is being drawn to the specified canvas
         with the specified paint. Subclass that want to modify either parameter
diff --git a/include/core/SkFlattenable.h b/include/core/SkFlattenable.h
index 6958462..ad4062f 100644
--- a/include/core/SkFlattenable.h
+++ b/include/core/SkFlattenable.h
@@ -33,7 +33,7 @@
  into a data stream for either transport or as part of the key to the
  font cache.
  */
-class SkFlattenable : public SkRefCnt {
+class SK_API SkFlattenable : public SkRefCnt {
 public:
     typedef SkFlattenable* (*Factory)(SkFlattenableReadBuffer&);
     
diff --git a/include/core/SkFloatBits.h b/include/core/SkFloatBits.h
index 1628f6e..288f2d8 100644
--- a/include/core/SkFloatBits.h
+++ b/include/core/SkFloatBits.h
@@ -51,17 +51,17 @@
 /** Given the bit representation of a float, return its floor as an int.
     If the value is out of range, or NaN, return return +/- SK_MaxS32
  */
-int32_t SkFloatBits_toIntFloor(int32_t floatBits);
+SK_API int32_t SkFloatBits_toIntFloor(int32_t floatBits);
 
 /** Given the bit representation of a float, return it rounded to an int.
     If the value is out of range, or NaN, return return +/- SK_MaxS32
  */
-int32_t SkFloatBits_toIntRound(int32_t floatBits);
+SK_API int32_t SkFloatBits_toIntRound(int32_t floatBits);
 
 /** Given the bit representation of a float, return its ceiling as an int.
     If the value is out of range, or NaN, return return +/- SK_MaxS32
  */
-int32_t SkFloatBits_toIntCeil(int32_t floatBits);
+SK_API int32_t SkFloatBits_toIntCeil(int32_t floatBits);
 
 
 #ifdef SK_CAN_USE_FLOAT
diff --git a/include/core/SkGeometry.h b/include/core/SkGeometry.h
index a209783..d4b13fb 100644
--- a/include/core/SkGeometry.h
+++ b/include/core/SkGeometry.h
@@ -90,7 +90,7 @@
     convert it into the cubic fitting the same curve. The new cubic
     curve is returned in dst[0..3].
 */
-void SkConvertQuadToCubic(const SkPoint src[3], SkPoint dst[4]);
+SK_API void SkConvertQuadToCubic(const SkPoint src[3], SkPoint dst[4]);
 
 ////////////////////////////////////////////////////////////////////////////////////////
 
diff --git a/include/core/SkMatrix.h b/include/core/SkMatrix.h
index 5c82d78..5ba9223 100644
--- a/include/core/SkMatrix.h
+++ b/include/core/SkMatrix.h
@@ -28,7 +28,7 @@
     using either reset() - to construct an identity matrix, or one of the set
     functions (e.g. setTranslate, setRotate, etc.).
 */
-class SkMatrix {
+class SK_API SkMatrix {
 public:
     /** Enum of bit fields for the mask return by getType().
         Use this to identify the complexity of the matrix.
diff --git a/include/core/SkPaint.h b/include/core/SkPaint.h
index a4def5f..4a20dd2 100644
--- a/include/core/SkPaint.h
+++ b/include/core/SkPaint.h
@@ -48,7 +48,7 @@
     The SkPaint class holds the style and color information about how to draw
     geometries, text and bitmaps.
 */
-class SkPaint {
+class SK_API SkPaint {
 public:
     SkPaint();
     SkPaint(const SkPaint& paint);
@@ -56,7 +56,7 @@
 
     SkPaint& operator=(const SkPaint&);
 
-    friend int operator==(const SkPaint& a, const SkPaint& b);
+    SK_API friend int operator==(const SkPaint& a, const SkPaint& b);
     friend int operator!=(const SkPaint& a, const SkPaint& b)
     {
         return !(a == b);
diff --git a/include/core/SkPath.h b/include/core/SkPath.h
index 3afea09..34f30b1 100644
--- a/include/core/SkPath.h
+++ b/include/core/SkPath.h
@@ -30,7 +30,7 @@
     The SkPath class encapsulates compound (multiple contour) geometric paths
     consisting of straight line segments, quadratic curves, and cubic curves.
 */
-class SkPath {
+class SK_API SkPath {
 public:
     SkPath();
     SkPath(const SkPath&);
@@ -514,7 +514,7 @@
     /** Iterate through all of the segments (lines, quadratics, cubics) of
         each contours in a path.
     */
-    class Iter {
+    class SK_API Iter {
     public:
                 Iter();
                 Iter(const SkPath&, bool forceClose);
diff --git a/include/core/SkPathEffect.h b/include/core/SkPathEffect.h
index f97adb7..eb1cc23 100644
--- a/include/core/SkPathEffect.h
+++ b/include/core/SkPathEffect.h
@@ -29,7 +29,7 @@
 
     Dashing is implemented as a subclass of SkPathEffect.
 */
-class SkPathEffect : public SkFlattenable {
+class SK_API SkPathEffect : public SkFlattenable {
 public:
     //  This method is not exported to java.
     SkPathEffect() {}
diff --git a/include/core/SkPoint.h b/include/core/SkPoint.h
index 79ca58c..c89f080 100644
--- a/include/core/SkPoint.h
+++ b/include/core/SkPoint.h
@@ -140,7 +140,7 @@
     }
 };
 
-struct SkPoint {
+struct SK_API SkPoint {
     SkScalar    fX, fY;
 
     static SkPoint Make(SkScalar x, SkScalar y) {
diff --git a/include/core/SkPreConfig.h b/include/core/SkPreConfig.h
index f907578..daf2041 100644
--- a/include/core/SkPreConfig.h
+++ b/include/core/SkPreConfig.h
@@ -96,5 +96,21 @@
     #define SK_CPU_HAS_CONDITIONAL_INSTR
 #endif
 
+//////////////////////////////////////////////////////////////////////
+
+#if !defined(SKIA_IMPLEMENTATION)
+    #define SKIA_IMPLEMENTATION 0
+#endif
+ 
+#if defined(WIN32) && defined(SKIA_DLL)
+    #if SKIA_IMPLEMENTATION
+        #define SK_API __declspec(dllexport)
+    #else
+        #define SK_API __declspec(dllimport)
+    #endif
+#else
+    #define SK_API
+#endif
+
 #endif
 
diff --git a/include/core/SkRect.h b/include/core/SkRect.h
index 114d1f9..53c61ea 100644
--- a/include/core/SkRect.h
+++ b/include/core/SkRect.h
@@ -24,7 +24,7 @@
 
     SkIRect holds four 32 bit integer coordinates for a rectangle
 */
-struct SkIRect {
+struct SK_API SkIRect {
     int32_t fLeft, fTop, fRight, fBottom;
 
     static SkIRect MakeEmpty() {
@@ -267,7 +267,7 @@
 
 /** \struct SkRect
 */
-struct SkRect {
+struct SK_API SkRect {
     SkScalar    fLeft, fTop, fRight, fBottom;
 
     static SkRect MakeEmpty() {
diff --git a/include/core/SkRefCnt.h b/include/core/SkRefCnt.h
index b9b2c98..36f4249 100644
--- a/include/core/SkRefCnt.h
+++ b/include/core/SkRefCnt.h
@@ -29,7 +29,7 @@
     explicitly (or via the object going out of scope on the stack or calling
     delete) if getRefCnt() > 1.
 */
-class SkRefCnt : SkNoncopyable {
+class SK_API SkRefCnt : SkNoncopyable {
 public:
     /** Default construct, initializing the reference count to 1.
     */
diff --git a/include/core/SkRefDict.h b/include/core/SkRefDict.h
index 3ee27d9..0c4b025 100644
--- a/include/core/SkRefDict.h
+++ b/include/core/SkRefDict.h
@@ -23,7 +23,7 @@
  *  A dictionary of string,refcnt pairs. The dictionary is also an owner of the
  *  refcnt objects while they are contained.
  */
-class SkRefDict : SkNoncopyable {
+class SK_API SkRefDict : SkNoncopyable {
 public:
     SkRefDict();
     ~SkRefDict();
diff --git a/include/core/SkRegion.h b/include/core/SkRegion.h
index 7ddf087..4cda2cd 100644
--- a/include/core/SkRegion.h
+++ b/include/core/SkRegion.h
@@ -34,7 +34,7 @@
     The SkRegion class encapsulates the geometric region used to specify
     clipping areas for drawing.
 */
-class SkRegion {
+class SK_API SkRegion {
 public:
     typedef int32_t RunType;
     enum {
@@ -258,7 +258,7 @@
     /** Returns the sequence of rectangles, sorted in Y and X, that make up
         this region.
     */
-    class Iterator {
+    class SK_API Iterator {
     public:
         Iterator() : fRgn(NULL), fDone(true) {}
         Iterator(const SkRegion&);
@@ -281,7 +281,7 @@
     /** Returns the sequence of rectangles, sorted in Y and X, that make up
         this region intersected with the specified clip rectangle.
     */
-    class Cliperator {
+    class SK_API Cliperator {
     public:
         Cliperator(const SkRegion&, const SkIRect& clip);
         bool            done() { return fDone; }
diff --git a/include/core/SkShader.h b/include/core/SkShader.h
index c59cc59..d837284 100644
--- a/include/core/SkShader.h
+++ b/include/core/SkShader.h
@@ -32,7 +32,7 @@
     any object (other than a bitmap) that is drawn with that paint will get its color(s) from the
     shader.
 */
-class SkShader : public SkFlattenable {
+class SK_API SkShader : public SkFlattenable {
 public:
             SkShader();
     virtual ~SkShader();
diff --git a/include/core/SkTDArray.h b/include/core/SkTDArray.h
index 954bcf8..c64d773 100644
--- a/include/core/SkTDArray.h
+++ b/include/core/SkTDArray.h
@@ -19,7 +19,7 @@
 
 #include "SkTypes.h"
 
-template <typename T> class SkTDArray {
+template <typename T> class SK_API SkTDArray {
 public:
     SkTDArray() {
         fReserve = fCount = 0;
diff --git a/include/core/SkTypeface.h b/include/core/SkTypeface.h
index f4b9507..c3b0f50 100644
--- a/include/core/SkTypeface.h
+++ b/include/core/SkTypeface.h
@@ -32,7 +32,7 @@
 
     Typeface objects are immutable, and so they can be shared between threads.
 */
-class SkTypeface : public SkRefCnt {
+class SK_API SkTypeface : public SkRefCnt {
 public:
     /** Style specifies the intrinsic style attributes of a given typeface
     */
diff --git a/include/core/SkTypes.h b/include/core/SkTypes.h
index 93f054e..1290935 100644
--- a/include/core/SkTypes.h
+++ b/include/core/SkTypes.h
@@ -59,7 +59,7 @@
     return null (if SK_MALLOC_TEMP bit is clear) or call sk_throw()
     (if SK_MALLOC_TEMP bit is set). To free the memory, call sk_free().
 */
-extern void* sk_malloc_flags(size_t size, unsigned flags);
+SK_API extern void* sk_malloc_flags(size_t size, unsigned flags);
 /** Same as sk_malloc(), but hard coded to pass SK_MALLOC_THROW as the flag
 */
 extern void* sk_malloc_throw(size_t size);
@@ -69,7 +69,7 @@
 extern void* sk_realloc_throw(void* buffer, size_t size);
 /** Free memory returned by sk_malloc(). It is safe to pass null.
 */
-extern void  sk_free(void*);
+SK_API extern void  sk_free(void*);
 
 // bzero is safer than memset, but we can't rely on it, so... sk_bzero()
 static inline void sk_bzero(void* buffer, size_t size) {
@@ -152,12 +152,12 @@
 typedef uint8_t SkBool8;
 
 #ifdef SK_DEBUG
-    int8_t      SkToS8(long);
-    uint8_t     SkToU8(size_t);
-    int16_t     SkToS16(long);
-    uint16_t    SkToU16(size_t);
-    int32_t     SkToS32(long);
-    uint32_t    SkToU32(size_t);
+    SK_API int8_t      SkToS8(long);
+    SK_API uint8_t     SkToU8(size_t);
+    SK_API int16_t     SkToS16(long);
+    SK_API uint16_t    SkToU16(size_t);
+    SK_API int32_t     SkToS32(long);
+    SK_API uint32_t    SkToU32(size_t);
 #else
     #define SkToS8(x)   ((int8_t)(x))
     #define SkToU8(x)   ((uint8_t)(x))
@@ -337,7 +337,7 @@
 SkNoncopyable is the base class for objects that may do not want to
 be copied. It hides its copy-constructor and its assignment-operator.
 */
-class SkNoncopyable {
+class SK_API SkNoncopyable {
 public:
     SkNoncopyable() {}
 
diff --git a/include/core/SkUnPreMultiply.h b/include/core/SkUnPreMultiply.h
index 4bdb980..44ea50e 100644
--- a/include/core/SkUnPreMultiply.h
+++ b/include/core/SkUnPreMultiply.h
@@ -22,7 +22,7 @@
 
 #include "SkColor.h"
 
-class SkUnPreMultiply {
+class SK_API SkUnPreMultiply {
 public:
     typedef uint32_t Scale;
     
diff --git a/include/core/SkXfermode.h b/include/core/SkXfermode.h
index 948d1dd..155d3f8 100644
--- a/include/core/SkXfermode.h
+++ b/include/core/SkXfermode.h
@@ -28,7 +28,7 @@
     specified in the Modes enum. When an SkXfermode is assigned to an SkPaint,
     then objects drawn with that paint have the xfermode applied.
 */
-class SkXfermode : public SkFlattenable {
+class SK_API SkXfermode : public SkFlattenable {
 public:
     SkXfermode() {}
 
diff --git a/include/effects/SkBlurDrawLooper.h b/include/effects/SkBlurDrawLooper.h
index e7af5c2..101d24e 100644
--- a/include/effects/SkBlurDrawLooper.h
+++ b/include/effects/SkBlurDrawLooper.h
@@ -28,7 +28,7 @@
     the original object in its original position.
     should there be an option to just draw the shadow/blur layer? webkit?
 */
-class SkBlurDrawLooper : public SkDrawLooper {
+class SK_API SkBlurDrawLooper : public SkDrawLooper {
 public:
     enum BlurFlags {
         kNone_BlurFlag = 0x00,
diff --git a/include/effects/SkCornerPathEffect.h b/include/effects/SkCornerPathEffect.h
index a459478..823de3f 100644
--- a/include/effects/SkCornerPathEffect.h
+++ b/include/effects/SkCornerPathEffect.h
@@ -24,7 +24,7 @@
     SkCornerPathEffect is a subclass of SkPathEffect that can turn sharp corners
     into various treatments (e.g. rounded corners)
 */
-class SkCornerPathEffect : public SkPathEffect {
+class SK_API SkCornerPathEffect : public SkPathEffect {
 public:
     /** radius must be > 0 to have an effect. It specifies the distance from each corner
         that should be "rounded".
diff --git a/include/effects/SkDashPathEffect.h b/include/effects/SkDashPathEffect.h
index cc414e3..145f67d 100644
--- a/include/effects/SkDashPathEffect.h
+++ b/include/effects/SkDashPathEffect.h
@@ -23,7 +23,7 @@
 
     SkDashPathEffect is a subclass of SkPathEffect that implements dashing
 */
-class SkDashPathEffect : public SkPathEffect {
+class SK_API SkDashPathEffect : public SkPathEffect {
 public:
     /** The intervals array must contain an even number of entries (>=2), with the even
         indices specifying the "on" intervals, and the odd indices specifying the "off"
diff --git a/include/effects/SkGradientShader.h b/include/effects/SkGradientShader.h
index c800c66..5623be4 100644
--- a/include/effects/SkGradientShader.h
+++ b/include/effects/SkGradientShader.h
@@ -26,7 +26,7 @@
     SkGradientShader hosts factories for creating subclasses of SkShader that
     render linear and radial gradients.
 */
-class SkGradientShader {
+class SK_API SkGradientShader {
 public:
     /** Returns a shader that generates a linear gradient between the two
         specified points.