Path: blob/master/editor/inspector/editor_preview_plugins.h
9898 views
/**************************************************************************/1/* editor_preview_plugins.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "editor/inspector/editor_resource_preview.h"3334class ScriptLanguage;3536void post_process_preview(Ref<Image> p_image);3738class EditorTexturePreviewPlugin : public EditorResourcePreviewGenerator {39GDCLASS(EditorTexturePreviewPlugin, EditorResourcePreviewGenerator);4041public:42virtual bool handles(const String &p_type) const override;43virtual bool generate_small_preview_automatically() const override;44virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override;45};4647class EditorImagePreviewPlugin : public EditorResourcePreviewGenerator {48GDCLASS(EditorImagePreviewPlugin, EditorResourcePreviewGenerator);4950public:51virtual bool handles(const String &p_type) const override;52virtual bool generate_small_preview_automatically() const override;53virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override;54};5556class EditorBitmapPreviewPlugin : public EditorResourcePreviewGenerator {57GDCLASS(EditorBitmapPreviewPlugin, EditorResourcePreviewGenerator);5859public:60virtual bool handles(const String &p_type) const override;61virtual bool generate_small_preview_automatically() const override;62virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override;63};6465class EditorPackedScenePreviewPlugin : public EditorResourcePreviewGenerator {66GDCLASS(EditorPackedScenePreviewPlugin, EditorResourcePreviewGenerator);6768public:69virtual bool handles(const String &p_type) const override;70virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override;71virtual Ref<Texture2D> generate_from_path(const String &p_path, const Size2 &p_size, Dictionary &p_metadata) const override;72};7374class EditorMaterialPreviewPlugin : public EditorResourcePreviewGenerator {75GDCLASS(EditorMaterialPreviewPlugin, EditorResourcePreviewGenerator);7677RID scenario;78RID sphere;79RID sphere_instance;80RID viewport;81RID viewport_texture;82RID light;83RID light_instance;84RID light2;85RID light_instance2;86RID camera;87RID camera_attributes;88mutable DrawRequester draw_requester;8990public:91virtual bool handles(const String &p_type) const override;92virtual bool generate_small_preview_automatically() const override;93virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override;94virtual void abort() override;9596EditorMaterialPreviewPlugin();97~EditorMaterialPreviewPlugin();98};99100class EditorScriptPreviewPlugin : public EditorResourcePreviewGenerator {101GDCLASS(EditorScriptPreviewPlugin, EditorResourcePreviewGenerator);102103Ref<Texture2D> _generate_from_source_code(const ScriptLanguage *p_language, const String &p_source_code, const Size2 &p_size, Dictionary &p_metadata) const;104105public:106virtual bool handles(const String &p_type) const override;107virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override;108virtual Ref<Texture2D> generate_from_path(const String &p_path, const Size2 &p_size, Dictionary &p_metadata) const override;109};110111class EditorAudioStreamPreviewPlugin : public EditorResourcePreviewGenerator {112GDCLASS(EditorAudioStreamPreviewPlugin, EditorResourcePreviewGenerator);113114public:115virtual bool handles(const String &p_type) const override;116virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override;117};118119class EditorMeshPreviewPlugin : public EditorResourcePreviewGenerator {120GDCLASS(EditorMeshPreviewPlugin, EditorResourcePreviewGenerator);121122RID scenario;123RID mesh_instance;124RID viewport;125RID viewport_texture;126RID light;127RID light_instance;128RID light2;129RID light_instance2;130RID camera;131RID camera_attributes;132mutable DrawRequester draw_requester;133134public:135virtual bool handles(const String &p_type) const override;136virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override;137virtual void abort() override;138139EditorMeshPreviewPlugin();140~EditorMeshPreviewPlugin();141};142143class EditorFontPreviewPlugin : public EditorResourcePreviewGenerator {144GDCLASS(EditorFontPreviewPlugin, EditorResourcePreviewGenerator);145146RID viewport;147RID viewport_texture;148RID canvas;149RID canvas_item;150mutable DrawRequester draw_requester;151152public:153virtual bool handles(const String &p_type) const override;154virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override;155virtual Ref<Texture2D> generate_from_path(const String &p_path, const Size2 &p_size, Dictionary &p_metadata) const override;156virtual void abort() override;157158EditorFontPreviewPlugin();159~EditorFontPreviewPlugin();160};161162class EditorGradientPreviewPlugin : public EditorResourcePreviewGenerator {163GDCLASS(EditorGradientPreviewPlugin, EditorResourcePreviewGenerator);164165public:166virtual bool handles(const String &p_type) const override;167virtual bool generate_small_preview_automatically() const override;168virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override;169};170171172