Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/editor/inspector/editor_preview_plugins.h
21103 views
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
#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
};
172
173