don't support converting from alpha to non-alpha

BUG=skia:

Change-Id: Ia06bef6c0bfc03b5ca9f569c07e993da0bbd67c3
Reviewed-on: https://skia-review.googlesource.com/5288
Reviewed-by: Matt Sarett <msarett@google.com>
Commit-Queue: Mike Reed <reed@google.com>
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index 7ea49a8..e4097b4 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -707,15 +707,18 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
-bool SkBitmap::canCopyTo(SkColorType dstColorType) const {
+bool SkBitmap::canCopyTo(SkColorType dstCT) const {
     const SkColorType srcCT = this->colorType();
 
     if (srcCT == kUnknown_SkColorType) {
         return false;
     }
+    if (srcCT == kAlpha_8_SkColorType && dstCT != kAlpha_8_SkColorType) {
+        return false;   // can't convert from alpha to non-alpha
+    }
 
-    bool sameConfigs = (srcCT == dstColorType);
-    switch (dstColorType) {
+    bool sameConfigs = (srcCT == dstCT);
+    switch (dstCT) {
         case kAlpha_8_SkColorType:
         case kRGB_565_SkColorType:
         case kRGBA_8888_SkColorType:
diff --git a/src/core/SkConfig8888.cpp b/src/core/SkConfig8888.cpp
index 9af3621..3906a9a 100644
--- a/src/core/SkConfig8888.cpp
+++ b/src/core/SkConfig8888.cpp
@@ -324,6 +324,12 @@
         return false;
     }
 
+    if (srcInfo.colorType() == kAlpha_8_SkColorType &&
+        dstInfo.colorType() != kAlpha_8_SkColorType)
+    {
+        return false;   // can't convert from alpha to non-alpha
+    }
+
     const int width = srcInfo.width();
     const int height = srcInfo.height();
 
diff --git a/tests/BitmapCopyTest.cpp b/tests/BitmapCopyTest.cpp
index 639c51a..ab0ec30 100644
--- a/tests/BitmapCopyTest.cpp
+++ b/tests/BitmapCopyTest.cpp
@@ -183,7 +183,7 @@
 
 static const Pair gPairs[] = {
     { kUnknown_SkColorType,     "000000"  },
-    { kAlpha_8_SkColorType,     "010101"  },
+    { kAlpha_8_SkColorType,     "010000"  },
     { kIndex_8_SkColorType,     "011111"  },
     { kRGB_565_SkColorType,     "010101"  },
     { kARGB_4444_SkColorType,   "010111"  },