SkBitmap::getColor repsects swizzle

Review URL: https://codereview.chromium.org/1510253002
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index 6fd97dc..1691c9d 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -572,10 +572,15 @@
             SkPMColor c = SkPixel4444ToPixel32(addr[0]);
             return SkUnPreMultiply::PMColorToColor(c);
         }
-        case kBGRA_8888_SkColorType:
+        case kBGRA_8888_SkColorType: {
+            uint32_t* addr = this->getAddr32(x, y);
+            SkPMColor c = SkSwizzle_BGRA_to_PMColor(addr[0]);
+            return SkUnPreMultiply::PMColorToColor(c);
+        }
         case kRGBA_8888_SkColorType: {
             uint32_t* addr = this->getAddr32(x, y);
-            return SkUnPreMultiply::PMColorToColor(addr[0]);
+            SkPMColor c = SkSwizzle_RGBA_to_PMColor(addr[0]);
+            return SkUnPreMultiply::PMColorToColor(c);
         }
         default:
             SkASSERT(false);
diff --git a/tests/BitmapTest.cpp b/tests/BitmapTest.cpp
index 4d68e73..2bd8490 100644
--- a/tests/BitmapTest.cpp
+++ b/tests/BitmapTest.cpp
@@ -122,3 +122,26 @@
     test_bigalloc(reporter);
     test_peekpixels(reporter);
 }
+
+/**
+ *  This test checks that getColor works for both swizzles.
+ */
+DEF_TEST(Bitmap_getColor_Swizzle, r) {
+    SkBitmap source;
+    source.allocN32Pixels(1,1);
+    source.eraseColor(SK_ColorRED);
+    SkColorType colorTypes[] = {
+        kRGBA_8888_SkColorType,
+        kBGRA_8888_SkColorType,
+    };
+    for (SkColorType ct : colorTypes) {
+        SkBitmap copy;
+        if (!source.copyTo(&copy, ct)) {
+            ERRORF(r, "SkBitmap::copy failed %d", (int)ct);
+            continue;
+        }
+        SkAutoLockPixels autoLockPixels1(copy);
+        SkAutoLockPixels autoLockPixels2(source);
+        REPORTER_ASSERT(r, source.getColor(0, 0) == copy.getColor(0, 0));
+    }
+}