Coverage Report

Created: 2025-12-08 09:28

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
284k
        : nRed(0)
33
284k
        , nGreen(0)
34
284k
        , nBlue(0)
35
284k
    {
36
284k
    }
37
38
    ImpErrorQuad(const BitmapColor& rColor)
39
41.5M
        : nRed(rColor.GetRed() << 5)
40
41.5M
        , nGreen(rColor.GetGreen() << 5)
41
41.5M
        , nBlue(rColor.GetBlue() << 5)
42
41.5M
    {
43
41.5M
    }
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
41.9M
{
58
41.9M
    nRed = rColor.GetRed() << 5;
59
41.9M
    nGreen = rColor.GetGreen() << 5;
60
41.9M
    nBlue = rColor.GetBlue() << 5;
61
41.9M
}
62
63
inline ImpErrorQuad& ImpErrorQuad::operator-=(const BitmapColor& rColor)
64
41.5M
{
65
41.5M
    nRed -= rColor.GetRed() << 5;
66
41.5M
    nGreen -= rColor.GetGreen() << 5;
67
41.5M
    nBlue -= rColor.GetBlue() << 5;
68
69
41.5M
    return *this;
70
41.5M
}
71
72
inline void ImpErrorQuad::ImplAddColorError1(const ImpErrorQuad& rErrQuad)
73
41.5M
{
74
41.5M
    nRed += rErrQuad.nRed >> 4;
75
41.5M
    nGreen += rErrQuad.nGreen >> 4;
76
41.5M
    nBlue += rErrQuad.nBlue >> 4;
77
41.5M
}
78
79
inline void ImpErrorQuad::ImplAddColorError3(const ImpErrorQuad& rErrQuad)
80
41.5M
{
81
41.5M
    nRed += rErrQuad.nRed * 3L >> 4;
82
41.5M
    nGreen += rErrQuad.nGreen * 3L >> 4;
83
41.5M
    nBlue += rErrQuad.nBlue * 3L >> 4;
84
41.5M
}
85
86
inline void ImpErrorQuad::ImplAddColorError5(const ImpErrorQuad& rErrQuad)
87
41.5M
{
88
41.5M
    nRed += rErrQuad.nRed * 5L >> 4;
89
41.5M
    nGreen += rErrQuad.nGreen * 5L >> 4;
90
41.5M
    nBlue += rErrQuad.nBlue * 5L >> 4;
91
41.5M
}
92
93
inline void ImpErrorQuad::ImplAddColorError7(const ImpErrorQuad& rErrQuad)
94
41.5M
{
95
41.5M
    nRed += rErrQuad.nRed * 7L >> 4;
96
41.5M
    nGreen += rErrQuad.nGreen * 7L >> 4;
97
41.5M
    nBlue += rErrQuad.nBlue * 7L >> 4;
98
41.5M
}
99
100
inline BitmapColor ImpErrorQuad::ImplGetColor() const
101
41.9M
{
102
41.9M
    return BitmapColor(std::clamp(nRed, sal_Int16(0), sal_Int16(8160)) >> 5,
103
41.9M
                       std::clamp(nGreen, sal_Int16(0), sal_Int16(8160)) >> 5,
104
41.9M
                       std::clamp(nBlue, sal_Int16(0), sal_Int16(8160)) >> 5);
105
41.9M
}
106
107
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */