Use make_intrusive/make_shared for smart pointer construction.

This commit is contained in:
Twan van Laarhoven
2020-04-23 23:51:34 +02:00
parent 815df01ba5
commit 708b4389a0
67 changed files with 313 additions and 329 deletions
+22 -23
View File
@@ -41,14 +41,14 @@ SCRIPT_FUNCTION(linear_blend) {
SCRIPT_PARAM(GeneratedImageP, image2);
SCRIPT_PARAM(double, x1); SCRIPT_PARAM(double, y1);
SCRIPT_PARAM(double, x2); SCRIPT_PARAM(double, y2);
return intrusive(new LinearBlendImage(image1, image2, x1,y1, x2,y2));
return make_intrusive<LinearBlendImage>(image1, image2, x1,y1, x2,y2);
}
SCRIPT_FUNCTION(masked_blend) {
SCRIPT_PARAM(GeneratedImageP, light);
SCRIPT_PARAM(GeneratedImageP, dark);
SCRIPT_PARAM(GeneratedImageP, mask);
return intrusive(new MaskedBlendImage(light, dark, mask));
return make_intrusive<MaskedBlendImage>(light, dark, mask);
}
SCRIPT_FUNCTION(combine_blend) {
@@ -57,19 +57,19 @@ SCRIPT_FUNCTION(combine_blend) {
SCRIPT_PARAM(GeneratedImageP, image2);
ImageCombine image_combine;
parse_enum(combine, image_combine);
return intrusive(new CombineBlendImage(image1, image2, image_combine));
return make_intrusive<CombineBlendImage>(image1, image2, image_combine);
}
SCRIPT_FUNCTION(set_mask) {
SCRIPT_PARAM(GeneratedImageP, image);
SCRIPT_PARAM(GeneratedImageP, mask);
return intrusive(new SetMaskImage(image, mask));
return make_intrusive<SetMaskImage>(image, mask);
}
SCRIPT_FUNCTION(set_alpha) {
SCRIPT_PARAM_C(GeneratedImageP, input);
SCRIPT_PARAM(double, alpha);
return intrusive(new SetAlphaImage(input, alpha));
return make_intrusive<SetAlphaImage>(input, alpha);
}
SCRIPT_FUNCTION(set_combine) {
@@ -77,18 +77,18 @@ SCRIPT_FUNCTION(set_combine) {
SCRIPT_PARAM_C(GeneratedImageP, input);
ImageCombine image_combine;
parse_enum(combine, image_combine);
return intrusive(new SetCombineImage(input, image_combine));
return make_intrusive<SetCombineImage>(input, image_combine);
}
SCRIPT_FUNCTION(saturate) {
SCRIPT_PARAM_C(GeneratedImageP, input);
SCRIPT_PARAM(double, amount);
return intrusive(new SaturateImage(input, amount));
return make_intrusive<SaturateImage>(input, amount);
}
SCRIPT_FUNCTION(invert_image) {
SCRIPT_PARAM_C(GeneratedImageP, input);
return intrusive(new InvertImage(input));
return make_intrusive<InvertImage>(input);
}
SCRIPT_FUNCTION(recolor_image) {
@@ -97,17 +97,17 @@ SCRIPT_FUNCTION(recolor_image) {
SCRIPT_PARAM(Color, green);
SCRIPT_PARAM(Color, blue);
SCRIPT_PARAM_DEFAULT(Color, white, *wxWHITE);
return intrusive(new RecolorImage2(input,red,green,blue,white));
return make_intrusive<RecolorImage2>(input,red,green,blue,white);
} else {
SCRIPT_PARAM(Color, color);
return intrusive(new RecolorImage(input,color));
return make_intrusive<RecolorImage>(input,color);
}
}
SCRIPT_FUNCTION(enlarge) {
SCRIPT_PARAM_C(GeneratedImageP, input);
SCRIPT_PARAM(double, border_size);
return intrusive(new EnlargeImage(input, border_size));
return make_intrusive<EnlargeImage>(input, border_size);
}
SCRIPT_FUNCTION(crop) {
@@ -116,23 +116,23 @@ SCRIPT_FUNCTION(crop) {
SCRIPT_PARAM(int, height);
SCRIPT_PARAM(double, offset_x);
SCRIPT_PARAM(double, offset_y);
return intrusive(new CropImage(input, width, height, offset_x, offset_y));
return make_intrusive<CropImage>(input, width, height, offset_x, offset_y);
}
SCRIPT_FUNCTION(flip_horizontal) {
SCRIPT_PARAM_C(GeneratedImageP, input);
return intrusive(new FlipImageHorizontal(input));
return make_intrusive<FlipImageHorizontal>(input);
}
SCRIPT_FUNCTION(flip_vertical) {
SCRIPT_PARAM_C(GeneratedImageP, input);
return intrusive(new FlipImageVertical(input));
return make_intrusive<FlipImageVertical>(input);
}
SCRIPT_FUNCTION(rotate) {
SCRIPT_PARAM_C(GeneratedImageP, input);
SCRIPT_PARAM(Degrees, angle);
return intrusive(new RotateImage(input,deg_to_rad(angle)));
return make_intrusive<RotateImage>(input,deg_to_rad(angle));
}
SCRIPT_FUNCTION(drop_shadow) {
@@ -142,7 +142,7 @@ SCRIPT_FUNCTION(drop_shadow) {
SCRIPT_OPTIONAL_PARAM_(double, alpha);
SCRIPT_OPTIONAL_PARAM_(double, blur_radius);
SCRIPT_OPTIONAL_PARAM_(Color, color);
return intrusive(new DropShadowImage(input, offset_x, offset_y, alpha, blur_radius, color));
return make_intrusive<DropShadowImage>(input, offset_x, offset_y, alpha, blur_radius, color);
}
SCRIPT_FUNCTION(symbol_variation) {
@@ -170,7 +170,7 @@ SCRIPT_FUNCTION(symbol_variation) {
FOR_EACH(v, style->variations) {
if (v->name == variation) {
// found it
return intrusive(new SymbolToImage(value, filename, value->last_update, v));
return make_intrusive<SymbolToImage>(value, filename, value->last_update, v);
}
}
throw ScriptError(_("Variation of symbol not found ('") + variation + _("')"));
@@ -183,7 +183,7 @@ SCRIPT_FUNCTION(symbol_variation) {
if (fill_type == _("solid") || fill_type.empty()) {
SCRIPT_PARAM(Color, fill_color);
SCRIPT_PARAM(Color, border_color);
var->filter = intrusive(new SolidFillSymbolFilter(fill_color, border_color));
var->filter = make_intrusive<SolidFillSymbolFilter>(fill_color, border_color);
} else if (fill_type == _("linear gradient")) {
SCRIPT_PARAM(Color, fill_color_1);
SCRIPT_PARAM(Color, border_color_1);
@@ -193,24 +193,23 @@ SCRIPT_FUNCTION(symbol_variation) {
SCRIPT_PARAM(double, center_y);
SCRIPT_PARAM(double, end_x);
SCRIPT_PARAM(double, end_y);
var->filter = intrusive(new LinearGradientSymbolFilter(fill_color_1, border_color_1, fill_color_2, border_color_2
,center_x, center_y, end_x, end_y));
var->filter = make_intrusive<LinearGradientSymbolFilter>(fill_color_1, border_color_1, fill_color_2, border_color_2, center_x, center_y, end_x, end_y);
} else if (fill_type == _("radial gradient")) {
SCRIPT_PARAM(Color, fill_color_1);
SCRIPT_PARAM(Color, border_color_1);
SCRIPT_PARAM(Color, fill_color_2);
SCRIPT_PARAM(Color, border_color_2);
var->filter = intrusive(new RadialGradientSymbolFilter(fill_color_1, border_color_1, fill_color_2, border_color_2));
var->filter = make_intrusive<RadialGradientSymbolFilter>(fill_color_1, border_color_1, fill_color_2, border_color_2);
} else {
throw ScriptError(_("Unknown fill type for symbol_variation: ") + fill_type);
}
return intrusive(new SymbolToImage(value, filename, value ? value->last_update : Age(0), var));
return make_intrusive<SymbolToImage>(value, filename, value ? value->last_update : Age(0), var);
}
}
SCRIPT_FUNCTION(built_in_image) {
SCRIPT_PARAM_C(String, input);
return intrusive(new BuiltInImage(input));
return make_intrusive<BuiltInImage>(input);
}
// ----------------------------------------------------------------------------- : Init