Coverage Report

Created: 2025-10-10 06:46

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ogre/OgreMain/include/OgreCompositionTechnique.h
Line
Count
Source
1
/*
2
-----------------------------------------------------------------------------
3
This source file is part of OGRE
4
    (Object-oriented Graphics Rendering Engine)
5
For the latest info, see http://www.ogre3d.org/
6
7
Copyright (c) 2000-2014 Torus Knot Software Ltd
8
9
Permission is hereby granted, free of charge, to any person obtaining a copy
10
of this software and associated documentation files (the "Software"), to deal
11
in the Software without restriction, including without limitation the rights
12
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
copies of the Software, and to permit persons to whom the Software is
14
furnished to do so, subject to the following conditions:
15
16
The above copyright notice and this permission notice shall be included in
17
all copies or substantial portions of the Software.
18
19
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25
THE SOFTWARE.
26
-----------------------------------------------------------------------------
27
*/
28
#ifndef __CompositionTechnique_H__
29
#define __CompositionTechnique_H__
30
31
#include "OgrePrerequisites.h"
32
#include "OgrePixelFormat.h"
33
#include "OgreHeaderPrefix.h"
34
35
namespace Ogre {
36
    template <typename T> class VectorIterator;
37
38
    /** \addtogroup Core
39
    *  @{
40
    */
41
    /** \addtogroup Effects
42
    *  @{
43
    */
44
    /** Base composition technique, can be subclassed in plugins.
45
     */
46
    class _OgreExport CompositionTechnique : public CompositorInstAlloc
47
    {
48
    public:
49
        CompositionTechnique(Compositor *parent);
50
        virtual ~CompositionTechnique();
51
    
52
        //The scope of a texture defined by the compositor
53
        enum TextureScope { 
54
            //Local texture - only available to the compositor passes in this technique
55
            TS_LOCAL, 
56
            //Chain texture - available to the other compositors in the chain
57
            TS_CHAIN, 
58
            //Global texture - available to everyone in every scope
59
            TS_GLOBAL 
60
        };
61
62
        /// Local texture definition
63
        class TextureDefinition : public CompositorInstAlloc
64
        {
65
        public:
66
            String name;
67
            //Texture definition being a reference is determined by these two fields not being empty.
68
            String refCompName; //If a reference, the name of the compositor being referenced
69
            String refTexName;  //If a reference, the name of the texture in the compositor being referenced
70
            uint32 width;       // 0 means adapt to target width
71
            uint32 height;      // 0 means adapt to target height
72
            uint32 depth;       // only used for 2d_array textures
73
            TextureType type;   // either 2d, 2d_array or cubic
74
            float widthFactor;  // multiple of target width to use (if width = 0)
75
            float heightFactor; // multiple of target height to use (if height = 0)
76
            PixelFormatList formatList; // more than one means MRT
77
            uint8 fsaa;         // FSAA level; 1 = determine from main target (if render_scene), 0 = disable
78
            bool hwGammaWrite;  // Do sRGB gamma correction on write (only 8-bit per channel formats) 
79
            uint16 depthBufferId;//Depth Buffer's pool ID. (unrelated to "pool" variable below)
80
            bool pooled;        // whether to use pooled textures for this one
81
            TextureScope scope; // Which scope has access to this texture
82
83
            TextureDefinition() :width(0), height(0), depth(1), type(TEX_TYPE_2D), widthFactor(1.0f), heightFactor(1.0f),
84
0
                fsaa(1), hwGammaWrite(false), depthBufferId(1), pooled(false), scope(TS_LOCAL) {}
85
        };
86
        /// Typedefs for several iterators
87
        typedef std::vector<CompositionTargetPass *> TargetPasses;
88
        typedef VectorIterator<TargetPasses> TargetPassIterator;
89
        typedef std::vector<TextureDefinition*> TextureDefinitions;
90
        typedef VectorIterator<TextureDefinitions> TextureDefinitionIterator;
91
        
92
        /** Create a new local texture definition, and return a pointer to it.
93
            @param name     Name of the local texture
94
        */
95
        TextureDefinition *createTextureDefinition(const String &name);
96
        
97
        /** Remove and destroy a local texture definition.
98
        */
99
        void removeTextureDefinition(size_t idx);
100
        
101
        /** Get a local texture definition.
102
        */
103
0
        TextureDefinition *getTextureDefinition(size_t idx) const { return mTextureDefinitions.at(idx); }
104
        
105
        /** Get a local texture definition with a specific name.
106
        */
107
        TextureDefinition *getTextureDefinition(const String& name) const;
108
109
        /** Get the number of local texture definitions.*/
110
0
        size_t getNumTextureDefinitions() const { return mTextureDefinitions.size(); }
111
        
112
        /** Remove all Texture Definitions
113
        */
114
        void removeAllTextureDefinitions();
115
        
116
        /** Get the TextureDefinitions in this Technique. */
117
0
        const TextureDefinitions& getTextureDefinitions() const { return mTextureDefinitions; }
118
119
        /// @deprecated use getTextureDefinitions()
120
        OGRE_DEPRECATED TextureDefinitionIterator getTextureDefinitionIterator(void);
121
        
122
        /** Create a new target pass, and return a pointer to it.
123
        */
124
        CompositionTargetPass *createTargetPass();
125
        
126
        /** Remove a target pass. It will also be destroyed.
127
        */
128
        void removeTargetPass(size_t idx);
129
        
130
        /** Get a target pass.
131
        */
132
0
        CompositionTargetPass* getTargetPass(size_t idx) const { return mTargetPasses.at(idx); }
133
        
134
        /** Get the number of target passes. */
135
0
        size_t getNumTargetPasses() const { return mTargetPasses.size(); }
136
        
137
        /** Remove all target passes.
138
        */
139
        void removeAllTargetPasses();
140
        
141
        /** Get the TargetPasses in this Technique. */
142
0
        const TargetPasses& getTargetPasses() const { return mTargetPasses; }
143
144
        /// @deprecated use getTargetPasses()
145
        OGRE_DEPRECATED TargetPassIterator getTargetPassIterator(void);
146
        
147
        /** Get output (final) target pass
148
         */
149
0
        CompositionTargetPass *getOutputTargetPass() const { return mOutputTarget; }
150
        
151
        /** Determine if this technique is supported on the current rendering device. 
152
        @param allowTextureDegradation True to accept a reduction in texture depth
153
         */
154
        virtual bool isSupported(bool allowTextureDegradation);
155
        
156
        /** Assign a scheme name to this technique, used to switch between 
157
            multiple techniques by choice rather than for hardware compatibility.
158
        */
159
        virtual void setSchemeName(const String& schemeName);
160
        /** Get the scheme name assigned to this technique. */
161
0
        const String& getSchemeName() const { return mSchemeName; }
162
        
163
        /** Set the name of the compositor logic assigned to this technique.
164
            Instances of this technique will be auto-coupled with the matching logic.
165
        */
166
        void setCompositorLogicName(const String& compositorLogicName) 
167
0
            { mCompositorLogicName = compositorLogicName; }
168
        /** Get the compositor logic name assigned to this technique */
169
0
        const String& getCompositorLogicName() const { return mCompositorLogicName; }
170
171
        /** Get parent object */
172
        Compositor *getParent();
173
    private:
174
        /// Parent compositor
175
        Compositor *mParent;
176
        /// Local texture definitions
177
        TextureDefinitions mTextureDefinitions;
178
        
179
        /// Intermediate target passes
180
        TargetPasses mTargetPasses;
181
        /// Output target pass (can be only one)
182
        CompositionTargetPass *mOutputTarget;  
183
184
        /// Optional scheme name
185
        String mSchemeName;
186
        
187
        /// Optional compositor logic name
188
        String mCompositorLogicName;
189
190
    };
191
    /** @} */
192
    /** @} */
193
194
}
195
196
#include "OgreHeaderSuffix.h"
197
198
#endif