Move alpha-ramp AA to GrContext, detect cases when AA is applied via other methods (smooth lines, MSAA) or rect falls on integer coords and skip the alpha ramp path. Use pre-fab index buffer for alpha-ramped fill rects and stroke rects.
Review URL: http://codereview.appspot.com/4449047/
git-svn-id: http://skia.googlecode.com/svn/trunk@1169 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/include/GrScalar.h b/gpu/include/GrScalar.h
index 1353fb2..7aaa43d 100644
--- a/gpu/include/GrScalar.h
+++ b/gpu/include/GrScalar.h
@@ -56,11 +56,19 @@
*/
#define GrFloatToFixed(x) ((GrFixed)((x) * GR_Fixed1))
-inline GrFixed GrFixedAbs(GrFixed x) {
+static inline GrFixed GrFixedAbs(GrFixed x) {
int32_t s = (x & 0x80000000) >> 31;
return (GrFixed)(((int32_t)x ^ s) - s);
}
+static inline bool GrFixedIsInt(GrFixed x) {
+ return 0 == (x & 0xffff);
+}
+
+static inline bool GrFloatIsInt(float x) {
+ return x == (float)(int)x;
+}
+
///////////////////////////////////////////////////////////////////////////////
#if GR_SCALAR_IS_FIXED
@@ -72,6 +80,7 @@
#define GrScalarHalf(x) ((x) >> 1)
#define GrScalarAve(x,y) (((x)+(y)) >> 1)
#define GrScalarAbs(x) GrFixedAbs(x)
+ #define GrScalarIsInt GrFixedIsInt
#define GR_Scalar1 GR_Fixed1
#define GR_ScalarHalf GR_FixedHalf
#define GR_ScalarMax GR_FixedMax
@@ -85,6 +94,7 @@
#define GrScalarHalf(x) ((x) * 0.5f)
#define GrScalarAbs(x) fabsf(x)
#define GrScalarAve(x,y) (((x) + (y)) * 0.5f)
+ #define GrScalarIsInt GrFloatIsInt
#define GR_Scalar1 1.f
#define GR_ScalarHalf 0.5f
#define GR_ScalarMax (FLT_MAX)