SkScalar

http://code.google.com/p/skia/wiki/SkScalar 

Skia使用SkScalar指定所有设备无关的坐标.

SkScalar 在编译时指定为32位整形(16.16 见SkFixed)或者IEEE 32位float

可以通过头文件SkScalar.h的宏定义/内联来判断SkScalar的准确定义。

   SkScalar x, y;

   // all of these work fine as floats or SkFixed    以下在float和SkFixed都正确
   x = SkIntToScalar(35);
   y = x * 5;
   x = y / 3;
   y += x;

   // these give drastically different results between floats and SkFixed 以下在float和SkFixed有巨大差异
   x += 1;
   x = y * y;
   // This won't compile if scalar == float   以下在float情况导致编译错误
   y >>= 2;

  SkScalar.h通过宏/内联抽象了大多数操作的知识

   SkScalarMul(a, b)  // mulitplies two scalars, returning a scalar   相乘
   SkScalarDiv(a, b)  // divides two scalars, returning a scalar    除以
   SkScalarCos(a)     // returns the cosine as a scalar [0 .. SK_Scalar1] given a scalar radians   
   SkScalarRound(a)   // returns the nearest int to the specified scalar

  

ezhong的博客园:http://www.cnblogs.com/ezhong/

原文地址:https://www.cnblogs.com/ezhong/p/2264212.html