Do writepixels alpha-premul using gpu

Review URL: http://codereview.appspot.com/5373064/



git-svn-id: http://skia.googlecode.com/svn/trunk@2668 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index 03a68dd..3d9195c 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -810,8 +810,15 @@
         }
     }
     for (int s = 0; s < GrDrawState::kNumStages; ++s) {
+        // We don't support using unpremultiplied textures with filters (other
+        // than nearest). Alpha-premulling is not distributive WRT to filtering.
+        // We'd have to filter each texel before filtering. We could do this for
+        // our custom filters but we would also have to disable bilerp and do
+        // a custom bilerp in the shader. Until Skia itself supports unpremul
+        // configs there is no pressure to implement this.
         if (this->isStageEnabled(s) &&
-            GrPixelConfigIsUnpremultiplied(fCurrDrawState.fTextures[s]->config())) {
+            GrPixelConfigIsUnpremultiplied(fCurrDrawState.fTextures[s]->config()) &&
+            GrSamplerState::kNearest_Filter != fCurrDrawState.fSamplerStates[s].getFilter()) {
             return false;
         }
     }