Fix pixelized previews, but also instances of breaking ImageTexture cache. Closes #25378.
This commit is contained in:
parent
b494de34aa
commit
a089061120
|
@ -952,6 +952,9 @@ void EditorNode::_save_scene_with_preview(String p_file, int p_idx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (img.is_valid()) {
|
if (img.is_valid()) {
|
||||||
|
|
||||||
|
img = img->duplicate();
|
||||||
|
|
||||||
save.step(TTR("Creating Thumbnail"), 2);
|
save.step(TTR("Creating Thumbnail"), 2);
|
||||||
save.step(TTR("Creating Thumbnail"), 3);
|
save.step(TTR("Creating Thumbnail"), 3);
|
||||||
|
|
||||||
|
|
|
@ -159,6 +159,7 @@ void EditorResourcePreview::_generate_preview(Ref<ImageTexture> &r_texture, Ref<
|
||||||
small_thumbnail_size *= EDSCALE;
|
small_thumbnail_size *= EDSCALE;
|
||||||
|
|
||||||
Ref<Image> small_image = r_texture->get_data();
|
Ref<Image> small_image = r_texture->get_data();
|
||||||
|
small_image = small_image->duplicate();
|
||||||
small_image->resize(small_thumbnail_size, small_thumbnail_size, Image::INTERPOLATE_CUBIC);
|
small_image->resize(small_thumbnail_size, small_thumbnail_size, Image::INTERPOLATE_CUBIC);
|
||||||
r_small_texture.instance();
|
r_small_texture.instance();
|
||||||
r_small_texture->create_from_image(small_image);
|
r_small_texture->create_from_image(small_image);
|
||||||
|
|
|
@ -174,6 +174,7 @@ void EditorAssetLibraryItemDescription::set_image(int p_type, int p_index, const
|
||||||
if (preview_images[i].is_video) {
|
if (preview_images[i].is_video) {
|
||||||
Ref<Image> overlay = get_icon("PlayOverlay", "EditorIcons")->get_data();
|
Ref<Image> overlay = get_icon("PlayOverlay", "EditorIcons")->get_data();
|
||||||
Ref<Image> thumbnail = p_image->get_data();
|
Ref<Image> thumbnail = p_image->get_data();
|
||||||
|
thumbnail = thumbnail->duplicate();
|
||||||
Point2 overlay_pos = Point2((thumbnail->get_width() - overlay->get_width()) / 2, (thumbnail->get_height() - overlay->get_height()) / 2);
|
Point2 overlay_pos = Point2((thumbnail->get_width() - overlay->get_width()) / 2, (thumbnail->get_height() - overlay->get_height()) / 2);
|
||||||
|
|
||||||
thumbnail->lock();
|
thumbnail->lock();
|
||||||
|
|
|
@ -99,12 +99,14 @@ Ref<Texture> EditorTexturePreviewPlugin::generate(const RES &p_from, const Size2
|
||||||
} else {
|
} else {
|
||||||
Ref<Texture> tex = p_from;
|
Ref<Texture> tex = p_from;
|
||||||
img = tex->get_data();
|
img = tex->get_data();
|
||||||
|
if (img.is_valid()) {
|
||||||
|
img = img->duplicate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (img.is_null() || img->empty())
|
if (img.is_null() || img->empty())
|
||||||
return Ref<Texture>();
|
return Ref<Texture>();
|
||||||
|
|
||||||
img = img->duplicate();
|
|
||||||
img->clear_mipmaps();
|
img->clear_mipmaps();
|
||||||
|
|
||||||
if (img->is_compressed()) {
|
if (img->is_compressed()) {
|
||||||
|
|
|
@ -442,6 +442,9 @@ void OS_JavaScript::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_s
|
||||||
|
|
||||||
if (texture.is_valid()) {
|
if (texture.is_valid()) {
|
||||||
image = texture->get_data();
|
image = texture->get_data();
|
||||||
|
if (image.is_valid()) {
|
||||||
|
image->duplicate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!image.is_valid() && atlas_texture.is_valid()) {
|
if (!image.is_valid() && atlas_texture.is_valid()) {
|
||||||
|
@ -468,6 +471,8 @@ void OS_JavaScript::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_s
|
||||||
|
|
||||||
ERR_FAIL_COND(!image.is_valid());
|
ERR_FAIL_COND(!image.is_valid());
|
||||||
|
|
||||||
|
image = image->duplicate();
|
||||||
|
|
||||||
if (atlas_texture.is_valid())
|
if (atlas_texture.is_valid())
|
||||||
image->crop_from_point(
|
image->crop_from_point(
|
||||||
atlas_rect.position.x,
|
atlas_rect.position.x,
|
||||||
|
|
Loading…
Reference in New Issue