Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(503)

Unified Diff: ui/gfx/transform.cc

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/transform.h ('k') | ui/gfx/transform_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/transform.cc
diff --git a/ui/gfx/transform.cc b/ui/gfx/transform.cc
index 7fe5174e750444225b748a34a67bb61fdea19c82..c13ae1d65f7565c678a185d43252312edb7ee742 100644
--- a/ui/gfx/transform.cc
+++ b/ui/gfx/transform.cc
@@ -40,6 +40,12 @@ inline bool ApproximatelyOne(SkMScalar x, SkMScalar tolerance) {
return std::abs(x - SkDoubleToMScalar(1.0)) <= tolerance;
}
+static float Round(float f) {
+ if (f == 0.f)
+ return f;
+ return (f > 0.f) ? std::floor(f + 0.5f) : std::ceil(f - 0.5f);
+}
+
} // namespace
Transform::Transform(SkMScalar col1row1,
@@ -493,6 +499,12 @@ bool Transform::Blend(const Transform& from, double progress) {
return true;
}
+void Transform::RoundTranslationComponents() {
+ matrix_.set(0, 3, Round(matrix_.get(0, 3)));
+ matrix_.set(1, 3, Round(matrix_.get(1, 3)));
+}
+
+
void Transform::TransformPointInternal(const SkMatrix44& xform,
Point3F* point) const {
if (xform.isIdentity())
« no previous file with comments | « ui/gfx/transform.h ('k') | ui/gfx/transform_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698