mirror of
https://github.com/Relintai/tile_map_backport.git
synced 2024-11-09 03:12:09 +01:00
Actually fix image locking issues.
This commit is contained in:
parent
17955723c3
commit
16172e9020
@ -1782,6 +1782,9 @@ Vector<Vector<Ref<Texture>>> RTileSet::generate_terrains_icons(Size2i p_size) {
|
|||||||
for (int terrain = 0; terrain < get_terrains_count(terrain_set); terrain++) {
|
for (int terrain = 0; terrain < get_terrains_count(terrain_set); terrain++) {
|
||||||
Ref<Image> image;
|
Ref<Image> image;
|
||||||
image.instance();
|
image.instance();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (counts[terrain_set][terrain].count > 0) {
|
if (counts[terrain_set][terrain].count > 0) {
|
||||||
// Get the best tile.
|
// Get the best tile.
|
||||||
Ref<Texture> texture = counts[terrain_set][terrain].texture;
|
Ref<Texture> texture = counts[terrain_set][terrain].texture;
|
||||||
@ -1791,8 +1794,11 @@ Vector<Vector<Ref<Texture>>> RTileSet::generate_terrains_icons(Size2i p_size) {
|
|||||||
image->resize(p_size.x, p_size.y, Image::INTERPOLATE_NEAREST);
|
image->resize(p_size.x, p_size.y, Image::INTERPOLATE_NEAREST);
|
||||||
} else {
|
} else {
|
||||||
image->create(1, 1, false, Image::FORMAT_RGBA8);
|
image->create(1, 1, false, Image::FORMAT_RGBA8);
|
||||||
|
image->lock();
|
||||||
image->set_pixel(0, 0, get_terrain_color(terrain_set, terrain));
|
image->set_pixel(0, 0, get_terrain_color(terrain_set, terrain));
|
||||||
|
image->unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<ImageTexture> icon;
|
Ref<ImageTexture> icon;
|
||||||
icon.instance();
|
icon.instance();
|
||||||
icon->create_from_image(image);
|
icon->create_from_image(image);
|
||||||
@ -4539,7 +4545,6 @@ void RTileSetAtlasSource::_update_padded_texture() {
|
|||||||
Ref<Image> image;
|
Ref<Image> image;
|
||||||
image.instance();
|
image.instance();
|
||||||
image->create(size.x, size.y, false, Image::FORMAT_RGBA8);
|
image->create(size.x, size.y, false, Image::FORMAT_RGBA8);
|
||||||
image->lock();
|
|
||||||
|
|
||||||
for (const Map<Vector2i, TileAlternativesData>::Element *kv = tiles.front(); kv; kv = kv->next()) {
|
for (const Map<Vector2i, TileAlternativesData>::Element *kv = tiles.front(); kv; kv = kv->next()) {
|
||||||
for (int frame = 0; frame < (int)kv->value().animation_frames_durations.size(); frame++) {
|
for (int frame = 0; frame < (int)kv->value().animation_frames_durations.size(); frame++) {
|
||||||
@ -4562,15 +4567,17 @@ void RTileSetAtlasSource::_update_padded_texture() {
|
|||||||
image->blit_rect(*src, left_src_rect, base_pos + Vector2i(-1, 0));
|
image->blit_rect(*src, left_src_rect, base_pos + Vector2i(-1, 0));
|
||||||
image->blit_rect(*src, right_src_rect, base_pos + Vector2i(src_rect.size.x, 0));
|
image->blit_rect(*src, right_src_rect, base_pos + Vector2i(src_rect.size.x, 0));
|
||||||
|
|
||||||
|
src->lock();
|
||||||
|
image->lock();
|
||||||
image->set_pixelv(base_pos + Vector2i(-1, -1), src->get_pixelv(src_rect.position));
|
image->set_pixelv(base_pos + Vector2i(-1, -1), src->get_pixelv(src_rect.position));
|
||||||
image->set_pixelv(base_pos + Vector2i(src_rect.size.x, -1), src->get_pixelv(src_rect.position + Vector2i(src_rect.size.x - 1, 0)));
|
image->set_pixelv(base_pos + Vector2i(src_rect.size.x, -1), src->get_pixelv(src_rect.position + Vector2i(src_rect.size.x - 1, 0)));
|
||||||
image->set_pixelv(base_pos + Vector2i(-1, src_rect.size.y), src->get_pixelv(src_rect.position + Vector2i(0, src_rect.size.y - 1)));
|
image->set_pixelv(base_pos + Vector2i(-1, src_rect.size.y), src->get_pixelv(src_rect.position + Vector2i(0, src_rect.size.y - 1)));
|
||||||
image->set_pixelv(base_pos + Vector2i(src_rect.size.x, src_rect.size.y), src->get_pixelv(src_rect.position + Vector2i(src_rect.size.x - 1, src_rect.size.y - 1)));
|
image->set_pixelv(base_pos + Vector2i(src_rect.size.x, src_rect.size.y), src->get_pixelv(src_rect.position + Vector2i(src_rect.size.x - 1, src_rect.size.y - 1)));
|
||||||
|
image->unlock();
|
||||||
|
src->unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
image->unlock();
|
|
||||||
|
|
||||||
if (!padded_texture.is_valid()) {
|
if (!padded_texture.is_valid()) {
|
||||||
padded_texture.instance();
|
padded_texture.instance();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user