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

Side by Side Diff: cc/trees/property_tree.cc

Issue 1067423002: Improve DCHECK in PropertyTree::UpdateSnapping (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: SkDoubleToMScalar 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <set> 5 #include <set>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "cc/base/math_util.h" 9 #include "cc/base/math_util.h"
10 #include "cc/trees/property_tree.h" 10 #include "cc/trees/property_tree.h"
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 // This means we effectively snap the target space transform. If TT is the 305 // This means we effectively snap the target space transform. If TT is the
306 // target space transform and TT' is TT with its translation components 306 // target space transform and TT' is TT with its translation components
307 // rounded, then what we're after is the scroll delta X, where TT * X = TT'. 307 // rounded, then what we're after is the scroll delta X, where TT * X = TT'.
308 // I.e., we want a transform that will realize our scroll snap. It follows 308 // I.e., we want a transform that will realize our scroll snap. It follows
309 // that X = TT^-1 * TT'. We cache TT and TT^-1 to make this more efficient. 309 // that X = TT^-1 * TT'. We cache TT and TT^-1 to make this more efficient.
310 gfx::Transform rounded = node->data.to_target; 310 gfx::Transform rounded = node->data.to_target;
311 rounded.RoundTranslationComponents(); 311 rounded.RoundTranslationComponents();
312 gfx::Transform delta = node->data.from_target; 312 gfx::Transform delta = node->data.from_target;
313 delta *= rounded; 313 delta *= rounded;
314 314
315 DCHECK(delta.IsIdentityOr2DTranslation()); 315 DCHECK(delta.IsApproximatelyIdentityOrTranslation(SkDoubleToMScalar(1e-4)))
316 << delta.ToString();
316 317
317 gfx::Vector2dF translation = delta.To2dTranslation(); 318 gfx::Vector2dF translation = delta.To2dTranslation();
318 319
319 // Now that we have our scroll delta, we must apply it to each of our 320 // Now that we have our scroll delta, we must apply it to each of our
320 // combined, to/from matrices. 321 // combined, to/from matrices.
321 node->data.to_parent.Translate(translation.x(), translation.y()); 322 node->data.to_parent.Translate(translation.x(), translation.y());
322 node->data.to_target.Translate(translation.x(), translation.y()); 323 node->data.to_target.Translate(translation.x(), translation.y());
323 node->data.from_target.matrix().postTranslate(-translation.x(), 324 node->data.from_target.matrix().postTranslate(-translation.x(),
324 -translation.y(), 0); 325 -translation.y(), 0);
325 node->data.to_screen.Translate(translation.x(), translation.y()); 326 node->data.to_screen.Translate(translation.x(), translation.y());
326 node->data.from_screen.matrix().postTranslate(-translation.x(), 327 node->data.from_screen.matrix().postTranslate(-translation.x(),
327 -translation.y(), 0); 328 -translation.y(), 0);
328 329
329 node->data.scroll_snap = translation; 330 node->data.scroll_snap = translation;
330 } 331 }
331 332
332 } // namespace cc 333 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698