alpha threshold bitmap shader

Committed: http://code.google.com/p/skia/source/detail?r=11122

R=reed@google.com

Author: bsalomon@google.com

Review URL: https://chromiumcodereview.appspot.com/23707019

git-svn-id: http://skia.googlecode.com/svn/trunk/include@11131 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/core/SkShader.h b/core/SkShader.h
index e1cab96..2632830 100644
--- a/core/SkShader.h
+++ b/core/SkShader.h
@@ -318,9 +318,11 @@
     virtual GradientType asAGradient(GradientInfo* info) const;
 
     /**
-     *  If the shader subclass has a GrEffect implementation, this installs an effect on the stage.
-     *  The GrContext may be used by the effect to create textures. The GPU device does not call
-     *  setContext. Instead we pass the paint here in case the shader needs paint info.
+     *  If the shader subclass has a GrEffect implementation, this resturns the effect to install.
+     *  The incoming color to the effect has r=g=b=a all extracted from the SkPaint's alpha.
+     *  The output color should be the computed SkShader premul color modulated by the incoming
+     *  color. The GrContext may be used by the effect to create textures. The GPU device does not
+     *  call setContext. Instead we pass the SkPaint here in case the shader needs paint info.
      */
     virtual GrEffectRef* asNewEffect(GrContext* context, const SkPaint& paint) const;
 
diff --git a/effects/SkBitmapAlphaThresholdShader.h b/effects/SkBitmapAlphaThresholdShader.h
new file mode 100644
index 0000000..61596da
--- /dev/null
+++ b/effects/SkBitmapAlphaThresholdShader.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkShader.h"
+#include "SkBitmap.h"
+#include "SkRegion.h"
+#include "SkString.h"
+
+class SK_API SkBitmapAlphaThresholdShader : public SkShader {
+public:
+    /**
+     * Creates a shader that samples a bitmap and a region. If the sample is inside the region
+     * the alpha of the bitmap color is boosted up to a threshold value. If it is
+     * outside the region then the bitmap alpha is decreased to the threshold value.
+     * The 0,0 point of the region corresponds to the upper left corner of the bitmap
+     * Currently, this only has a GPU implementation, doesn't respect the paint's bitmap
+     * filter setting, and always uses clamp mode.
+     */
+    static SkShader* Create(const SkBitmap& bitmap, const SkRegion& region, U8CPU threshold);
+};
diff --git a/gpu/GrEffect.h b/gpu/GrEffect.h
index 942e580..a84810c 100644
--- a/gpu/GrEffect.h
+++ b/gpu/GrEffect.h
@@ -204,8 +204,9 @@
 protected:
     /**
      * Subclasses call this from their constructor to register GrTextureAccesses. The effect
-     * subclass manages the lifetime of the accesses (this function only stores a pointer). This
-     * must only be called from the constructor because GrEffects are immutable.
+     * subclass manages the lifetime of the accesses (this function only stores a pointer). The
+     * GrTextureAccess is typically a member field of the GrEffet subclass. This must only be
+     * called from the constructor because GrEffects are immutable.
      */
     void addTextureAccess(const GrTextureAccess* textureAccess);
 
diff --git a/gpu/GrTextureAccess.h b/gpu/GrTextureAccess.h
index 0f44807..f8bb554 100644
--- a/gpu/GrTextureAccess.h
+++ b/gpu/GrTextureAccess.h
@@ -18,7 +18,7 @@
  * Represents the filtering and tile modes used to access a texture. It is mostly used with
  * GrTextureAccess (defined below). Also, some of the texture cache methods require knowledge about
  * filtering and tiling to perform a cache lookup. If it wasn't for this latter usage this would
- * be folded into GrTextureAccess.
+ * be folded into GrTextureAccess. The default is clamp tile modes and no filtering.
  */
 class GrTextureParams {
 public: