@@ -45,11 +45,14 @@ struct filter_9slice {
45
45
struct vec2 output_pixel_scale ;
46
46
struct vec2 last_source_size ;
47
47
bool show_uvs ;
48
+ bool uniform_scale ;
49
+ bool use_linear_filtering ;
48
50
struct filter_9slice_params_t {
49
51
gs_eparam_t * border ;
50
52
gs_eparam_t * output_size ;
51
53
gs_eparam_t * source_size ;
52
54
gs_eparam_t * show_uvs ;
55
+ gs_eparam_t * use_linear_filtering ;
53
56
} params ;
54
57
};
55
58
@@ -97,6 +100,7 @@ static bool filter_reload_effect(void *data)
97
100
params -> border = NULL ;
98
101
params -> output_size = NULL ;
99
102
params -> source_size = NULL ;
103
+ params -> use_linear_filtering = NULL ;
100
104
params -> show_uvs = NULL ;
101
105
102
106
if (!context -> effect ) {
@@ -107,12 +111,17 @@ static bool filter_reload_effect(void *data)
107
111
108
112
params -> show_uvs =
109
113
gs_effect_get_param_by_name (effect , "show_uvs" );
114
+ params -> use_linear_filtering =
115
+ gs_effect_get_param_by_name (effect , "use_linear_filtering" );
110
116
params -> border = gs_effect_get_param_by_name (effect , "border" );
111
117
params -> output_size =
112
118
gs_effect_get_param_by_name (effect , "output_size" );
113
119
params -> source_size =
114
120
gs_effect_get_param_by_name (effect , "source_size" );
115
121
122
+ if (params -> use_linear_filtering == NULL ) {
123
+ warn ("Failed to get use_linear_filtering param." );
124
+ }
116
125
if (params -> show_uvs == NULL ) {
117
126
warn ("Failed to get show_uvs param." );
118
127
}
@@ -161,6 +170,8 @@ static void filter_render(void *data, gs_effect_t *effect)
161
170
gs_effect_set_vec2 (params -> source_size , & context -> last_source_size );
162
171
gs_effect_set_vec2 (params -> output_size , & output_size );
163
172
gs_effect_set_bool (params -> show_uvs , context -> show_uvs );
173
+ gs_effect_set_bool (params -> use_linear_filtering ,
174
+ context -> use_linear_filtering );
164
175
165
176
obs_source_process_filter_end (context -> source , context -> effect , width ,
166
177
height );
@@ -171,6 +182,9 @@ static void filter_update(void *data, obs_data_t *settings)
171
182
struct filter_9slice * context = data ;
172
183
173
184
const bool show_uvs = obs_data_get_bool (settings , "show_uvs" );
185
+ const bool uniform_scale = obs_data_get_bool (settings , "uniform_scale" );
186
+ const bool use_linear_filtering =
187
+ obs_data_get_bool (settings , "use_linear_filtering" );
174
188
175
189
const double output_scale_x =
176
190
obs_data_get_double (settings , "output_scale_x" );
@@ -185,9 +199,15 @@ static void filter_update(void *data, obs_data_t *settings)
185
199
obs_data_get_double (settings , "border_right" );
186
200
187
201
context -> show_uvs = show_uvs ;
202
+ context -> uniform_scale = uniform_scale ;
203
+ context -> use_linear_filtering = use_linear_filtering ;
188
204
189
205
context -> output_pixel_scale .x = (float )output_scale_x ;
190
- context -> output_pixel_scale .y = (float )output_scale_y ;
206
+ context -> output_pixel_scale .y = uniform_scale ? (float ) output_scale_x : (float )output_scale_y ;
207
+
208
+ if (uniform_scale ) {
209
+ obs_data_set_double (settings , "output_scale_y" , output_scale_x );
210
+ }
191
211
192
212
context -> border .x = (float )border_top ;
193
213
context -> border .y = (float )border_left ;
@@ -221,6 +241,8 @@ static void filter_get_defaults(obs_data_t *settings)
221
241
const double BorderDefault = 8.0 ;
222
242
223
243
obs_data_set_default_bool (settings , "show_uvs" , false);
244
+ obs_data_set_default_bool (settings , "uniform_scale" , true);
245
+ obs_data_set_default_bool (settings , "use_linear_filtering" , false);
224
246
225
247
obs_data_set_default_double (settings , "output_scale_x" , ScaleDefault );
226
248
obs_data_set_default_double (settings , "output_scale_y" , ScaleDefault );
@@ -246,25 +268,27 @@ static obs_properties_t *filter_get_properties(void *data)
246
268
247
269
// limit the border sizes to half of the source size
248
270
const double SliceWidthMax =
249
- context == NULL
250
- ? ScaleMin
251
- : floor ((context -> last_source_size .x / 2.0 ) - 0.5 );
271
+ context == NULL ? ScaleMin : context -> last_source_size .x - 1.0 ;
252
272
const double SliceHeightMax =
253
- context == NULL
254
- ? ScaleMin
255
- : floor ((context -> last_source_size .y / 2.0 ) - 0.5 );
273
+ context == NULL ? ScaleMin : context -> last_source_size .y - 1.0 ;
256
274
257
275
// debug options
258
276
obs_properties_add_bool (props , "show_uvs" ,
259
277
obs_module_text ("NineSlice.ShowUVs" ));
260
278
279
+ obs_properties_add_bool (props , "uniform_scale" ,
280
+ obs_module_text ("NineSlice.UniformScale" ));
281
+
282
+ obs_properties_add_bool (props , "use_linear_filtering" ,
283
+ obs_module_text ("NineSlice.LinearFiltering" ));
284
+
261
285
// output scale x/y
262
286
obs_properties_add_float_slider (props , "output_scale_x" ,
263
287
obs_module_text ("NineSlice.ScaleX" ),
264
288
ScaleMin , ScaleMax , ScaleStep );
265
289
266
290
obs_properties_add_float_slider (props , "output_scale_y" ,
267
- obs_module_text ("NineSlice.Scaley " ),
291
+ obs_module_text ("NineSlice.ScaleY " ),
268
292
ScaleMin , ScaleMax , ScaleStep );
269
293
270
294
// border sizes
0 commit comments