Add support for SK_MSCALAR_IS_FLOAT

The default is SK_MSCALAR_IS_FLOAT. You'll have to explicitly define SK_MSCALAR_IS_DOUBLE if that's what you want.

BUG=None

Review URL: https://codereview.appspot.com/6843049

git-svn-id: http://skia.googlecode.com/svn/trunk@6403 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
vollick@chromium.org 2012-11-13 20:12:00 +00:00
parent a09e8838f2
commit 5596a69e9f
3 changed files with 10 additions and 4 deletions

View File

@ -30,6 +30,12 @@
#define SK_SCALAR_IS_FLOAT
#endif
#if defined(SK_MSCALAR_IS_DOUBLE) && defined(SK_MSCALAR_IS_FLOAT)
#error "cannot define both SK_MSCALAR_IS_DOUBLE and SK_MSCALAR_IS_FLOAT"
#elif !defined(SK_MSCALAR_IS_DOUBLE) && !defined(SK_MSCALAR_IS_FLOAT)
#define SK_MSCALAR_IS_FLOAT
#endif
#if defined(SK_CPU_LENDIAN) && defined(SK_CPU_BENDIAN)
#error "cannot define both SK_CPU_LENDIAN and SK_CPU_BENDIAN"
#elif !defined(SK_CPU_LENDIAN) && !defined(SK_CPU_BENDIAN)

View File

@ -29,7 +29,7 @@
return x;
}
static const SkMScalar SK_MScalarPI = 3.141592653589793;
#else
#elif defined SK_MSCALAR_IS_FLOAT
typedef float SkMScalar;
static inline float SkFloatToMScalar(float x) {
return x;
@ -202,7 +202,7 @@ public:
#ifdef SK_MSCALAR_IS_DOUBLE
void mapMScalars(const SkMScalar src[4], SkMScalar dst[4]) const;
#else
#elif defined SK_MSCALAR_IS_FLOAT
void mapMScalars(const SkMScalar src[4], SkMScalar dst[4]) const {
this->mapScalars(src, dst);
}

View File

@ -42,7 +42,7 @@ void SkMatrix44::asColMajorf(float dst[]) const {
for (int i = 0; i < 16; ++i) {
dst[i] = SkMScalarToFloat(src[i]);
}
#else
#elif defined SK_MSCALAR_IS_FLOAT
memcpy(dst, src, 16 * sizeof(float));
#endif
}
@ -51,7 +51,7 @@ void SkMatrix44::asColMajord(double dst[]) const {
const SkMScalar* src = &fMat[0][0];
#ifdef SK_MSCALAR_IS_DOUBLE
memcpy(dst, src, 16 * sizeof(double));
#else
#elif defined SK_MSCALAR_IS_FLOAT
for (int i = 0; i < 16; ++i) {
dst[i] = SkMScalarToDouble(src[i]);
}