LayoutLib: Misc rendering fixes.

- always set up the stroke. Paint may not have the proper
  style when drawing lines. stroke should still be setup.

- Fixed vertical linear gradient. Old code generated
  a gradient ratio of NaN

- Fixed alpha rendering when using shaders. In that
  case the alpha channel from the paint color should be
  used in conjunction with the shader.

- Fixed miter limit. Java expects the value to be multiplied
  by the stroke width

- Fixed support for drawing ALPHA_8 bitmaps. Java2D doesn't
  have bitmaps with only alpha channels, so we keep using
  ARGB bitmaps but when drawing them into a bitmap we erase
  the color information.

Change-Id: I4f04341fc843e3f7dadd1fdbf709b11a4f1e24b9
diff --git a/bridge/src/android/graphics/Paint_Delegate.java b/bridge/src/android/graphics/Paint_Delegate.java
index fa26bcf..0a597ca 100644
--- a/bridge/src/android/graphics/Paint_Delegate.java
+++ b/bridge/src/android/graphics/Paint_Delegate.java
@@ -114,6 +114,10 @@
         return mColor;
     }
 
+    public int getAlpha() {
+        return mColor >>> 24;
+    }
+
     public int getTextAlign() {
         return mTextAlign;
     }
@@ -122,8 +126,11 @@
         return mStrokeWidth;
     }
 
-    public float getStrokeMiter() {
-        return mStrokeMiter;
+    /**
+     * returns the value of stroke miter needed by the java api.
+     */
+    public float getJavaStrokeMiter() {
+        return mStrokeMiter * mStrokeWidth;
     }
 
     public int getJavaCap() {
@@ -256,7 +263,7 @@
             return 0;
         }
 
-        return delegate.mColor >>> 24;
+        return delegate.getAlpha();
     }
 
     /*package*/ static void setAlpha(Paint thisPaint, int a) {
@@ -860,9 +867,9 @@
     private void reset() {
         mFlags = Paint.DEFAULT_PAINT_FLAGS;
         mColor = 0;
-        mStyle = 0;
-        mCap = 0;
-        mJoin = 0;
+        mStyle = Paint.Style.FILL.nativeInt;
+        mCap = Paint.Cap.BUTT.nativeInt;
+        mJoin = Paint.Join.MITER.nativeInt;
         mTextAlign = 0;
         mTypeface = Typeface.sDefaults[0].native_instance;
         mStrokeWidth = 1.f;