editor_preview_plugins.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /**************************************************************************/
  2. /* editor_preview_plugins.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 EDITOR_PREVIEW_PLUGINS_H
  31. #define EDITOR_PREVIEW_PLUGINS_H
  32. #include "editor/editor_resource_preview.h"
  33. #include "core/safe_refcount.h"
  34. void post_process_preview(Ref<Image> p_image);
  35. class EditorTexturePreviewPlugin : public EditorResourcePreviewGenerator {
  36. GDCLASS(EditorTexturePreviewPlugin, EditorResourcePreviewGenerator);
  37. public:
  38. virtual bool handles(const String &p_type) const;
  39. virtual bool generate_small_preview_automatically() const;
  40. virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const;
  41. EditorTexturePreviewPlugin();
  42. };
  43. class EditorImagePreviewPlugin : public EditorResourcePreviewGenerator {
  44. GDCLASS(EditorImagePreviewPlugin, EditorResourcePreviewGenerator);
  45. public:
  46. virtual bool handles(const String &p_type) const;
  47. virtual bool generate_small_preview_automatically() const;
  48. virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const;
  49. EditorImagePreviewPlugin();
  50. };
  51. class EditorBitmapPreviewPlugin : public EditorResourcePreviewGenerator {
  52. GDCLASS(EditorBitmapPreviewPlugin, EditorResourcePreviewGenerator);
  53. public:
  54. virtual bool handles(const String &p_type) const;
  55. virtual bool generate_small_preview_automatically() const;
  56. virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const;
  57. EditorBitmapPreviewPlugin();
  58. };
  59. class EditorPackedScenePreviewPlugin : public EditorResourcePreviewGenerator {
  60. public:
  61. virtual bool handles(const String &p_type) const;
  62. virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const;
  63. virtual Ref<Texture> generate_from_path(const String &p_path, const Size2 &p_size) const;
  64. EditorPackedScenePreviewPlugin();
  65. };
  66. class EditorMaterialPreviewPlugin : public EditorResourcePreviewGenerator {
  67. GDCLASS(EditorMaterialPreviewPlugin, EditorResourcePreviewGenerator);
  68. RID scenario;
  69. RID sphere;
  70. RID sphere_instance;
  71. RID viewport;
  72. RID viewport_texture;
  73. RID light;
  74. RID light_instance;
  75. RID light2;
  76. RID light_instance2;
  77. RID camera;
  78. mutable SafeFlag preview_done;
  79. void _preview_done(const Variant &p_udata);
  80. protected:
  81. static void _bind_methods();
  82. public:
  83. virtual bool handles(const String &p_type) const;
  84. virtual bool generate_small_preview_automatically() const;
  85. virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const;
  86. EditorMaterialPreviewPlugin();
  87. ~EditorMaterialPreviewPlugin();
  88. };
  89. class EditorScriptPreviewPlugin : public EditorResourcePreviewGenerator {
  90. public:
  91. virtual bool handles(const String &p_type) const;
  92. virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const;
  93. EditorScriptPreviewPlugin();
  94. };
  95. class EditorAudioStreamPreviewPlugin : public EditorResourcePreviewGenerator {
  96. public:
  97. virtual bool handles(const String &p_type) const;
  98. virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const;
  99. EditorAudioStreamPreviewPlugin();
  100. };
  101. class EditorMeshPreviewPlugin : public EditorResourcePreviewGenerator {
  102. GDCLASS(EditorMeshPreviewPlugin, EditorResourcePreviewGenerator);
  103. RID scenario;
  104. RID mesh_instance;
  105. RID viewport;
  106. RID viewport_texture;
  107. RID light;
  108. RID light_instance;
  109. RID light2;
  110. RID light_instance2;
  111. RID camera;
  112. mutable SafeFlag preview_done;
  113. void _preview_done(const Variant &p_udata);
  114. protected:
  115. static void _bind_methods();
  116. public:
  117. virtual bool handles(const String &p_type) const;
  118. virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const;
  119. EditorMeshPreviewPlugin();
  120. ~EditorMeshPreviewPlugin();
  121. };
  122. class EditorFontPreviewPlugin : public EditorResourcePreviewGenerator {
  123. GDCLASS(EditorFontPreviewPlugin, EditorResourcePreviewGenerator);
  124. RID viewport;
  125. RID viewport_texture;
  126. RID canvas;
  127. RID canvas_item;
  128. mutable SafeFlag preview_done;
  129. void _preview_done(const Variant &p_udata);
  130. protected:
  131. static void _bind_methods();
  132. public:
  133. virtual bool handles(const String &p_type) const;
  134. virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const;
  135. virtual Ref<Texture> generate_from_path(const String &p_path, const Size2 &p_size) const;
  136. EditorFontPreviewPlugin();
  137. ~EditorFontPreviewPlugin();
  138. };
  139. class EditorGradientPreviewPlugin : public EditorResourcePreviewGenerator {
  140. GDCLASS(EditorGradientPreviewPlugin, EditorResourcePreviewGenerator);
  141. public:
  142. virtual bool handles(const String &p_type) const;
  143. virtual bool generate_small_preview_automatically() const;
  144. virtual Ref<Texture> generate(const Ref<Resource> &p_from, const Size2 &p_size) const;
  145. EditorGradientPreviewPlugin();
  146. };
  147. #endif // EDITOR_PREVIEW_PLUGINS_H