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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | ui/gfx/transform_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 "cc/trees/layer_tree_host_common.h" 5 #include "cc/trees/layer_tree_host_common.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "cc/base/math_util.h" 10 #include "cc/base/math_util.h"
(...skipping 2447 matching lines...) Expand 10 before | Expand all | Expand 10 after
2458 // TODO(vollick): This tolerance should be lower: crbug.com/471786 2458 // TODO(vollick): This tolerance should be lower: crbug.com/471786
2459 static const int tolerance = 2; 2459 static const int tolerance = 2;
2460 return std::abs(r1.x() - r2.x()) <= tolerance && 2460 return std::abs(r1.x() - r2.x()) <= tolerance &&
2461 std::abs(r1.y() - r2.y()) <= tolerance && 2461 std::abs(r1.y() - r2.y()) <= tolerance &&
2462 std::abs(r1.right() - r2.right()) <= tolerance && 2462 std::abs(r1.right() - r2.right()) <= tolerance &&
2463 std::abs(r1.bottom() - r2.bottom()) <= tolerance; 2463 std::abs(r1.bottom() - r2.bottom()) <= tolerance;
2464 } 2464 }
2465 2465
2466 static bool ApproximatelyEqual(const gfx::Transform& a, 2466 static bool ApproximatelyEqual(const gfx::Transform& a,
2467 const gfx::Transform& b) { 2467 const gfx::Transform& b) {
2468 static const float tolerance = 0.1f; 2468 static const float component_tolerance = 0.1f;
2469 return gfx::MatrixDistance(a, b) <= tolerance; 2469
2470 // We may have a larger discrepancy in the scroll components due to snapping
2471 // (floating point error might round the other way).
2472 static const float translation_tolerance = 1.f;
2473
2474 for (int row = 0; row < 4; row++) {
2475 for (int col = 0; col < 4; col++) {
2476 static const float delta =
2477 std::abs(a.matrix().get(row, col) - b.matrix().get(row, col));
2478 const float tolerance =
2479 col == 3 && row < 3 ? translation_tolerance : component_tolerance;
2480 if (delta > tolerance)
2481 return false;
2482 }
2483 }
2484
2485 return true;
2470 } 2486 }
2471 2487
2472 void LayerTreeHostCommon::CalculateDrawProperties( 2488 void LayerTreeHostCommon::CalculateDrawProperties(
2473 CalcDrawPropsMainInputs* inputs) { 2489 CalcDrawPropsMainInputs* inputs) {
2474 UpdateRenderSurfaces(inputs->root_layer, 2490 UpdateRenderSurfaces(inputs->root_layer,
2475 inputs->can_render_to_separate_surface, gfx::Transform(), 2491 inputs->can_render_to_separate_surface, gfx::Transform(),
2476 false); 2492 false);
2477 LayerList dummy_layer_list; 2493 LayerList dummy_layer_list;
2478 SubtreeGlobals<Layer> globals; 2494 SubtreeGlobals<Layer> globals;
2479 DataForRecursion<Layer> data_for_recursion; 2495 DataForRecursion<Layer> data_for_recursion;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
2571 inputs->current_render_surface_layer_list_id); 2587 inputs->current_render_surface_layer_list_id);
2572 2588
2573 // The dummy layer list should not have been used. 2589 // The dummy layer list should not have been used.
2574 DCHECK_EQ(0u, dummy_layer_list.size()); 2590 DCHECK_EQ(0u, dummy_layer_list.size());
2575 // A root layer render_surface should always exist after 2591 // A root layer render_surface should always exist after
2576 // CalculateDrawProperties. 2592 // CalculateDrawProperties.
2577 DCHECK(inputs->root_layer->render_surface()); 2593 DCHECK(inputs->root_layer->render_surface());
2578 } 2594 }
2579 2595
2580 } // namespace cc 2596 } // namespace cc
OLDNEW
« 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