Coverage Report

Created: 2021-08-22 09:07

/src/skia/src/core/SkMath.cpp
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright 2008 The Android Open Source Project
3
 *
4
 * Use of this source code is governed by a BSD-style license that can be
5
 * found in the LICENSE file.
6
 */
7
8
#include "include/core/SkScalar.h"
9
#include "include/private/SkFixed.h"
10
#include "include/private/SkFloatBits.h"
11
#include "include/private/SkFloatingPoint.h"
12
#include "src/core/SkMathPriv.h"
13
#include "src/core/SkSafeMath.h"
14
15
///////////////////////////////////////////////////////////////////////////////
16
17
/* www.worldserver.com/turk/computergraphics/FixedSqrt.pdf
18
*/
19
0
int32_t SkSqrtBits(int32_t x, int count) {
20
0
    SkASSERT(x >= 0 && count > 0 && (unsigned)count <= 30);
21
22
0
    uint32_t    root = 0;
23
0
    uint32_t    remHi = 0;
24
0
    uint32_t    remLo = x;
25
26
0
    do {
27
0
        root <<= 1;
28
29
0
        remHi = (remHi<<2) | (remLo>>30);
30
0
        remLo <<= 2;
31
32
0
        uint32_t testDiv = (root << 1) + 1;
33
0
        if (remHi >= testDiv) {
34
0
            remHi -= testDiv;
35
0
            root++;
36
0
        }
37
0
    } while (--count >= 0);
38
39
0
    return root;
40
0
}
Unexecuted instantiation: SkSqrtBits(int, int)
Unexecuted instantiation: SkSqrtBits(int, int)
41
42
///////////////////////////////////////////////////////////////////////////////////////////////////
43
44
0
size_t SkSafeMath::Add(size_t x, size_t y) {
45
0
    SkSafeMath tmp;
46
0
    size_t sum = tmp.add(x, y);
47
0
    return tmp.ok() ? sum : SIZE_MAX;
48
0
}
49
50
18.2M
size_t SkSafeMath::Mul(size_t x, size_t y) {
51
18.2M
    SkSafeMath tmp;
52
18.2M
    size_t prod = tmp.mul(x, y);
53
18.2M
    return tmp.ok() ? prod : SIZE_MAX;
54
18.2M
}
55
56
///////////////////////////////////////////////////////////////////////////////////////////////////
57
58
0
bool sk_floats_are_unit(const float array[], size_t count) {
59
0
    bool is_unit = true;
60
0
    for (size_t i = 0; i < count; ++i) {
61
0
        is_unit &= (array[i] >= 0) & (array[i] <= 1);
62
0
    }
63
0
    return is_unit;
64
0
}