Texture refactor

-Texture renamed to Texture2D
-TextureLayered as base now inherits 2Darray, cubemap and cubemap array
-Removed all references to flags in textures (they will go in the shader)
-Texture3D gone for now (will come back later done properly)
-Create base rasterizer for RenderDevice, RasterizerRD
This commit is contained in:
Juan Linietsky 2019-06-11 15:43:37 -03:00
parent 9ffe57a10e
commit 3f335ce3d4
287 changed files with 2829 additions and 2540 deletions

View file

@ -24,8 +24,8 @@ SConscript('winmidi/SCsub')
# Graphics drivers
if (env["platform"] != "server"):
SConscript('gles3/SCsub')
SConscript('gles2/SCsub')
# SConscript('gles3/SCsub')
# SConscript('gles2/SCsub')
SConscript('vulkan/SCsub')
SConscript('gl_context/SCsub')
else:

View file

@ -35,7 +35,7 @@
#include "core/rid_owner.h"
#include "core/self_list.h"
#include "scene/resources/mesh.h"
#include "servers/visual/rasterizer.h"
#include "servers/visual/rasterizer/rasterizer.h"
#include "servers/visual_server.h"
class RasterizerSceneDummy : public RasterizerScene {

View file

@ -74,7 +74,7 @@ void ResourceFormatDummyTexture::get_recognized_extensions(List<String> *p_exten
}
bool ResourceFormatDummyTexture::handles_type(const String &p_type) const {
return ClassDB::is_parent_class(p_type, "Texture");
return ClassDB::is_parent_class(p_type, "Texture2D");
}
String ResourceFormatDummyTexture::get_resource_type(const String &p_path) const {

View file

@ -32,7 +32,7 @@
#define RASTERIZERCANVASGLES2_H
#include "rasterizer_storage_gles2.h"
#include "servers/visual/rasterizer.h"
#include "servers/visual/rasterizer/rasterizer.h"
#include "shaders/canvas.glsl.gen.h"
#include "shaders/lens_distorted.glsl.gen.h"

View file

@ -34,7 +34,7 @@
#include "rasterizer_canvas_gles2.h"
#include "rasterizer_scene_gles2.h"
#include "rasterizer_storage_gles2.h"
#include "servers/visual/rasterizer.h"
#include "servers/visual/rasterizer/rasterizer.h"
class RasterizerGLES2 : public Rasterizer {

View file

@ -1721,7 +1721,7 @@ void RasterizerStorageGLES2::shader_get_param_list(RID p_shader, List<PropertyIn
case ShaderLanguage::TYPE_USAMPLER2D: {
pi.type = Variant::OBJECT;
pi.hint = PROPERTY_HINT_RESOURCE_TYPE;
pi.hint_string = "Texture";
pi.hint_string = "Texture2D";
} break;
case ShaderLanguage::TYPE_SAMPLERCUBE: {

View file

@ -33,7 +33,7 @@
#include "core/pool_vector.h"
#include "core/self_list.h"
#include "servers/visual/rasterizer.h"
#include "servers/visual/rasterizer/rasterizer.h"
#include "servers/visual/shader_language.h"
#include "shader_compiler_gles2.h"
#include "shader_gles2.h"
@ -341,7 +341,7 @@ public:
}
};
mutable RID_PtrOwner<Texture> texture_owner;
mutable RID_PtrOwner<Texture2D> texture_owner;
Ref<Image> _get_gl_image_and_format(const Ref<Image> &p_image, Image::Format p_format, uint32_t p_flags, Image::Format &r_real_format, GLenum &r_gl_format, GLenum &r_gl_internal_format, GLenum &r_gl_type, bool &r_compressed, bool p_force_decompress) const;

View file

@ -32,7 +32,7 @@
#define RASTERIZERCANVASGLES3_H
#include "rasterizer_storage_gles3.h"
#include "servers/visual/rasterizer.h"
#include "servers/visual/rasterizer/rasterizer.h"
#include "shaders/canvas_shadow.glsl.gen.h"
#include "shaders/lens_distorted.glsl.gen.h"

View file

@ -34,7 +34,7 @@
#include "rasterizer_canvas_gles3.h"
#include "rasterizer_scene_gles3.h"
#include "rasterizer_storage_gles3.h"
#include "servers/visual/rasterizer.h"
#include "servers/visual/rasterizer/rasterizer.h"
class RasterizerGLES3 : public Rasterizer {

View file

@ -2471,7 +2471,7 @@ void RasterizerStorageGLES3::shader_get_param_list(RID p_shader, List<PropertyIn
pi.type = Variant::OBJECT;
pi.hint = PROPERTY_HINT_RESOURCE_TYPE;
pi.hint_string = "Texture";
pi.hint_string = "Texture2D";
} break;
case ShaderLanguage::TYPE_SAMPLER2DARRAY:
case ShaderLanguage::TYPE_ISAMPLER2DARRAY:

View file

@ -32,7 +32,7 @@
#define RASTERIZERSTORAGEGLES3_H
#include "core/self_list.h"
#include "servers/visual/rasterizer.h"
#include "servers/visual/rasterizer/rasterizer.h"
#include "servers/visual/shader_language.h"
#include "shader_compiler_gles3.h"
#include "shader_gles3.h"
@ -344,7 +344,7 @@ public:
}
};
mutable RID_PtrOwner<Texture> texture_owner;
mutable RID_PtrOwner<Texture2D> texture_owner;
Ref<Image> _get_gl_image_and_format(const Ref<Image> &p_image, Image::Format p_format, uint32_t p_flags, Image::Format &r_real_format, GLenum &r_gl_format, GLenum &r_gl_internal_format, GLenum &r_gl_type, bool &r_compressed, bool &r_srgb, bool p_force_decompress) const;

View file

@ -258,7 +258,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
draw_line(Point2(right_limit, 0), Point2(right_limit, get_size().height), linecolor);
Ref<Texture> close_icon = get_icon("Close", "EditorIcons");
Ref<Texture2D> close_icon = get_icon("Close", "EditorIcons");
close_icon_rect.position = Vector2(get_size().width - close_icon->get_width() - hsep, hsep);
close_icon_rect.size = close_icon->get_size();
@ -290,7 +290,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
if (node) {
int ofs = 0;
Ref<Texture> icon = EditorNode::get_singleton()->get_object_icon(node, "Node");
Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(node, "Node");
h = MAX(h, icon->get_height());
@ -391,7 +391,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
{ //draw OTHER curves
float scale = timeline->get_zoom_scale();
Ref<Texture> point = get_icon("KeyValue", "EditorIcons");
Ref<Texture2D> point = get_icon("KeyValue", "EditorIcons");
for (Map<int, Color>::Element *E = subtrack_colors.front(); E; E = E->next()) {
_draw_track(E->key(), E->get());

View file

@ -63,9 +63,9 @@ class AnimationBezierTrackEdit : public Control {
Vector<Rect2> view_rects;
Ref<Texture> bezier_icon;
Ref<Texture> bezier_handle_icon;
Ref<Texture> selected_icon;
Ref<Texture2D> bezier_icon;
Ref<Texture2D> bezier_handle_icon;
Ref<Texture2D> selected_icon;
Rect2 close_icon_rect;

View file

@ -1442,11 +1442,11 @@ void AnimationTimelineEdit::_anim_loop_pressed() {
int AnimationTimelineEdit::get_buttons_width() const {
Ref<Texture> interp_mode = get_icon("TrackContinuous", "EditorIcons");
Ref<Texture> interp_type = get_icon("InterpRaw", "EditorIcons");
Ref<Texture> loop_type = get_icon("InterpWrapClamp", "EditorIcons");
Ref<Texture> remove_icon = get_icon("Remove", "EditorIcons");
Ref<Texture> down_icon = get_icon("select_arrow", "Tree");
Ref<Texture2D> interp_mode = get_icon("TrackContinuous", "EditorIcons");
Ref<Texture2D> interp_type = get_icon("InterpRaw", "EditorIcons");
Ref<Texture2D> loop_type = get_icon("InterpWrapClamp", "EditorIcons");
Ref<Texture2D> remove_icon = get_icon("Remove", "EditorIcons");
Ref<Texture2D> down_icon = get_icon("select_arrow", "Tree");
int total_w = interp_mode->get_width() + interp_type->get_width() + loop_type->get_width() + remove_icon->get_width();
total_w += (down_icon->get_width() + 4 * EDSCALE) * 4;
@ -1456,7 +1456,7 @@ int AnimationTimelineEdit::get_buttons_width() const {
int AnimationTimelineEdit::get_name_limit() const {
Ref<Texture> hsize_icon = get_icon("Hsize", "EditorIcons");
Ref<Texture2D> hsize_icon = get_icon("Hsize", "EditorIcons");
int limit = MAX(name_limit, add_track->get_minimum_size().width + hsize_icon->get_width());
@ -1504,7 +1504,7 @@ void AnimationTimelineEdit::_notification(int p_what) {
if (l <= 0)
l = 0.001; //avoid crashor
Ref<Texture> hsize_icon = get_icon("Hsize", "EditorIcons");
Ref<Texture2D> hsize_icon = get_icon("Hsize", "EditorIcons");
hsize_rect = Rect2(get_name_limit() - hsize_icon->get_width() - 2 * EDSCALE, (get_size().height - hsize_icon->get_height()) / 2, hsize_icon->get_width(), hsize_icon->get_height());
draw_texture(hsize_icon, hsize_rect.position);
@ -1934,7 +1934,7 @@ void AnimationTrackEdit::_notification(int p_what) {
Ref<Font> font = get_font("font", "Label");
Color color = get_color("font_color", "Label");
Ref<Texture> type_icons[6] = {
Ref<Texture2D> type_icons[6] = {
get_icon("KeyValue", "EditorIcons"),
get_icon("KeyXform", "EditorIcons"),
get_icon("KeyCall", "EditorIcons"),
@ -1950,7 +1950,7 @@ void AnimationTrackEdit::_notification(int p_what) {
{
Ref<Texture> check = animation->track_is_enabled(track) ? get_icon("checked", "CheckBox") : get_icon("unchecked", "CheckBox");
Ref<Texture2D> check = animation->track_is_enabled(track) ? get_icon("checked", "CheckBox") : get_icon("unchecked", "CheckBox");
int ofs = in_group ? check->get_width() : 0; //not the best reference for margin but..
@ -1958,7 +1958,7 @@ void AnimationTrackEdit::_notification(int p_what) {
draw_texture(check, check_rect.position);
ofs += check->get_width() + hsep;
Ref<Texture> type_icon = type_icons[animation->track_get_type(track)];
Ref<Texture2D> type_icon = type_icons[animation->track_get_type(track)];
draw_texture(type_icon, Point2(ofs, int(get_size().height - type_icon->get_height()) / 2));
ofs += type_icon->get_width() + hsep;
@ -1987,7 +1987,7 @@ void AnimationTrackEdit::_notification(int p_what) {
}
text_color.a *= 0.7;
} else if (node) {
Ref<Texture> icon = EditorNode::get_singleton()->get_object_icon(node, "Node");
Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(node, "Node");
draw_texture(icon, Point2(ofs, int(get_size().height - icon->get_height()) / 2));
icon_cache = icon;
@ -2049,17 +2049,17 @@ void AnimationTrackEdit::_notification(int p_what) {
{
Ref<Texture> wrap_icon[2] = {
Ref<Texture2D> wrap_icon[2] = {
get_icon("InterpWrapClamp", "EditorIcons"),
get_icon("InterpWrapLoop", "EditorIcons"),
};
Ref<Texture> interp_icon[3] = {
Ref<Texture2D> interp_icon[3] = {
get_icon("InterpRaw", "EditorIcons"),
get_icon("InterpLinear", "EditorIcons"),
get_icon("InterpCubic", "EditorIcons")
};
Ref<Texture> cont_icon[4] = {
Ref<Texture2D> cont_icon[4] = {
get_icon("TrackContinuous", "EditorIcons"),
get_icon("TrackDiscrete", "EditorIcons"),
get_icon("TrackTrigger", "EditorIcons"),
@ -2068,7 +2068,7 @@ void AnimationTrackEdit::_notification(int p_what) {
int ofs = get_size().width - timeline->get_buttons_width();
Ref<Texture> down_icon = get_icon("select_arrow", "Tree");
Ref<Texture2D> down_icon = get_icon("select_arrow", "Tree");
draw_line(Point2(ofs, 0), Point2(ofs, get_size().height), linecolor, Math::round(EDSCALE));
@ -2084,7 +2084,7 @@ void AnimationTrackEdit::_notification(int p_what) {
update_mode = Animation::UPDATE_CONTINUOUS;
}
Ref<Texture> update_icon = cont_icon[update_mode];
Ref<Texture2D> update_icon = cont_icon[update_mode];
update_mode_rect.position.x = ofs;
update_mode_rect.position.y = int(get_size().height - update_icon->get_height()) / 2;
@ -2105,7 +2105,7 @@ void AnimationTrackEdit::_notification(int p_what) {
update_mode_rect.size.x += down_icon->get_width();
bezier_edit_rect = Rect2();
} else if (animation->track_get_type(track) == Animation::TYPE_BEZIER) {
Ref<Texture> bezier_icon = get_icon("EditBezier", "EditorIcons");
Ref<Texture2D> bezier_icon = get_icon("EditBezier", "EditorIcons");
update_mode_rect.size.x += down_icon->get_width();
bezier_edit_rect.position = update_mode_rect.position + (update_mode_rect.size - bezier_icon->get_size()) / 2;
bezier_edit_rect.size = bezier_icon->get_size();
@ -2126,7 +2126,7 @@ void AnimationTrackEdit::_notification(int p_what) {
Animation::InterpolationType interp_mode = animation->track_get_interpolation_type(track);
Ref<Texture> icon = interp_icon[interp_mode];
Ref<Texture2D> icon = interp_icon[interp_mode];
interp_mode_rect.position.x = ofs;
interp_mode_rect.position.y = int(get_size().height - icon->get_height()) / 2;
@ -2159,7 +2159,7 @@ void AnimationTrackEdit::_notification(int p_what) {
bool loop_wrap = animation->track_get_interpolation_loop_wrap(track);
Ref<Texture> icon = wrap_icon[loop_wrap ? 1 : 0];
Ref<Texture2D> icon = wrap_icon[loop_wrap ? 1 : 0];
loop_mode_rect.position.x = ofs;
loop_mode_rect.position.y = int(get_size().height - icon->get_height()) / 2;
@ -2190,7 +2190,7 @@ void AnimationTrackEdit::_notification(int p_what) {
{
//erase
Ref<Texture> icon = get_icon("Remove", "EditorIcons");
Ref<Texture2D> icon = get_icon("Remove", "EditorIcons");
remove_rect.position.x = ofs + ((get_size().width - ofs) - icon->get_width()) / 2;
remove_rect.position.y = int(get_size().height - icon->get_height()) / 2;
@ -2271,7 +2271,7 @@ void AnimationTrackEdit::draw_key(int p_index, float p_pixels_sec, int p_x, bool
if (p_x < p_clip_left || p_x > p_clip_right)
return;
Ref<Texture> icon_to_draw = p_selected ? selected_icon : type_icon;
Ref<Texture2D> icon_to_draw = p_selected ? selected_icon : type_icon;
// Override type icon for invalid value keys, unless selected.
if (!p_selected && animation->track_get_type(track) == Animation::TYPE_VALUE) {
@ -2335,12 +2335,12 @@ void AnimationTrackEdit::draw_bg(int p_clip_left, int p_clip_right) {
void AnimationTrackEdit::draw_fg(int p_clip_left, int p_clip_right) {
}
void AnimationTrackEdit::draw_texture_clipped(const Ref<Texture> &p_texture, const Vector2 &p_pos) {
void AnimationTrackEdit::draw_texture_clipped(const Ref<Texture2D> &p_texture, const Vector2 &p_pos) {
draw_texture_region_clipped(p_texture, Rect2(p_pos, p_texture->get_size()), Rect2(Point2(), p_texture->get_size()));
}
void AnimationTrackEdit::draw_texture_region_clipped(const Ref<Texture> &p_texture, const Rect2 &p_rect, const Rect2 &p_region) {
void AnimationTrackEdit::draw_texture_region_clipped(const Ref<Texture2D> &p_texture, const Rect2 &p_rect, const Rect2 &p_region) {
int clip_left = timeline->get_name_limit();
int clip_right = get_size().width - timeline->get_buttons_width();
@ -2391,7 +2391,7 @@ void AnimationTrackEdit::set_animation_and_track(const Ref<Animation> &p_animati
track = p_track;
update();
Ref<Texture> type_icons[6] = {
Ref<Texture2D> type_icons[6] = {
get_icon("KeyValue", "EditorIcons"),
get_icon("KeyXform", "EditorIcons"),
get_icon("KeyCall", "EditorIcons"),
@ -2413,7 +2413,7 @@ NodePath AnimationTrackEdit::get_path() const {
Size2 AnimationTrackEdit::get_minimum_size() const {
Ref<Texture> texture = get_icon("Object", "EditorIcons");
Ref<Texture2D> texture = get_icon("Object", "EditorIcons");
Ref<Font> font = get_font("font", "Label");
int separation = get_constant("vseparation", "ItemList");
@ -3199,7 +3199,7 @@ void AnimationTrackEditGroup::_notification(int p_what) {
}
}
void AnimationTrackEditGroup::set_type_and_name(const Ref<Texture> &p_type, const String &p_name, const NodePath &p_node) {
void AnimationTrackEditGroup::set_type_and_name(const Ref<Texture2D> &p_type, const String &p_name, const NodePath &p_node) {
icon = p_type;
node_name = p_name;
node = p_node;
@ -4214,7 +4214,7 @@ void AnimationTrackEditor::_update_tracks() {
if (!group_sort.has(base_path)) {
AnimationTrackEditGroup *g = memnew(AnimationTrackEditGroup);
Ref<Texture> icon = get_icon("Node", "EditorIcons");
Ref<Texture2D> icon = get_icon("Node", "EditorIcons");
String name = base_path;
String tooltip;
if (root && root->has_node(base_path)) {
@ -5273,7 +5273,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) {
}
String text;
Ref<Texture> icon = get_icon("Node", "EditorIcons");
Ref<Texture2D> icon = get_icon("Node", "EditorIcons");
if (node) {
if (has_icon(node->get_class(), "EditorIcons")) {
icon = get_icon(node->get_class(), "EditorIcons");

View file

@ -158,8 +158,8 @@ class AnimationTrackEdit : public Control {
Rect2 remove_rect;
Rect2 bezier_edit_rect;
Ref<Texture> type_icon;
Ref<Texture> selected_icon;
Ref<Texture2D> type_icon;
Ref<Texture2D> selected_icon;
PopupMenu *menu;
@ -167,7 +167,7 @@ class AnimationTrackEdit : public Control {
void _zoom_changed();
Ref<Texture> icon_cache;
Ref<Texture2D> icon_cache;
String path_cache;
void _menu_selected(int p_index);
@ -208,8 +208,8 @@ public:
virtual void draw_fg(int p_clip_left, int p_clip_right);
//helper
void draw_texture_clipped(const Ref<Texture> &p_texture, const Vector2 &p_pos);
void draw_texture_region_clipped(const Ref<Texture> &p_texture, const Rect2 &p_rect, const Rect2 &p_region);
void draw_texture_clipped(const Ref<Texture2D> &p_texture, const Vector2 &p_pos);
void draw_texture_region_clipped(const Ref<Texture2D> &p_texture, const Rect2 &p_rect, const Rect2 &p_region);
void draw_rect_clipped(const Rect2 &p_rect, const Color &p_color, bool p_filled = true);
int get_track() const;
@ -251,7 +251,7 @@ class AnimationBezierTrackEdit;
class AnimationTrackEditGroup : public Control {
GDCLASS(AnimationTrackEditGroup, Control);
Ref<Texture> icon;
Ref<Texture2D> icon;
String node_name;
NodePath node;
Node *root;
@ -264,7 +264,7 @@ protected:
void _notification(int p_what);
public:
void set_type_and_name(const Ref<Texture> &p_type, const String &p_name, const NodePath &p_node);
void set_type_and_name(const Ref<Texture2D> &p_type, const String &p_name, const NodePath &p_node);
virtual Size2 get_minimum_size() const;
void set_timeline(AnimationTimelineEdit *p_timeline);
void set_root(Node *p_root);

View file

@ -42,12 +42,12 @@
/// BOOL ///
int AnimationTrackEditBool::get_key_height() const {
Ref<Texture> checked = get_icon("checked", "CheckBox");
Ref<Texture2D> checked = get_icon("checked", "CheckBox");
return checked->get_height();
}
Rect2 AnimationTrackEditBool::get_key_rect(int p_index, float p_pixels_sec) {
Ref<Texture> checked = get_icon("checked", "CheckBox");
Ref<Texture2D> checked = get_icon("checked", "CheckBox");
return Rect2(-checked->get_width() / 2, 0, checked->get_width(), get_size().height);
}
@ -58,7 +58,7 @@ bool AnimationTrackEditBool::is_key_selectable_by_distance() const {
void AnimationTrackEditBool::draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right) {
bool checked = get_animation()->track_get_key_value(get_track(), p_index);
Ref<Texture> icon = get_icon(checked ? "checked" : "unchecked", "CheckBox");
Ref<Texture2D> icon = get_icon(checked ? "checked" : "unchecked", "CheckBox");
Vector2 ofs(p_x - icon->get_width() / 2, int(get_size().height - icon->get_height()) / 2);
@ -360,7 +360,7 @@ Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_se
if (Object::cast_to<Sprite>(object) || Object::cast_to<Sprite3D>(object)) {
Ref<Texture> texture = object->call("get_texture");
Ref<Texture2D> texture = object->call("get_texture");
if (!texture.is_valid()) {
return AnimationTrackEdit::get_key_rect(p_index, p_pixels_sec);
}
@ -404,7 +404,7 @@ Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_se
animation = get_animation()->track_get_key_value(animation_track, animaiton_index);
}
Ref<Texture> texture = sf->get_frame(animation, frame);
Ref<Texture2D> texture = sf->get_frame(animation, frame);
if (!texture.is_valid()) {
return AnimationTrackEdit::get_key_rect(p_index, p_pixels_sec);
}
@ -434,7 +434,7 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in
return;
}
Ref<Texture> texture;
Ref<Texture2D> texture;
Rect2 region;
if (Object::cast_to<Sprite>(object) || Object::cast_to<Sprite3D>(object)) {
@ -710,13 +710,13 @@ void AnimationTrackEditSubAnim::set_node(Object *p_object) {
int AnimationTrackEditVolumeDB::get_key_height() const {
Ref<Texture> volume_texture = get_icon("ColorTrackVu", "EditorIcons");
Ref<Texture2D> volume_texture = get_icon("ColorTrackVu", "EditorIcons");
return volume_texture->get_height() * 1.2;
}
void AnimationTrackEditVolumeDB::draw_bg(int p_clip_left, int p_clip_right) {
Ref<Texture> volume_texture = get_icon("ColorTrackVu", "EditorIcons");
Ref<Texture2D> volume_texture = get_icon("ColorTrackVu", "EditorIcons");
int tex_h = volume_texture->get_height();
int y_from = (get_size().height - tex_h) / 2;
@ -728,7 +728,7 @@ void AnimationTrackEditVolumeDB::draw_bg(int p_clip_left, int p_clip_right) {
void AnimationTrackEditVolumeDB::draw_fg(int p_clip_left, int p_clip_right) {
Ref<Texture> volume_texture = get_icon("ColorTrackVu", "EditorIcons");
Ref<Texture2D> volume_texture = get_icon("ColorTrackVu", "EditorIcons");
int tex_h = volume_texture->get_height();
int y_from = (get_size().height - tex_h) / 2;
int db0 = y_from + (24 / 80.0) * tex_h;
@ -763,7 +763,7 @@ void AnimationTrackEditVolumeDB::draw_key_link(int p_index, float p_pixels_sec,
to_x = p_clip_right;
}
Ref<Texture> volume_texture = get_icon("ColorTrackVu", "EditorIcons");
Ref<Texture2D> volume_texture = get_icon("ColorTrackVu", "EditorIcons");
int tex_h = volume_texture->get_height();
int y_from = (get_size().height - tex_h) / 2;

View file

@ -35,8 +35,8 @@
class AnimationTrackEditBool : public AnimationTrackEdit {
GDCLASS(AnimationTrackEditBool, AnimationTrackEdit);
Ref<Texture> icon_checked;
Ref<Texture> icon_unchecked;
Ref<Texture2D> icon_checked;
Ref<Texture2D> icon_unchecked;
public:
virtual int get_key_height() const;

View file

@ -819,8 +819,8 @@ void CodeTextEditor::_complete_request() {
text_editor->code_complete(entries, forced);
}
Ref<Texture> CodeTextEditor::_get_completion_icon(const ScriptCodeCompletionOption &p_option) {
Ref<Texture> tex;
Ref<Texture2D> CodeTextEditor::_get_completion_icon(const ScriptCodeCompletionOption &p_option) {
Ref<Texture2D> tex;
switch (p_option.kind) {
case ScriptCodeCompletionOption::KIND_CLASS: {
if (has_icon(p_option.display, "EditorIcons")) {

View file

@ -167,7 +167,7 @@ class CodeTextEditor : public VBoxContainer {
void _update_font();
void _complete_request();
Ref<Texture> _get_completion_icon(const ScriptCodeCompletionOption &p_option);
Ref<Texture2D> _get_completion_icon(const ScriptCodeCompletionOption &p_option);
void _font_resize_timeout();
bool _add_font_size(int p_delta);

View file

@ -903,7 +903,7 @@ void ConnectionsDock::update_tree() {
while (base) {
List<MethodInfo> node_signals2;
Ref<Texture> icon;
Ref<Texture2D> icon;
String name;
if (!did_script) {

View file

@ -77,7 +77,7 @@ class CreateDialog : public ConfirmationDialog {
void _confirmed();
void _text_changed(const String &p_newtext);
Ref<Texture> _get_editor_icon(const String &p_type) const;
Ref<Texture2D> _get_editor_icon(const String &p_type) const;
void add_type(const String &p_type, HashMap<String, TreeItem *> &p_types, TreeItem *p_root, TreeItem **to_select);

View file

@ -174,7 +174,7 @@ void DependencyEditor::_update_list() {
TreeItem *root = tree->create_item();
Ref<Texture> folder = get_icon("folder", "FileDialog");
Ref<Texture2D> folder = get_icon("folder", "FileDialog");
bool broken = false;
@ -195,7 +195,7 @@ void DependencyEditor::_update_list() {
}
String name = path.get_file();
Ref<Texture> icon = EditorNode::get_singleton()->get_class_icon(type);
Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(type);
item->set_text(0, name);
item->set_icon(0, icon);
item->set_metadata(0, type);
@ -338,7 +338,7 @@ void DependencyEditorOwners::_fill_owners(EditorFileSystemDirectory *efsd) {
if (!found)
continue;
Ref<Texture> icon = EditorNode::get_singleton()->get_class_icon(efsd->get_file_type(i));
Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(efsd->get_file_type(i));
owners->add_item(efsd->get_file_path(i), icon);
}
@ -446,7 +446,7 @@ void DependencyRemoveDialog::_build_removed_dependency_tree(const Vector<Removed
}
//List this file under this dependency
Ref<Texture> icon = EditorNode::get_singleton()->get_class_icon(rd.file_type);
Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(rd.file_type);
TreeItem *file_item = owners->create_item(tree_items[rd.dependency]);
file_item->set_text(0, rd.file);
file_item->set_icon(0, icon);
@ -609,7 +609,7 @@ void DependencyErrorDialog::show(Mode p_mode, const String &p_for_file, const Ve
if (report[i].get_slice_count("::") > 0)
type = report[i].get_slice("::", 1);
Ref<Texture> icon = EditorNode::get_singleton()->get_class_icon(type);
Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(type);
TreeItem *ti = files->create_item(root);
ti->set_text(0, dep);
@ -720,7 +720,7 @@ bool OrphanResourcesDialog::_fill_owners(EditorFileSystemDirectory *efsd, HashMa
String type = efsd->get_file_type(i);
Ref<Texture> icon = EditorNode::get_singleton()->get_class_icon(type);
Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(type);
ti->set_icon(0, icon);
int ds = efsd->get_file_deps(i).size();
ti->set_text(1, itos(ds));

View file

@ -483,7 +483,7 @@ void DocData::generate(bool p_basic_types) {
PropertyDoc pd;
pd.name = E->get();
pd.type = "Texture";
pd.type = "Texture2D";
c.theme_properties.push_back(pd);
}
l.clear();

View file

@ -110,7 +110,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) {
ret = unzGoToNextFile(pkg);
}
Map<String, Ref<Texture> > extension_guess;
Map<String, Ref<Texture2D> > extension_guess;
{
extension_guess["png"] = get_icon("ImageTexture", "EditorIcons");
extension_guess["jpg"] = get_icon("ImageTexture", "EditorIcons");
@ -122,7 +122,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) {
extension_guess["vs"] = get_icon("VisualScript", "EditorIcons");
}
Ref<Texture> generic_extension = get_icon("Object", "EditorIcons");
Ref<Texture2D> generic_extension = get_icon("Object", "EditorIcons");
unzClose(pkg);

View file

@ -144,8 +144,8 @@ void EditorAudioBus::_notification(int p_what) {
if (activity_found != channel[i].prev_active) {
if (activity_found) {
channel[i].vu_l->set_over_texture(Ref<Texture>());
channel[i].vu_r->set_over_texture(Ref<Texture>());
channel[i].vu_l->set_over_texture(Ref<Texture2D>());
channel[i].vu_r->set_over_texture(Ref<Texture2D>());
} else {
channel[i].vu_l->set_over_texture(disabled_vu);
channel[i].vu_r->set_over_texture(disabled_vu);
@ -944,7 +944,7 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) {
if (!ClassDB::can_instance(E->get()))
continue;
Ref<Texture> icon = EditorNode::get_singleton()->get_class_icon(E->get());
Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(E->get());
String name = E->get().operator String().replace("AudioEffect", "");
effect_options->add_item(name);
effect_options->set_item_metadata(effect_options->get_item_count() - 1, E->get());

View file

@ -54,7 +54,7 @@ class EditorAudioBus : public PanelContainer {
GDCLASS(EditorAudioBus, PanelContainer);
Ref<Texture> disabled_vu;
Ref<Texture2D> disabled_vu;
LineEdit *track_name;
MenuButton *bus_options;
VSlider *slider;

View file

@ -479,7 +479,7 @@ EditorPlugin *EditorData::get_editor_plugin(int p_idx) {
return editor_plugins[p_idx];
}
void EditorData::add_custom_type(const String &p_type, const String &p_inherits, const Ref<Script> &p_script, const Ref<Texture> &p_icon) {
void EditorData::add_custom_type(const String &p_type, const String &p_inherits, const Ref<Script> &p_script, const Ref<Texture2D> &p_icon) {
ERR_FAIL_COND_MSG(p_script.is_null(), "It's not a reference to a valid Script object.");
CustomType ct;

View file

@ -112,7 +112,7 @@ public:
String name;
Ref<Script> script;
Ref<Texture> icon;
Ref<Texture2D> icon;
};
struct EditedScene {
@ -178,7 +178,7 @@ public:
void save_editor_global_states();
void restore_editor_global_states();
void add_custom_type(const String &p_type, const String &p_inherits, const Ref<Script> &p_script, const Ref<Texture> &p_icon);
void add_custom_type(const String &p_type, const String &p_inherits, const Ref<Script> &p_script, const Ref<Texture2D> &p_icon);
Object *instance_custom_type(const String &p_type, const String &p_inherits);
void remove_custom_type(const String &p_type);
const Map<String, Vector<CustomType> > &get_custom_types() const { return custom_types; }

View file

@ -1477,7 +1477,7 @@ String EditorExportPlatformPC::get_os_name() const {
return os_name;
}
Ref<Texture> EditorExportPlatformPC::get_logo() const {
Ref<Texture2D> EditorExportPlatformPC::get_logo() const {
return logo;
}
@ -1629,7 +1629,7 @@ void EditorExportPlatformPC::set_os_name(const String &p_name) {
os_name = p_name;
}
void EditorExportPlatformPC::set_logo(const Ref<Texture> &p_logo) {
void EditorExportPlatformPC::set_logo(const Ref<Texture2D> &p_logo) {
logo = p_logo;
}

View file

@ -236,7 +236,7 @@ public:
virtual String get_os_name() const = 0;
virtual String get_name() const = 0;
virtual Ref<Texture> get_logo() const = 0;
virtual Ref<Texture2D> get_logo() const = 0;
Error export_project_files(const Ref<EditorExportPreset> &p_preset, EditorExportSaveFunction p_func, void *p_udata, EditorExportSaveSharedObject p_so_func = NULL);
@ -259,7 +259,7 @@ public:
};
virtual Error run(const Ref<EditorExportPreset> &p_preset, int p_device, int p_debug_flags) { return OK; }
virtual Ref<Texture> get_run_icon() const { return get_logo(); }
virtual Ref<Texture2D> get_run_icon() const { return get_logo(); }
String test_etc2() const; //generic test for etc2 since most platforms use it
virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const = 0;
@ -420,7 +420,7 @@ public:
virtual String get_name() const;
virtual String get_os_name() const;
virtual Ref<Texture> get_logo() const;
virtual Ref<Texture2D> get_logo() const;
virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const;
virtual List<String> get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const;
@ -431,7 +431,7 @@ public:
void set_name(const String &p_name);
void set_os_name(const String &p_name);
void set_logo(const Ref<Texture> &p_logo);
void set_logo(const Ref<Texture2D> &p_logo);
void set_release_64(const String &p_file);
void set_release_32(const String &p_file);

View file

@ -78,7 +78,7 @@ void EditorFileDialog::_notification(int p_what) {
preview_wheel_index++;
if (preview_wheel_index >= 8)
preview_wheel_index = 0;
Ref<Texture> frame = get_icon("Progress" + itos(preview_wheel_index + 1), "EditorIcons");
Ref<Texture2D> frame = get_icon("Progress" + itos(preview_wheel_index + 1), "EditorIcons");
preview->set_texture(frame);
preview_wheel_timeout = 0.1;
}
@ -263,7 +263,7 @@ void EditorFileDialog::_post_popup() {
_request_single_thumbnail(get_current_dir().plus_file(get_current_file()));
if (is_visible_in_tree()) {
Ref<Texture> folder = get_icon("folder", "FileDialog");
Ref<Texture2D> folder = get_icon("folder", "FileDialog");
const Color folder_color = get_color("folder_icon_modulate", "FileDialog");
recent->clear();
@ -295,7 +295,7 @@ void EditorFileDialog::_post_popup() {
set_process_unhandled_input(true);
}
void EditorFileDialog::_thumbnail_result(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, const Variant &p_udata) {
void EditorFileDialog::_thumbnail_result(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata) {
if (display_mode == DISPLAY_LIST || p_preview.is_null())
return;
@ -305,12 +305,12 @@ void EditorFileDialog::_thumbnail_result(const String &p_path, const Ref<Texture
String pname = d["path"];
if (pname == p_path) {
item_list->set_item_icon(i, p_preview);
item_list->set_item_tag_icon(i, Ref<Texture>());
item_list->set_item_tag_icon(i, Ref<Texture2D>());
}
}
}
void EditorFileDialog::_thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, const Variant &p_udata) {
void EditorFileDialog::_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata) {
set_process(false);
preview_waiting = false;
@ -326,7 +326,7 @@ void EditorFileDialog::_thumbnail_done(const String &p_path, const Ref<Texture>
} else {
preview_vb->hide();
preview->set_texture(Ref<Texture>());
preview->set_texture(Ref<Texture2D>());
}
}
@ -704,8 +704,8 @@ void EditorFileDialog::update_file_list() {
int thumbnail_size = EditorSettings::get_singleton()->get("filesystem/file_dialog/thumbnail_size");
thumbnail_size *= EDSCALE;
Ref<Texture> folder_thumbnail;
Ref<Texture> file_thumbnail;
Ref<Texture2D> folder_thumbnail;
Ref<Texture2D> file_thumbnail;
item_list->clear();
@ -745,7 +745,7 @@ void EditorFileDialog::update_file_list() {
dir_access->list_dir_begin();
Ref<Texture> folder = get_icon("folder", "FileDialog");
Ref<Texture2D> folder = get_icon("folder", "FileDialog");
const Color folder_color = get_color("folder_icon_modulate", "FileDialog");
List<String> files;
List<String> dirs;
@ -841,7 +841,7 @@ void EditorFileDialog::update_file_list() {
if (get_icon_func) {
Ref<Texture> icon = get_icon_func(cdir.plus_file(files.front()->get()));
Ref<Texture2D> icon = get_icon_func(cdir.plus_file(files.front()->get()));
if (display_mode == DISPLAY_THUMBNAILS) {
item_list->set_item_icon(item_list->get_item_count() - 1, file_thumbnail);
@ -1215,7 +1215,7 @@ void EditorFileDialog::_update_favorites() {
bool res = access == ACCESS_RESOURCES;
String current = get_current_dir();
Ref<Texture> folder_icon = get_icon("Folder", "EditorIcons");
Ref<Texture2D> folder_icon = get_icon("Folder", "EditorIcons");
const Color folder_color = get_color("folder_icon_modulate", "FileDialog");
favorites->clear();

View file

@ -68,7 +68,7 @@ public:
MODE_SAVE_FILE
};
typedef Ref<Texture> (*GetIconFunc)(const String &);
typedef Ref<Texture2D> (*GetIconFunc)(const String &);
typedef void (*RegisterFunc)(EditorFileDialog *);
static GetIconFunc get_icon_func;
@ -188,10 +188,10 @@ private:
virtual void _post_popup();
void _save_to_recent();
//callback function is callback(String p_path,Ref<Texture> preview,Variant udata) preview null if could not load
//callback function is callback(String p_path,Ref<Texture2D> preview,Variant udata) preview null if could not load
void _thumbnail_result(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, const Variant &p_udata);
void _thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, const Variant &p_udata);
void _thumbnail_result(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata);
void _thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata);
void _request_single_thumbnail(const String &p_path);
void _unhandled_input(const Ref<InputEvent> &p_event);

View file

@ -1374,7 +1374,7 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) {
end = bbcode.length();
String image = bbcode.substr(brk_end + 1, end - brk_end - 1);
Ref<Texture> texture = ResourceLoader::load(base_path.plus_file(image), "Texture");
Ref<Texture2D> texture = ResourceLoader::load(base_path.plus_file(image), "Texture2D");
if (texture.is_valid())
p_rt->add_image(texture);

View file

@ -483,7 +483,7 @@ TreeItem *EditorHelpSearch::Runner::_create_class_hierarchy(const ClassMatch &p_
TreeItem *EditorHelpSearch::Runner::_create_class_item(TreeItem *p_parent, const DocData::ClassDoc *p_doc, bool p_gray) {
Ref<Texture> icon = empty_icon;
Ref<Texture2D> icon = empty_icon;
if (ui_service->has_icon(p_doc->name, "EditorIcons"))
icon = ui_service->get_icon(p_doc->name, "EditorIcons");
else if (ClassDB::class_exists(p_doc->name) && ClassDB::is_parent_class(p_doc->name, "Object"))
@ -559,7 +559,7 @@ TreeItem *EditorHelpSearch::Runner::_create_theme_property_item(TreeItem *p_pare
TreeItem *EditorHelpSearch::Runner::_create_member_item(TreeItem *p_parent, const String &p_class_name, const String &p_icon, const String &p_name, const String &p_type, const String &p_metatype, const String &p_tooltip) {
Ref<Texture> icon;
Ref<Texture2D> icon;
String text;
if (search_flags & SEARCH_SHOW_HIERARCHY) {
icon = ui_service->get_icon(p_icon, "EditorIcons");

View file

@ -116,7 +116,7 @@ class EditorHelpSearch::Runner : public Reference {
String term;
int search_flags;
Ref<Texture> empty_icon;
Ref<Texture2D> empty_icon;
Color disabled_color;
Map<String, DocData::ClassDoc>::Element *iterator_doc;

View file

@ -61,12 +61,12 @@ Size2 EditorProperty::get_minimum_size() const {
}
if (keying) {
Ref<Texture> key = get_icon("Key", "EditorIcons");
Ref<Texture2D> key = get_icon("Key", "EditorIcons");
ms.width += key->get_width() + get_constant("hseparator", "Tree");
}
if (checkable) {
Ref<Texture> check = get_icon("checked", "CheckBox");
Ref<Texture2D> check = get_icon("checked", "CheckBox");
ms.width += check->get_width() + get_constant("hseparation", "CheckBox") + get_constant("hseparator", "Tree");
}
@ -139,7 +139,7 @@ void EditorProperty::_notification(int p_what) {
}
if (keying) {
Ref<Texture> key;
Ref<Texture2D> key;
if (use_keying_next()) {
key = get_icon("KeyNext", "EditorIcons");
@ -215,7 +215,7 @@ void EditorProperty::_notification(int p_what) {
int text_limit = text_size;
if (checkable) {
Ref<Texture> checkbox;
Ref<Texture2D> checkbox;
if (checked)
checkbox = get_icon("GuiChecked", "EditorIcons");
else
@ -236,7 +236,7 @@ void EditorProperty::_notification(int p_what) {
}
if (can_revert) {
Ref<Texture> reload_icon = get_icon("ReloadSmall", "EditorIcons");
Ref<Texture2D> reload_icon = get_icon("ReloadSmall", "EditorIcons");
text_limit -= reload_icon->get_width() + get_constant("hseparator", "Tree") * 2;
revert_rect = Rect2(text_limit + get_constant("hseparator", "Tree"), (size.height - reload_icon->get_height()) / 2, reload_icon->get_width(), reload_icon->get_height());
@ -256,7 +256,7 @@ void EditorProperty::_notification(int p_what) {
draw_string(font, Point2(ofs, v_ofs + font->get_ascent()), label, color, text_limit);
if (keying) {
Ref<Texture> key;
Ref<Texture2D> key;
if (use_keying_next()) {
key = get_icon("KeyNext", "EditorIcons");
@ -1055,7 +1055,7 @@ void EditorInspectorSection::_notification(int p_what) {
if (p_what == NOTIFICATION_SORT_CHILDREN) {
Ref<Font> font = get_font("font", "Tree");
Ref<Texture> arrow;
Ref<Texture2D> arrow;
if (foldable) {
if (object->editor_is_section_unfolded(section)) {
@ -1096,7 +1096,7 @@ void EditorInspectorSection::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW) {
Ref<Texture> arrow;
Ref<Texture2D> arrow;
if (foldable) {
if (object->editor_is_section_unfolded(section)) {

View file

@ -198,7 +198,7 @@ class EditorInspectorCategory : public Control {
GDCLASS(EditorInspectorCategory, Control);
friend class EditorInspector;
Ref<Texture> icon;
Ref<Texture2D> icon;
String label;
Color bg_color;
mutable String tooltip_text;

View file

@ -76,7 +76,7 @@ void EditorLog::_notification(int p_what) {
void EditorLog::_clear_request() {
log->clear();
tool_button->set_icon(Ref<Texture>());
tool_button->set_icon(Ref<Texture2D>());
}
void EditorLog::_copy_request() {
@ -102,14 +102,14 @@ void EditorLog::add_message(const String &p_msg, MessageType p_type) {
} break;
case MSG_TYPE_ERROR: {
log->push_color(get_color("error_color", "Editor"));
Ref<Texture> icon = get_icon("Error", "EditorIcons");
Ref<Texture2D> icon = get_icon("Error", "EditorIcons");
log->add_image(icon);
log->add_text(" ");
tool_button->set_icon(icon);
} break;
case MSG_TYPE_WARNING: {
log->push_color(get_color("warning_color", "Editor"));
Ref<Texture> icon = get_icon("Warning", "EditorIcons");
Ref<Texture2D> icon = get_icon("Warning", "EditorIcons");
log->add_image(icon);
log->add_text(" ");
tool_button->set_icon(icon);

View file

@ -183,11 +183,11 @@ void EditorNode::_update_scene_tabs() {
OS::get_singleton()->global_menu_clear("_dock");
scene_tabs->clear_tabs();
Ref<Texture> script_icon = gui_base->get_icon("Script", "EditorIcons");
Ref<Texture2D> script_icon = gui_base->get_icon("Script", "EditorIcons");
for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
Node *type_node = editor_data.get_edited_scene_root(i);
Ref<Texture> icon;
Ref<Texture2D> icon;
if (type_node) {
icon = EditorNode::get_singleton()->get_object_icon(type_node, "Node");
}
@ -461,7 +461,7 @@ void EditorNode::_notification(int p_what) {
ToolButton *tb = singleton->main_editor_buttons[i];
EditorPlugin *p_editor = singleton->editor_table[i];
Ref<Texture> icon = p_editor->get_icon();
Ref<Texture2D> icon = p_editor->get_icon();
if (icon.is_valid()) {
tb->set_icon(icon);
@ -2942,7 +2942,7 @@ void EditorNode::add_editor_plugin(EditorPlugin *p_editor, bool p_config_changed
tb->set_toggle_mode(true);
tb->connect("pressed", singleton, "_editor_select", varray(singleton->main_editor_buttons.size()));
tb->set_text(p_editor->get_name());
Ref<Texture> icon = p_editor->get_icon();
Ref<Texture2D> icon = p_editor->get_icon();
if (icon.is_valid()) {
tb->set_icon(icon);
@ -3767,7 +3767,7 @@ Ref<ImageTexture> EditorNode::_load_custom_class_icon(const String &p_path) cons
return NULL;
}
Ref<Texture> EditorNode::get_object_icon(const Object *p_object, const String &p_fallback) const {
Ref<Texture2D> EditorNode::get_object_icon(const Object *p_object, const String &p_fallback) const {
ERR_FAIL_COND_V(!p_object || !gui_base, NULL);
Ref<Script> script = p_object->get_script();
@ -3812,7 +3812,7 @@ Ref<Texture> EditorNode::get_object_icon(const Object *p_object, const String &p
return NULL;
}
Ref<Texture> EditorNode::get_class_icon(const String &p_class, const String &p_fallback) const {
Ref<Texture2D> EditorNode::get_class_icon(const String &p_class, const String &p_fallback) const {
ERR_FAIL_COND_V_MSG(p_class.empty(), NULL, "Class name cannot be empty.");
if (gui_base->has_icon(p_class, "EditorIcons")) {
@ -3907,7 +3907,7 @@ void EditorNode::progress_end_task_bg(const String &p_task) {
singleton->progress_hb->end_task(p_task);
}
Ref<Texture> EditorNode::_file_dialog_get_icon(const String &p_path) {
Ref<Texture2D> EditorNode::_file_dialog_get_icon(const String &p_path) {
EditorFileSystemDirectory *efsd = EditorFileSystem::get_singleton()->get_filesystem_path(p_path.get_base_dir());
if (efsd) {
@ -4732,7 +4732,7 @@ void EditorNode::_reposition_active_tab(int idx_to) {
_update_scene_tabs();
}
void EditorNode::_thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, const Variant &p_udata) {
void EditorNode::_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata) {
int p_tab = p_udata.operator signed int();
if (p_preview.is_valid()) {
Rect2 rect = scene_tabs->get_tab_rect(p_tab);
@ -4972,7 +4972,7 @@ Variant EditorNode::drag_resource(const Ref<Resource> &p_res, Control *p_from) {
TextureRect *drag_preview = memnew(TextureRect);
Label *label = memnew(Label);
Ref<Texture> preview;
Ref<Texture2D> preview;
{
//todo make proper previews
@ -5582,7 +5582,6 @@ EditorNode::EditorNode() {
Input::get_singleton()->set_use_accumulated_input(true);
Resource::_get_local_scene_func = _resource_get_edited_scene;
VisualServer::get_singleton()->textures_keep_original(true);
VisualServer::get_singleton()->set_debug_generate_wireframes(true);
NavigationServer::get_singleton()->set_active(false); // no nav by default if editor
@ -5682,16 +5681,21 @@ EditorNode::EditorNode() {
import_texture.instance();
ResourceFormatImporter::get_singleton()->add_importer(import_texture);
Ref<ResourceImporterLayeredTexture> import_3d;
import_3d.instance();
import_3d->set_3d(true);
ResourceFormatImporter::get_singleton()->add_importer(import_3d);
Ref<ResourceImporterLayeredTexture> import_cubemap;
import_cubemap.instance();
import_cubemap->set_mode(ResourceImporterLayeredTexture::MODE_CUBEMAP);
ResourceFormatImporter::get_singleton()->add_importer(import_cubemap);
Ref<ResourceImporterLayeredTexture> import_array;
import_array.instance();
import_array->set_3d(false);
import_array->set_mode(ResourceImporterLayeredTexture::MODE_2D_ARRAY);
ResourceFormatImporter::get_singleton()->add_importer(import_array);
Ref<ResourceImporterLayeredTexture> import_cubemap_array;
import_cubemap_array.instance();
import_cubemap_array->set_mode(ResourceImporterLayeredTexture::MODE_CUBEMAP_ARRAY);
ResourceFormatImporter::get_singleton()->add_importer(import_cubemap_array);
Ref<ResourceImporterImage> import_image;
import_image.instance();
ResourceFormatImporter::get_singleton()->add_importer(import_image);

View file

@ -522,13 +522,13 @@ private:
Set<FileDialog *> file_dialogs;
Set<EditorFileDialog *> editor_file_dialogs;
Map<String, Ref<Texture> > icon_type_cache;
Map<String, Ref<Texture2D> > icon_type_cache;
void _build_icon_type_cache();
bool _initializing_addons;
Map<String, EditorPlugin *> plugin_addons;
static Ref<Texture> _file_dialog_get_icon(const String &p_path);
static Ref<Texture2D> _file_dialog_get_icon(const String &p_path);
static void _file_dialog_register(FileDialog *p_dialog);
static void _file_dialog_unregister(FileDialog *p_dialog);
static void _editor_file_dialog_register(EditorFileDialog *p_dialog);
@ -582,7 +582,7 @@ private:
void _scene_tab_exit();
void _scene_tab_input(const Ref<InputEvent> &p_input);
void _reposition_active_tab(int idx_to);
void _thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, const Variant &p_udata);
void _thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata);
void _scene_tab_script_edited(int p_tab);
Dictionary _get_main_scene_state();
@ -772,8 +772,8 @@ public:
Ref<Theme> get_editor_theme() const { return theme; }
Ref<Script> get_object_custom_type_base(const Object *p_object) const;
StringName get_object_custom_type_name(const Object *p_object) const;
Ref<Texture> get_object_icon(const Object *p_object, const String &p_fallback = "Object") const;
Ref<Texture> get_class_icon(const String &p_class, const String &p_fallback = "Object") const;
Ref<Texture2D> get_object_icon(const Object *p_object, const String &p_fallback = "Object") const;
Ref<Texture2D> get_class_icon(const String &p_class, const String &p_fallback = "Object") const;
void show_accept(const String &p_text, const String &p_title);
void show_warning(const String &p_text, const String &p_title = TTR("Warning!"));

View file

@ -54,7 +54,7 @@ void EditorPath::_add_children_to_popup(Object *p_obj, int p_depth) {
if (!obj)
continue;
Ref<Texture> icon = EditorNode::get_singleton()->get_object_icon(obj);
Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(obj);
int index = get_popup()->get_item_count();
get_popup()->add_icon_item(icon, E->get().name.capitalize(), objects.size());
@ -90,7 +90,7 @@ void EditorPath::update_path() {
if (!obj)
continue;
Ref<Texture> icon = EditorNode::get_singleton()->get_object_icon(obj);
Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(obj);
if (icon.is_valid())
set_icon(icon);

View file

@ -51,7 +51,7 @@ Array EditorInterface::_make_mesh_previews(const Array &p_meshes, int p_preview_
meshes.push_back(p_meshes[i]);
}
Vector<Ref<Texture> > textures = make_mesh_previews(meshes, NULL, p_preview_size);
Vector<Ref<Texture2D> > textures = make_mesh_previews(meshes, NULL, p_preview_size);
Array ret;
for (int i = 0; i < textures.size(); i++) {
ret.push_back(textures[i]);
@ -60,7 +60,7 @@ Array EditorInterface::_make_mesh_previews(const Array &p_meshes, int p_preview_
return ret;
}
Vector<Ref<Texture> > EditorInterface::make_mesh_previews(const Vector<Ref<Mesh> > &p_meshes, Vector<Transform> *p_transforms, int p_preview_size) {
Vector<Ref<Texture2D> > EditorInterface::make_mesh_previews(const Vector<Ref<Mesh> > &p_meshes, Vector<Transform> *p_transforms, int p_preview_size) {
int size = p_preview_size;
@ -87,13 +87,13 @@ Vector<Ref<Texture> > EditorInterface::make_mesh_previews(const Vector<Ref<Mesh>
EditorProgress ep("mlib", TTR("Creating Mesh Previews"), p_meshes.size());
Vector<Ref<Texture> > textures;
Vector<Ref<Texture2D> > textures;
for (int i = 0; i < p_meshes.size(); i++) {
Ref<Mesh> mesh = p_meshes[i];
if (!mesh.is_valid()) {
textures.push_back(Ref<Texture>());
textures.push_back(Ref<Texture2D>());
continue;
}
@ -114,7 +114,7 @@ Vector<Ref<Texture> > EditorInterface::make_mesh_previews(const Vector<Ref<Mesh>
AABB rot_aabb = xform.xform(aabb);
float m = MAX(rot_aabb.size.x, rot_aabb.size.y) * 0.5;
if (m == 0) {
textures.push_back(Ref<Texture>());
textures.push_back(Ref<Texture2D>());
continue;
}
xform.origin = -xform.basis.xform(ofs); //-ofs*m;
@ -131,7 +131,7 @@ Vector<Ref<Texture> > EditorInterface::make_mesh_previews(const Vector<Ref<Mesh>
ep.step(TTR("Thumbnail..."), i);
Main::iteration();
Main::iteration();
Ref<Image> img = VS::get_singleton()->texture_get_data(viewport_texture);
Ref<Image> img = VS::get_singleton()->texture_2d_get(viewport_texture);
ERR_CONTINUE(!img.is_valid() || img->empty());
Ref<ImageTexture> it(memnew(ImageTexture));
it->create_from_image(img);
@ -314,7 +314,7 @@ EditorInterface::EditorInterface() {
}
///////////////////////////////////////////
void EditorPlugin::add_custom_type(const String &p_type, const String &p_base, const Ref<Script> &p_script, const Ref<Texture> &p_icon) {
void EditorPlugin::add_custom_type(const String &p_type, const String &p_base, const Ref<Script> &p_script, const Ref<Texture2D> &p_icon) {
EditorNode::get_editor_data().add_custom_type(p_type, p_base, p_script, p_icon);
}
@ -605,13 +605,13 @@ String EditorPlugin::get_name() const {
return String();
}
const Ref<Texture> EditorPlugin::get_icon() const {
const Ref<Texture2D> EditorPlugin::get_icon() const {
if (get_script_instance() && get_script_instance()->has_method("get_plugin_icon")) {
return get_script_instance()->call("get_plugin_icon");
}
return Ref<Texture>();
return Ref<Texture2D>();
}
bool EditorPlugin::has_main_screen() const {

View file

@ -98,7 +98,7 @@ public:
Error save_scene();
void save_scene_as(const String &p_scene, bool p_with_preview = true);
Vector<Ref<Texture> > make_mesh_previews(const Vector<Ref<Mesh> > &p_meshes, Vector<Transform> *p_transforms, int p_preview_size);
Vector<Ref<Texture2D> > make_mesh_previews(const Vector<Ref<Mesh> > &p_meshes, Vector<Transform> *p_transforms, int p_preview_size);
void set_main_screen_editor(const String &p_name);
void set_distraction_free_mode(bool p_enter);
@ -123,7 +123,7 @@ protected:
static void _bind_methods();
UndoRedo &get_undo_redo() { return *undo_redo; }
void add_custom_type(const String &p_type, const String &p_base, const Ref<Script> &p_script, const Ref<Texture> &p_icon);
void add_custom_type(const String &p_type, const String &p_base, const Ref<Script> &p_script, const Ref<Texture2D> &p_icon);
void remove_custom_type(const String &p_type);
public:
@ -187,7 +187,7 @@ public:
virtual void forward_spatial_force_draw_over_viewport(Control *p_overlay);
virtual String get_name() const;
virtual const Ref<Texture> get_icon() const;
virtual const Ref<Texture2D> get_icon() const;
virtual bool has_main_screen() const;
virtual void make_visible(bool p_visible);
virtual void selected_notify() {} //notify that it was raised by the user, not the editor

View file

@ -353,10 +353,10 @@ void EditorProfiler::_update_plot() {
if (graph_texture.is_null()) {
graph_texture.instance();
}
graph_texture->create(img->get_width(), img->get_height(), img->get_format(), Texture::FLAG_VIDEO_SURFACE);
graph_texture->create_from_image(img);
}
graph_texture->set_data(img);
graph_texture->update(img, true);
graph->set_texture(graph_texture);
graph->update();

View file

@ -135,7 +135,7 @@ void EditorPropertyMultilineText::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_THEME_CHANGED:
case NOTIFICATION_ENTER_TREE: {
Ref<Texture> df = get_icon("DistractionFree", "EditorIcons");
Ref<Texture2D> df = get_icon("DistractionFree", "EditorIcons");
open_big_text->set_icon(df);
Ref<Font> font = get_font("font", "Label");
text->set_custom_minimum_size(Vector2(0, font->get_height() * 6));
@ -865,7 +865,7 @@ void EditorPropertyObjectID::update_property() {
} else {
edit->set_text(TTR("[Empty]"));
edit->set_disabled(true);
edit->set_icon(Ref<Texture>());
edit->set_icon(Ref<Texture2D>());
}
}
@ -1983,7 +1983,7 @@ void EditorPropertyNodePath::update_property() {
assign->set_tooltip(p);
if (p == NodePath()) {
assign->set_icon(Ref<Texture>());
assign->set_icon(Ref<Texture2D>());
assign->set_text(TTR("Assign..."));
assign->set_flat(false);
return;
@ -2000,7 +2000,7 @@ void EditorPropertyNodePath::update_property() {
}
if (!base_node || !base_node->has_node(p)) {
assign->set_icon(Ref<Texture>());
assign->set_icon(Ref<Texture2D>());
assign->set_text(p);
return;
}
@ -2009,7 +2009,7 @@ void EditorPropertyNodePath::update_property() {
ERR_FAIL_COND(!target_node);
if (String(target_node->get_name()).find("@") != -1) {
assign->set_icon(Ref<Texture>());
assign->set_icon(Ref<Texture2D>());
assign->set_text(p);
return;
}
@ -2028,7 +2028,7 @@ void EditorPropertyNodePath::setup(const NodePath &p_base_hint, Vector<StringNam
void EditorPropertyNodePath::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
Ref<Texture> t = get_icon("Clear", "EditorIcons");
Ref<Texture2D> t = get_icon("Clear", "EditorIcons");
clear->set_icon(t);
}
}
@ -2331,7 +2331,7 @@ void EditorPropertyResource::_menu_option(int p_which) {
}
}
void EditorPropertyResource::_resource_preview(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, ObjectID p_obj) {
void EditorPropertyResource::_resource_preview(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, ObjectID p_obj) {
RES p = get_edited_object()->get(get_edited_property());
if (p.is_valid() && p->get_instance_id() == p_obj) {
@ -2412,7 +2412,7 @@ void EditorPropertyResource::_update_menu_items() {
const String &t = F->get();
bool is_custom_resource = false;
Ref<Texture> icon;
Ref<Texture2D> icon;
if (!custom_resources.empty()) {
for (int j = 0; j < custom_resources.size(); j++) {
if (custom_resources[j].name == t) {
@ -2493,7 +2493,7 @@ void EditorPropertyResource::_update_menu_items() {
}
for (int i = 0; i < conversions.size(); i++) {
String what = conversions[i]->converts_to();
Ref<Texture> icon;
Ref<Texture2D> icon;
if (has_icon(what, "EditorIcons")) {
icon = get_icon(what, "EditorIcons");
@ -2659,9 +2659,9 @@ void EditorPropertyResource::update_property() {
}
}
preview->set_texture(Ref<Texture>());
preview->set_texture(Ref<Texture2D>());
if (res == RES()) {
assign->set_icon(Ref<Texture>());
assign->set_icon(Ref<Texture2D>());
assign->set_text(TTR("[empty]"));
} else {
@ -2712,7 +2712,7 @@ void EditorPropertyResource::setup(const String &p_base_type) {
void EditorPropertyResource::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
Ref<Texture> t = get_icon("select_arrow", "Tree");
Ref<Texture2D> t = get_icon("select_arrow", "Tree");
edit->set_icon(t);
}

View file

@ -574,7 +574,7 @@ class EditorPropertyResource : public EditorProperty {
void _file_selected(const String &p_path);
void _menu_option(int p_which);
void _resource_preview(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, ObjectID p_obj);
void _resource_preview(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, ObjectID p_obj);
void _resource_selected();
void _viewport_selected(const NodePath &p_path);

View file

@ -49,15 +49,15 @@ bool EditorResourcePreviewGenerator::handles(const String &p_type) const {
ERR_FAIL_V_MSG(false, "EditorResourcePreviewGenerator::handles needs to be overridden.");
}
Ref<Texture> EditorResourcePreviewGenerator::generate(const RES &p_from, const Size2 &p_size) const {
Ref<Texture2D> EditorResourcePreviewGenerator::generate(const RES &p_from, const Size2 &p_size) const {
if (get_script_instance() && get_script_instance()->has_method("generate")) {
return get_script_instance()->call("generate", p_from, p_size);
}
ERR_FAIL_V_MSG(Ref<Texture>(), "EditorResourcePreviewGenerator::generate needs to be overridden.");
ERR_FAIL_V_MSG(Ref<Texture2D>(), "EditorResourcePreviewGenerator::generate needs to be overridden.");
}
Ref<Texture> EditorResourcePreviewGenerator::generate_from_path(const String &p_path, const Size2 &p_size) const {
Ref<Texture2D> EditorResourcePreviewGenerator::generate_from_path(const String &p_path, const Size2 &p_size) const {
if (get_script_instance() && get_script_instance()->has_method("generate_from_path")) {
return get_script_instance()->call("generate_from_path", p_path, p_size);
@ -90,8 +90,8 @@ bool EditorResourcePreviewGenerator::can_generate_small_preview() const {
void EditorResourcePreviewGenerator::_bind_methods() {
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "handles", PropertyInfo(Variant::STRING, "type")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo(CLASS_INFO(Texture), "generate", PropertyInfo(Variant::OBJECT, "from", PROPERTY_HINT_RESOURCE_TYPE, "Resource"), PropertyInfo(Variant::VECTOR2, "size")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo(CLASS_INFO(Texture), "generate_from_path", PropertyInfo(Variant::STRING, "path", PROPERTY_HINT_FILE), PropertyInfo(Variant::VECTOR2, "size")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo(CLASS_INFO(Texture2D), "generate", PropertyInfo(Variant::OBJECT, "from", PROPERTY_HINT_RESOURCE_TYPE, "Resource"), PropertyInfo(Variant::VECTOR2, "size")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo(CLASS_INFO(Texture2D), "generate_from_path", PropertyInfo(Variant::STRING, "path", PROPERTY_HINT_FILE), PropertyInfo(Variant::VECTOR2, "size")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "generate_small_preview_automatically"));
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "can_generate_small_preview"));
}
@ -107,7 +107,7 @@ void EditorResourcePreview::_thread_func(void *ud) {
erp->_thread();
}
void EditorResourcePreview::_preview_ready(const String &p_str, const Ref<Texture> &p_texture, const Ref<Texture> &p_small_texture, ObjectID id, const StringName &p_func, const Variant &p_ud) {
void EditorResourcePreview::_preview_ready(const String &p_str, const Ref<Texture2D> &p_texture, const Ref<Texture2D> &p_small_texture, ObjectID id, const StringName &p_func, const Variant &p_ud) {
preview_mutex->lock();
@ -160,7 +160,7 @@ void EditorResourcePreview::_generate_preview(Ref<ImageTexture> &r_texture, Ref<
if (!preview_generators[i]->handles(type))
continue;
Ref<Texture> generated;
Ref<Texture2D> generated;
if (p_item.resource.is_valid()) {
generated = preview_generators[i]->generate(p_item.resource, Vector2(thumbnail_size, thumbnail_size));
} else {
@ -172,7 +172,7 @@ void EditorResourcePreview::_generate_preview(Ref<ImageTexture> &r_texture, Ref<
small_thumbnail_size *= EDSCALE;
if (preview_generators[i]->can_generate_small_preview()) {
Ref<Texture> generated_small;
Ref<Texture2D> generated_small;
if (p_item.resource.is_valid()) {
generated_small = preview_generators[i]->generate(p_item.resource, Vector2(small_thumbnail_size, small_thumbnail_size));
} else {
@ -322,14 +322,14 @@ void EditorResourcePreview::_thread() {
} else {
texture.instance();
texture->create_from_image(img, Texture::FLAG_FILTER);
texture->create_from_image(img);
if (has_small_texture) {
if (small_img->load(cache_base + "_small.png") != OK) {
cache_valid = false;
} else {
small_texture.instance();
small_texture->create_from_image(small_img, Texture::FLAG_FILTER);
small_texture->create_from_image(small_img);
}
}
}

View file

@ -45,8 +45,8 @@ protected:
public:
virtual bool handles(const String &p_type) const;
virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const;
virtual Ref<Texture> generate_from_path(const String &p_path, const Size2 &p_size) const;
virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const;
virtual Ref<Texture2D> generate_from_path(const String &p_path, const Size2 &p_size) const;
virtual bool generate_small_preview_automatically() const;
virtual bool can_generate_small_preview() const;
@ -77,8 +77,8 @@ class EditorResourcePreview : public Node {
volatile bool exited;
struct Item {
Ref<Texture> preview;
Ref<Texture> small_preview;
Ref<Texture2D> preview;
Ref<Texture2D> small_preview;
int order;
uint32_t last_hash;
uint64_t modified_time;
@ -88,7 +88,7 @@ class EditorResourcePreview : public Node {
Map<String, Item> cache;
void _preview_ready(const String &p_str, const Ref<Texture> &p_texture, const Ref<Texture> &p_small_texture, ObjectID id, const StringName &p_func, const Variant &p_ud);
void _preview_ready(const String &p_str, const Ref<Texture2D> &p_texture, const Ref<Texture2D> &p_small_texture, ObjectID id, const StringName &p_func, const Variant &p_ud);
void _generate_preview(Ref<ImageTexture> &r_texture, Ref<ImageTexture> &r_small_texture, const QueueItem &p_item, const String &cache_base);
static void _thread_func(void *ud);
@ -102,7 +102,7 @@ protected:
public:
static EditorResourcePreview *get_singleton();
//callback function is callback(String p_path,Ref<Texture> preview,Variant udata) preview null if could not load
//callback function is callback(String p_path,Ref<Texture2D> preview,Variant udata) preview null if could not load
void queue_resource_preview(const String &p_path, Object *p_receiver, const StringName &p_receiver_func, const Variant &p_userdata);
void queue_edited_resource_preview(const Ref<Resource> &p_res, Object *p_receiver, const StringName &p_receiver_func, const Variant &p_userdata);

View file

@ -53,7 +53,7 @@ void EditorRunNative::_notification(int p_what) {
im->resize(16 * EDSCALE, 16 * EDSCALE);
Ref<ImageTexture> small_icon;
small_icon.instance();
small_icon->create_from_image(im, 0);
small_icon->create_from_image(im);
MenuButton *mb = memnew(MenuButton);
mb->get_popup()->connect("id_pressed", this, "_run_native", varray(i));
mb->connect("pressed", this, "_run_native", varray(-1, i));

View file

@ -200,7 +200,7 @@ void EditorSpinSlider::_notification(int p_what) {
int string_width = font->get_string_size(label).width;
int number_width = get_size().width - sb->get_minimum_size().width - string_width - sep;
Ref<Texture> updown = get_icon("updown", "SpinBox");
Ref<Texture2D> updown = get_icon("updown", "SpinBox");
if (get_step() == 1) {
number_width -= updown->get_width();
@ -233,7 +233,7 @@ void EditorSpinSlider::_notification(int p_what) {
draw_string(font, Vector2(Math::round(sb->get_offset().x + string_width + sep), vofs), numstr, fc, number_width);
if (get_step() == 1) {
Ref<Texture> updown2 = get_icon("updown", "SpinBox");
Ref<Texture2D> updown2 = get_icon("updown", "SpinBox");
int updown_vofs = (get_size().height - updown2->get_height()) / 2;
updown_offset = get_size().width - sb->get_margin(MARGIN_RIGHT) - updown2->get_width();
Color c(1, 1, 1);
@ -268,7 +268,7 @@ void EditorSpinSlider::_notification(int p_what) {
}
if (display_grabber) {
Ref<Texture> grabber_tex;
Ref<Texture2D> grabber_tex;
if (mouse_over_grabber) {
grabber_tex = get_icon("grabber_highlight", "HSlider");
} else {

View file

@ -41,7 +41,7 @@
#include "modules/svg/image_loader_svg.h"
#endif
static Ref<StyleBoxTexture> make_stylebox(Ref<Texture> p_texture, float p_left, float p_top, float p_right, float p_botton, float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_botton = -1, bool p_draw_center = true) {
static Ref<StyleBoxTexture> make_stylebox(Ref<Texture2D> p_texture, float p_left, float p_top, float p_right, float p_botton, float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_botton = -1, bool p_draw_center = true) {
Ref<StyleBoxTexture> style(memnew(StyleBoxTexture));
style->set_texture(p_texture);
style->set_margin_size(MARGIN_LEFT, p_left * EDSCALE);
@ -99,10 +99,7 @@ Ref<ImageTexture> editor_generate_icon(int p_index, bool p_convert_color, float
const bool upsample = !Math::is_equal_approx(Math::round(p_scale), p_scale);
ImageLoaderSVG::create_image_from_string(img, editor_icons_sources[p_index], p_scale, upsample, p_convert_color);
if ((p_scale - (float)((int)p_scale)) > 0.0 || is_gizmo || p_force_filter)
icon->create_from_image(img); // in this case filter really helps
else
icon->create_from_image(img, 0);
icon->create_from_image(img); // in this case filter really helps
return icon;
}
@ -931,7 +928,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_stylebox("panel", "EditorAbout", style_complex_window);
// HScrollBar
Ref<Texture> empty_icon = memnew(ImageTexture);
Ref<Texture2D> empty_icon = memnew(ImageTexture);
theme->set_stylebox("scroll", "HScrollBar", make_stylebox(theme->get_icon("GuiScrollBg", "EditorIcons"), 5, 5, 5, 5, 0, 0, 0, 0));
theme->set_stylebox("scroll_focus", "HScrollBar", make_stylebox(theme->get_icon("GuiScrollBg", "EditorIcons"), 5, 5, 5, 5, 0, 0, 0, 0));

View file

@ -45,8 +45,8 @@
#include "scene/main/viewport.h"
#include "scene/resources/packed_scene.h"
Ref<Texture> FileSystemDock::_get_tree_item_icon(EditorFileSystemDirectory *p_dir, int p_idx) {
Ref<Texture> file_icon;
Ref<Texture2D> FileSystemDock::_get_tree_item_icon(EditorFileSystemDirectory *p_dir, int p_idx) {
Ref<Texture2D> file_icon;
if (!p_dir->get_file_import_is_valid(p_idx)) {
file_icon = get_icon("ImportFail", "EditorIcons");
} else {
@ -198,11 +198,11 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo
if (!fave.begins_with("res://"))
continue;
Ref<Texture> folder_icon = get_icon("Folder", "EditorIcons");
Ref<Texture2D> folder_icon = get_icon("Folder", "EditorIcons");
const Color folder_color = get_color("folder_icon_modulate", "FileDialog");
String text;
Ref<Texture> icon;
Ref<Texture2D> icon;
Color color;
if (fave == "res://") {
text = "/";
@ -496,7 +496,7 @@ void FileSystemDock::navigate_to_path(const String &p_path) {
_navigate_to_path(p_path);
}
void FileSystemDock::_file_list_thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, const Variant &p_udata) {
void FileSystemDock::_file_list_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata) {
if ((file_list_vb->is_visible_in_tree() || path == p_path.get_base_dir()) && p_preview.is_valid()) {
Array uarr = p_udata;
int idx = uarr[0];
@ -512,7 +512,7 @@ void FileSystemDock::_file_list_thumbnail_done(const String &p_path, const Ref<T
}
}
void FileSystemDock::_tree_thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, const Variant &p_udata) {
void FileSystemDock::_tree_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata) {
if (p_small_preview.is_valid()) {
Array uarr = p_udata;
if (tree_update_id == (int)uarr[0]) {
@ -613,9 +613,9 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) {
String ei = "EditorIcons";
int thumbnail_size = EditorSettings::get_singleton()->get("docks/filesystem/thumbnail_size");
thumbnail_size *= EDSCALE;
Ref<Texture> folder_thumbnail;
Ref<Texture> file_thumbnail;
Ref<Texture> file_thumbnail_broken;
Ref<Texture2D> folder_thumbnail;
Ref<Texture2D> file_thumbnail;
Ref<Texture2D> file_thumbnail_broken;
bool use_thumbnails = (file_list_display_mode == FILE_LIST_DISPLAY_THUMBNAILS);
@ -645,7 +645,7 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) {
files->set_fixed_icon_size(Size2());
}
Ref<Texture> folder_icon = (use_thumbnails) ? folder_thumbnail : get_icon("folder", "FileDialog");
Ref<Texture2D> folder_icon = (use_thumbnails) ? folder_thumbnail : get_icon("folder", "FileDialog");
const Color folder_color = get_color("folder_icon_modulate", "FileDialog");
// Build the FileInfo list.
@ -656,7 +656,7 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) {
for (int i = 0; i < favorites.size(); i++) {
String favorite = favorites[i];
String text;
Ref<Texture> icon;
Ref<Texture2D> icon;
if (favorite == "res://") {
text = "/";
icon = folder_icon;
@ -759,8 +759,8 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) {
String fpath = finfo->path;
String ftype = finfo->type;
Ref<Texture> type_icon;
Ref<Texture> big_icon;
Ref<Texture2D> type_icon;
Ref<Texture2D> big_icon;
String tooltip = fpath;

View file

@ -176,7 +176,7 @@ private:
ItemList *files;
bool import_dock_needs_update;
Ref<Texture> _get_tree_item_icon(EditorFileSystemDirectory *p_dir, int p_idx);
Ref<Texture2D> _get_tree_item_icon(EditorFileSystemDirectory *p_dir, int p_idx);
bool _create_tree(TreeItem *p_parent, EditorFileSystemDirectory *p_dir, Vector<String> &uncollapsed_paths, bool p_select_in_favorites, bool p_unfold_path = false);
Vector<String> _compute_uncollapsed_paths();
void _update_tree(const Vector<String> &p_uncollapsed_paths = Vector<String>(), bool p_uncollapse_root = false, bool p_select_in_favorites = false, bool p_unfold_path = false);
@ -269,8 +269,8 @@ private:
void _get_drag_target_folder(String &target, bool &target_favorites, const Point2 &p_point, Control *p_from) const;
void _preview_invalidated(const String &p_path);
void _file_list_thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, const Variant &p_udata);
void _tree_thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, const Variant &p_udata);
void _file_list_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata);
void _tree_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata);
void _update_display_mode(bool p_force = false);

View file

@ -88,7 +88,7 @@ void GroupDialog::_load_nodes(Node *p_current) {
node->set_metadata(0, path);
node->set_tooltip(0, path);
Ref<Texture> icon = EditorNode::get_singleton()->get_object_icon(p_current, "Node");
Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(p_current, "Node");
node->set_icon(0, icon);
if (!_can_edit(p_current, selected_group)) {

View file

@ -380,7 +380,7 @@ Error ColladaImport::_create_material(const String &p_target) {
if (texfile.begins_with("/")) {
texfile = texfile.replace_first("/", "res://");
}
Ref<Texture> texture = ResourceLoader::load(texfile, "Texture");
Ref<Texture2D> texture = ResourceLoader::load(texfile, "Texture2D");
if (texture.is_valid()) {
material->set_texture(SpatialMaterial::TEXTURE_ALBEDO, texture);
@ -405,7 +405,7 @@ Error ColladaImport::_create_material(const String &p_target) {
texfile = texfile.replace_first("/", "res://");
}
Ref<Texture> texture = ResourceLoader::load(texfile, "Texture");
Ref<Texture2D> texture = ResourceLoader::load(texfile, "Texture2D");
if (texture.is_valid()) {
material->set_texture(SpatialMaterial::TEXTURE_METALLIC, texture);
material->set_specular(1.0);
@ -432,7 +432,7 @@ Error ColladaImport::_create_material(const String &p_target) {
texfile = texfile.replace_first("/", "res://");
}
Ref<Texture> texture = ResourceLoader::load(texfile, "Texture");
Ref<Texture2D> texture = ResourceLoader::load(texfile, "Texture2D");
if (texture.is_valid()) {
material->set_feature(SpatialMaterial::FEATURE_EMISSION, true);
@ -462,7 +462,7 @@ Error ColladaImport::_create_material(const String &p_target) {
texfile = texfile.replace_first("/", "res://");
}
Ref<Texture> texture = ResourceLoader::load(texfile, "Texture");
Ref<Texture2D> texture = ResourceLoader::load(texfile, "Texture2D");
if (texture.is_valid()) {
material->set_feature(SpatialMaterial::FEATURE_NORMAL_MAPPING, true);
material->set_texture(SpatialMaterial::TEXTURE_NORMAL, texture);

View file

@ -1277,7 +1277,7 @@ Error EditorSceneImporterGLTF::_parse_images(GLTFState &state, const String &p_b
} else {
uri = p_base_path.plus_file(uri).replace("\\", "/"); //fix for windows
Ref<Texture> texture = ResourceLoader::load(uri);
Ref<Texture2D> texture = ResourceLoader::load(uri);
state.images.push_back(texture);
continue;
}
@ -1362,11 +1362,11 @@ Error EditorSceneImporterGLTF::_parse_textures(GLTFState &state) {
return OK;
}
Ref<Texture> EditorSceneImporterGLTF::_get_texture(GLTFState &state, const GLTFTextureIndex p_texture) {
ERR_FAIL_INDEX_V(p_texture, state.textures.size(), Ref<Texture>());
Ref<Texture2D> EditorSceneImporterGLTF::_get_texture(GLTFState &state, const GLTFTextureIndex p_texture) {
ERR_FAIL_INDEX_V(p_texture, state.textures.size(), Ref<Texture2D>());
const GLTFImageIndex image = state.textures[p_texture].src_image;
ERR_FAIL_INDEX_V(image, state.images.size(), Ref<Texture>());
ERR_FAIL_INDEX_V(image, state.images.size(), Ref<Texture2D>());
return state.images[image];
}
@ -1423,7 +1423,7 @@ Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) {
if (mr.has("metallicRoughnessTexture")) {
const Dictionary &bct = mr["metallicRoughnessTexture"];
if (bct.has("index")) {
const Ref<Texture> t = _get_texture(state, bct["index"]);
const Ref<Texture2D> t = _get_texture(state, bct["index"]);
material->set_texture(SpatialMaterial::TEXTURE_METALLIC, t);
material->set_metallic_texture_channel(SpatialMaterial::TEXTURE_CHANNEL_BLUE);
material->set_texture(SpatialMaterial::TEXTURE_ROUGHNESS, t);

View file

@ -310,7 +310,7 @@ class EditorSceneImporterGLTF : public EditorSceneImporter {
Vector<int> root_nodes;
Vector<GLTFTexture> textures;
Vector<Ref<Texture> > images;
Vector<Ref<Texture2D> > images;
Vector<GLTFSkin> skins;
Vector<GLTFCamera> cameras;
@ -335,7 +335,7 @@ class EditorSceneImporterGLTF : public EditorSceneImporter {
String _sanitize_bone_name(const String &name);
String _gen_unique_bone_name(GLTFState &state, const GLTFSkeletonIndex skel_i, const String &p_name);
Ref<Texture> _get_texture(GLTFState &state, const GLTFTextureIndex p_texture);
Ref<Texture2D> _get_texture(GLTFState &state, const GLTFTextureIndex p_texture);
Error _parse_json(const String &p_path, GLTFState &state);
Error _parse_glb(const String &p_path, GLTFState &state);

View file

@ -40,24 +40,71 @@
String ResourceImporterLayeredTexture::get_importer_name() const {
return is_3d ? "texture_3d" : "texture_array";
switch (mode) {
case MODE_CUBEMAP: {
return "cubemap_texture";
} break;
case MODE_2D_ARRAY: {
return "2d_array_texture";
} break;
case MODE_CUBEMAP_ARRAY: {
return "cubemap_array_texture";
} break;
}
ERR_FAIL_V("");
}
String ResourceImporterLayeredTexture::get_visible_name() const {
return is_3d ? "Texture3D" : "TextureArray";
switch (mode) {
case MODE_CUBEMAP: {
return "Cubemap";
} break;
case MODE_2D_ARRAY: {
return "Texture2DArray";
} break;
case MODE_CUBEMAP_ARRAY: {
return "CubemapArray";
} break;
}
ERR_FAIL_V("");
}
void ResourceImporterLayeredTexture::get_recognized_extensions(List<String> *p_extensions) const {
ImageLoader::get_recognized_extensions(p_extensions);
}
String ResourceImporterLayeredTexture::get_save_extension() const {
return is_3d ? "tex3d" : "texarr";
switch (mode) {
case MODE_CUBEMAP: {
return "cube";
} break;
case MODE_2D_ARRAY: {
return "tex2darr";
} break;
case MODE_CUBEMAP_ARRAY: {
return "cubearr";
} break;
}
ERR_FAIL_V(String());
}
String ResourceImporterLayeredTexture::get_resource_type() const {
return is_3d ? "Texture3D" : "TextureArray";
switch (mode) {
case MODE_CUBEMAP: {
return "Cubemap";
} break;
case MODE_2D_ARRAY: {
return "Texture2DArray";
} break;
case MODE_CUBEMAP_ARRAY: {
return "CubemapArray";
} break;
}
ERR_FAIL_V(String());
}
bool ResourceImporterLayeredTexture::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
@ -66,47 +113,48 @@ bool ResourceImporterLayeredTexture::get_option_visibility(const String &p_optio
}
int ResourceImporterLayeredTexture::get_preset_count() const {
return 3;
return 0;
}
String ResourceImporterLayeredTexture::get_preset_name(int p_idx) const {
static const char *preset_names[] = {
"3D",
"2D",
"ColorCorrect"
};
return preset_names[p_idx];
return "";
}
void ResourceImporterLayeredTexture::get_import_options(List<ImportOption> *r_options, int p_preset) const {
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/mode", PROPERTY_HINT_ENUM, "Lossless,Video RAM,Uncompressed", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), p_preset == PRESET_3D ? 1 : 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/mode", PROPERTY_HINT_ENUM, "Lossless,Video RAM,Uncompressed", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), 1));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "compress/no_bptc_if_rgb"), false));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "flags/repeat", PROPERTY_HINT_ENUM, "Disabled,Enabled,Mirrored"), 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "flags/filter"), true));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "flags/mipmaps"), p_preset == PRESET_COLOR_CORRECT ? 0 : 1));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "flags/srgb", PROPERTY_HINT_ENUM, "Disable,Enable"), p_preset == PRESET_3D ? 1 : 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "slices/horizontal", PROPERTY_HINT_RANGE, "1,256,1"), p_preset == PRESET_COLOR_CORRECT ? 16 : 8));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "slices/vertical", PROPERTY_HINT_RANGE, "1,256,1"), p_preset == PRESET_COLOR_CORRECT ? 1 : 8));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/channel_pack", PROPERTY_HINT_ENUM, "sRGB Friendly,Optimized"), 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "flags/mipmaps"), true));
if (mode == MODE_2D_ARRAY) {
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "slices/horizontal", PROPERTY_HINT_RANGE, "1,256,1"), 8));
}
if (mode == MODE_2D_ARRAY || mode == MODE_CUBEMAP_ARRAY) {
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "slices/vertical", PROPERTY_HINT_RANGE, "1,256,1"), 8));
}
}
void ResourceImporterLayeredTexture::_save_tex(const Vector<Ref<Image> > &p_images, const String &p_to_path, int p_compress_mode, Image::CompressMode p_vram_compression, bool p_mipmaps, int p_texture_flags) {
void ResourceImporterLayeredTexture::_save_tex(const Vector<Ref<Image> > &p_images, const String &p_to_path, int p_compress_mode, Image::CompressMode p_vram_compression, bool p_mipmaps) {
FileAccess *f = FileAccess::open(p_to_path, FileAccess::WRITE);
f->store_8('G');
f->store_8('D');
if (is_3d) {
f->store_8('3');
} else {
f->store_8('A');
switch (mode) {
case MODE_2D_ARRAY: f->store_8('A'); break;
case MODE_CUBEMAP: f->store_8('C'); break;
case MODE_CUBEMAP_ARRAY: f->store_8('X'); break;
}
f->store_8('T'); //godot streamable texture
f->store_32(p_images[0]->get_width());
f->store_32(p_images[0]->get_height());
f->store_32(p_images.size()); //depth
f->store_32(p_texture_flags);
uint32_t flags = 0;
if (p_mipmaps) {
flags |= TEXTURE_FLAGS_MIPMAPS;
}
f->store_32(flags);
if (p_compress_mode != COMPRESS_VIDEO_RAM) {
//vram needs to do a first compression to tell what the format is, for the rest its ok
f->store_32(p_images[0]->get_format());
@ -195,12 +243,18 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const
int compress_mode = p_options["compress/mode"];
int no_bptc_if_rgb = p_options["compress/no_bptc_if_rgb"];
int repeat = p_options["flags/repeat"];
bool filter = p_options["flags/filter"];
bool mipmaps = p_options["flags/mipmaps"];
int srgb = p_options["flags/srgb"];
int hslices = p_options["slices/horizontal"];
int vslices = p_options["slices/vertical"];
int channel_pack = p_options["compress/channel_pack"];
int hslices = (p_options.has("slices/horizontal")) ? int(p_options["slices/horizontal"]) : 0;
int vslices = (p_options.has("slices/vertical")) ? int(p_options["slices/vertical"]) : 0;
if (mode == MODE_CUBEMAP) {
hslices = 3;
vslices = 2;
} else if (mode == MODE_CUBEMAP_ARRAY) {
hslices = 3;
vslices *= 2; //put cubemaps vertically
}
Ref<Image> image;
image.instance();
@ -208,17 +262,9 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const
if (err != OK)
return err;
int tex_flags = 0;
if (repeat > 0)
tex_flags |= Texture::FLAG_REPEAT;
if (repeat == 2)
tex_flags |= Texture::FLAG_MIRRORED_REPEAT;
if (filter)
tex_flags |= Texture::FLAG_FILTER;
if (mipmaps || compress_mode == COMPRESS_VIDEO_RAM)
tex_flags |= Texture::FLAG_MIPMAPS;
if (srgb == 1)
tex_flags |= Texture::FLAG_CONVERT_TO_LINEAR;
if (compress_mode == COMPRESS_VIDEO_RAM) {
mipmaps = true;
}
Vector<Ref<Image> > slices;
@ -228,7 +274,7 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const
//optimize
if (compress_mode == COMPRESS_VIDEO_RAM) {
//if using video ram, optimize
if (srgb) {
if (channel_pack == 0) {
//remove alpha if not needed, so compression is more efficient
if (image->get_format() == Image::FORMAT_RGBA8 && !image->detect_alpha()) {
image->convert(Image::FORMAT_RGB8);
@ -277,14 +323,14 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const
if (encode_bptc) {
_save_tex(slices, p_save_path + ".bptc." + extension, compress_mode, Image::COMPRESS_BPTC, mipmaps, tex_flags);
_save_tex(slices, p_save_path + ".bptc." + extension, compress_mode, Image::COMPRESS_BPTC, mipmaps);
r_platform_variants->push_back("bptc");
ok_on_pc = true;
}
if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_s3tc")) {
_save_tex(slices, p_save_path + ".s3tc." + extension, compress_mode, Image::COMPRESS_S3TC, mipmaps, tex_flags);
_save_tex(slices, p_save_path + ".s3tc." + extension, compress_mode, Image::COMPRESS_S3TC, mipmaps);
r_platform_variants->push_back("s3tc");
ok_on_pc = true;
formats_imported.push_back("s3tc");
@ -292,20 +338,20 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const
if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc2")) {
_save_tex(slices, p_save_path + ".etc2." + extension, compress_mode, Image::COMPRESS_ETC2, mipmaps, tex_flags);
_save_tex(slices, p_save_path + ".etc2." + extension, compress_mode, Image::COMPRESS_ETC2, mipmaps);
r_platform_variants->push_back("etc2");
formats_imported.push_back("etc2");
}
if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc")) {
_save_tex(slices, p_save_path + ".etc." + extension, compress_mode, Image::COMPRESS_ETC, mipmaps, tex_flags);
_save_tex(slices, p_save_path + ".etc." + extension, compress_mode, Image::COMPRESS_ETC, mipmaps);
r_platform_variants->push_back("etc");
formats_imported.push_back("etc");
}
if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_pvrtc")) {
_save_tex(slices, p_save_path + ".pvrtc." + extension, compress_mode, Image::COMPRESS_PVRTC4, mipmaps, tex_flags);
_save_tex(slices, p_save_path + ".pvrtc." + extension, compress_mode, Image::COMPRESS_PVRTC4, mipmaps);
r_platform_variants->push_back("pvrtc");
formats_imported.push_back("pvrtc");
}
@ -315,7 +361,7 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const
}
} else {
//import normally
_save_tex(slices, p_save_path + "." + extension, compress_mode, Image::COMPRESS_S3TC /*this is ignored */, mipmaps, tex_flags);
_save_tex(slices, p_save_path + "." + extension, compress_mode, Image::COMPRESS_S3TC /*this is ignored */, mipmaps);
}
if (r_metadata) {
@ -396,7 +442,7 @@ ResourceImporterLayeredTexture *ResourceImporterLayeredTexture::singleton = NULL
ResourceImporterLayeredTexture::ResourceImporterLayeredTexture() {
singleton = this;
is_3d = true;
mode = MODE_CUBEMAP;
}
ResourceImporterLayeredTexture::~ResourceImporterLayeredTexture() {

View file

@ -38,8 +38,19 @@ class StreamTexture;
class ResourceImporterLayeredTexture : public ResourceImporter {
GDCLASS(ResourceImporterLayeredTexture, ResourceImporter);
public:
enum Mode {
MODE_CUBEMAP,
MODE_2D_ARRAY,
MODE_CUBEMAP_ARRAY
};
bool is_3d;
enum TextureFlags {
TEXTURE_FLAGS_MIPMAPS = 1
};
private:
Mode mode;
static const char *compression_formats[];
protected:
@ -57,12 +68,6 @@ public:
virtual String get_save_extension() const;
virtual String get_resource_type() const;
enum Preset {
PRESET_3D,
PRESET_2D,
PRESET_COLOR_CORRECT,
};
enum CompressMode {
COMPRESS_LOSSLESS,
COMPRESS_VIDEO_RAM,
@ -75,7 +80,7 @@ public:
virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const;
virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const;
void _save_tex(const Vector<Ref<Image> > &p_images, const String &p_to_path, int p_compress_mode, Image::CompressMode p_vram_compression, bool p_mipmaps, int p_texture_flags);
void _save_tex(const Vector<Ref<Image> > &p_images, const String &p_to_path, int p_compress_mode, Image::CompressMode p_vram_compression, bool p_mipmaps);
virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL, Variant *r_metadata = NULL);
@ -84,7 +89,8 @@ public:
virtual bool are_import_settings_valid(const String &p_path) const;
virtual String get_import_settings_string() const;
void set_3d(bool p_3d) { is_3d = p_3d; }
void set_mode(Mode p_mode) { mode = p_mode; }
ResourceImporterLayeredTexture();
~ResourceImporterLayeredTexture();
};

View file

@ -133,7 +133,7 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Spati
path = base_path.plus_file(p);
}
Ref<Texture> texture = ResourceLoader::load(path);
Ref<Texture2D> texture = ResourceLoader::load(path);
if (texture.is_valid()) {
current->set_texture(SpatialMaterial::TEXTURE_ALBEDO, texture);
@ -153,7 +153,7 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Spati
path = base_path.plus_file(p);
}
Ref<Texture> texture = ResourceLoader::load(path);
Ref<Texture2D> texture = ResourceLoader::load(path);
if (texture.is_valid()) {
current->set_texture(SpatialMaterial::TEXTURE_METALLIC, texture);
@ -173,7 +173,7 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Spati
path = base_path.plus_file(p);
}
Ref<Texture> texture = ResourceLoader::load(path);
Ref<Texture2D> texture = ResourceLoader::load(path);
if (texture.is_valid()) {
current->set_texture(SpatialMaterial::TEXTURE_ROUGHNESS, texture);
@ -187,7 +187,7 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Spati
String p = l.replace("map_bump", "").replace("\\", "/").strip_edges();
String path = base_path.plus_file(p);
Ref<Texture> texture = ResourceLoader::load(path);
Ref<Texture2D> texture = ResourceLoader::load(path);
if (texture.is_valid()) {
current->set_feature(SpatialMaterial::FEATURE_NORMAL_MAPPING, true);

View file

@ -36,16 +36,18 @@
#include "editor/editor_node.h"
#include "scene/resources/texture.h"
void ResourceImporterTexture::_texture_reimport_srgb(const Ref<StreamTexture> &p_tex) {
void ResourceImporterTexture::_texture_reimport_roughness(const Ref<StreamTexture> &p_tex, const String &p_normal_path, VS::TextureDetectRoughnessChannel p_channel) {
singleton->mutex->lock();
StringName path = p_tex->get_path();
if (!singleton->make_flags.has(path)) {
singleton->make_flags[path] = 0;
singleton->make_flags[path] = MakeInfo();
}
singleton->make_flags[path] |= MAKE_SRGB_FLAG;
singleton->make_flags[path].flags |= MAKE_ROUGHNESS_FLAG;
singleton->make_flags[path].channel_for_roughness = p_channel;
singleton->make_flags[path].normal_path_for_roughness = p_normal_path;
singleton->mutex->unlock();
}
@ -56,10 +58,10 @@ void ResourceImporterTexture::_texture_reimport_3d(const Ref<StreamTexture> &p_t
StringName path = p_tex->get_path();
if (!singleton->make_flags.has(path)) {
singleton->make_flags[path] = 0;
singleton->make_flags[path] = MakeInfo();
}
singleton->make_flags[path] |= MAKE_3D_FLAG;
singleton->make_flags[path].flags |= MAKE_3D_FLAG;
singleton->mutex->unlock();
}
@ -70,10 +72,10 @@ void ResourceImporterTexture::_texture_reimport_normal(const Ref<StreamTexture>
StringName path = p_tex->get_path();
if (!singleton->make_flags.has(path)) {
singleton->make_flags[path] = 0;
singleton->make_flags[path] = MakeInfo();
}
singleton->make_flags[path] |= MAKE_NORMAL_FLAG;
singleton->make_flags[path].flags |= MAKE_NORMAL_FLAG;
singleton->mutex->unlock();
}
@ -91,7 +93,7 @@ void ResourceImporterTexture::update_imports() {
}
Vector<String> to_reimport;
for (Map<StringName, int>::Element *E = make_flags.front(); E; E = E->next()) {
for (Map<StringName, MakeInfo>::Element *E = make_flags.front(); E; E = E->next()) {
Ref<ConfigFile> cf;
cf.instance();
@ -101,22 +103,22 @@ void ResourceImporterTexture::update_imports() {
ERR_CONTINUE(err != OK);
bool changed = false;
if (E->get() & MAKE_SRGB_FLAG && int(cf->get_value("params", "flags/srgb")) == 2) {
cf->set_value("params", "flags/srgb", 1);
changed = true;
}
if (E->get() & MAKE_NORMAL_FLAG && int(cf->get_value("params", "compress/normal_map")) == 0) {
if (E->get().flags & MAKE_NORMAL_FLAG && int(cf->get_value("params", "compress/normal_map")) == 0) {
cf->set_value("params", "compress/normal_map", 1);
changed = true;
}
if (E->get() & MAKE_3D_FLAG && bool(cf->get_value("params", "detect_3d"))) {
if (E->get().flags & MAKE_ROUGHNESS_FLAG && int(cf->get_value("params", "roughness/mode")) == 0) {
cf->set_value("params", "roughness/mode", E->get().channel_for_roughness + 2);
cf->set_value("params", "roughness/src_normal", E->get().normal_path_for_roughness);
changed = true;
}
if (E->get().flags & MAKE_3D_FLAG && bool(cf->get_value("params", "detect_3d"))) {
cf->set_value("params", "detect_3d", false);
cf->set_value("params", "compress/mode", 2);
cf->set_value("params", "flags/repeat", true);
cf->set_value("params", "flags/filter", true);
cf->set_value("params", "flags/mipmaps", true);
cf->set_value("params", "format/mipmaps", true);
changed = true;
}
@ -142,7 +144,7 @@ String ResourceImporterTexture::get_importer_name() const {
String ResourceImporterTexture::get_visible_name() const {
return "Texture";
return "Texture2D";
}
void ResourceImporterTexture::get_recognized_extensions(List<String> *p_extensions) const {
@ -204,14 +206,12 @@ void ResourceImporterTexture::get_import_options(List<ImportOption> *r_options,
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/hdr_mode", PROPERTY_HINT_ENUM, "Enabled,Force RGBE"), 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/bptc_ldr", PROPERTY_HINT_ENUM, "Enabled,RGBA Only"), 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/normal_map", PROPERTY_HINT_ENUM, "Detect,Enable,Disabled"), 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "flags/repeat", PROPERTY_HINT_ENUM, "Disabled,Enabled,Mirrored"), p_preset == PRESET_3D ? 1 : 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "flags/filter"), p_preset != PRESET_2D_PIXEL));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "flags/mipmaps"), p_preset == PRESET_3D));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "flags/anisotropic"), false));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "flags/srgb", PROPERTY_HINT_ENUM, "Disable,Enable,Detect"), 2));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/channel_pack", PROPERTY_HINT_ENUM, "sRGB Friendly,Optimized"), 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "format/mipmaps", PROPERTY_HINT_ENUM, "Detect,Disabled,Enabled"), p_preset == PRESET_DETECT ? 0 : (p_preset == PRESET_3D ? 2 : 1)));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "roughness/mode", PROPERTY_HINT_ENUM, "Detect,Disabled,Red,Green,Blue,Alpha,Gray"), 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "roughness/src_normal", PROPERTY_HINT_FILE, "*.png,*.jpg"), ""));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "process/fix_alpha_border"), p_preset != PRESET_3D));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "process/premult_alpha"), false));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "process/HDR_as_SRGB"), false));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "process/invert_color"), false));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "stream"), false));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "size_limit", PROPERTY_HINT_RANGE, "0,4096,1"), 0));
@ -219,7 +219,7 @@ void ResourceImporterTexture::get_import_options(List<ImportOption> *r_options,
r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "svg/scale", PROPERTY_HINT_RANGE, "0.001,100,0.001"), 1.0));
}
void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String &p_to_path, int p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, int p_texture_flags, bool p_streamable, bool p_detect_3d, bool p_detect_srgb, bool p_force_rgbe, bool p_detect_normal, bool p_force_normal, bool p_force_po2_for_compressed) {
void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String &p_to_path, int p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, bool p_streamable, bool p_detect_3d, bool p_detect_roughness, bool p_force_rgbe, bool p_detect_normal, bool p_force_normal, bool p_srgb_friendly, bool p_force_po2_for_compressed) {
FileAccess *f = FileAccess::open(p_to_path, FileAccess::WRITE);
f->store_8('G');
@ -229,7 +229,7 @@ void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String
bool resize_to_po2 = false;
if (p_compress_mode == COMPRESS_VIDEO_RAM && p_force_po2_for_compressed && (p_mipmaps || p_texture_flags & Texture::FLAG_REPEAT)) {
if (p_compress_mode == COMPRESS_VIDEO_RAM && p_force_po2_for_compressed && p_mipmaps) {
resize_to_po2 = true;
f->store_16(next_power_of_2(p_image->get_width()));
f->store_16(p_image->get_width());
@ -241,7 +241,7 @@ void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String
f->store_16(p_image->get_height());
f->store_16(0);
}
f->store_32(p_texture_flags);
f->store_32(0); //texture flags deprecated
uint32_t format = 0;
@ -251,8 +251,8 @@ void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String
format |= StreamTexture::FORMAT_BIT_HAS_MIPMAPS; //mipmaps bit
if (p_detect_3d)
format |= StreamTexture::FORMAT_BIT_DETECT_3D;
if (p_detect_srgb)
format |= StreamTexture::FORMAT_BIT_DETECT_SRGB;
if (p_detect_roughness)
format |= StreamTexture::FORMAT_BIT_DETECT_ROUGNESS;
if (p_detect_normal)
format |= StreamTexture::FORMAT_BIT_DETECT_NORMAL;
@ -335,7 +335,7 @@ void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String
Image::CompressSource csource = Image::COMPRESS_SOURCE_GENERIC;
if (p_force_normal) {
csource = Image::COMPRESS_SOURCE_NORMAL;
} else if (p_texture_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) {
} else if (p_srgb_friendly) {
csource = Image::COMPRESS_SOURCE_SRGB;
}
@ -379,11 +379,8 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String
int compress_mode = p_options["compress/mode"];
float lossy = p_options["compress/lossy_quality"];
int repeat = p_options["flags/repeat"];
bool filter = p_options["flags/filter"];
bool mipmaps = p_options["flags/mipmaps"];
bool anisotropic = p_options["flags/anisotropic"];
int srgb = p_options["flags/srgb"];
int pack_channels = p_options["compress/channel_pack"];
bool mipmaps = p_options["format/mipmaps"];
bool fix_alpha_border = p_options["process/fix_alpha_border"];
bool premult_alpha = p_options["process/premult_alpha"];
bool invert_color = p_options["process/invert_color"];
@ -394,6 +391,7 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String
float scale = p_options["svg/scale"];
bool force_rgbe = p_options["compress/hdr_mode"];
int bptc_ldr = p_options["compress/bptc_ldr"];
int roughness = p_options["roughness/mode"];
Ref<Image> image;
image.instance();
@ -403,20 +401,6 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String
Array formats_imported;
int tex_flags = 0;
if (repeat > 0)
tex_flags |= Texture::FLAG_REPEAT;
if (repeat == 2)
tex_flags |= Texture::FLAG_MIRRORED_REPEAT;
if (filter)
tex_flags |= Texture::FLAG_FILTER;
if (mipmaps || compress_mode == COMPRESS_VIDEO_RAM)
tex_flags |= Texture::FLAG_MIPMAPS;
if (anisotropic)
tex_flags |= Texture::FLAG_ANISOTROPIC_FILTER;
if (srgb == 1)
tex_flags |= Texture::FLAG_CONVERT_TO_LINEAR;
if (size_limit > 0 && (image->get_width() > size_limit || image->get_height() > size_limit)) {
//limit size
if (image->get_width() >= image->get_height()) {
@ -459,9 +443,10 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String
}
bool detect_3d = p_options["detect_3d"];
bool detect_srgb = srgb == 2;
bool detect_roughness = roughness == 0;
bool detect_normal = normal == 0;
bool force_normal = normal == 1;
bool srgb_friendly_pack = pack_channels == 0;
if (compress_mode == COMPRESS_VIDEO_RAM) {
//must import in all formats, in order of priority (so platform choses the best supported one. IE, etc2 over etc).
@ -497,7 +482,7 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String
}
if (can_bptc || can_s3tc) {
_save_stex(image, p_save_path + ".s3tc.stex", compress_mode, lossy, can_bptc ? Image::COMPRESS_BPTC : Image::COMPRESS_S3TC, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal, false);
_save_stex(image, p_save_path + ".s3tc.stex", compress_mode, lossy, can_bptc ? Image::COMPRESS_BPTC : Image::COMPRESS_S3TC, mipmaps, stream, detect_3d, detect_roughness, force_rgbe, detect_normal, force_normal, srgb_friendly_pack, false);
r_platform_variants->push_back("s3tc");
formats_imported.push_back("s3tc");
ok_on_pc = true;
@ -505,20 +490,20 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String
if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc2")) {
_save_stex(image, p_save_path + ".etc2.stex", compress_mode, lossy, Image::COMPRESS_ETC2, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal, true);
_save_stex(image, p_save_path + ".etc2.stex", compress_mode, lossy, Image::COMPRESS_ETC2, mipmaps, stream, detect_3d, detect_roughness, force_rgbe, detect_normal, force_normal, srgb_friendly_pack, true);
r_platform_variants->push_back("etc2");
formats_imported.push_back("etc2");
}
if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc")) {
_save_stex(image, p_save_path + ".etc.stex", compress_mode, lossy, Image::COMPRESS_ETC, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal, true);
_save_stex(image, p_save_path + ".etc.stex", compress_mode, lossy, Image::COMPRESS_ETC, mipmaps, stream, detect_3d, detect_roughness, force_rgbe, detect_normal, force_normal, srgb_friendly_pack, true);
r_platform_variants->push_back("etc");
formats_imported.push_back("etc");
}
if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_pvrtc")) {
_save_stex(image, p_save_path + ".pvrtc.stex", compress_mode, lossy, Image::COMPRESS_PVRTC4, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal, true);
_save_stex(image, p_save_path + ".pvrtc.stex", compress_mode, lossy, Image::COMPRESS_PVRTC4, mipmaps, stream, detect_3d, detect_roughness, force_rgbe, detect_normal, force_normal, srgb_friendly_pack, true);
r_platform_variants->push_back("pvrtc");
formats_imported.push_back("pvrtc");
}
@ -528,7 +513,7 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String
}
} else {
//import normally
_save_stex(image, p_save_path + ".stex", compress_mode, lossy, Image::COMPRESS_S3TC /*this is ignored */, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal, false);
_save_stex(image, p_save_path + ".stex", compress_mode, lossy, Image::COMPRESS_S3TC /*this is ignored */, mipmaps, stream, detect_3d, detect_roughness, force_rgbe, detect_normal, force_normal, srgb_friendly_pack, false);
}
if (r_metadata) {
@ -609,7 +594,7 @@ ResourceImporterTexture::ResourceImporterTexture() {
singleton = this;
StreamTexture::request_3d_callback = _texture_reimport_3d;
StreamTexture::request_srgb_callback = _texture_reimport_srgb;
StreamTexture::request_roughness_callback = _texture_reimport_roughness;
StreamTexture::request_normal_callback = _texture_reimport_normal;
mutex = Mutex::create();
}

View file

@ -33,7 +33,7 @@
#include "core/image.h"
#include "core/io/resource_importer.h"
#include "servers/visual_server.h"
class StreamTexture;
class ResourceImporterTexture : public ResourceImporter {
@ -42,14 +42,25 @@ class ResourceImporterTexture : public ResourceImporter {
protected:
enum {
MAKE_3D_FLAG = 1,
MAKE_SRGB_FLAG = 2,
MAKE_ROUGHNESS_FLAG = 2,
MAKE_NORMAL_FLAG = 4
};
Mutex *mutex;
Map<StringName, int> make_flags;
struct MakeInfo {
static void _texture_reimport_srgb(const Ref<StreamTexture> &p_tex);
int flags;
String normal_path_for_roughness;
VS::TextureDetectRoughnessChannel channel_for_roughness;
MakeInfo() {
flags = 0;
channel_for_roughness = VS::TEXTURE_DETECT_ROUGNHESS_R;
}
};
Map<StringName, MakeInfo> make_flags;
static void _texture_reimport_roughness(const Ref<StreamTexture> &p_tex, const String &p_normal_path, VisualServer::TextureDetectRoughnessChannel p_channel);
static void _texture_reimport_3d(const Ref<StreamTexture> &p_tex);
static void _texture_reimport_normal(const Ref<StreamTexture> &p_tex);
@ -84,7 +95,7 @@ public:
virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const;
virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const;
void _save_stex(const Ref<Image> &p_image, const String &p_to_path, int p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, int p_texture_flags, bool p_streamable, bool p_detect_3d, bool p_detect_srgb, bool p_force_rgbe, bool p_detect_normal, bool p_force_normal, bool p_force_po2_for_compressed);
void _save_stex(const Ref<Image> &p_image, const String &p_to_path, int p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, bool p_streamable, bool p_detect_3d, bool p_detect_srgb, bool p_force_rgbe, bool p_detect_normal, bool p_force_normal, bool p_srgb_friendly, bool p_force_po2_for_compressed);
virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL, Variant *r_metadata = NULL);

View file

@ -58,7 +58,7 @@ String ResourceImporterTextureAtlas::get_save_extension() const {
String ResourceImporterTextureAtlas::get_resource_type() const {
return "Texture";
return "Texture2D";
}
bool ResourceImporterTextureAtlas::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
@ -313,7 +313,7 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file
new_atlas->save_png(p_group_file);
//update cache if existing, else create
Ref<Texture> cache;
Ref<Texture2D> cache;
if (ResourceCache::has(p_group_file)) {
Resource *resptr = ResourceCache::get(p_group_file);
cache.reference_ptr(resptr);
@ -331,7 +331,7 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file
PackData &pack_data = pack_data_files.write[idx];
Ref<Texture> texture;
Ref<Texture2D> texture;
if (!pack_data.is_mesh) {
Vector2 offset = charts[pack_data.chart_pieces[0]].vertices[0] + charts[pack_data.chart_pieces[0]].final_offset;

View file

@ -215,7 +215,7 @@ void InspectorDock::_prepare_history() {
history_menu->get_popup()->clear();
Ref<Texture> base_icon = get_icon("Object", "EditorIcons");
Ref<Texture2D> base_icon = get_icon("Object", "EditorIcons");
Set<ObjectID> already;
for (int i = editor_history->get_history_len() - 1; i >= history_to; i--) {
@ -230,7 +230,7 @@ void InspectorDock::_prepare_history() {
already.insert(id);
Ref<Texture> icon = EditorNode::get_singleton()->get_object_icon(obj, "");
Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(obj, "");
if (icon.is_null()) {
icon = base_icon;
}

View file

@ -45,7 +45,7 @@ void PaneDrag::_notification(int p_what) {
case NOTIFICATION_DRAW: {
Ref<Texture> icon = mouse_over ? get_icon("PaneDragHover", "EditorIcons") : get_icon("PaneDrag", "EditorIcons");
Ref<Texture2D> icon = mouse_over ? get_icon("PaneDragHover", "EditorIcons") : get_icon("PaneDrag", "EditorIcons");
if (!icon.is_null())
icon->draw(get_canvas_item(), Point2(0, 0));
@ -62,7 +62,7 @@ void PaneDrag::_notification(int p_what) {
}
Size2 PaneDrag::get_minimum_size() const {
Ref<Texture> icon = get_icon("PaneDrag", "EditorIcons");
Ref<Texture2D> icon = get_icon("PaneDrag", "EditorIcons");
if (!icon.is_null())
return icon->get_size();
return Size2();

View file

@ -573,7 +573,7 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl
Transform2D xform = canvas_item_editor->get_canvas_transform() * _get_node()->get_global_transform();
// All polygon points are sharp, so use the sharp handle icon
const Ref<Texture> handle = get_icon("EditorPathSharpHandle", "EditorIcons");
const Ref<Texture2D> handle = get_icon("EditorPathSharpHandle", "EditorIcons");
const Vertex active_point = get_active_point();
const int n_polygons = _get_polygon_count();
@ -661,7 +661,7 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl
if (edge_point.valid()) {
Ref<Texture> add_handle = get_icon("EditorHandleAdd", "EditorIcons");
Ref<Texture2D> add_handle = get_icon("EditorHandleAdd", "EditorIcons");
p_overlay->draw_texture(add_handle, edge_point.pos - add_handle->get_size() * 0.5);
}
}

View file

@ -202,8 +202,8 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_draw() {
linecolor_soft.a *= 0.5;
Ref<Font> font = get_font("font", "Label");
Ref<Texture> icon = get_icon("KeyValue", "EditorIcons");
Ref<Texture> icon_selected = get_icon("KeySelected", "EditorIcons");
Ref<Texture2D> icon = get_icon("KeyValue", "EditorIcons");
Ref<Texture2D> icon_selected = get_icon("KeySelected", "EditorIcons");
Size2 s = blend_space_draw->get_size();

View file

@ -410,8 +410,8 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() {
Color linecolor_soft = linecolor;
linecolor_soft.a *= 0.5;
Ref<Font> font = get_font("font", "Label");
Ref<Texture> icon = get_icon("KeyValue", "EditorIcons");
Ref<Texture> icon_selected = get_icon("KeySelected", "EditorIcons");
Ref<Texture2D> icon = get_icon("KeyValue", "EditorIcons");
Ref<Texture2D> icon_selected = get_icon("KeySelected", "EditorIcons");
Size2 s = blend_space_draw->get_size();

View file

@ -105,7 +105,7 @@ class AnimationPlayerEditor : public VBoxContainer {
LineEdit *name;
Label *name_title;
UndoRedo *undo_redo;
Ref<Texture> autoplay_icon;
Ref<Texture2D> autoplay_icon;
bool last_active;
float timeline_position;

View file

@ -514,7 +514,7 @@ void AnimationNodeStateMachineEditor::_connection_draw(const Vector2 &p_from, co
accent.a *= 0.6;
}
Ref<Texture> icons[6] = {
Ref<Texture2D> icons[6] = {
get_icon("TransitionImmediateBig", "EditorIcons"),
get_icon("TransitionSyncBig", "EditorIcons"),
get_icon("TransitionEndBig", "EditorIcons"),
@ -533,7 +533,7 @@ void AnimationNodeStateMachineEditor::_connection_draw(const Vector2 &p_from, co
}
state_machine_draw->draw_line(p_from, p_to, linecolor, 2, true);
Ref<Texture> icon = icons[p_mode + (p_auto_advance ? 3 : 0)];
Ref<Texture2D> icon = icons[p_mode + (p_auto_advance ? 3 : 0)];
Transform2D xf;
xf.elements[0] = (p_to - p_from).normalized();
@ -578,9 +578,9 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() {
Ref<Font> font = get_font("title_font", "GraphNode");
Color font_color = get_color("title_color", "GraphNode");
Ref<Texture> play = get_icon("Play", "EditorIcons");
Ref<Texture> auto_play = get_icon("AutoPlay", "EditorIcons");
Ref<Texture> edit = get_icon("Edit", "EditorIcons");
Ref<Texture2D> play = get_icon("Play", "EditorIcons");
Ref<Texture2D> auto_play = get_icon("AutoPlay", "EditorIcons");
Ref<Texture2D> edit = get_icon("Edit", "EditorIcons");
Color accent = get_color("accent_color", "Editor");
Color linecolor = get_color("font_color", "Label");
linecolor.a *= 0.3;
@ -686,7 +686,7 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() {
_connection_draw(from, to, AnimationNodeStateMachineTransition::SwitchMode(transition_mode->get_selected()), true, false, false, false);
}
Ref<Texture> tr_reference_icon = get_icon("TransitionImmediateBig", "EditorIcons");
Ref<Texture2D> tr_reference_icon = get_icon("TransitionImmediateBig", "EditorIcons");
float tr_bidi_offset = int(tr_reference_icon->get_height() * 0.8);
//draw transition lines
@ -796,7 +796,7 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() {
nr.play.position = offset + Vector2(0, (h - play->get_height()) / 2).floor();
nr.play.size = play->get_size();
Ref<Texture> play_tex = onstart ? auto_play : play;
Ref<Texture2D> play_tex = onstart ? auto_play : play;
if (over_node == name && over_node_what == 0) {
state_machine_draw->draw_texture(play_tex, nr.play.position, accent);
@ -918,14 +918,6 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) {
transition_mode->add_icon_item(get_icon("TransitionSync", "EditorIcons"), TTR("Sync"));
transition_mode->add_icon_item(get_icon("TransitionEnd", "EditorIcons"), TTR("At End"));
//force filter on those, so they deform better
get_icon("TransitionImmediateBig", "EditorIcons")->set_flags(Texture::FLAG_FILTER);
get_icon("TransitionEndBig", "EditorIcons")->set_flags(Texture::FLAG_FILTER);
get_icon("TransitionSyncBig", "EditorIcons")->set_flags(Texture::FLAG_FILTER);
get_icon("TransitionImmediateAutoBig", "EditorIcons")->set_flags(Texture::FLAG_FILTER);
get_icon("TransitionEndAutoBig", "EditorIcons")->set_flags(Texture::FLAG_FILTER);
get_icon("TransitionSyncAutoBig", "EditorIcons")->set_flags(Texture::FLAG_FILTER);
tool_erase->set_icon(get_icon("Remove", "EditorIcons"));
tool_autoplay->set_icon(get_icon("AutoPlay", "EditorIcons"));
tool_end->set_icon(get_icon("AutoEnd", "EditorIcons"));

View file

@ -50,7 +50,7 @@ void EditorAssetLibraryItem::configure(const String &p_title, int p_asset_id, co
price->set_text(p_cost);
}
void EditorAssetLibraryItem::set_image(int p_type, int p_index, const Ref<Texture> &p_image) {
void EditorAssetLibraryItem::set_image(int p_type, int p_index, const Ref<Texture2D> &p_image) {
ERR_FAIL_COND(p_type != EditorAssetLibrary::IMAGE_QUEUE_ICON);
ERR_FAIL_COND(p_index != 0);
@ -145,7 +145,7 @@ EditorAssetLibraryItem::EditorAssetLibraryItem() {
//////////////////////////////////////////////////////////////////////////////
void EditorAssetLibraryItemDescription::set_image(int p_type, int p_index, const Ref<Texture> &p_image) {
void EditorAssetLibraryItemDescription::set_image(int p_type, int p_index, const Ref<Texture2D> &p_image) {
switch (p_type) {
@ -393,7 +393,7 @@ void EditorAssetLibraryItemDownload::_http_download_completed(int p_status, int
set_process(false);
}
void EditorAssetLibraryItemDownload::configure(const String &p_title, int p_asset_id, const Ref<Texture> &p_preview, const String &p_download_url, const String &p_sha256_hash) {
void EditorAssetLibraryItemDownload::configure(const String &p_title, int p_asset_id, const Ref<Texture2D> &p_preview, const String &p_download_url, const String &p_sha256_hash) {
title->set_text(p_title);
icon->set_texture(p_preview);

View file

@ -68,7 +68,7 @@ class EditorAssetLibraryItem : public PanelContainer {
void _category_clicked();
void _author_clicked();
void set_image(int p_type, int p_index, const Ref<Texture> &p_image);
void set_image(int p_type, int p_index, const Ref<Texture2D> &p_image);
protected:
void _notification(int p_what);
@ -95,19 +95,19 @@ class EditorAssetLibraryItemDescription : public ConfirmationDialog {
bool is_video;
String video_link;
Button *button;
Ref<Texture> image;
Ref<Texture2D> image;
};
Vector<Preview> preview_images;
TextureRect *preview;
void set_image(int p_type, int p_index, const Ref<Texture> &p_image);
void set_image(int p_type, int p_index, const Ref<Texture2D> &p_image);
int asset_id;
String download_url;
String title;
String sha256;
Ref<Texture> icon;
Ref<Texture2D> icon;
void _link_click(const String &p_url);
void _preview_click(int p_id);
@ -121,7 +121,7 @@ public:
void add_preview(int p_id, bool p_video, const String &p_url);
String get_title() { return title; }
Ref<Texture> get_preview_icon() { return icon; }
Ref<Texture2D> get_preview_icon() { return icon; }
String get_download_url() { return download_url; }
int get_asset_id() { return asset_id; }
String get_sha256() { return sha256; }
@ -165,7 +165,7 @@ protected:
public:
void set_external_install(bool p_enable) { external_install = p_enable; }
int get_asset_id() { return asset_id; }
void configure(const String &p_title, int p_asset_id, const Ref<Texture> &p_preview, const String &p_download_url, const String &p_sha256_hash);
void configure(const String &p_title, int p_asset_id, const Ref<Texture2D> &p_preview, const String &p_download_url, const String &p_sha256_hash);
EditorAssetLibraryItemDownload();
};

View file

@ -2244,7 +2244,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
for (int i = 0; i < selection_results.size(); i++) {
CanvasItem *item = selection_results[i].item;
Ref<Texture> icon = EditorNode::get_singleton()->get_object_icon(item, "Node");
Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(item, "Node");
String node_path = "/" + root_name + "/" + root_path.rel_path_to(item->get_path());
int locked = 0;
@ -2966,7 +2966,7 @@ void CanvasItemEditor::_draw_ruler_tool() {
} else {
if (grid_snap_active) {
Ref<Texture> position_icon = get_icon("EditorPosition", "EditorIcons");
Ref<Texture2D> position_icon = get_icon("EditorPosition", "EditorIcons");
viewport->draw_texture(get_icon("EditorPosition", "EditorIcons"), (ruler_tool_origin - view_offset) * zoom - position_icon->get_size() / 2);
}
}
@ -3179,9 +3179,9 @@ void CanvasItemEditor::_draw_control_helpers(Control *control) {
}
void CanvasItemEditor::_draw_selection() {
Ref<Texture> pivot_icon = get_icon("EditorPivot", "EditorIcons");
Ref<Texture> position_icon = get_icon("EditorPosition", "EditorIcons");
Ref<Texture> previous_position_icon = get_icon("EditorPositionPrevious", "EditorIcons");
Ref<Texture2D> pivot_icon = get_icon("EditorPivot", "EditorIcons");
Ref<Texture2D> position_icon = get_icon("EditorPosition", "EditorIcons");
Ref<Texture2D> previous_position_icon = get_icon("EditorPositionPrevious", "EditorIcons");
RID ci = viewport->get_canvas_item();
@ -3540,7 +3540,7 @@ void CanvasItemEditor::_draw_invisible_nodes_positions(Node *p_node, const Trans
Transform2D xform = transform * canvas_xform * parent_xform;
// Draw the node's position
Ref<Texture> position_icon = get_icon("EditorPositionUnselected", "EditorIcons");
Ref<Texture2D> position_icon = get_icon("EditorPositionUnselected", "EditorIcons");
Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized();
Transform2D simple_xform = viewport->get_transform() * unscaled_transform;
viewport->draw_set_transform_matrix(simple_xform);
@ -3554,7 +3554,7 @@ void CanvasItemEditor::_draw_hover() {
for (int i = 0; i < hovering_results.size(); i++) {
Ref<Texture> node_icon = hovering_results[i].icon;
Ref<Texture2D> node_icon = hovering_results[i].icon;
String node_name = hovering_results[i].name;
Ref<Font> font = get_font("font", "Label");
@ -3608,13 +3608,13 @@ void CanvasItemEditor::_draw_locks_and_groups(Node *p_node, const Transform2D &p
if (canvas_item) {
float offset = 0;
Ref<Texture> lock = get_icon("LockViewport", "EditorIcons");
Ref<Texture2D> lock = get_icon("LockViewport", "EditorIcons");
if (p_node->has_meta("_edit_lock_") && show_edit_locks) {
lock->draw(viewport_canvas_item, (transform * canvas_xform * parent_xform).xform(Point2(0, 0)) + Point2(offset, 0));
offset += lock->get_size().x;
}
Ref<Texture> group = get_icon("GroupViewport", "EditorIcons");
Ref<Texture2D> group = get_icon("GroupViewport", "EditorIcons");
if (canvas_item->has_meta("_edit_group_") && show_edit_locks) {
group->draw(viewport_canvas_item, (transform * canvas_xform * parent_xform).xform(Point2(0, 0)) + Point2(offset, 0));
//offset += group->get_size().x;
@ -5887,7 +5887,7 @@ void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) cons
String path = files[i];
RES res = ResourceLoader::load(path);
ERR_FAIL_COND(res.is_null());
Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(*res));
Ref<Texture2D> texture = Ref<Texture2D>(Object::cast_to<Texture2D>(*res));
Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res));
if (texture != NULL || scene != NULL) {
if (texture != NULL) {
@ -5944,7 +5944,7 @@ bool CanvasItemEditorViewport::_cyclical_dependency_exists(const String &p_targe
void CanvasItemEditorViewport::_create_nodes(Node *parent, Node *child, String &path, const Point2 &p_point) {
child->set_name(path.get_file().get_basename());
Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(ResourceCache::get(path)));
Ref<Texture2D> texture = Ref<Texture2D>(Object::cast_to<Texture2D>(ResourceCache::get(path)));
Size2 texture_size = texture->get_size();
if (parent) {
@ -6081,7 +6081,7 @@ void CanvasItemEditorViewport::_perform_drop_data() {
}
}
} else {
Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(*res));
Ref<Texture2D> texture = Ref<Texture2D>(Object::cast_to<Texture2D>(*res));
if (texture != NULL && texture.is_valid()) {
Node *child;
if (default_type == "Light2D")
@ -6136,7 +6136,7 @@ bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Varian
continue;
}
memdelete(instanced_scene);
} else if (type == "Texture" ||
} else if (type == "Texture2D" ||
type == "ImageTexture" ||
type == "ViewportTexture" ||
type == "CurveTexture" ||
@ -6144,7 +6144,7 @@ bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Varian
type == "StreamTexture" ||
type == "AtlasTexture" ||
type == "LargeTexture") {
Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(*res));
Ref<Texture2D> texture = Ref<Texture2D>(Object::cast_to<Texture2D>(*res));
if (!texture.is_valid()) {
continue;
}

View file

@ -306,7 +306,7 @@ private:
struct _HoverResult {
Point2 position;
Ref<Texture> icon;
Ref<Texture2D> icon;
String name;
};
Vector<_HoverResult> hovering_results;
@ -406,8 +406,8 @@ private:
Point2 box_selecting_to;
Ref<StyleBoxTexture> select_sb;
Ref<Texture> select_handle;
Ref<Texture> anchor_handle;
Ref<Texture2D> select_handle;
Ref<Texture2D> anchor_handle;
Ref<ShortCut> drag_pivot_shortcut;
Ref<ShortCut> set_pivot_shortcut;

View file

@ -384,7 +384,7 @@ void Polygon3DEditor::_polygon_draw() {
imgeom->clear();
imgeom->set_material_override(line_material);
imgeom->begin(Mesh::PRIMITIVE_LINES, Ref<Texture>());
imgeom->begin(Mesh::PRIMITIVE_LINES, Ref<Texture2D>());
Rect2 rect;
@ -561,7 +561,7 @@ Polygon3DEditor::Polygon3DEditor(EditorNode *p_editor) {
handle_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
handle_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
handle_material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
Ref<Texture> handle = editor->get_gui_base()->get_icon("Editor3DHandle", "EditorIcons");
Ref<Texture2D> handle = editor->get_gui_base()->get_icon("Editor3DHandle", "EditorIcons");
handle_material->set_point_size(handle->get_width());
handle_material->set_texture(SpatialMaterial::TEXTURE_ALBEDO, handle);

View file

@ -435,7 +435,7 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla
Transform2D gt = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
Ref<Texture> h = get_icon("EditorHandle", "EditorIcons");
Ref<Texture2D> h = get_icon("EditorHandle", "EditorIcons");
Vector2 size = h->get_size() * 0.5;
handles.clear();

View file

@ -787,10 +787,10 @@ bool CurvePreviewGenerator::handles(const String &p_type) const {
return p_type == "Curve";
}
Ref<Texture> CurvePreviewGenerator::generate(const Ref<Resource> &p_from, const Size2 &p_size) const {
Ref<Texture2D> CurvePreviewGenerator::generate(const Ref<Resource> &p_from, const Size2 &p_size) const {
Ref<Curve> curve_ref = p_from;
ERR_FAIL_COND_V_MSG(curve_ref.is_null(), Ref<Texture>(), "It's not a reference to a valid Resource object.");
ERR_FAIL_COND_V_MSG(curve_ref.is_null(), Ref<Texture2D>(), "It's not a reference to a valid Resource object.");
Curve &curve = **curve_ref;
// FIXME: Should be ported to use p_size as done in b2633a97
@ -848,6 +848,6 @@ Ref<Texture> CurvePreviewGenerator::generate(const Ref<Resource> &p_from, const
Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture));
ptex->create_from_image(img_ref, 0);
ptex->create_from_image(img_ref);
return ptex;
}

View file

@ -141,7 +141,7 @@ class CurvePreviewGenerator : public EditorResourcePreviewGenerator {
public:
virtual bool handles(const String &p_type) const;
virtual Ref<Texture> generate(const Ref<Resource> &p_from, const Size2 &p_size) const;
virtual Ref<Texture2D> generate(const Ref<Resource> &p_from, const Size2 &p_size) const;
};
#endif // CURVE_EDITOR_PLUGIN_H

View file

@ -76,34 +76,34 @@ void post_process_preview(Ref<Image> p_image) {
bool EditorTexturePreviewPlugin::handles(const String &p_type) const {
return ClassDB::is_parent_class(p_type, "Texture");
return ClassDB::is_parent_class(p_type, "Texture2D");
}
bool EditorTexturePreviewPlugin::generate_small_preview_automatically() const {
return true;
}
Ref<Texture> EditorTexturePreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
Ref<Texture2D> EditorTexturePreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
Ref<Image> img;
Ref<AtlasTexture> atex = p_from;
Ref<LargeTexture> ltex = p_from;
if (atex.is_valid()) {
Ref<Texture> tex = atex->get_atlas();
Ref<Texture2D> tex = atex->get_atlas();
if (!tex.is_valid()) {
return Ref<Texture>();
return Ref<Texture2D>();
}
Ref<Image> atlas = tex->get_data();
if (!atlas.is_valid()) {
return Ref<Texture>();
return Ref<Texture2D>();
}
img = atlas->get_rect(atex->get_region());
} else if (ltex.is_valid()) {
img = ltex->to_image();
} else {
Ref<Texture> tex = p_from;
Ref<Texture2D> tex = p_from;
if (tex.is_valid()) {
img = tex->get_data();
if (img.is_valid()) {
@ -113,13 +113,13 @@ Ref<Texture> EditorTexturePreviewPlugin::generate(const RES &p_from, const Size2
}
if (img.is_null() || img->empty())
return Ref<Texture>();
return Ref<Texture2D>();
img->clear_mipmaps();
if (img->is_compressed()) {
if (img->decompress() != OK)
return Ref<Texture>();
return Ref<Texture2D>();
} else if (img->get_format() != Image::FORMAT_RGB8 && img->get_format() != Image::FORMAT_RGBA8) {
img->convert(Image::FORMAT_RGBA8);
}
@ -137,7 +137,7 @@ Ref<Texture> EditorTexturePreviewPlugin::generate(const RES &p_from, const Size2
Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture));
ptex->create_from_image(img, 0);
ptex->create_from_image(img);
return ptex;
}
@ -151,7 +151,7 @@ bool EditorImagePreviewPlugin::handles(const String &p_type) const {
return p_type == "Image";
}
Ref<Texture> EditorImagePreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
Ref<Texture2D> EditorImagePreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
Ref<Image> img = p_from;
@ -182,7 +182,7 @@ Ref<Texture> EditorImagePreviewPlugin::generate(const RES &p_from, const Size2 &
Ref<ImageTexture> ptex;
ptex.instance();
ptex->create_from_image(img, 0);
ptex->create_from_image(img);
return ptex;
}
@ -199,12 +199,12 @@ bool EditorBitmapPreviewPlugin::handles(const String &p_type) const {
return ClassDB::is_parent_class(p_type, "BitMap");
}
Ref<Texture> EditorBitmapPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
Ref<Texture2D> EditorBitmapPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
Ref<BitMap> bm = p_from;
if (bm->get_size() == Size2()) {
return Ref<Texture>();
return Ref<Texture2D>();
}
PoolVector<uint8_t> data;
@ -231,7 +231,7 @@ Ref<Texture> EditorBitmapPreviewPlugin::generate(const RES &p_from, const Size2
if (img->is_compressed()) {
if (img->decompress() != OK)
return Ref<Texture>();
return Ref<Texture2D>();
} else if (img->get_format() != Image::FORMAT_RGB8 && img->get_format() != Image::FORMAT_RGBA8) {
img->convert(Image::FORMAT_RGBA8);
}
@ -249,7 +249,7 @@ Ref<Texture> EditorBitmapPreviewPlugin::generate(const RES &p_from, const Size2
Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture));
ptex->create_from_image(img, 0);
ptex->create_from_image(img);
return ptex;
}
@ -266,12 +266,13 @@ bool EditorPackedScenePreviewPlugin::handles(const String &p_type) const {
return ClassDB::is_parent_class(p_type, "PackedScene");
}
Ref<Texture> EditorPackedScenePreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
Ref<Texture2D> EditorPackedScenePreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
return generate_from_path(p_from->get_path(), p_size);
}
Ref<Texture> EditorPackedScenePreviewPlugin::generate_from_path(const String &p_path, const Size2 &p_size) const {
Ref<Texture2D> EditorPackedScenePreviewPlugin::generate_from_path(const String &p_path, const Size2 &p_size) const {
String temp_path = EditorSettings::get_singleton()->get_cache_dir();
String cache_base = ProjectSettings::get_singleton()->globalize_path(p_path).md5_text();
@ -282,7 +283,7 @@ Ref<Texture> EditorPackedScenePreviewPlugin::generate_from_path(const String &p_
String path = cache_base + ".png";
if (!FileAccess::exists(path))
return Ref<Texture>();
return Ref<Texture2D>();
Ref<Image> img;
img.instance();
@ -292,11 +293,11 @@ Ref<Texture> EditorPackedScenePreviewPlugin::generate_from_path(const String &p_
Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture));
post_process_preview(img);
ptex->create_from_image(img, 0);
ptex->create_from_image(img);
return ptex;
} else {
return Ref<Texture>();
return Ref<Texture2D>();
}
}
@ -324,10 +325,10 @@ bool EditorMaterialPreviewPlugin::generate_small_preview_automatically() const {
return true;
}
Ref<Texture> EditorMaterialPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
Ref<Texture2D> EditorMaterialPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
Ref<Material> material = p_from;
ERR_FAIL_COND_V(material.is_null(), Ref<Texture>());
ERR_FAIL_COND_V(material.is_null(), Ref<Texture2D>());
if (material->get_shader_mode() == Shader::MODE_SPATIAL) {
@ -342,7 +343,7 @@ Ref<Texture> EditorMaterialPreviewPlugin::generate(const RES &p_from, const Size
OS::get_singleton()->delay_usec(10);
}
Ref<Image> img = VS::get_singleton()->texture_get_data(viewport_texture);
Ref<Image> img = VS::get_singleton()->texture_2d_get(viewport_texture);
VS::get_singleton()->mesh_surface_set_material(sphere, 0, RID());
ERR_FAIL_COND_V(!img.is_valid(), Ref<ImageTexture>());
@ -352,11 +353,11 @@ Ref<Texture> EditorMaterialPreviewPlugin::generate(const RES &p_from, const Size
img->resize(thumbnail_size, thumbnail_size, Image::INTERPOLATE_CUBIC);
post_process_preview(img);
Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture));
ptex->create_from_image(img, 0);
ptex->create_from_image(img);
return ptex;
}
return Ref<Texture>();
return Ref<Texture2D>();
}
EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() {
@ -490,15 +491,15 @@ bool EditorScriptPreviewPlugin::handles(const String &p_type) const {
return ClassDB::is_parent_class(p_type, "Script");
}
Ref<Texture> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
Ref<Script> scr = p_from;
if (scr.is_null())
return Ref<Texture>();
return Ref<Texture2D>();
String code = scr->get_source_code().strip_edges();
if (code == "")
return Ref<Texture>();
return Ref<Texture2D>();
List<String> kwors;
scr->get_language()->get_reserved_words(&kwors);
@ -599,7 +600,7 @@ Ref<Texture> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size2
Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture));
ptex->create_from_image(img, 0);
ptex->create_from_image(img);
return ptex;
}
@ -612,10 +613,10 @@ bool EditorAudioStreamPreviewPlugin::handles(const String &p_type) const {
return ClassDB::is_parent_class(p_type, "AudioStream");
}
Ref<Texture> EditorAudioStreamPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
Ref<Texture2D> EditorAudioStreamPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
Ref<AudioStream> stream = p_from;
ERR_FAIL_COND_V(stream.is_null(), Ref<Texture>());
ERR_FAIL_COND_V(stream.is_null(), Ref<Texture2D>());
PoolVector<uint8_t> img;
@ -627,7 +628,7 @@ Ref<Texture> EditorAudioStreamPreviewPlugin::generate(const RES &p_from, const S
uint8_t *imgw = imgdata.ptr();
Ref<AudioStreamPlayback> playback = stream->instance_playback();
ERR_FAIL_COND_V(playback.is_null(), Ref<Texture>());
ERR_FAIL_COND_V(playback.is_null(), Ref<Texture2D>());
float len_s = stream->get_length();
if (len_s == 0) {
@ -687,7 +688,7 @@ Ref<Texture> EditorAudioStreamPreviewPlugin::generate(const RES &p_from, const S
Ref<Image> image;
image.instance();
image->create(w, h, false, Image::FORMAT_RGB8, img);
ptex->create_from_image(image, 0);
ptex->create_from_image(image);
return ptex;
}
@ -710,10 +711,10 @@ bool EditorMeshPreviewPlugin::handles(const String &p_type) const {
return ClassDB::is_parent_class(p_type, "Mesh"); //any Mesh
}
Ref<Texture> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
Ref<Texture2D> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
Ref<Mesh> mesh = p_from;
ERR_FAIL_COND_V(mesh.is_null(), Ref<Texture>());
ERR_FAIL_COND_V(mesh.is_null(), Ref<Texture2D>());
VS::get_singleton()->instance_set_base(mesh_instance, mesh->get_rid());
@ -726,7 +727,7 @@ Ref<Texture> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2 &p
AABB rot_aabb = xform.xform(aabb);
float m = MAX(rot_aabb.size.x, rot_aabb.size.y) * 0.5;
if (m == 0)
return Ref<Texture>();
return Ref<Texture2D>();
m = 1.0 / m;
m *= 0.5;
xform.basis.scale(Vector3(m, m, m));
@ -743,7 +744,7 @@ Ref<Texture> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2 &p
OS::get_singleton()->delay_usec(10);
}
Ref<Image> img = VS::get_singleton()->texture_get_data(viewport_texture);
Ref<Image> img = VS::get_singleton()->texture_2d_get(viewport_texture);
ERR_FAIL_COND_V(img.is_null(), Ref<ImageTexture>());
VS::get_singleton()->instance_set_base(mesh_instance, RID());
@ -762,7 +763,7 @@ Ref<Texture> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2 &p
post_process_preview(img);
Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture));
ptex->create_from_image(img, 0);
ptex->create_from_image(img);
return ptex;
}
@ -831,7 +832,7 @@ bool EditorFontPreviewPlugin::handles(const String &p_type) const {
return ClassDB::is_parent_class(p_type, "DynamicFontData") || ClassDB::is_parent_class(p_type, "DynamicFont");
}
Ref<Texture> EditorFontPreviewPlugin::generate_from_path(const String &p_path, const Size2 &p_size) const {
Ref<Texture2D> EditorFontPreviewPlugin::generate_from_path(const String &p_path, const Size2 &p_size) const {
RES res = ResourceLoader::load(p_path);
Ref<DynamicFont> sampled_font;
@ -868,7 +869,7 @@ Ref<Texture> EditorFontPreviewPlugin::generate_from_path(const String &p_path, c
VS::get_singleton()->canvas_item_clear(canvas_item);
Ref<Image> img = VS::get_singleton()->texture_get_data(viewport_texture);
Ref<Image> img = VS::get_singleton()->texture_2d_get(viewport_texture);
ERR_FAIL_COND_V(img.is_null(), Ref<ImageTexture>());
img->convert(Image::FORMAT_RGBA8);
@ -885,16 +886,16 @@ Ref<Texture> EditorFontPreviewPlugin::generate_from_path(const String &p_path, c
post_process_preview(img);
Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture));
ptex->create_from_image(img, 0);
ptex->create_from_image(img);
return ptex;
}
Ref<Texture> EditorFontPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
Ref<Texture2D> EditorFontPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
String path = p_from->get_path();
if (!FileAccess::exists(path)) {
return Ref<Texture>();
return Ref<Texture2D>();
}
return generate_from_path(path, p_size);
}

View file

@ -41,7 +41,7 @@ class EditorTexturePreviewPlugin : public EditorResourcePreviewGenerator {
public:
virtual bool handles(const String &p_type) const;
virtual bool generate_small_preview_automatically() const;
virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const;
virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const;
EditorTexturePreviewPlugin();
};
@ -52,7 +52,7 @@ class EditorImagePreviewPlugin : public EditorResourcePreviewGenerator {
public:
virtual bool handles(const String &p_type) const;
virtual bool generate_small_preview_automatically() const;
virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const;
virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const;
EditorImagePreviewPlugin();
};
@ -63,7 +63,7 @@ class EditorBitmapPreviewPlugin : public EditorResourcePreviewGenerator {
public:
virtual bool handles(const String &p_type) const;
virtual bool generate_small_preview_automatically() const;
virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const;
virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const;
EditorBitmapPreviewPlugin();
};
@ -72,8 +72,8 @@ class EditorPackedScenePreviewPlugin : public EditorResourcePreviewGenerator {
public:
virtual bool handles(const String &p_type) const;
virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const;
virtual Ref<Texture> generate_from_path(const String &p_path, const Size2 &p_size) const;
virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const;
virtual Ref<Texture2D> generate_from_path(const String &p_path, const Size2 &p_size) const;
EditorPackedScenePreviewPlugin();
};
@ -102,7 +102,7 @@ protected:
public:
virtual bool handles(const String &p_type) const;
virtual bool generate_small_preview_automatically() const;
virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const;
virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const;
EditorMaterialPreviewPlugin();
~EditorMaterialPreviewPlugin();
@ -111,7 +111,7 @@ public:
class EditorScriptPreviewPlugin : public EditorResourcePreviewGenerator {
public:
virtual bool handles(const String &p_type) const;
virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const;
virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const;
EditorScriptPreviewPlugin();
};
@ -119,7 +119,7 @@ public:
class EditorAudioStreamPreviewPlugin : public EditorResourcePreviewGenerator {
public:
virtual bool handles(const String &p_type) const;
virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const;
virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const;
EditorAudioStreamPreviewPlugin();
};
@ -146,7 +146,7 @@ protected:
public:
virtual bool handles(const String &p_type) const;
virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const;
virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const;
EditorMeshPreviewPlugin();
~EditorMeshPreviewPlugin();
@ -169,8 +169,8 @@ protected:
public:
virtual bool handles(const String &p_type) const;
virtual Ref<Texture> generate(const RES &p_from, const Size2 &p_size) const;
virtual Ref<Texture> generate_from_path(const String &p_path, const Size2 &p_size) const;
virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const;
virtual Ref<Texture2D> generate_from_path(const String &p_path, const Size2 &p_size) const;
EditorFontPreviewPlugin();
~EditorFontPreviewPlugin();

View file

@ -105,7 +105,7 @@ void ItemListPlugin::_get_property_list(List<PropertyInfo> *p_list) const {
String base = itos(i) + "/";
p_list->push_back(PropertyInfo(Variant::STRING, base + "text"));
p_list->push_back(PropertyInfo(Variant::OBJECT, base + "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture"));
p_list->push_back(PropertyInfo(Variant::OBJECT, base + "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"));
int flags = get_flags();

View file

@ -66,8 +66,8 @@ public:
virtual void set_item_text(int p_idx, const String &p_text) {}
virtual String get_item_text(int p_idx) const { return ""; };
virtual void set_item_icon(int p_idx, const Ref<Texture> &p_tex) {}
virtual Ref<Texture> get_item_icon(int p_idx) const { return Ref<Texture>(); };
virtual void set_item_icon(int p_idx, const Ref<Texture2D> &p_tex) {}
virtual Ref<Texture2D> get_item_icon(int p_idx) const { return Ref<Texture2D>(); };
virtual void set_item_checkable(int p_idx, bool p_check) {}
virtual void set_item_radio_checkable(int p_idx, bool p_check) {}
@ -109,8 +109,8 @@ public:
virtual void set_item_text(int p_idx, const String &p_text) { ob->set_item_text(p_idx, p_text); }
virtual String get_item_text(int p_idx) const { return ob->get_item_text(p_idx); }
virtual void set_item_icon(int p_idx, const Ref<Texture> &p_tex) { ob->set_item_icon(p_idx, p_tex); }
virtual Ref<Texture> get_item_icon(int p_idx) const { return ob->get_item_icon(p_idx); }
virtual void set_item_icon(int p_idx, const Ref<Texture2D> &p_tex) { ob->set_item_icon(p_idx, p_tex); }
virtual Ref<Texture2D> get_item_icon(int p_idx) const { return ob->get_item_icon(p_idx); }
virtual void set_item_enabled(int p_idx, int p_enabled) { ob->set_item_disabled(p_idx, !p_enabled); }
virtual bool is_item_enabled(int p_idx) const { return !ob->is_item_disabled(p_idx); }
@ -139,8 +139,8 @@ public:
virtual void set_item_text(int p_idx, const String &p_text) { pp->set_item_text(p_idx, p_text); }
virtual String get_item_text(int p_idx) const { return pp->get_item_text(p_idx); }
virtual void set_item_icon(int p_idx, const Ref<Texture> &p_tex) { pp->set_item_icon(p_idx, p_tex); }
virtual Ref<Texture> get_item_icon(int p_idx) const { return pp->get_item_icon(p_idx); }
virtual void set_item_icon(int p_idx, const Ref<Texture2D> &p_tex) { pp->set_item_icon(p_idx, p_tex); }
virtual Ref<Texture2D> get_item_icon(int p_idx) const { return pp->get_item_icon(p_idx); }
virtual void set_item_checkable(int p_idx, bool p_check) { pp->set_item_as_checkable(p_idx, p_check); }
virtual void set_item_radio_checkable(int p_idx, bool p_check) { pp->set_item_as_radio_checkable(p_idx, p_check); }
@ -182,8 +182,8 @@ public:
virtual void set_item_text(int p_idx, const String &p_text) { pp->set_item_text(p_idx, p_text); }
virtual String get_item_text(int p_idx) const { return pp->get_item_text(p_idx); }
virtual void set_item_icon(int p_idx, const Ref<Texture> &p_tex) { pp->set_item_icon(p_idx, p_tex); }
virtual Ref<Texture> get_item_icon(int p_idx) const { return pp->get_item_icon(p_idx); }
virtual void set_item_icon(int p_idx, const Ref<Texture2D> &p_tex) { pp->set_item_icon(p_idx, p_tex); }
virtual Ref<Texture2D> get_item_icon(int p_idx) const { return pp->get_item_icon(p_idx); }
virtual void set_item_enabled(int p_idx, int p_enabled) { pp->set_item_disabled(p_idx, !p_enabled); }
virtual bool is_item_enabled(int p_idx) const { return !pp->is_item_disabled(p_idx); }

View file

@ -59,7 +59,7 @@ void MaterialEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW) {
Ref<Texture> checkerboard = get_icon("Checkerboard", "EditorIcons");
Ref<Texture2D> checkerboard = get_icon("Checkerboard", "EditorIcons");
Size2 size = get_size();
draw_texture_rect(checkerboard, Rect2(Point2(), size), true);
@ -268,7 +268,7 @@ Ref<Resource> SpatialMaterialConversionPlugin::convert(const Ref<Resource> &p_re
// Texture parameter has to be treated specially since SpatialMaterial saved it
// as RID but ShaderMaterial needs Texture itself
Ref<Texture> texture = mat->get_texture_by_name(E->get().name);
Ref<Texture2D> texture = mat->get_texture_by_name(E->get().name);
if (texture.is_valid()) {
smat->set_shader_param(E->get().name, texture);
} else {

View file

@ -182,7 +182,7 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
}
}
Vector<Ref<Texture> > textures = EditorInterface::get_singleton()->make_mesh_previews(meshes, &transforms, EditorSettings::get_singleton()->get("editors/grid_map/preview_size"));
Vector<Ref<Texture2D> > textures = EditorInterface::get_singleton()->make_mesh_previews(meshes, &transforms, EditorSettings::get_singleton()->get("editors/grid_map/preview_size"));
int j = 0;
for (int i = 0; i < ids.size(); i++) {

View file

@ -292,7 +292,7 @@ void Particles2DEditorPlugin::_generate_emission_mask() {
Ref<ImageTexture> imgt;
imgt.instance();
imgt->create_from_image(img, 0);
imgt->create_from_image(img);
pm->set_emission_point_texture(imgt);
pm->set_emission_point_count(vpc);
@ -314,7 +314,7 @@ void Particles2DEditorPlugin::_generate_emission_mask() {
img->create(w, h, false, Image::FORMAT_RGBA8, colordata);
imgt.instance();
imgt->create_from_image(img, 0);
imgt->create_from_image(img);
pm->set_emission_color_texture(imgt);
}
@ -337,7 +337,7 @@ void Particles2DEditorPlugin::_generate_emission_mask() {
img->create(w, h, false, Image::FORMAT_RGF, normdata);
imgt.instance();
imgt->create_from_image(img, 0);
imgt->create_from_image(img);
pm->set_emission_normal_texture(imgt);
} else {

View file

@ -410,7 +410,6 @@ void ParticlesEditor::_generate_emission_points() {
Ref<ImageTexture> tex;
tex.instance();
tex->create_from_image(image, Texture::FLAG_FILTER);
Ref<ParticlesMaterial> material = node->get_process_material();
ERR_FAIL_COND(material.is_null());
@ -440,7 +439,6 @@ void ParticlesEditor::_generate_emission_points() {
Ref<ImageTexture> tex2;
tex2.instance();
tex2->create_from_image(image2, Texture::FLAG_FILTER);
material->set_emission_normal_texture(tex2);
} else {

View file

@ -373,12 +373,12 @@ void Path2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
const Ref<Texture> path_sharp_handle = get_icon("EditorPathSharpHandle", "EditorIcons");
const Ref<Texture> path_smooth_handle = get_icon("EditorPathSmoothHandle", "EditorIcons");
const Ref<Texture2D> path_sharp_handle = get_icon("EditorPathSharpHandle", "EditorIcons");
const Ref<Texture2D> path_smooth_handle = get_icon("EditorPathSmoothHandle", "EditorIcons");
// Both handle icons must be of the same size
const Size2 handle_size = path_sharp_handle->get_size();
const Ref<Texture> curve_handle = get_icon("EditorCurveHandle", "EditorIcons");
const Ref<Texture2D> curve_handle = get_icon("EditorCurveHandle", "EditorIcons");
const Size2 curve_handle_size = curve_handle->get_size();
Ref<Curve2D> curve = node->get_curve();
@ -420,7 +420,7 @@ void Path2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
}
if (on_edge) {
Ref<Texture> add_handle = get_icon("EditorHandleAdd", "EditorIcons");
Ref<Texture2D> add_handle = get_icon("EditorHandleAdd", "EditorIcons");
p_overlay->draw_texture(add_handle, edge_point - add_handle->get_size() * 0.5);
}
}

View file

@ -980,7 +980,7 @@ void Polygon2DEditor::_uv_draw() {
if (!uv_edit->is_visible() || !_get_node())
return;
Ref<Texture> base_tex = node->get_texture();
Ref<Texture2D> base_tex = node->get_texture();
if (base_tex.is_null())
return;
@ -1050,7 +1050,7 @@ void Polygon2DEditor::_uv_draw() {
}
// All UV points are sharp, so use the sharp handle icon
Ref<Texture> handle = get_icon("EditorPathSharpHandle", "EditorIcons");
Ref<Texture2D> handle = get_icon("EditorPathSharpHandle", "EditorIcons");
Color poly_line_color = Color(0.9, 0.5, 0.5);
if (polygons.size() || polygon_create.size()) {

View file

@ -205,7 +205,7 @@ void EditorPropertyRootMotion::update_property() {
assign->set_tooltip(p);
if (p == NodePath()) {
assign->set_icon(Ref<Texture>());
assign->set_icon(Ref<Texture2D>());
assign->set_text(TTR("Assign..."));
assign->set_flat(false);
return;
@ -222,7 +222,7 @@ void EditorPropertyRootMotion::update_property() {
}
if (!base_node || !base_node->has_node(p)) {
assign->set_icon(Ref<Texture>());
assign->set_icon(Ref<Texture2D>());
assign->set_text(p);
return;
}
@ -242,7 +242,7 @@ void EditorPropertyRootMotion::setup(const NodePath &p_base_hint) {
void EditorPropertyRootMotion::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
Ref<Texture> t = get_icon("Clear", "EditorIcons");
Ref<Texture2D> t = get_icon("Clear", "EditorIcons");
clear->set_icon(t);
}
}

View file

@ -1647,7 +1647,7 @@ struct _ScriptEditorItemData {
String name;
String sort_key;
Ref<Texture> icon;
Ref<Texture2D> icon;
int index;
String tooltip;
bool used;
@ -1832,7 +1832,7 @@ void ScriptEditor::_update_script_names() {
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (se) {
Ref<Texture> icon = se->get_icon();
Ref<Texture2D> icon = se->get_icon();
String path = se->get_edited_resource()->get_path();
bool built_in = !path.is_resource_file();
String name;
@ -1893,7 +1893,7 @@ void ScriptEditor::_update_script_names() {
if (eh) {
String name = eh->get_class();
Ref<Texture> icon = get_icon("Help", "EditorIcons");
Ref<Texture2D> icon = get_icon("Help", "EditorIcons");
String tooltip = vformat(TTR("%s Class Reference"), name);
_ScriptEditorItemData sd;
@ -2416,7 +2416,7 @@ Variant ScriptEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
HBoxContainer *drag_preview = memnew(HBoxContainer);
String preview_name = "";
Ref<Texture> preview_icon;
Ref<Texture2D> preview_icon;
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(cur_node);
if (se) {

View file

@ -92,7 +92,7 @@ public:
virtual void set_edited_resource(const RES &p_res) = 0;
virtual void reload_text() = 0;
virtual String get_name() = 0;
virtual Ref<Texture> get_icon() = 0;
virtual Ref<Texture2D> get_icon() = 0;
virtual bool is_unsaved() = 0;
virtual Variant get_edit_state() = 0;
virtual void set_edit_state(const Variant &p_state) = 0;

View file

@ -548,13 +548,13 @@ String ScriptTextEditor::get_name() {
return name;
}
Ref<Texture> ScriptTextEditor::get_icon() {
Ref<Texture2D> ScriptTextEditor::get_icon() {
if (get_parent_control() && get_parent_control()->has_icon(script->get_class(), "EditorIcons")) {
return get_parent_control()->get_icon(script->get_class(), "EditorIcons");
}
return Ref<Texture>();
return Ref<Texture2D>();
}
void ScriptTextEditor::_validate_script() {

View file

@ -199,7 +199,7 @@ public:
virtual Vector<String> get_functions();
virtual void reload_text();
virtual String get_name();
virtual Ref<Texture> get_icon();
virtual Ref<Texture2D> get_icon();
virtual bool is_unsaved();
virtual Variant get_edit_state();
virtual void set_edit_state(const Variant &p_state);

View file

@ -864,7 +864,7 @@ void SpatialEditorViewport::_list_select(Ref<InputEventMouseButton> b) {
Spatial *spat = selection_results[i].item;
Ref<Texture> icon = EditorNode::get_singleton()->get_object_icon(spat, "Node");
Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(spat, "Node");
String node_path = "/" + root_name + "/" + root_path.rel_path_to(spat->get_path());
@ -2371,7 +2371,7 @@ void SpatialEditorViewport::_notification(int p_what) {
}
}
static void draw_indicator_bar(Control &surface, real_t fill, Ref<Texture> icon) {
static void draw_indicator_bar(Control &surface, real_t fill, Ref<Texture2D> icon) {
// Adjust bar size from control height
Vector2 surface_size = surface.get_size();
@ -3841,12 +3841,12 @@ void SpatialEditorViewportContainer::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW && mouseover) {
Ref<Texture> h_grabber = get_icon("grabber", "HSplitContainer");
Ref<Texture> v_grabber = get_icon("grabber", "VSplitContainer");
Ref<Texture2D> h_grabber = get_icon("grabber", "HSplitContainer");
Ref<Texture2D> v_grabber = get_icon("grabber", "VSplitContainer");
Ref<Texture> hdiag_grabber = get_icon("GuiViewportHdiagsplitter", "EditorIcons");
Ref<Texture> vdiag_grabber = get_icon("GuiViewportVdiagsplitter", "EditorIcons");
Ref<Texture> vh_grabber = get_icon("GuiViewportVhsplitter", "EditorIcons");
Ref<Texture2D> hdiag_grabber = get_icon("GuiViewportHdiagsplitter", "EditorIcons");
Ref<Texture2D> vdiag_grabber = get_icon("GuiViewportVdiagsplitter", "EditorIcons");
Ref<Texture2D> vh_grabber = get_icon("GuiViewportVhsplitter", "EditorIcons");
Vector2 size = get_size();
@ -6181,7 +6181,7 @@ void EditorSpatialGizmoPlugin::create_material(const String &p_name, const Color
materials[p_name] = mats;
}
void EditorSpatialGizmoPlugin::create_icon_material(const String &p_name, const Ref<Texture> &p_texture, bool p_on_top, const Color &p_albedo) {
void EditorSpatialGizmoPlugin::create_icon_material(const String &p_name, const Ref<Texture2D> &p_texture, bool p_on_top, const Color &p_albedo) {
Color instanced_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/instanced", Color(0.7, 0.7, 0.7, 0.6));
@ -6227,7 +6227,7 @@ void EditorSpatialGizmoPlugin::create_handle_material(const String &p_name, bool
handle_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
handle_material->set_flag(SpatialMaterial::FLAG_USE_POINT_SIZE, true);
Ref<Texture> handle_t = SpatialEditor::get_singleton()->get_icon("Editor3DHandle", "EditorIcons");
Ref<Texture2D> handle_t = SpatialEditor::get_singleton()->get_icon("Editor3DHandle", "EditorIcons");
handle_material->set_point_size(handle_t->get_width());
handle_material->set_texture(SpatialMaterial::TEXTURE_ALBEDO, handle_t);
handle_material->set_albedo(Color(1, 1, 1));

View file

@ -785,7 +785,7 @@ protected:
public:
void create_material(const String &p_name, const Color &p_color, bool p_billboard = false, bool p_on_top = false, bool p_use_vertex_color = false);
void create_icon_material(const String &p_name, const Ref<Texture> &p_texture, bool p_on_top = false, const Color &p_albedo = Color(1, 1, 1, 1));
void create_icon_material(const String &p_name, const Ref<Texture2D> &p_texture, bool p_on_top = false, const Color &p_albedo = Color(1, 1, 1, 1));
void create_handle_material(const String &p_name, bool p_billboard = false);
void add_material(const String &p_name, Ref<SpatialMaterial> p_material);

View file

@ -167,7 +167,7 @@ void SpriteEditor::_menu_option(int p_option) {
void SpriteEditor::_update_mesh_data() {
Ref<Texture> texture = node->get_texture();
Ref<Texture2D> texture = node->get_texture();
if (texture.is_null()) {
err_dialog->set_text(TTR("Sprite is empty!"));
err_dialog->popup_centered_minsize();
@ -476,7 +476,7 @@ void SpriteEditor::_add_as_sibling_or_child(Node *p_own_node, Node *p_new_node)
void SpriteEditor::_debug_uv_draw() {
Ref<Texture> tex = node->get_texture();
Ref<Texture2D> tex = node->get_texture();
ERR_FAIL_COND(!tex.is_valid());
Point2 draw_pos_offset = Point2(1.0, 1.0);

View file

@ -44,7 +44,7 @@ void SpriteFramesEditor::_open_sprite_sheet() {
file_split_sheet->clear_filters();
List<String> extensions;
ResourceLoader::get_recognized_extensions_for_type("Texture", &extensions);
ResourceLoader::get_recognized_extensions_for_type("Texture2D", &extensions);
for (int i = 0; i < extensions.size(); i++) {
file_split_sheet->add_filter("*." + extensions[i]);
}
@ -249,11 +249,11 @@ void SpriteFramesEditor::_file_load_request(const PoolVector<String> &p_path, in
ERR_FAIL_COND(!frames->has_animation(edited_anim));
List<Ref<Texture> > resources;
List<Ref<Texture2D> > resources;
for (int i = 0; i < p_path.size(); i++) {
Ref<Texture> resource;
Ref<Texture2D> resource;
resource = ResourceLoader::load(p_path[i]);
if (resource.is_null()) {
@ -278,7 +278,7 @@ void SpriteFramesEditor::_file_load_request(const PoolVector<String> &p_path, in
int count = 0;
for (List<Ref<Texture> >::Element *E = resources.front(); E; E = E->next()) {
for (List<Ref<Texture2D> >::Element *E = resources.front(); E; E = E->next()) {
undo_redo->add_do_method(frames, "add_frame", edited_anim, E->get(), p_at_pos == -1 ? -1 : p_at_pos + count);
undo_redo->add_undo_method(frames, "remove_frame", edited_anim, p_at_pos == -1 ? fc : p_at_pos);
@ -297,7 +297,7 @@ void SpriteFramesEditor::_load_pressed() {
file->clear_filters();
List<String> extensions;
ResourceLoader::get_recognized_extensions_for_type("Texture", &extensions);
ResourceLoader::get_recognized_extensions_for_type("Texture2D", &extensions);
for (int i = 0; i < extensions.size(); i++)
file->add_filter("*." + extensions[i]);
@ -310,7 +310,7 @@ void SpriteFramesEditor::_paste_pressed() {
ERR_FAIL_COND(!frames->has_animation(edited_anim));
Ref<Texture> r = EditorSettings::get_singleton()->get_resource_clipboard();
Ref<Texture2D> r = EditorSettings::get_singleton()->get_resource_clipboard();
if (!r.is_valid()) {
dialog->set_text(TTR("Resource clipboard is empty or not a texture!"));
dialog->set_title(TTR("Error!"));
@ -333,7 +333,7 @@ void SpriteFramesEditor::_copy_pressed() {
if (tree->get_current() < 0)
return;
Ref<Texture> r = frames->get_frame(edited_anim, tree->get_current());
Ref<Texture2D> r = frames->get_frame(edited_anim, tree->get_current());
if (!r.is_valid()) {
return;
}
@ -356,7 +356,7 @@ void SpriteFramesEditor::_empty_pressed() {
from = frames->get_frame_count(edited_anim);
}
Ref<Texture> r;
Ref<Texture2D> r;
undo_redo->create_action(TTR("Add Empty"));
undo_redo->add_do_method(frames, "add_frame", edited_anim, r, from);
@ -381,7 +381,7 @@ void SpriteFramesEditor::_empty2_pressed() {
from = frames->get_frame_count(edited_anim);
}
Ref<Texture> r;
Ref<Texture2D> r;
undo_redo->create_action(TTR("Add Empty"));
undo_redo->add_do_method(frames, "add_frame", edited_anim, r, from + 1);
@ -603,7 +603,7 @@ void SpriteFramesEditor::_animation_remove_confirmed() {
undo_redo->add_undo_method(frames, "set_animation_loop", edited_anim, frames->get_animation_loop(edited_anim));
int fc = frames->get_frame_count(edited_anim);
for (int i = 0; i < fc; i++) {
Ref<Texture> frame = frames->get_frame(edited_anim, i);
Ref<Texture2D> frame = frames->get_frame(edited_anim, i);
undo_redo->add_undo_method(frames, "add_frame", edited_anim, frame);
}
undo_redo->add_do_method(this, "_update_library");
@ -688,7 +688,7 @@ void SpriteFramesEditor::_update_library(bool p_skip_selector) {
for (int i = 0; i < frames->get_frame_count(edited_anim); i++) {
String name;
Ref<Texture> icon;
Ref<Texture2D> icon;
if (frames->get_frame(edited_anim, i).is_null()) {
@ -775,7 +775,7 @@ bool SpriteFramesEditor::can_drop_data_fw(const Point2 &p_point, const Variant &
if (String(d["type"]) == "resource" && d.has("resource")) {
RES r = d["resource"];
Ref<Texture> texture = r;
Ref<Texture2D> texture = r;
if (texture.is_valid()) {
@ -794,7 +794,7 @@ bool SpriteFramesEditor::can_drop_data_fw(const Point2 &p_point, const Variant &
String file = files[i];
String ftype = EditorFileSystem::get_singleton()->get_file_type(file);
if (!ClassDB::is_parent_class(ftype, "Texture")) {
if (!ClassDB::is_parent_class(ftype, "Texture2D")) {
return false;
}
}
@ -819,7 +819,7 @@ void SpriteFramesEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
if (String(d["type"]) == "resource" && d.has("resource")) {
RES r = d["resource"];
Ref<Texture> texture = r;
Ref<Texture2D> texture = r;
if (texture.is_valid()) {
bool reorder = false;

View file

@ -163,7 +163,7 @@ String TextEditor::get_name() {
return name;
}
Ref<Texture> TextEditor::get_icon() {
Ref<Texture2D> TextEditor::get_icon() {
return EditorNode::get_singleton()->get_object_icon(text_file.operator->(), "");
}

View file

@ -120,7 +120,7 @@ public:
virtual void set_syntax_highlighter(SyntaxHighlighter *p_highlighter);
virtual String get_name();
virtual Ref<Texture> get_icon();
virtual Ref<Texture2D> get_icon();
virtual RES get_edited_resource() const;
virtual void set_edited_resource(const RES &p_res);
void set_edited_file(const Ref<TextFile> &p_file);

View file

@ -46,7 +46,7 @@ void TextureEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW) {
Ref<Texture> checkerboard = get_icon("Checkerboard", "EditorIcons");
Ref<Texture2D> checkerboard = get_icon("Checkerboard", "EditorIcons");
Size2 size = get_size();
draw_texture_rect(checkerboard, Rect2(Point2(), size), true);
@ -110,7 +110,7 @@ void TextureEditor::_changed_callback(Object *p_changed, const char *p_prop) {
update();
}
void TextureEditor::edit(Ref<Texture> p_texture) {
void TextureEditor::edit(Ref<Texture2D> p_texture) {
if (!texture.is_null())
texture->remove_change_receptor(this);
@ -148,11 +148,11 @@ bool EditorInspectorPluginTexture::can_handle(Object *p_object) {
void EditorInspectorPluginTexture::parse_begin(Object *p_object) {
Texture *texture = Object::cast_to<Texture>(p_object);
Texture2D *texture = Object::cast_to<Texture2D>(p_object);
if (!texture) {
return;
}
Ref<Texture> m(texture);
Ref<Texture2D> m(texture);
TextureEditor *editor = memnew(TextureEditor);
editor->edit(m);

Some files were not shown because too many files have changed in this diff Show more