Index: ui/gfx/skia_util.cc |
diff --git a/ui/gfx/skia_util.cc b/ui/gfx/skia_util.cc |
index c1e6c184ce17a257a08669dfd745636eb698f563..a971c9f22ecbe483a13e07a509fd13bca8aa469d 100644 |
--- a/ui/gfx/skia_util.cc |
+++ b/ui/gfx/skia_util.cc |
@@ -7,6 +7,7 @@ |
#include <stddef.h> |
#include <stdint.h> |
+#include "base/numerics/safe_conversions.h" |
#include "third_party/skia/include/core/SkBitmap.h" |
#include "third_party/skia/include/core/SkColorFilter.h" |
#include "third_party/skia/include/core/SkColorPriv.h" |
@@ -226,4 +227,21 @@ void QuadFToSkPoints(const gfx::QuadF& quad, SkPoint points[4]) { |
points[3] = PointFToSkPoint(quad.p4()); |
} |
+// We treat HarfBuzz ints as 16.16 fixed-point. |
+static const int kHbUnit1 = 1 << 16; |
+ |
+int SkiaScalarToHarfBuzzUnits(SkScalar value) { |
+ return base::saturated_cast<int>(value * kHbUnit1); |
+} |
+ |
+SkScalar HarfBuzzUnitsToSkiaScalar(int value) { |
+ static const SkScalar kSkToHbRatio = SK_Scalar1 / kHbUnit1; |
+ return kSkToHbRatio * value; |
+} |
+ |
+float HarfBuzzUnitsToFloat(int value) { |
+ static const float kFloatToHbRatio = 1.0f / kHbUnit1; |
+ return kFloatToHbRatio * value; |
+} |
+ |
} // namespace gfx |