Coverage Report

Created: 2026-08-14 10:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/vcl/inc/bitmap/impoctree.hxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
5
 * This Source Code Form is subject to the terms of the Mozilla Public
6
 * License, v. 2.0. If a copy of the MPL was not distributed with this
7
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
 *
9
 * This file incorporates work covered by the following license notice:
10
 *
11
 *   Licensed to the Apache Software Foundation (ASF) under one or more
12
 *   contributor license agreements. See the NOTICE file distributed
13
 *   with this work for additional information regarding copyright
14
 *   ownership. The ASF licenses this file to you under the Apache
15
 *   License, Version 2.0 (the "License"); you may not use this file
16
 *   except in compliance with the License. You may obtain a copy of
17
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18
 */
19
20
#pragma once
21
22
#include <vcl/BitmapColor.hxx>
23
24
class ImpErrorQuad
25
{
26
    sal_Int16 nRed;
27
    sal_Int16 nGreen;
28
    sal_Int16 nBlue;
29
30
public:
31
    ImpErrorQuad()
32
84.2k
        : nRed(0)
33
84.2k
        , nGreen(0)
34
84.2k
        , nBlue(0)
35
84.2k
    {
36
84.2k
    }
37
38
    ImpErrorQuad(const BitmapColor& rColor)
39
7.37M
        : nRed(rColor.GetRed() << 5)
40
7.37M
        , nGreen(rColor.GetGreen() << 5)
41
7.37M
        , nBlue(rColor.GetBlue() << 5)
42
7.37M
    {
43
7.37M
    }
44
45
    inline void operator=(const BitmapColor& rColor);
46
    inline ImpErrorQuad& operator-=(const BitmapColor& rColor);
47
48
    inline void ImplAddColorError1(const ImpErrorQuad& rErrQuad);
49
    inline void ImplAddColorError3(const ImpErrorQuad& rErrQuad);
50
    inline void ImplAddColorError5(const ImpErrorQuad& rErrQuad);
51
    inline void ImplAddColorError7(const ImpErrorQuad& rErrQuad);
52
53
    inline BitmapColor ImplGetColor() const;
54
};
55
56
inline void ImpErrorQuad::operator=(const BitmapColor& rColor)
57
7.51M
{
58
7.51M
    nRed = rColor.GetRed() << 5;
59
7.51M
    nGreen = rColor.GetGreen() << 5;
60
7.51M
    nBlue = rColor.GetBlue() << 5;
61
7.51M
}
62
63
inline ImpErrorQuad& ImpErrorQuad::operator-=(const BitmapColor& rColor)
64
7.37M
{
65
7.37M
    nRed -= rColor.GetRed() << 5;
66
7.37M
    nGreen -= rColor.GetGreen() << 5;
67
7.37M
    nBlue -= rColor.GetBlue() << 5;
68
69
7.37M
    return *this;
70
7.37M
}
71
72
inline void ImpErrorQuad::ImplAddColorError1(const ImpErrorQuad& rErrQuad)
73
7.37M
{
74
7.37M
    nRed += rErrQuad.nRed >> 4;
75
7.37M
    nGreen += rErrQuad.nGreen >> 4;
76
7.37M
    nBlue += rErrQuad.nBlue >> 4;
77
7.37M
}
78
79
inline void ImpErrorQuad::ImplAddColorError3(const ImpErrorQuad& rErrQuad)
80
7.37M
{
81
7.37M
    nRed += rErrQuad.nRed * 3L >> 4;
82
7.37M
    nGreen += rErrQuad.nGreen * 3L >> 4;
83
7.37M
    nBlue += rErrQuad.nBlue * 3L >> 4;
84
7.37M
}
85
86
inline void ImpErrorQuad::ImplAddColorError5(const ImpErrorQuad& rErrQuad)
87
7.37M
{
88
7.37M
    nRed += rErrQuad.nRed * 5L >> 4;
89
7.37M
    nGreen += rErrQuad.nGreen * 5L >> 4;
90
7.37M
    nBlue += rErrQuad.nBlue * 5L >> 4;
91
7.37M
}
92
93
inline void ImpErrorQuad::ImplAddColorError7(const ImpErrorQuad& rErrQuad)
94
7.37M
{
95
7.37M
    nRed += rErrQuad.nRed * 7L >> 4;
96
7.37M
    nGreen += rErrQuad.nGreen * 7L >> 4;
97
7.37M
    nBlue += rErrQuad.nBlue * 7L >> 4;
98
7.37M
}
99
100
inline BitmapColor ImpErrorQuad::ImplGetColor() const
101
7.51M
{
102
7.51M
    return BitmapColor(std::clamp(nRed, sal_Int16(0), sal_Int16(8160)) >> 5,
103
7.51M
                       std::clamp(nGreen, sal_Int16(0), sal_Int16(8160)) >> 5,
104
7.51M
                       std::clamp(nBlue, sal_Int16(0), sal_Int16(8160)) >> 5);
105
7.51M
}
106
107
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */