| 1 | /**************************************************************************/ |
| 2 | /* texture_rd.h */ |
| 3 | /**************************************************************************/ |
| 4 | /* This file is part of: */ |
| 5 | /* GODOT ENGINE */ |
| 6 | /* https://godotengine.org */ |
| 7 | /**************************************************************************/ |
| 8 | /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ |
| 9 | /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ |
| 10 | /* */ |
| 11 | /* Permission is hereby granted, free of charge, to any person obtaining */ |
| 12 | /* a copy of this software and associated documentation files (the */ |
| 13 | /* "Software"), to deal in the Software without restriction, including */ |
| 14 | /* without limitation the rights to use, copy, modify, merge, publish, */ |
| 15 | /* distribute, sublicense, and/or sell copies of the Software, and to */ |
| 16 | /* permit persons to whom the Software is furnished to do so, subject to */ |
| 17 | /* the following conditions: */ |
| 18 | /* */ |
| 19 | /* The above copyright notice and this permission notice shall be */ |
| 20 | /* included in all copies or substantial portions of the Software. */ |
| 21 | /* */ |
| 22 | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ |
| 23 | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ |
| 24 | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ |
| 25 | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ |
| 26 | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ |
| 27 | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ |
| 28 | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ |
| 29 | /**************************************************************************/ |
| 30 | |
| 31 | #ifndef TEXTURE_RD_H |
| 32 | #define TEXTURE_RD_H |
| 33 | |
| 34 | // Note, these classes are part of the Rendering Device based renderer. |
| 35 | // They are included here to ensure the correct order of registration |
| 36 | // is performed. |
| 37 | // Once the renderer has been moved into a module, these classes should |
| 38 | // be moved as well. |
| 39 | |
| 40 | #include "scene/resources/texture.h" |
| 41 | |
| 42 | class Texture2DRD : public Texture2D { |
| 43 | GDCLASS(Texture2DRD, Texture2D) |
| 44 | |
| 45 | mutable RID texture_rid; |
| 46 | RID texture_rd_rid; |
| 47 | Size2i size; |
| 48 | |
| 49 | protected: |
| 50 | static void _bind_methods(); |
| 51 | |
| 52 | public: |
| 53 | virtual int get_width() const override; |
| 54 | virtual int get_height() const override; |
| 55 | virtual RID get_rid() const override; |
| 56 | virtual bool has_alpha() const override; |
| 57 | |
| 58 | virtual Ref<Image> get_image() const override; |
| 59 | |
| 60 | void set_texture_rd_rid(RID p_texture_rd_rid); |
| 61 | RID get_texture_rd_rid() const; |
| 62 | |
| 63 | Texture2DRD(); |
| 64 | ~Texture2DRD(); |
| 65 | }; |
| 66 | |
| 67 | class TextureLayeredRD : public TextureLayered { |
| 68 | GDCLASS(TextureLayeredRD, TextureLayered) |
| 69 | |
| 70 | LayeredType layer_type; |
| 71 | |
| 72 | mutable RID texture_rid; |
| 73 | RID texture_rd_rid; |
| 74 | |
| 75 | Image::Format image_format; |
| 76 | Size2i size; |
| 77 | uint32_t layers = 0; |
| 78 | uint32_t mipmaps = 0; |
| 79 | |
| 80 | protected: |
| 81 | static void _bind_methods(); |
| 82 | |
| 83 | public: |
| 84 | virtual Image::Format get_format() const override; |
| 85 | virtual LayeredType get_layered_type() const override; |
| 86 | virtual int get_width() const override; |
| 87 | virtual int get_height() const override; |
| 88 | virtual int get_layers() const override; |
| 89 | virtual bool has_mipmaps() const override; |
| 90 | virtual RID get_rid() const override; |
| 91 | |
| 92 | virtual Ref<Image> get_layer_data(int p_layer) const override; |
| 93 | |
| 94 | void set_texture_rd_rid(RID p_texture_rd_rid); |
| 95 | RID get_texture_rd_rid() const; |
| 96 | |
| 97 | TextureLayeredRD(LayeredType p_layer_type); |
| 98 | ~TextureLayeredRD(); |
| 99 | }; |
| 100 | |
| 101 | class Texture2DArrayRD : public TextureLayeredRD { |
| 102 | GDCLASS(Texture2DArrayRD, TextureLayeredRD) |
| 103 | |
| 104 | public: |
| 105 | Texture2DArrayRD() : |
| 106 | TextureLayeredRD(LAYERED_TYPE_2D_ARRAY) {} |
| 107 | }; |
| 108 | |
| 109 | class TextureCubemapRD : public TextureLayeredRD { |
| 110 | GDCLASS(TextureCubemapRD, TextureLayeredRD) |
| 111 | |
| 112 | public: |
| 113 | TextureCubemapRD() : |
| 114 | TextureLayeredRD(LAYERED_TYPE_CUBEMAP) {} |
| 115 | }; |
| 116 | |
| 117 | class TextureCubemapArrayRD : public TextureLayeredRD { |
| 118 | GDCLASS(TextureCubemapArrayRD, TextureLayeredRD) |
| 119 | |
| 120 | public: |
| 121 | TextureCubemapArrayRD() : |
| 122 | TextureLayeredRD(LAYERED_TYPE_CUBEMAP_ARRAY) {} |
| 123 | }; |
| 124 | |
| 125 | class Texture3DRD : public Texture3D { |
| 126 | GDCLASS(Texture3DRD, Texture3D) |
| 127 | |
| 128 | mutable RID texture_rid; |
| 129 | RID texture_rd_rid; |
| 130 | |
| 131 | Image::Format image_format; |
| 132 | Vector3i size; |
| 133 | uint32_t mipmaps = 0; |
| 134 | |
| 135 | protected: |
| 136 | static void _bind_methods(); |
| 137 | |
| 138 | public: |
| 139 | virtual Image::Format get_format() const override; |
| 140 | virtual int get_width() const override; |
| 141 | virtual int get_height() const override; |
| 142 | virtual int get_depth() const override; |
| 143 | virtual bool has_mipmaps() const override; |
| 144 | virtual RID get_rid() const override; |
| 145 | |
| 146 | void set_texture_rd_rid(RID p_texture_rd_rid); |
| 147 | RID get_texture_rd_rid() const; |
| 148 | |
| 149 | Texture3DRD(); |
| 150 | ~Texture3DRD(); |
| 151 | }; |
| 152 | |
| 153 | #endif // TEXTURE_RD_H |
| 154 | |