editor_preview_plugins.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*************************************************************************/
  2. /* editor_preview_plugins.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
  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 EDITORPREVIEWPLUGINS_H
  31. #define EDITORPREVIEWPLUGINS_H
  32. #include "editor/editor_resource_preview.h"
  33. void post_process_preview(Ref<Image> p_image);
  34. class EditorTexturePreviewPlugin : public EditorResourcePreviewGenerator {
  35. GDCLASS(EditorTexturePreviewPlugin, EditorResourcePreviewGenerator)
  36. public:
  37. virtual bool handles(const String &p_type) const;
  38. virtual bool should_generate_small_preview() const;
  39. virtual Ref<Texture> generate(const RES &p_from, const Size2 p_size) const;
  40. EditorTexturePreviewPlugin();
  41. };
  42. class EditorImagePreviewPlugin : public EditorResourcePreviewGenerator {
  43. GDCLASS(EditorImagePreviewPlugin, EditorResourcePreviewGenerator)
  44. public:
  45. virtual bool handles(const String &p_type) const;
  46. virtual bool should_generate_small_preview() const;
  47. virtual Ref<Texture> generate(const RES &p_from, const Size2 p_size) const;
  48. EditorImagePreviewPlugin();
  49. };
  50. class EditorBitmapPreviewPlugin : public EditorResourcePreviewGenerator {
  51. GDCLASS(EditorBitmapPreviewPlugin, EditorResourcePreviewGenerator)
  52. public:
  53. virtual bool handles(const String &p_type) const;
  54. virtual bool should_generate_small_preview() const;
  55. virtual Ref<Texture> generate(const RES &p_from, const Size2 p_size) const;
  56. EditorBitmapPreviewPlugin();
  57. };
  58. class EditorPackedScenePreviewPlugin : public EditorResourcePreviewGenerator {
  59. public:
  60. virtual bool handles(const String &p_type) const;
  61. virtual Ref<Texture> generate(const RES &p_from, const Size2 p_size) const;
  62. virtual Ref<Texture> generate_from_path(const String &p_path, const Size2 p_size) const;
  63. EditorPackedScenePreviewPlugin();
  64. };
  65. class EditorMaterialPreviewPlugin : public EditorResourcePreviewGenerator {
  66. GDCLASS(EditorMaterialPreviewPlugin, EditorResourcePreviewGenerator)
  67. RID scenario;
  68. RID sphere;
  69. RID sphere_instance;
  70. RID viewport;
  71. RID viewport_texture;
  72. RID light;
  73. RID light_instance;
  74. RID light2;
  75. RID light_instance2;
  76. RID camera;
  77. mutable volatile bool preview_done;
  78. void _preview_done(const Variant &p_udata);
  79. protected:
  80. static void _bind_methods();
  81. public:
  82. virtual bool handles(const String &p_type) const;
  83. virtual bool should_generate_small_preview() const;
  84. virtual Ref<Texture> generate(const RES &p_from, const Size2 p_size) const;
  85. EditorMaterialPreviewPlugin();
  86. ~EditorMaterialPreviewPlugin();
  87. };
  88. class EditorScriptPreviewPlugin : public EditorResourcePreviewGenerator {
  89. public:
  90. virtual bool handles(const String &p_type) const;
  91. virtual Ref<Texture> generate(const RES &p_from, const Size2 p_size) const;
  92. EditorScriptPreviewPlugin();
  93. };
  94. class EditorAudioStreamPreviewPlugin : public EditorResourcePreviewGenerator {
  95. public:
  96. virtual bool handles(const String &p_type) const;
  97. virtual Ref<Texture> generate(const RES &p_from, const Size2 p_size) const;
  98. EditorAudioStreamPreviewPlugin();
  99. };
  100. class EditorMeshPreviewPlugin : public EditorResourcePreviewGenerator {
  101. GDCLASS(EditorMeshPreviewPlugin, EditorResourcePreviewGenerator)
  102. RID scenario;
  103. RID mesh_instance;
  104. RID viewport;
  105. RID viewport_texture;
  106. RID light;
  107. RID light_instance;
  108. RID light2;
  109. RID light_instance2;
  110. RID camera;
  111. mutable volatile bool preview_done;
  112. void _preview_done(const Variant &p_udata);
  113. protected:
  114. static void _bind_methods();
  115. public:
  116. virtual bool handles(const String &p_type) const;
  117. virtual Ref<Texture> generate(const RES &p_from, const Size2 p_size) const;
  118. EditorMeshPreviewPlugin();
  119. ~EditorMeshPreviewPlugin();
  120. };
  121. class EditorFontPreviewPlugin : public EditorResourcePreviewGenerator {
  122. GDCLASS(EditorFontPreviewPlugin, EditorResourcePreviewGenerator)
  123. RID viewport;
  124. RID viewport_texture;
  125. RID canvas;
  126. RID canvas_item;
  127. mutable volatile bool preview_done;
  128. void _preview_done(const Variant &p_udata);
  129. protected:
  130. static void _bind_methods();
  131. public:
  132. virtual bool handles(const String &p_type) const;
  133. virtual Ref<Texture> generate(const RES &p_from, const Size2 p_size) const;
  134. virtual Ref<Texture> generate_from_path(const String &p_path, const Size2 p_size) const;
  135. EditorFontPreviewPlugin();
  136. ~EditorFontPreviewPlugin();
  137. };
  138. #endif // EDITORPREVIEWPLUGINS_H