GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/resources/image/subimage.h Lines: 0 2 0.0 %
Date: 2017-11-29 Branches: 0 0 0.0 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2004-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_SUBIMAGE_H
24
#define RESOURCES_SUBIMAGE_H
25
26
#include "localconsts.h"
27
28
#include "resources/image/image.h"
29
30
/**
31
 * A clipped version of a larger image.
32
 */
33
class SubImage final : public Image
34
{
35
    public:
36
        /**
37
         * Constructor.
38
         */
39
#ifdef USE_SDL2
40
        SubImage(Image *const parent, SDL_Texture *const image,
41
                 const int x, const int y, const int width, const int height);
42
#endif  // USE_SDL2
43
44
        SubImage(Image *const parent, SDL_Surface *const image,
45
                 const int x, const int y, const int width, const int height);
46
#ifdef USE_OPENGL
47
        SubImage(Image *const parent, const GLuint image,
48
                 const int x, const int y, const int width, const int height,
49
                 const int texWidth, const int textHeight);
50
#endif  // USE_OPENGL
51
52
        A_DELETE_COPY(SubImage)
53
54
        /**
55
         * Destructor.
56
         */
57
        ~SubImage();
58
59
        /**
60
         * Creates a new image with the desired clipping rectangle.
61
         *
62
         * @return <code>NULL</code> if creation failed and a valid
63
         *         image otherwise.
64
         */
65
        Image *getSubImage(const int x, const int y,
66
                           const int width,
67
                           const int height) override final A_WARN_UNUSED;
68
69
        ImageTypeT getType() const noexcept2 override final
70
        { return ImageType::SubImage; }
71
72
        int calcMemoryLocal() const override;
73
74
#ifdef USE_OPENGL
75
        void decRef() override final;
76
#endif  // USE_OPENGL
77
78
        SDL_Rect mInternalBounds;
79
80
    private:
81
        Image *mParent;
82
};
83
84
#endif  // RESOURCES_SUBIMAGE_H