summaryrefslogtreecommitdiffstats
path: root/cc/trees
diff options
context:
space:
mode:
authorshawnsingh@google.com <shawnsingh@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-29 21:42:03 +0000
committershawnsingh@google.com <shawnsingh@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-29 21:42:03 +0000
commit81d20544b54bdc302d06315428b6be7311d7d784 (patch)
treed76bbc26e0b698f0f4ea0eaaab30286152a173fb /cc/trees
parentee38bc4084d0812df5fa0d9a615f8a8193e04ab2 (diff)
downloadchromium_src-81d20544b54bdc302d06315428b6be7311d7d784.zip
chromium_src-81d20544b54bdc302d06315428b6be7311d7d784.tar.gz
chromium_src-81d20544b54bdc302d06315428b6be7311d7d784.tar.bz2
Add PRESUBMIT check to cc to ensure that C++ std::abs is used
This is try #2, previous patch r214144 was reverted in r214149. Before this patch, it is possible to use abs() without the std:: namespace qualifier, which may link to the C standard library implementation of abs(). Thus, someone using abs(float) may get wrong results because C standard version will convert the float to an int. This patch updates the occurrences of of abs() and fabs() in cc/ (though technically none were incorrect, thankfully) and adds a PRESUBMIT to enforce that all uses of abs from now on have an explicit std:: to resolve them correctly. BUG=261900 R=enne@chromium.org Review URL: https://codereview.chromium.org/21061004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@214225 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/trees')
-rw-r--r--cc/trees/layer_sorter.cc7
-rw-r--r--cc/trees/layer_tree_host_perftest.cc2
2 files changed, 5 insertions, 4 deletions
diff --git a/cc/trees/layer_sorter.cc b/cc/trees/layer_sorter.cc
index 6729b19..73fe3ef 100644
--- a/cc/trees/layer_sorter.cc
+++ b/cc/trees/layer_sorter.cc
@@ -159,7 +159,8 @@ LayerSorter::ABCompareResult LayerSorter::CheckOverlap(LayerShape* a,
return ABeforeB;
float max_diff =
- fabsf(max_positive) > fabsf(max_negative) ? max_positive : max_negative;
+ std::abs(max_positive) > std::abs(max_negative) ?
+ max_positive : max_negative;
// If the results are inconsistent (and the z difference substantial to rule
// out numerical errors) then the layers are intersecting. We will still
@@ -169,7 +170,7 @@ LayerSorter::ABCompareResult LayerSorter::CheckOverlap(LayerShape* a,
if (max_positive > z_threshold && max_negative < -z_threshold)
*weight = 0.f;
else
- *weight = fabsf(max_diff);
+ *weight = std::abs(max_diff);
// Maintain relative order if the layers have the same depth at all
// intersection points.
@@ -293,7 +294,7 @@ void LayerSorter::CreateGraphNodes(LayerImplList::iterator first,
min_z = std::min(min_z, node.shape.transform_origin.z());
}
- z_range_ = fabsf(max_z - min_z);
+ z_range_ = std::abs(max_z - min_z);
}
void LayerSorter::CreateGraphEdges() {
diff --git a/cc/trees/layer_tree_host_perftest.cc b/cc/trees/layer_tree_host_perftest.cc
index 4103158..fc7673c 100644
--- a/cc/trees/layer_tree_host_perftest.cc
+++ b/cc/trees/layer_tree_host_perftest.cc
@@ -268,7 +268,7 @@ class PageScaleImplSidePaintingPerfTest : public ImplSidePaintingPerfTest {
: time_in_two_intervals;
// Normalize time to -1..1.
float normalized = 2.f * time_in_one_interval - 1.f;
- float scale_factor = std::fabs(normalized) * (max_scale_ - 1.f) + 1.f;
+ float scale_factor = std::abs(normalized) * (max_scale_ - 1.f) + 1.f;
float total_scale = normalized < 0.f ? 1.f / scale_factor : scale_factor;
float desired_delta =