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

Side by Side Diff: ui/compositor/dip_util.cc

Issue 2771663004: Relax the eplison to check snapping (Closed)
Patch Set: Created 3 years, 9 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/compositor/dip_util.h" 5 #include "ui/compositor/dip_util.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "cc/layers/layer.h" 8 #include "cc/layers/layer.h"
9 #include "ui/compositor/compositor.h" 9 #include "ui/compositor/compositor.h"
10 #include "ui/compositor/compositor_switches.h" 10 #include "ui/compositor/compositor_switches.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 gfx::Rect ConvertRectToPixel(const Layer* layer, 60 gfx::Rect ConvertRectToPixel(const Layer* layer,
61 const gfx::Rect& rect_in_dip) { 61 const gfx::Rect& rect_in_dip) {
62 return gfx::ConvertRectToPixel(GetDeviceScaleFactor(layer), rect_in_dip); 62 return gfx::ConvertRectToPixel(GetDeviceScaleFactor(layer), rect_in_dip);
63 } 63 }
64 64
65 #if DCHECK_IS_ON() 65 #if DCHECK_IS_ON()
66 namespace { 66 namespace {
67 67
68 void CheckSnapped(float snapped_position) { 68 void CheckSnapped(float snapped_position) {
69 const float kEplison = 0.0001f; 69 const float kEplison = 0.0002f;
servolk 2017/03/23 21:49:00 Nit: fix the typo while you are at it kEplison ->
servolk 2017/03/23 21:50:23 Also, I'm pretty sure 0.0002f is not enough. I hav
70 float diff = std::abs(snapped_position - gfx::ToRoundedInt(snapped_position)); 70 float diff = std::abs(snapped_position - gfx::ToRoundedInt(snapped_position));
71 DCHECK_LT(diff, kEplison); 71 DCHECK_LT(diff, kEplison);
72 } 72 }
73 73
74 } // namespace 74 } // namespace
75 #endif 75 #endif
76 76
77 void SnapLayerToPhysicalPixelBoundary(ui::Layer* snapped_layer, 77 void SnapLayerToPhysicalPixelBoundary(ui::Layer* snapped_layer,
78 ui::Layer* layer_to_snap) { 78 ui::Layer* layer_to_snap) {
79 DCHECK_NE(snapped_layer, layer_to_snap); 79 DCHECK_NE(snapped_layer, layer_to_snap);
(...skipping 23 matching lines...) Expand all
103 layer_to_snap->subpixel_position_offset(); 103 layer_to_snap->subpixel_position_offset();
104 } else { 104 } else {
105 origin = layer_to_snap->position(); 105 origin = layer_to_snap->position();
106 } 106 }
107 CheckSnapped((layer_offset.x() + origin.x()) * scale_factor); 107 CheckSnapped((layer_offset.x() + origin.x()) * scale_factor);
108 CheckSnapped((layer_offset.y() + origin.y()) * scale_factor); 108 CheckSnapped((layer_offset.y() + origin.y()) * scale_factor);
109 #endif 109 #endif
110 } 110 }
111 111
112 } // namespace ui 112 } // namespace ui
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