Skip to content

Commit

Permalink
SVG: Use resvg_transform_identity()
Browse files Browse the repository at this point in the history
  • Loading branch information
HappySeaFox committed Oct 27, 2023
1 parent 3d64e30 commit 5d9fd76
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
20 changes: 20 additions & 0 deletions src/sail-codecs/svg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@ if (NOT SVG_LIBRARY OR NOT SVG_INCLUDE_DIRS)
return()
endif()

cmake_push_check_state(RESET)
set(CMAKE_REQUIRED_INCLUDES ${SVG_INCLUDE_DIRS})

check_c_source_compiles(
"
#include <resvg.h>
int main(int argc, char *argv[]) {
resvg_fit_to resvg_fit_to = { RESVG_FIT_TO_ORIGINAL, 0 };
return 0;
}
"
HAVE_RESVG_FIT_TO
)
cmake_pop_check_state()

# This will add the following CMake rules to the CMake config for static builds so a client
# application links against the required dependencies:
#
Expand All @@ -21,3 +37,7 @@ sail_codec(NAME svg
ICON svg.png
DEPENDENCY_INCLUDE_DIRS ${SVG_INCLUDE_DIRS}
DEPENDENCY_LIBS ${SVG_LIBRARY})

if (HAVE_RESVG_FIT_TO)
target_compile_definitions(${SAIL_CODEC_TARGET} PRIVATE SAIL_HAVE_RESVG_FIT_TO)
endif()
5 changes: 4 additions & 1 deletion src/sail-codecs/svg/svg.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,12 @@ SAIL_EXPORT sail_status_t sail_codec_load_frame_v8_svg(void *state, struct sail_

memset(image->pixels, 0, (size_t)image->bytes_per_line * image->height);

#ifdef SAIL_HAVE_RESVG_FIT_TO
const resvg_fit_to resvg_fit_to = { RESVG_FIT_TO_ORIGINAL, 0 };

resvg_render(svg_state->resvg_tree, resvg_fit_to, image->width, image->height, image->pixels);
#else
resvg_render(svg_state->resvg_tree, resvg_transform_identity(), image->width, image->height, image->pixels);
#endif

return SAIL_OK;
}
Expand Down

0 comments on commit 5d9fd76

Please sign in to comment.