texture_rd.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. #ifndef TEXTURE_RD_H
  31. #define TEXTURE_RD_H
  32. // Note, these classes are part of the Rendering Device based renderer.
  33. // They are included here to ensure the correct order of registration
  34. // is performed.
  35. // Once the renderer has been moved into a module, these classes should
  36. // be moved as well.
  37. #include "scene/resources/texture.h"
  38. class Texture2DRD : public Texture2D {
  39. GDCLASS(Texture2DRD, Texture2D)
  40. mutable RID texture_rid;
  41. RID texture_rd_rid;
  42. Size2i size;
  43. protected:
  44. static void _bind_methods();
  45. public:
  46. virtual int get_width() const override;
  47. virtual int get_height() const override;
  48. virtual RID get_rid() const override;
  49. virtual bool has_alpha() const override;
  50. virtual Ref<Image> get_image() const override;
  51. void set_texture_rd_rid(RID p_texture_rd_rid);
  52. RID get_texture_rd_rid() const;
  53. // Internal function that should only be called from the rendering thread.
  54. void _set_texture_rd_rid(RID p_texture_rd_rid);
  55. Texture2DRD();
  56. ~Texture2DRD();
  57. };
  58. class TextureLayeredRD : public TextureLayered {
  59. GDCLASS(TextureLayeredRD, TextureLayered)
  60. LayeredType layer_type;
  61. mutable RID texture_rid;
  62. RID texture_rd_rid;
  63. Image::Format image_format;
  64. Size2i size;
  65. uint32_t layers = 0;
  66. uint32_t mipmaps = 0;
  67. protected:
  68. static void _bind_methods();
  69. public:
  70. virtual Image::Format get_format() const override;
  71. virtual LayeredType get_layered_type() const override;
  72. virtual int get_width() const override;
  73. virtual int get_height() const override;
  74. virtual int get_layers() const override;
  75. virtual bool has_mipmaps() const override;
  76. virtual RID get_rid() const override;
  77. virtual Ref<Image> get_layer_data(int p_layer) const override;
  78. void set_texture_rd_rid(RID p_texture_rd_rid);
  79. RID get_texture_rd_rid() const;
  80. // Internal function that should only be called from the rendering thread.
  81. void _set_texture_rd_rid(RID p_texture_rd_rid);
  82. TextureLayeredRD(LayeredType p_layer_type);
  83. ~TextureLayeredRD();
  84. };
  85. class Texture2DArrayRD : public TextureLayeredRD {
  86. GDCLASS(Texture2DArrayRD, TextureLayeredRD)
  87. public:
  88. Texture2DArrayRD() :
  89. TextureLayeredRD(LAYERED_TYPE_2D_ARRAY) {}
  90. };
  91. class TextureCubemapRD : public TextureLayeredRD {
  92. GDCLASS(TextureCubemapRD, TextureLayeredRD)
  93. public:
  94. TextureCubemapRD() :
  95. TextureLayeredRD(LAYERED_TYPE_CUBEMAP) {}
  96. };
  97. class TextureCubemapArrayRD : public TextureLayeredRD {
  98. GDCLASS(TextureCubemapArrayRD, TextureLayeredRD)
  99. public:
  100. TextureCubemapArrayRD() :
  101. TextureLayeredRD(LAYERED_TYPE_CUBEMAP_ARRAY) {}
  102. };
  103. class Texture3DRD : public Texture3D {
  104. GDCLASS(Texture3DRD, Texture3D)
  105. mutable RID texture_rid;
  106. RID texture_rd_rid;
  107. Image::Format image_format;
  108. Vector3i size;
  109. uint32_t mipmaps = 0;
  110. protected:
  111. static void _bind_methods();
  112. public:
  113. virtual Image::Format get_format() const override;
  114. virtual int get_width() const override;
  115. virtual int get_height() const override;
  116. virtual int get_depth() const override;
  117. virtual bool has_mipmaps() const override;
  118. virtual RID get_rid() const override;
  119. void set_texture_rd_rid(RID p_texture_rd_rid);
  120. RID get_texture_rd_rid() const;
  121. // Internal function that should only be called from the rendering thread.
  122. void _set_texture_rd_rid(RID p_texture_rd_rid);
  123. Texture3DRD();
  124. ~Texture3DRD();
  125. };
  126. #endif // TEXTURE_RD_H