| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "core/io/image.h" |
| 34 |
#include "editor/inspector/editor_resource_preview.h" |
| 35 |
|
| 36 |
class ScriptLanguage; |
| 37 |
|
| 38 |
void post_process_preview(Ref<Image> p_image); |
| 39 |
|
| 40 |
class EditorTexturePreviewPlugin : public EditorResourcePreviewGenerator { |
| 41 |
GDCLASS(EditorTexturePreviewPlugin, EditorResourcePreviewGenerator); |
| 42 |
|
| 43 |
public: |
| 44 |
virtual bool handles(const String &p_type) const override; |
| 45 |
virtual bool generate_small_preview_automatically() const override; |
| 46 |
virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override; |
| 47 |
}; |
| 48 |
|
| 49 |
class EditorImagePreviewPlugin : public EditorResourcePreviewGenerator { |
| 50 |
GDCLASS(EditorImagePreviewPlugin, EditorResourcePreviewGenerator); |
| 51 |
|
| 52 |
public: |
| 53 |
virtual bool handles(const String &p_type) const override; |
| 54 |
virtual bool generate_small_preview_automatically() const override; |
| 55 |
virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override; |
| 56 |
}; |
| 57 |
|
| 58 |
class EditorBitmapPreviewPlugin : public EditorResourcePreviewGenerator { |
| 59 |
GDCLASS(EditorBitmapPreviewPlugin, EditorResourcePreviewGenerator); |
| 60 |
|
| 61 |
public: |
| 62 |
virtual bool handles(const String &p_type) const override; |
| 63 |
virtual bool generate_small_preview_automatically() const override; |
| 64 |
virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override; |
| 65 |
}; |
| 66 |
|
| 67 |
class EditorPackedScenePreviewPlugin : public EditorResourcePreviewGenerator { |
| 68 |
GDCLASS(EditorPackedScenePreviewPlugin, EditorResourcePreviewGenerator); |
| 69 |
|
| 70 |
public: |
| 71 |
virtual bool handles(const String &p_type) const override; |
| 72 |
virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override; |
| 73 |
virtual Ref<Texture2D> generate_from_path(const String &p_path, const Size2 &p_size, Dictionary &p_metadata) const override; |
| 74 |
}; |
| 75 |
|
| 76 |
class EditorMaterialPreviewPlugin : public EditorResourcePreviewGenerator { |
| 77 |
GDCLASS(EditorMaterialPreviewPlugin, EditorResourcePreviewGenerator); |
| 78 |
|
| 79 |
RID scenario; |
| 80 |
RID sphere; |
| 81 |
RID sphere_instance; |
| 82 |
RID viewport; |
| 83 |
RID viewport_texture; |
| 84 |
RID light; |
| 85 |
RID light_instance; |
| 86 |
RID light2; |
| 87 |
RID light_instance2; |
| 88 |
RID camera; |
| 89 |
RID camera_attributes; |
| 90 |
mutable DrawRequester draw_requester; |
| 91 |
|
| 92 |
public: |
| 93 |
virtual bool handles(const String &p_type) const override; |
| 94 |
virtual bool generate_small_preview_automatically() const override; |
| 95 |
virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override; |
| 96 |
virtual void abort() override; |
| 97 |
|
| 98 |
EditorMaterialPreviewPlugin(); |
| 99 |
~EditorMaterialPreviewPlugin(); |
| 100 |
}; |
| 101 |
|
| 102 |
class EditorScriptPreviewPlugin : public EditorResourcePreviewGenerator { |
| 103 |
GDCLASS(EditorScriptPreviewPlugin, EditorResourcePreviewGenerator); |
| 104 |
|
| 105 |
Ref<Texture2D> _generate_from_source_code(const ScriptLanguage *p_language, const String &p_source_code, const Size2 &p_size, Dictionary &p_metadata) const; |
| 106 |
|
| 107 |
public: |
| 108 |
virtual bool handles(const String &p_type) const override; |
| 109 |
virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override; |
| 110 |
virtual Ref<Texture2D> generate_from_path(const String &p_path, const Size2 &p_size, Dictionary &p_metadata) const override; |
| 111 |
}; |
| 112 |
|
| 113 |
class EditorAudioStreamPreviewPlugin : public EditorResourcePreviewGenerator { |
| 114 |
GDCLASS(EditorAudioStreamPreviewPlugin, EditorResourcePreviewGenerator); |
| 115 |
|
| 116 |
public: |
| 117 |
virtual bool handles(const String &p_type) const override; |
| 118 |
virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override; |
| 119 |
}; |
| 120 |
|
| 121 |
class EditorMeshPreviewPlugin : public EditorResourcePreviewGenerator { |
| 122 |
GDCLASS(EditorMeshPreviewPlugin, EditorResourcePreviewGenerator); |
| 123 |
|
| 124 |
RID scenario; |
| 125 |
RID mesh_instance; |
| 126 |
RID viewport; |
| 127 |
RID viewport_texture; |
| 128 |
RID light; |
| 129 |
RID light_instance; |
| 130 |
RID light2; |
| 131 |
RID light_instance2; |
| 132 |
RID camera; |
| 133 |
RID camera_attributes; |
| 134 |
mutable DrawRequester draw_requester; |
| 135 |
|
| 136 |
public: |
| 137 |
virtual bool handles(const String &p_type) const override; |
| 138 |
virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override; |
| 139 |
virtual void abort() override; |
| 140 |
|
| 141 |
EditorMeshPreviewPlugin(); |
| 142 |
~EditorMeshPreviewPlugin(); |
| 143 |
}; |
| 144 |
|
| 145 |
class EditorFontPreviewPlugin : public EditorResourcePreviewGenerator { |
| 146 |
GDCLASS(EditorFontPreviewPlugin, EditorResourcePreviewGenerator); |
| 147 |
|
| 148 |
RID viewport; |
| 149 |
RID viewport_texture; |
| 150 |
RID canvas; |
| 151 |
RID canvas_item; |
| 152 |
mutable DrawRequester draw_requester; |
| 153 |
|
| 154 |
public: |
| 155 |
virtual bool handles(const String &p_type) const override; |
| 156 |
virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override; |
| 157 |
virtual Ref<Texture2D> generate_from_path(const String &p_path, const Size2 &p_size, Dictionary &p_metadata) const override; |
| 158 |
virtual void abort() override; |
| 159 |
|
| 160 |
EditorFontPreviewPlugin(); |
| 161 |
~EditorFontPreviewPlugin(); |
| 162 |
}; |
| 163 |
|
| 164 |
class EditorGradientPreviewPlugin : public EditorResourcePreviewGenerator { |
| 165 |
GDCLASS(EditorGradientPreviewPlugin, EditorResourcePreviewGenerator); |
| 166 |
|
| 167 |
public: |
| 168 |
virtual bool handles(const String &p_type) const override; |
| 169 |
virtual bool generate_small_preview_automatically() const override; |
| 170 |
virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override; |
| 171 |
}; |