Index: include/effects/SkBitmapAlphaThresholdShader.h |
diff --git a/include/effects/SkBitmapAlphaThresholdShader.h b/include/effects/SkBitmapAlphaThresholdShader.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..90d19d27b6257bce896e95aab3955ec562cf316f |
--- /dev/null |
+++ b/include/effects/SkBitmapAlphaThresholdShader.h |
@@ -0,0 +1,46 @@ |
+/* |
+ * 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" |
+ |
+/** |
+ * This shader 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. |
+ */ |
+class SK_API SkBitmapAlphaThresholdShader : public SkShader { |
+public: |
+ SK_DECLARE_INST_COUNT(SkThresholdShader); |
+ |
+ static SkShader* Create(SkBitmap bitmap, const SkRegion& region, U8CPU threshold); |
reed1
2013/09/05 15:14:54
nit: const SkBitmap&
bsalomon
2013/09/05 19:54:50
Done.
|
+ |
+ virtual void shadeSpan(int x, int y, SkPMColor[], int count) SK_OVERRIDE {}; |
reed1
2013/09/05 15:14:54
Suggestion:
move all of this method stuff into th
bsalomon
2013/09/05 19:54:50
Done.
|
+ |
+#if SK_SUPPORT_GPU |
+ virtual GrEffectRef* asNewEffect(GrContext* context, const SkPaint& paint) const SK_OVERRIDE; |
+#endif |
+ |
+ SK_DEVELOPER_TO_STRING(); |
+ SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapAlphaThresholdShader) |
+ |
+private: |
+ SkBitmapAlphaThresholdShader(SkBitmap bitmap, SkRegion region, U8CPU); |
+ SkBitmapAlphaThresholdShader(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {} |
+ |
+ |
+ SkBitmap fBitmap; |
+ SkRegion fRegion; |
+ U8CPU fThreshold; |
+ |
+ typedef SkShader INHERITED; |
+}; |