| OLD | NEW |
| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 return gfx::ToEnclosingRect( | 74 return gfx::ToEnclosingRect( |
| 75 gfx::RectF(gfx::ScalePoint(rect_in_dip.origin(), scale), | 75 gfx::RectF(gfx::ScalePoint(rect_in_dip.origin(), scale), |
| 76 gfx::ScaleSize(rect_in_dip.size(), scale))); | 76 gfx::ScaleSize(rect_in_dip.size(), scale))); |
| 77 } | 77 } |
| 78 | 78 |
| 79 #if DCHECK_IS_ON | 79 #if DCHECK_IS_ON |
| 80 namespace { | 80 namespace { |
| 81 | 81 |
| 82 void CheckSnapped(float snapped_position) { | 82 void CheckSnapped(float snapped_position) { |
| 83 const float kEplison = 0.0001f; | 83 const float kEplison = 0.0001f; |
| 84 float diff = std::abs(snapped_position - static_cast<int>(snapped_position)); | 84 float diff = std::abs(snapped_position - gfx::ToRoundedInt(snapped_position)); |
| 85 DCHECK_LT(diff, kEplison); | 85 DCHECK_LT(diff, kEplison); |
| 86 } | 86 } |
| 87 | 87 |
| 88 } // namespace | 88 } // namespace |
| 89 #endif | 89 #endif |
| 90 | 90 |
| 91 void SnapLayerToPhysicalPixelBoundary(ui::Layer* snapped_layer, | 91 void SnapLayerToPhysicalPixelBoundary(ui::Layer* snapped_layer, |
| 92 ui::Layer* layer_to_snap) { | 92 ui::Layer* layer_to_snap) { |
| 93 DCHECK_NE(snapped_layer, layer_to_snap); | 93 DCHECK_NE(snapped_layer, layer_to_snap); |
| 94 DCHECK(snapped_layer); | 94 DCHECK(snapped_layer); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 118 } else { | 118 } else { |
| 119 cc::Layer* cc_layer = layer_to_snap->cc_layer(); | 119 cc::Layer* cc_layer = layer_to_snap->cc_layer(); |
| 120 origin = cc_layer->position(); | 120 origin = cc_layer->position(); |
| 121 } | 121 } |
| 122 CheckSnapped((layer_offset.x() + origin.x()) * scale_factor); | 122 CheckSnapped((layer_offset.x() + origin.x()) * scale_factor); |
| 123 CheckSnapped((layer_offset.y() + origin.y()) * scale_factor); | 123 CheckSnapped((layer_offset.y() + origin.y()) * scale_factor); |
| 124 #endif | 124 #endif |
| 125 } | 125 } |
| 126 | 126 |
| 127 } // namespace ui | 127 } // namespace ui |
| OLD | NEW |