Path: blob/master/editor/inspector/editor_preview_plugins.h
21103 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 "core/io/image.h"33#include "editor/inspector/editor_resource_preview.h"3435class ScriptLanguage;3637void post_process_preview(Ref<Image> p_image);3839class EditorTexturePreviewPlugin : public EditorResourcePreviewGenerator {40GDCLASS(EditorTexturePreviewPlugin, EditorResourcePreviewGenerator);4142public:43virtual bool handles(const String &p_type) const override;44virtual bool generate_small_preview_automatically() const override;45virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override;46};4748class EditorImagePreviewPlugin : public EditorResourcePreviewGenerator {49GDCLASS(EditorImagePreviewPlugin, EditorResourcePreviewGenerator);5051public:52virtual bool handles(const String &p_type) const override;53virtual bool generate_small_preview_automatically() const override;54virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override;55};5657class EditorBitmapPreviewPlugin : public EditorResourcePreviewGenerator {58GDCLASS(EditorBitmapPreviewPlugin, EditorResourcePreviewGenerator);5960public:61virtual bool handles(const String &p_type) const override;62virtual bool generate_small_preview_automatically() const override;63virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override;64};6566class EditorPackedScenePreviewPlugin : public EditorResourcePreviewGenerator {67GDCLASS(EditorPackedScenePreviewPlugin, EditorResourcePreviewGenerator);6869public:70virtual bool handles(const String &p_type) const override;71virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override;72virtual Ref<Texture2D> generate_from_path(const String &p_path, const Size2 &p_size, Dictionary &p_metadata) const override;73};7475class EditorMaterialPreviewPlugin : public EditorResourcePreviewGenerator {76GDCLASS(EditorMaterialPreviewPlugin, EditorResourcePreviewGenerator);7778RID scenario;79RID sphere;80RID sphere_instance;81RID viewport;82RID viewport_texture;83RID light;84RID light_instance;85RID light2;86RID light_instance2;87RID camera;88RID camera_attributes;89mutable DrawRequester draw_requester;9091public:92virtual bool handles(const String &p_type) const override;93virtual bool generate_small_preview_automatically() const override;94virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override;95virtual void abort() override;9697EditorMaterialPreviewPlugin();98~EditorMaterialPreviewPlugin();99};100101class EditorScriptPreviewPlugin : public EditorResourcePreviewGenerator {102GDCLASS(EditorScriptPreviewPlugin, EditorResourcePreviewGenerator);103104Ref<Texture2D> _generate_from_source_code(const ScriptLanguage *p_language, const String &p_source_code, const Size2 &p_size, Dictionary &p_metadata) const;105106public:107virtual bool handles(const String &p_type) const override;108virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override;109virtual Ref<Texture2D> generate_from_path(const String &p_path, const Size2 &p_size, Dictionary &p_metadata) const override;110};111112class EditorAudioStreamPreviewPlugin : public EditorResourcePreviewGenerator {113GDCLASS(EditorAudioStreamPreviewPlugin, EditorResourcePreviewGenerator);114115public:116virtual bool handles(const String &p_type) const override;117virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override;118};119120class EditorMeshPreviewPlugin : public EditorResourcePreviewGenerator {121GDCLASS(EditorMeshPreviewPlugin, EditorResourcePreviewGenerator);122123RID scenario;124RID mesh_instance;125RID viewport;126RID viewport_texture;127RID light;128RID light_instance;129RID light2;130RID light_instance2;131RID camera;132RID camera_attributes;133mutable DrawRequester draw_requester;134135public:136virtual bool handles(const String &p_type) const override;137virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override;138virtual void abort() override;139140EditorMeshPreviewPlugin();141~EditorMeshPreviewPlugin();142};143144class EditorFontPreviewPlugin : public EditorResourcePreviewGenerator {145GDCLASS(EditorFontPreviewPlugin, EditorResourcePreviewGenerator);146147RID viewport;148RID viewport_texture;149RID canvas;150RID canvas_item;151mutable DrawRequester draw_requester;152153public:154virtual bool handles(const String &p_type) const override;155virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override;156virtual Ref<Texture2D> generate_from_path(const String &p_path, const Size2 &p_size, Dictionary &p_metadata) const override;157virtual void abort() override;158159EditorFontPreviewPlugin();160~EditorFontPreviewPlugin();161};162163class EditorGradientPreviewPlugin : public EditorResourcePreviewGenerator {164GDCLASS(EditorGradientPreviewPlugin, EditorResourcePreviewGenerator);165166public:167virtual bool handles(const String &p_type) const override;168virtual bool generate_small_preview_automatically() const override;169virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size, Dictionary &p_metadata) const override;170};171172173