/* * Copyright 2006 The Android Open Source Project * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file.
*/
// Handy util that can be passed two ints, and will automatically promote to // 64bits before the multiply, so the caller doesn't have to remember to cast // e.g. (int64_t)a * b; staticinline int64_t sk_64_mul(int64_t a, int64_t b) { return a * b;
}
/** * Returns true if value is a power of 2. Does not explicitly check for * value <= 0.
*/ template <typename T> constexpr inlinebool SkIsPow2(T value) { return (value & (value - 1)) == 0;
}
/** * Return a*b/((1 << shift) - 1), rounding any fractional bits. * Only valid if a and b are unsigned and <= 32767 and shift is > 0 and <= 8
*/ staticinlineunsigned SkMul16ShiftRound(U16CPU a, U16CPU b, int shift) {
SkASSERT(a <= 32767);
SkASSERT(b <= 32767);
SkASSERT(shift > 0 && shift <= 8); unsigned prod = a*b + (1 << (shift - 1)); return (prod + (prod >> shift)) >> shift;
}
/** * Return a*b/255, rounding any fractional bits. * Only valid if a and b are unsigned and <= 32767.
*/ staticinline U8CPU SkMulDiv255Round(U16CPU a, U16CPU b) { return SkMul16ShiftRound(a, b, 8);
}
#endif
Messung V0.5
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.