GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/resources/dye/dye.h Lines: 2 2 100.0 %
Date: 2021-03-17 Branches: 0 0 0.0 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2007-2009  The Mana World Development Team
4
 *  Copyright (C) 2009-2010  The Mana Developers
5
 *  Copyright (C) 2011-2019  The ManaPlus Developers
6
 *  Copyright (C) 2019-2021  Andrei Karas
7
 *
8
 *  This file is part of The ManaPlus Client.
9
 *
10
 *  This program is free software; you can redistribute it and/or modify
11
 *  it under the terms of the GNU General Public License as published by
12
 *  the Free Software Foundation; either version 2 of the License, or
13
 *  any later version.
14
 *
15
 *  This program is distributed in the hope that it will be useful,
16
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 *  GNU General Public License for more details.
19
 *
20
 *  You should have received a copy of the GNU General Public License
21
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
 */
23
24
#ifndef RESOURCES_DYE_DYE_H
25
#define RESOURCES_DYE_DYE_H
26
27
#include <string>
28
29
#include "localconsts.h"
30
31
class DyePalette;
32
33
const int dyePalateSize = 9;
34
const int sPaleteIndex = 7;
35
const int aPaleteIndex = 8;
36
37
/**
38
 * Class for dispatching pixel-recoloring amongst several palettes.
39
 */
40
class Dye final
41
{
42
    public:
43
        /**
44
         * Creates a set of palettes based on the given string.
45
         *
46
         * The parts of string are separated by semi-colons. Each part starts
47
         * by an uppercase letter, followed by a colon and then a palette name.
48
         */
49
        explicit Dye(const std::string &restrict dye);
50
51
        A_DELETE_COPY(Dye)
52
53
        /**
54
         * Destroys the associated palettes.
55
         */
56
        ~Dye();
57
58
        /**
59
         * Fills the blank in a dye placeholder with some palette names.
60
         */
61
        static void instantiate(std::string &restrict target,
62
                                const std::string &restrict palettes);
63
64
        /**
65
         * Return special dye palete (S)
66
         */
67
        const DyePalette *getSPalete() const restrict2 noexcept2 A_WARN_UNUSED
68
3
        { return mDyePalettes[sPaleteIndex]; }
69
70
        /**
71
         * Return special dye palete (A)
72
         */
73
        const DyePalette *getAPalete() const restrict2 noexcept2 A_WARN_UNUSED
74
1
        { return mDyePalettes[aPaleteIndex]; }
75
76
        /**
77
         * Return dye type for S - 1, for A - 2, 0 for other
78
         */
79
        int getType() const restrict2 noexcept2 A_WARN_UNUSED;
80
81
        void normalDye(uint32_t *restrict pixels,
82
                       const int bufSize) const restrict2;
83
84
        void normalOGLDye(uint32_t *restrict pixels,
85
                          const int bufSize) const restrict2;
86
87
    private:
88
        /**
89
         * The order of the palettes, as well as their uppercase letter, is:
90
         *
91
         * Red, Green, Yellow, Blue, Magenta, White (or rather gray), Simple.
92
         */
93
        DyePalette *restrict mDyePalettes[dyePalateSize];
94
};
95
96
#endif  // RESOURCES_DYE_DYE_H