fixes around isOpaque and dithering

- copyTo() now preserves isOpaqueness, and BitmapCopyTest tests it
- bitmap shader doesn't claim to have shadespan16 if dithering is on, since its
  sampler doesn't auto-dither (note that gradients do auto-dither in their
  16bit sampler)
- blitter setup just relies on the shader to report if its 16bit sampler can be
  called (allowing gradients to say yes regardless of dither, but bitmaps to say
  no if dithering is on)



git-svn-id: http://skia.googlecode.com/svn/trunk@331 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index d87f001..9478fae 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -793,6 +793,8 @@
         canvas.drawBitmap(*this, 0, 0, &paint);
     }
 
+    tmp.setIsOpaque(this->isOpaque());
+
     dst->swap(tmp);
     return true;
 }
diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp
index 7eb8ea1..353388b 100644
--- a/src/core/SkBitmapProcShader.cpp
+++ b/src/core/SkBitmapProcShader.cpp
@@ -102,19 +102,19 @@
     }
 
     // update fFlags
-    fFlags = 0;
+    uint32_t flags = 0;
     if (bitmapIsOpaque && (255 == this->getPaintAlpha())) {
-        fFlags |= kOpaqueAlpha_Flag;
+        flags |= kOpaqueAlpha_Flag;
     }
 
     switch (fState.fBitmap->config()) {
         case SkBitmap::kRGB_565_Config:
-            fFlags |= (kHasSpan16_Flag | kIntrinsicly16_Flag);
+            flags |= (kHasSpan16_Flag | kIntrinsicly16_Flag);
             break;
         case SkBitmap::kIndex8_Config:
         case SkBitmap::kARGB_8888_Config:
             if (bitmapIsOpaque) {
-                fFlags |= kHasSpan16_Flag;
+                flags |= kHasSpan16_Flag;
             }
             break;
         case SkBitmap::kA8_Config:
@@ -123,11 +123,19 @@
             break;
     }
 
+    if (paint.isDither()) {
+        // gradients can auto-dither in their 16bit sampler, but we don't so
+        // we clear the flag here
+        flags &= ~kHasSpan16_Flag;
+    }
+
     // if we're only 1-pixel heigh, and we don't rotate, then we can claim this
     if (1 == fState.fBitmap->height() &&
             only_scale_and_translate(this->getTotalInverse())) {
-        fFlags |= kConstInY_Flag;
+        flags |= kConstInY_Flag;
     }
+
+    fFlags = flags;
     return true;
 }
 
diff --git a/src/core/SkBlitter.cpp b/src/core/SkBlitter.cpp
index faf29c1..e60887e 100644
--- a/src/core/SkBlitter.cpp
+++ b/src/core/SkBlitter.cpp
@@ -896,16 +896,8 @@
         ((SkPaint*)&paint)->setShader(shader)->unref();
     }
     
-    bool doDither = paint.isDither();
-
-    if (shader)
-    {
-        if (!shader->setContext(device, paint, matrix))
-            return SkNEW(SkNullBlitter);
-        
-        // disable dither if our shader is natively 16bit (no need to upsample)
-        if (shader->getFlags() & SkShader::kIntrinsicly16_Flag)
-            doDither = false;
+    if (shader && !shader->setContext(device, paint, matrix)) {
+        return SkNEW(SkNullBlitter);
     }
 
     switch (device.getConfig()) {
@@ -929,7 +921,7 @@
         {
             if (mode)
                 SK_PLACEMENT_NEW_ARGS(blitter, SkRGB16_Shader_Xfermode_Blitter, storage, storageSize, (device, paint));
-            else if (SkShader::CanCallShadeSpan16(shader->getFlags()) && !doDither)
+            else if (shader->canCallShadeSpan16())
                 SK_PLACEMENT_NEW_ARGS(blitter, SkRGB16_Shader16_Blitter, storage, storageSize, (device, paint));
             else
                 SK_PLACEMENT_NEW_ARGS(blitter, SkRGB16_Shader_Blitter, storage, storageSize, (device, paint));
diff --git a/src/core/SkColorTable.cpp b/src/core/SkColorTable.cpp
index 41e6895..308287c 100644
--- a/src/core/SkColorTable.cpp
+++ b/src/core/SkColorTable.cpp
@@ -132,6 +132,14 @@
     return f16BitCache;
 }
 
+void SkColorTable::setIsOpaque(bool isOpaque) {
+    if (isOpaque) {
+        fFlags |= kColorsAreOpaque_Flag;
+    } else {
+        fFlags &= ~kColorsAreOpaque_Flag;
+    }
+}
+
 ///////////////////////////////////////////////////////////////////////////////
 
 SkColorTable::SkColorTable(SkFlattenableReadBuffer& buffer) {