Index: src/core/SkDistanceFieldGen.h |
diff --git a/src/core/SkDistanceFieldGen.h b/src/core/SkDistanceFieldGen.h |
index 3d2ec23b75de31460a23290dcc603491b0064da2..9157639832c2bacac85efa98d3271fce481ab75d 100644 |
--- a/src/core/SkDistanceFieldGen.h |
+++ b/src/core/SkDistanceFieldGen.h |
@@ -7,6 +7,20 @@ |
#ifndef SkDistanceFieldGen_DEFINED |
#define SkDistanceFieldGen_DEFINED |
+#include "SkTypes.h" |
+ |
robertphillips
2014/04/11 14:13:00
Is this comment right? Seems like this would be ma
jvanverth1
2014/04/11 17:54:14
Done.
|
+// the max magnitude for the distance field |
+#define SK_DistanceFieldRange 4 |
+// the final distance field needs additional texels on each side to handle |
+// the maximum distance + 1 for bilerp |
+#define SK_DistanceFieldPad (SK_DistanceFieldRange+1) |
+ |
+// for the fragment shader |
+// The distance field is constructed as unsigned char values, so that the zero value is at 128, |
+// and the range is [-4, 4 - 1/255). Hence our multiplier is 8 - 1/32 and zero threshold is 128/255. |
+#define SK_DistanceFieldMultiplier "7.96875" |
+#define SK_DistanceFieldThreshold "0.50196078431" |
+ |
/** Given 8-bit mask data, generate the associated distance field |
* @param distanceField The distance field to be generated. Should already be allocated |
robertphillips
2014/04/11 14:13:00
padding below?
jvanverth1
2014/04/11 17:54:14
Done.
|
@@ -14,12 +28,29 @@ |
* @param image 8-bit mask we're using to generate the distance field. |
* @param w Width of the image. |
* @param h Height of the image. |
robertphillips
2014/04/11 14:13:00
rowBytes?
jvanverth1
2014/04/11 17:54:14
Done.
|
- * @param distanceMagnitude Largest possible absolute value for the distance. The distance field |
- * will be padded to w + 2*distanceMagnitude, h + 2*distanceMagnitude. |
*/ |
-bool SkGenerateDistanceFieldFromImage(unsigned char* distanceField, |
- const unsigned char* image, |
- int w, int h, |
- int distanceMagnitude); |
+bool SkGenerateDistanceFieldFromA8Image(unsigned char* distanceField, |
+ const unsigned char* image, |
+ int w, int h, int rowBytes); |
+ |
+/** Given 1-bit mask data, generate the associated distance field |
+ |
+ * @param distanceField The distance field to be generated. Should already be allocated |
+ * by the client with the padding below. |
+ * @param image 1-bit mask we're using to generate the distance field. |
+ * @param w Width of the image. |
+ * @param h Height of the image. |
robertphillips
2014/04/11 14:13:00
rowBytes?
jvanverth1
2014/04/11 17:54:14
Done.
|
+ */ |
+bool SkGenerateDistanceFieldFromBWImage(unsigned char* distanceField, |
+ const unsigned char* image, |
+ int w, int h, int rowBytes); |
+ |
+/** Given width and height of original image, return size (in bytes) of distance field |
+ * @param w Width of the original image. |
+ * @param h Height of the original image. |
+ */ |
+inline size_t SkComputeDistanceFieldSize(int w, int h) { |
+ return (w + 2*SK_DistanceFieldPad) * (h + 2*SK_DistanceFieldPad) * sizeof(unsigned char); |
+} |
#endif |