@@ -97,34 +97,35 @@ void DPITexture::set_source(const String &p_source) {
97
97
return ;
98
98
}
99
99
source = p_source;
100
- _update_texture ();
100
+ _request_update ();
101
101
}
102
102
103
103
String DPITexture::get_source () const {
104
104
return source;
105
105
}
106
106
107
107
void DPITexture::set_base_scale (float p_scale) {
108
+ p_scale = MAX (0.01 , p_scale);
108
109
if (base_scale == p_scale) {
109
110
return ;
110
111
}
111
- ERR_FAIL_COND (p_scale <= 0.0 );
112
112
113
113
base_scale = p_scale;
114
- _update_texture ();
114
+ _request_update ();
115
115
}
116
116
117
117
float DPITexture::get_base_scale () const {
118
118
return base_scale;
119
119
}
120
120
121
121
void DPITexture::set_saturation (float p_saturation) {
122
+ p_saturation = CLAMP (p_saturation, 0.0 , 1.0 );
122
123
if (saturation == p_saturation) {
123
124
return ;
124
125
}
125
126
126
127
saturation = p_saturation;
127
- _update_texture ();
128
+ _request_update ();
128
129
}
129
130
130
131
float DPITexture::get_saturation () const {
@@ -140,7 +141,7 @@ void DPITexture::set_color_map(const Dictionary &p_color_map) {
140
141
for (const Variant *E = color_map.next (); E; E = color_map.next (E)) {
141
142
cmap[*E] = color_map[*E];
142
143
}
143
- _update_texture ();
144
+ _request_update ();
144
145
}
145
146
146
147
Dictionary DPITexture::get_color_map () const {
@@ -196,12 +197,13 @@ RID DPITexture::_load_at_scale(double p_scale, bool p_set_size) const {
196
197
if (err != OK) {
197
198
return RID ();
198
199
}
199
- #else
200
- img = Image::create_empty (Math::round (16 * p_scale * base_scale), Math::round (16 * p_scale * base_scale), false , Image::FORMAT_RGBA8);
201
- #endif
202
200
if (saturation != 1.0 ) {
203
201
img->adjust_bcs (1.0 , 1.0 , saturation);
204
202
}
203
+ img->fix_alpha_edges ();
204
+ #else
205
+ img = Image::create_empty (Math::round (16 * p_scale * base_scale), Math::round (16 * p_scale * base_scale), false , Image::FORMAT_RGBA8);
206
+ #endif
205
207
206
208
Size2 current_size = size;
207
209
if (p_set_size) {
@@ -244,6 +246,15 @@ void DPITexture::_clear() {
244
246
void DPITexture::_update_texture () {
245
247
_clear ();
246
248
emit_changed ();
249
+ update_requested = false ;
250
+ }
251
+
252
+ void DPITexture::_request_update () {
253
+ if (update_requested) {
254
+ return ;
255
+ }
256
+ update_requested = true ;
257
+ callable_mp (this , &DPITexture::_update_texture).call_deferred ();
247
258
}
248
259
249
260
Ref<Image> DPITexture::get_image () const {
0 commit comments