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