Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/editor/inspector/editor_preview_plugins.h
9898 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 "editor/inspector/editor_resource_preview.h"
34
35
class ScriptLanguage;
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
48
class EditorImagePreviewPlugin : public EditorResourcePreviewGenerator {
49
GDCLASS(EditorImagePreviewPlugin, EditorResourcePreviewGenerator);
50
51
public:
52
virtual bool handles(const String &p_type) const override;
53
virtual bool generate_small_preview_automatically() const override;
54
virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override;
55
};
56
57
class EditorBitmapPreviewPlugin : public EditorResourcePreviewGenerator {
58
GDCLASS(EditorBitmapPreviewPlugin, EditorResourcePreviewGenerator);
59
60
public:
61
virtual bool handles(const String &p_type) const override;
62
virtual bool generate_small_preview_automatically() const override;
63
virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override;
64
};
65
66
class EditorPackedScenePreviewPlugin : public EditorResourcePreviewGenerator {
67
GDCLASS(EditorPackedScenePreviewPlugin, EditorResourcePreviewGenerator);
68
69
public:
70
virtual bool handles(const String &p_type) const override;
71
virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override;
72
virtual Ref<Texture2D> generate_from_path(const String &p_path, const Size2 &p_size, Dictionary &p_metadata) const override;
73
};
74
75
class EditorMaterialPreviewPlugin : public EditorResourcePreviewGenerator {
76
GDCLASS(EditorMaterialPreviewPlugin, EditorResourcePreviewGenerator);
77
78
RID scenario;
79
RID sphere;
80
RID sphere_instance;
81
RID viewport;
82
RID viewport_texture;
83
RID light;
84
RID light_instance;
85
RID light2;
86
RID light_instance2;
87
RID camera;
88
RID camera_attributes;
89
mutable DrawRequester draw_requester;
90
91
public:
92
virtual bool handles(const String &p_type) const override;
93
virtual bool generate_small_preview_automatically() const override;
94
virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override;
95
virtual void abort() override;
96
97
EditorMaterialPreviewPlugin();
98
~EditorMaterialPreviewPlugin();
99
};
100
101
class EditorScriptPreviewPlugin : public EditorResourcePreviewGenerator {
102
GDCLASS(EditorScriptPreviewPlugin, EditorResourcePreviewGenerator);
103
104
Ref<Texture2D> _generate_from_source_code(const ScriptLanguage *p_language, const String &p_source_code, const Size2 &p_size, Dictionary &p_metadata) const;
105
106
public:
107
virtual bool handles(const String &p_type) const override;
108
virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override;
109
virtual Ref<Texture2D> generate_from_path(const String &p_path, const Size2 &p_size, Dictionary &p_metadata) const override;
110
};
111
112
class EditorAudioStreamPreviewPlugin : public EditorResourcePreviewGenerator {
113
GDCLASS(EditorAudioStreamPreviewPlugin, EditorResourcePreviewGenerator);
114
115
public:
116
virtual bool handles(const String &p_type) const override;
117
virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override;
118
};
119
120
class EditorMeshPreviewPlugin : public EditorResourcePreviewGenerator {
121
GDCLASS(EditorMeshPreviewPlugin, EditorResourcePreviewGenerator);
122
123
RID scenario;
124
RID mesh_instance;
125
RID viewport;
126
RID viewport_texture;
127
RID light;
128
RID light_instance;
129
RID light2;
130
RID light_instance2;
131
RID camera;
132
RID camera_attributes;
133
mutable DrawRequester draw_requester;
134
135
public:
136
virtual bool handles(const String &p_type) const override;
137
virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override;
138
virtual void abort() override;
139
140
EditorMeshPreviewPlugin();
141
~EditorMeshPreviewPlugin();
142
};
143
144
class EditorFontPreviewPlugin : public EditorResourcePreviewGenerator {
145
GDCLASS(EditorFontPreviewPlugin, EditorResourcePreviewGenerator);
146
147
RID viewport;
148
RID viewport_texture;
149
RID canvas;
150
RID canvas_item;
151
mutable DrawRequester draw_requester;
152
153
public:
154
virtual bool handles(const String &p_type) const override;
155
virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override;
156
virtual Ref<Texture2D> generate_from_path(const String &p_path, const Size2 &p_size, Dictionary &p_metadata) const override;
157
virtual void abort() override;
158
159
EditorFontPreviewPlugin();
160
~EditorFontPreviewPlugin();
161
};
162
163
class EditorGradientPreviewPlugin : public EditorResourcePreviewGenerator {
164
GDCLASS(EditorGradientPreviewPlugin, EditorResourcePreviewGenerator);
165
166
public:
167
virtual bool handles(const String &p_type) const override;
168
virtual bool generate_small_preview_automatically() const override;
169
virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override;
170
};
171
172