Modify SkBitmap::extractSubset() to respect opaqueness

The resulting subset bitmap will always have the same opaqueness flag as the
source bitmap.

BUG=439
Review URL: http://codereview.appspot.com/5534051

git-svn-id: http://skia.googlecode.com/svn/trunk@3036 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index 2b3e7c4..fe32845 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -821,6 +821,7 @@
 
     SkBitmap dst;
     dst.setConfig(this->config(), r.width(), r.height(), this->rowBytes());
+    dst.setIsOpaque(this->isOpaque());
 
     if (fPixelRef) {
         // share the pixelref with a custom offset
diff --git a/tests/BitmapCopyTest.cpp b/tests/BitmapCopyTest.cpp
index b8d16bf..c3c6f12 100644
--- a/tests/BitmapCopyTest.cpp
+++ b/tests/BitmapCopyTest.cpp
@@ -308,12 +308,16 @@
                 }
                 // test extractSubset
                 {
+                    SkBitmap bitmap(src);
                     SkBitmap subset;
                     SkIRect r;
                     r.set(1, 1, 2, 2);
-                    if (src.extractSubset(&subset, r)) {
+                    bitmap.setIsOpaque(true);
+                    if (bitmap.extractSubset(&subset, r)) {
                         REPORTER_ASSERT(reporter, subset.width() == 1);
                         REPORTER_ASSERT(reporter, subset.height() == 1);
+                        REPORTER_ASSERT(reporter,
+                                        subset.isOpaque() == bitmap.isOpaque());
 
                         SkBitmap copy;
                         REPORTER_ASSERT(reporter,
@@ -329,6 +333,11 @@
                         REPORTER_ASSERT(reporter,
                                     (copy.getColorTable() != NULL) == hasCT);
                     }
+                    bitmap.setIsOpaque(false);
+                    if (bitmap.extractSubset(&subset, r)) {
+                        REPORTER_ASSERT(reporter,
+                                        subset.isOpaque() == bitmap.isOpaque());
+                    }
                 }
             } else {
                 // dst should be unchanged from its initial state