[M120 Migration][VD] Remove accessing oom_score_adj in zygote process
[platform/framework/web/chromium-efl.git] / printing / units.cc
1 // Copyright 2011 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "printing/units.h"
6
7 #include "base/check_op.h"
8 #include "printing/print_job_constants.h"
9
10 namespace printing {
11
12 int ConvertUnit(float value, int old_unit, int new_unit) {
13   DCHECK_GT(new_unit, 0);
14   DCHECK_GT(old_unit, 0);
15   // With integer arithmetic, to divide a value with correct rounding, you need
16   // to add half of the divisor value to the dividend value. You need to do the
17   // reverse with negative number.
18   if (value >= 0) {
19     return ((value * new_unit) + (old_unit / 2)) / old_unit;
20   } else {
21     return ((value * new_unit) - (old_unit / 2)) / old_unit;
22   }
23 }
24
25 float ConvertUnitFloat(float value, float old_unit, float new_unit) {
26   DCHECK_GT(new_unit, 0);
27   DCHECK_GT(old_unit, 0);
28   return value * new_unit / old_unit;
29 }
30
31 }  // namespace printing