From 1d92a167395bbddadb5a388d0c57c774c2b8b223 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Fri, 4 Jul 2025 15:27:30 +0900 Subject: [PATCH] common: chores wrt scene effect - corrected data type (float -> double) - guarantee to call va_end() - docs / samples revision - include cstdarg as an essential header --- examples/SceneEffects.cpp | 2 +- inc/thorvg.h | 12 +++++++----- src/renderer/tvgScene.cpp | 5 +++-- src/renderer/tvgScene.h | 1 - 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/examples/SceneEffects.cpp b/examples/SceneEffects.cpp index 586b50c4..6aa6b0ac 100644 --- a/examples/SceneEffects.cpp +++ b/examples/SceneEffects.cpp @@ -104,7 +104,7 @@ struct UserExample : tvgexam::Example //Apply GaussianBlur post effect (sigma, direction, border option, quality) for (int i = 0; i < 3; ++i) { blur[i]->push(tvg::SceneEffect::ClearAll); - blur[i]->push(tvg::SceneEffect::GaussianBlur, (double)(10.0f * progress), i, 0, 100); + blur[i]->push(tvg::SceneEffect::GaussianBlur, 10.0 * double(progress), i, 0, 100); } //Apply Fill post effect (rgba) diff --git a/inc/thorvg.h b/inc/thorvg.h index e053d6e4..2a0759c4 100644 --- a/inc/thorvg.h +++ b/inc/thorvg.h @@ -4,6 +4,7 @@ #include #include #include +#include #ifdef TVG_API #undef TVG_API @@ -230,10 +231,10 @@ enum class BlendMethod : uint8_t enum class SceneEffect : uint8_t { ClearAll = 0, ///< Reset all previously applied scene effects, restoring the scene to its original state. - GaussianBlur, ///< Apply a blur effect with a Gaussian filter. Param(4) = {sigma(float)[> 0], direction(int)[both: 0 / horizontal: 1 / vertical: 2], border(int)[duplicate: 0 / wrap: 1], quality(int)[0 - 100]} + GaussianBlur, ///< Apply a blur effect with a Gaussian filter. Param(4) = {sigma(double)[> 0], direction(int)[both: 0 / horizontal: 1 / vertical: 2], border(int)[duplicate: 0 / wrap: 1], quality(int)[0 - 100]} DropShadow, ///< Apply a drop shadow effect with a Gaussian Blur filter. Param(8) = {color_R(int)[0 - 255], color_G(int)[0 - 255], color_B(int)[0 - 255], opacity(int)[0 - 255], angle(double)[0 - 360], distance(double), blur_sigma(double)[> 0], quality(int)[0 - 100]} Fill, ///< Override the scene content color with a given fill information (Experimental API). Param(4) = {color_R(int)[0 - 255], color_G(int)[0 - 255], color_B(int)[0 - 255], opacity(int)[0 - 255]} - Tint, ///< Tinting the current scene color with a given black, white color paramters (Experimental API). Param(7) = {black_R(int)[0 - 255], black_G(int)[0 - 255], black_B(int)[0 - 255], white_R(int)[0 - 255], white_G(int)[0 - 255], white_B(int)[0 - 255], intensity(float)[0 - 100]} + Tint, ///< Tinting the current scene color with a given black, white color parameters (Experimental API). Param(7) = {black_R(int)[0 - 255], black_G(int)[0 - 255], black_B(int)[0 - 255], white_R(int)[0 - 255], white_G(int)[0 - 255], white_B(int)[0 - 255], intensity(double)[0 - 100]} Tritone ///< Apply a tritone color effect to the scene using three color parameters for shadows, midtones, and highlights (Experimental API). Param(9) = {Shadow_R(int)[0 - 255], Shadow_G(int)[0 - 255], Shadow_B(int)[0 - 255], Midtone_R(int)[0 - 255], Midtone_G(int)[0 - 255], Midtone_B(int)[0 - 255], Highlight_R(int)[0 - 255], Highlight_G(int)[0 - 255], Highlight_B(int)[0 - 255]} }; @@ -1520,12 +1521,13 @@ public: /** * @brief Apply a post-processing effect to the scene. * - * This function adds a specified scene effect, such as clearing all effects or applying a Gaussian blur, - * to the scene after it has been rendered. Multiple effects can be applied in sequence. + * This function adds a specified effect—such as clearing all effects, applying a Gaussian blur, + * or adding a drop shadow—to the scene after rendering. Multiple effects can be applied in sequence + * by calling this function multiple times. * * @param[in] effect The scene effect to apply. Options are defined in the SceneEffect enum. * For example, use SceneEffect::GaussianBlur to apply a blur with specific parameters. - * @param[in] ... Additional variadic parameters required for certain effects (e.g., sigma and direction for GaussianBlur). + * @param[in] ... Additional variadic parameters required for certain effects (e.g., sigma and direction for GaussianBlur). * * @since 1.0 */ diff --git a/src/renderer/tvgScene.cpp b/src/renderer/tvgScene.cpp index 207eb07f..d06a6b5f 100644 --- a/src/renderer/tvgScene.cpp +++ b/src/renderer/tvgScene.cpp @@ -61,6 +61,7 @@ Result Scene::push(SceneEffect effect, ...) noexcept { va_list args; va_start(args, effect); - - return SCENE(this)->push(effect, args); + auto ret = SCENE(this)->push(effect, args); + va_end(args); + return ret; } diff --git a/src/renderer/tvgScene.h b/src/renderer/tvgScene.h index 41c529c2..368ea68e 100644 --- a/src/renderer/tvgScene.h +++ b/src/renderer/tvgScene.h @@ -24,7 +24,6 @@ #define _TVG_SCENE_H_ #include -#include #include "tvgMath.h" #include "tvgPaint.h"