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

Unified Diff: cc/trees/layer_tree_host_common.cc

Issue 1071803003: Update matrix distance metric to account for snapping. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: grammar Created 5 years, 8 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 | « no previous file | ui/gfx/transform_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_common.cc
diff --git a/cc/trees/layer_tree_host_common.cc b/cc/trees/layer_tree_host_common.cc
index 038c259bb47af26779416028b940b28a659a2eb3..cdb67611826cc66e8cb3af2567c46f5a84729c48 100644
--- a/cc/trees/layer_tree_host_common.cc
+++ b/cc/trees/layer_tree_host_common.cc
@@ -2465,8 +2465,24 @@ static bool ApproximatelyEqual(const gfx::Rect& r1, const gfx::Rect& r2) {
static bool ApproximatelyEqual(const gfx::Transform& a,
const gfx::Transform& b) {
- static const float tolerance = 0.1f;
- return gfx::MatrixDistance(a, b) <= tolerance;
+ static const float component_tolerance = 0.1f;
+
+ // We may have a larger discrepancy in the scroll components due to snapping
+ // (floating point error might round the other way).
+ static const float translation_tolerance = 1.f;
+
+ for (int row = 0; row < 4; row++) {
+ for (int col = 0; col < 4; col++) {
+ static const float delta =
+ std::abs(a.matrix().get(row, col) - b.matrix().get(row, col));
+ const float tolerance =
+ col == 3 && row < 3 ? translation_tolerance : component_tolerance;
+ if (delta > tolerance)
+ return false;
+ }
+ }
+
+ return true;
}
void LayerTreeHostCommon::CalculateDrawProperties(
« no previous file with comments | « no previous file | ui/gfx/transform_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698