| 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 | |
| 31 | #ifndef EDITOR_PREVIEW_PLUGINS_H |
| 32 | #define EDITOR_PREVIEW_PLUGINS_H |
| 33 | |
| 34 | #include "core/templates/safe_refcount.h" |
| 35 | #include "editor/editor_resource_preview.h" |
| 36 | |
| 37 | void post_process_preview(Ref<Image> p_image); |
| 38 | |
| 39 | class EditorTexturePreviewPlugin : public EditorResourcePreviewGenerator { |
| 40 | GDCLASS(EditorTexturePreviewPlugin, EditorResourcePreviewGenerator); |
| 41 | |
| 42 | public: |
| 43 | virtual bool handles(const String &p_type) const override; |
| 44 | virtual bool generate_small_preview_automatically() const override; |
| 45 | virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override; |
| 46 | |
| 47 | EditorTexturePreviewPlugin(); |
| 48 | }; |
| 49 | |
| 50 | class EditorImagePreviewPlugin : public EditorResourcePreviewGenerator { |
| 51 | GDCLASS(EditorImagePreviewPlugin, EditorResourcePreviewGenerator); |
| 52 | |
| 53 | public: |
| 54 | virtual bool handles(const String &p_type) const override; |
| 55 | virtual bool generate_small_preview_automatically() const override; |
| 56 | virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override; |
| 57 | |
| 58 | EditorImagePreviewPlugin(); |
| 59 | }; |
| 60 | |
| 61 | class EditorBitmapPreviewPlugin : public EditorResourcePreviewGenerator { |
| 62 | GDCLASS(EditorBitmapPreviewPlugin, EditorResourcePreviewGenerator); |
| 63 | |
| 64 | public: |
| 65 | virtual bool handles(const String &p_type) const override; |
| 66 | virtual bool generate_small_preview_automatically() const override; |
| 67 | virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override; |
| 68 | |
| 69 | EditorBitmapPreviewPlugin(); |
| 70 | }; |
| 71 | |
| 72 | class EditorPackedScenePreviewPlugin : public EditorResourcePreviewGenerator { |
| 73 | GDCLASS(EditorPackedScenePreviewPlugin, EditorResourcePreviewGenerator); |
| 74 | |
| 75 | public: |
| 76 | virtual bool handles(const String &p_type) const override; |
| 77 | virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override; |
| 78 | virtual Ref<Texture2D> generate_from_path(const String &p_path, const Size2 &p_size, Dictionary &p_metadata) const override; |
| 79 | |
| 80 | EditorPackedScenePreviewPlugin(); |
| 81 | }; |
| 82 | |
| 83 | class EditorMaterialPreviewPlugin : public EditorResourcePreviewGenerator { |
| 84 | GDCLASS(EditorMaterialPreviewPlugin, EditorResourcePreviewGenerator); |
| 85 | |
| 86 | RID scenario; |
| 87 | RID sphere; |
| 88 | RID sphere_instance; |
| 89 | RID viewport; |
| 90 | RID viewport_texture; |
| 91 | RID light; |
| 92 | RID light_instance; |
| 93 | RID light2; |
| 94 | RID light_instance2; |
| 95 | RID camera; |
| 96 | RID camera_attributes; |
| 97 | Semaphore preview_done; |
| 98 | |
| 99 | void _generate_frame_started(); |
| 100 | void _preview_done(); |
| 101 | |
| 102 | public: |
| 103 | virtual bool handles(const String &p_type) const override; |
| 104 | virtual bool generate_small_preview_automatically() const override; |
| 105 | virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override; |
| 106 | |
| 107 | EditorMaterialPreviewPlugin(); |
| 108 | ~EditorMaterialPreviewPlugin(); |
| 109 | }; |
| 110 | |
| 111 | class EditorScriptPreviewPlugin : public EditorResourcePreviewGenerator { |
| 112 | GDCLASS(EditorScriptPreviewPlugin, EditorResourcePreviewGenerator); |
| 113 | |
| 114 | public: |
| 115 | virtual bool handles(const String &p_type) const override; |
| 116 | virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override; |
| 117 | |
| 118 | EditorScriptPreviewPlugin(); |
| 119 | }; |
| 120 | |
| 121 | class EditorAudioStreamPreviewPlugin : public EditorResourcePreviewGenerator { |
| 122 | GDCLASS(EditorAudioStreamPreviewPlugin, EditorResourcePreviewGenerator); |
| 123 | |
| 124 | public: |
| 125 | virtual bool handles(const String &p_type) const override; |
| 126 | virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override; |
| 127 | |
| 128 | EditorAudioStreamPreviewPlugin(); |
| 129 | }; |
| 130 | |
| 131 | class EditorMeshPreviewPlugin : public EditorResourcePreviewGenerator { |
| 132 | GDCLASS(EditorMeshPreviewPlugin, EditorResourcePreviewGenerator); |
| 133 | |
| 134 | RID scenario; |
| 135 | RID mesh_instance; |
| 136 | RID viewport; |
| 137 | RID viewport_texture; |
| 138 | RID light; |
| 139 | RID light_instance; |
| 140 | RID light2; |
| 141 | RID light_instance2; |
| 142 | RID camera; |
| 143 | RID camera_attributes; |
| 144 | Semaphore preview_done; |
| 145 | |
| 146 | void _generate_frame_started(); |
| 147 | void _preview_done(); |
| 148 | |
| 149 | public: |
| 150 | virtual bool handles(const String &p_type) const override; |
| 151 | virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override; |
| 152 | |
| 153 | EditorMeshPreviewPlugin(); |
| 154 | ~EditorMeshPreviewPlugin(); |
| 155 | }; |
| 156 | |
| 157 | class EditorFontPreviewPlugin : public EditorResourcePreviewGenerator { |
| 158 | GDCLASS(EditorFontPreviewPlugin, EditorResourcePreviewGenerator); |
| 159 | |
| 160 | RID viewport; |
| 161 | RID viewport_texture; |
| 162 | RID canvas; |
| 163 | RID canvas_item; |
| 164 | Semaphore preview_done; |
| 165 | |
| 166 | void _generate_frame_started(); |
| 167 | void _preview_done(); |
| 168 | |
| 169 | public: |
| 170 | virtual bool handles(const String &p_type) const override; |
| 171 | virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override; |
| 172 | virtual Ref<Texture2D> generate_from_path(const String &p_path, const Size2 &p_size, Dictionary &p_metadata) const override; |
| 173 | |
| 174 | EditorFontPreviewPlugin(); |
| 175 | ~EditorFontPreviewPlugin(); |
| 176 | }; |
| 177 | |
| 178 | class EditorTileMapPatternPreviewPlugin : public EditorResourcePreviewGenerator { |
| 179 | GDCLASS(EditorTileMapPatternPreviewPlugin, EditorResourcePreviewGenerator); |
| 180 | |
| 181 | Semaphore preview_done; |
| 182 | |
| 183 | void _generate_frame_started(); |
| 184 | void _preview_done(); |
| 185 | |
| 186 | public: |
| 187 | virtual bool handles(const String &p_type) const override; |
| 188 | virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override; |
| 189 | |
| 190 | EditorTileMapPatternPreviewPlugin(); |
| 191 | ~EditorTileMapPatternPreviewPlugin(); |
| 192 | }; |
| 193 | |
| 194 | class EditorGradientPreviewPlugin : public EditorResourcePreviewGenerator { |
| 195 | GDCLASS(EditorGradientPreviewPlugin, EditorResourcePreviewGenerator); |
| 196 | |
| 197 | public: |
| 198 | virtual bool handles(const String &p_type) const override; |
| 199 | virtual bool generate_small_preview_automatically() const override; |
| 200 | virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override; |
| 201 | |
| 202 | EditorGradientPreviewPlugin(); |
| 203 | }; |
| 204 | |
| 205 | #endif // EDITOR_PREVIEW_PLUGINS_H |
| 206 | |