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-2020 Juan Linietsky, Ariel Manzur. */ 9 /* Copyright (c) 2014-2020 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 31 #ifndef EDITORPREVIEWPLUGINS_H 32 #define EDITORPREVIEWPLUGINS_H 33 34 #include "editor/editor_resource_preview.h" 35 36 void post_process_preview(Ref<Image> p_image); 37 38 class EditorTexturePreviewPlugin : public EditorResourcePreviewGenerator { 39 GDCLASS(EditorTexturePreviewPlugin, EditorResourcePreviewGenerator); 40 41 public: 42 virtual bool handles(const String &p_type) const; 43 virtual bool generate_small_preview_automatically() const; 44 virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const; 45 46 EditorTexturePreviewPlugin(); 47 }; 48 49 class EditorImagePreviewPlugin : public EditorResourcePreviewGenerator { 50 GDCLASS(EditorImagePreviewPlugin, EditorResourcePreviewGenerator); 51 52 public: 53 virtual bool handles(const String &p_type) const; 54 virtual bool generate_small_preview_automatically() const; 55 virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const; 56 57 EditorImagePreviewPlugin(); 58 }; 59 60 class EditorBitmapPreviewPlugin : public EditorResourcePreviewGenerator { 61 GDCLASS(EditorBitmapPreviewPlugin, EditorResourcePreviewGenerator); 62 63 public: 64 virtual bool handles(const String &p_type) const; 65 virtual bool generate_small_preview_automatically() const; 66 virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const; 67 68 EditorBitmapPreviewPlugin(); 69 }; 70 71 class EditorPackedScenePreviewPlugin : public EditorResourcePreviewGenerator { 72 73 public: 74 virtual bool handles(const String &p_type) const; 75 virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const; 76 virtual Ref<Texture> generate_from_path(const String &p_path, const Size2 &p_size) const; 77 78 EditorPackedScenePreviewPlugin(); 79 }; 80 81 class EditorMaterialPreviewPlugin : public EditorResourcePreviewGenerator { 82 83 GDCLASS(EditorMaterialPreviewPlugin, EditorResourcePreviewGenerator); 84 85 RID scenario; 86 RID sphere; 87 RID sphere_instance; 88 RID viewport; 89 RID viewport_texture; 90 RID light; 91 RID light_instance; 92 RID light2; 93 RID light_instance2; 94 RID camera; 95 mutable volatile bool preview_done; 96 97 void _preview_done(const Variant &p_udata); 98 99 protected: 100 static void _bind_methods(); 101 102 public: 103 virtual bool handles(const String &p_type) const; 104 virtual bool generate_small_preview_automatically() const; 105 virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const; 106 107 EditorMaterialPreviewPlugin(); 108 ~EditorMaterialPreviewPlugin(); 109 }; 110 111 class EditorScriptPreviewPlugin : public EditorResourcePreviewGenerator { 112 public: 113 virtual bool handles(const String &p_type) const; 114 virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const; 115 116 EditorScriptPreviewPlugin(); 117 }; 118 119 class EditorAudioStreamPreviewPlugin : public EditorResourcePreviewGenerator { 120 public: 121 virtual bool handles(const String &p_type) const; 122 virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const; 123 124 EditorAudioStreamPreviewPlugin(); 125 }; 126 127 class EditorMeshPreviewPlugin : public EditorResourcePreviewGenerator { 128 129 GDCLASS(EditorMeshPreviewPlugin, EditorResourcePreviewGenerator); 130 131 RID scenario; 132 RID mesh_instance; 133 RID viewport; 134 RID viewport_texture; 135 RID light; 136 RID light_instance; 137 RID light2; 138 RID light_instance2; 139 RID camera; 140 mutable volatile bool preview_done; 141 142 void _preview_done(const Variant &p_udata); 143 144 protected: 145 static void _bind_methods(); 146 147 public: 148 virtual bool handles(const String &p_type) const; 149 virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const; 150 151 EditorMeshPreviewPlugin(); 152 ~EditorMeshPreviewPlugin(); 153 }; 154 155 class EditorFontPreviewPlugin : public EditorResourcePreviewGenerator { 156 157 GDCLASS(EditorFontPreviewPlugin, EditorResourcePreviewGenerator); 158 159 RID viewport; 160 RID viewport_texture; 161 RID canvas; 162 RID canvas_item; 163 mutable volatile bool preview_done; 164 165 void _preview_done(const Variant &p_udata); 166 167 protected: 168 static void _bind_methods(); 169 170 public: 171 virtual bool handles(const String &p_type) const; 172 virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const; 173 virtual Ref<Texture> generate_from_path(const String &p_path, const Size2 &p_size) const; 174 175 EditorFontPreviewPlugin(); 176 ~EditorFontPreviewPlugin(); 177 }; 178 #endif // EDITORPREVIEWPLUGINS_H 179