UI: SVG Thumbnails #109567

Merged
Harley Acheson merged 11 commits from Harley/blender:SvgThumbs into main 2023-07-12 22:39:30 +02:00
8 changed files with 43 additions and 13 deletions
Showing only changes of commit 22892766df - Show all commits

View File

@ -18,6 +18,7 @@ endif()
add_subdirectory(rangetree)
add_subdirectory(nanosvg)
add_subdirectory(wcwidth)
if(WITH_BULLET)

21
extern/nanosvg/CMakeLists.txt vendored Normal file
View File

@ -0,0 +1,21 @@
# SPDX-FileCopyrightText: 2002-2022 Blender Foundation
#
# SPDX-License-Identifier: GPL-2.0-or-later
set(INC
PUBLIC .
../../source/blender/blenlib
)
set(SRC
nanosvg.h
nanosvgrast.h
blender_nanosvg.c
blender_raster.c
)
set(LIB
)
blender_add_lib(extern_nanosvg "${SRC}" "${INC}" "" "${LIB}")
add_library(bf::extern::nanosvg ALIAS extern_nanosvg)

10
extern/nanosvg/blender_nanosvg.c vendored Normal file
View File

@ -0,0 +1,10 @@
/* SPDX-FileCopyrightText: 2023 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#define NANOSVG_IMPLEMENTATION
#define NANOSVG_ALL_COLOR_KEYWORDS
#include <stdio.h>
#include "BLI_utildefines.h"
#include "nanosvg.h"

6
extern/nanosvg/blender_raster.c vendored Normal file
View File

@ -0,0 +1,6 @@
/* SPDX-FileCopyrightText: 2023 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#define NANOSVGRAST_IMPLEMENTATION
#include "nanosvgrast.h"

View File

@ -84,6 +84,7 @@ set(LIB
bf_intern_guardedalloc
bf_intern_memutil
bf_intern_opencolorio
PRIVATE bf::extern::nanosvg
${JPEG_LIBRARIES}
)

View File

@ -14,13 +14,8 @@
#include "IMB_colormanagement.h"
#include "IMB_filetype.h"
#include "IMB_imbuf_types.h"
Harley marked this conversation as resolved
Review

Could the C-only function call a static local function? (to avoid extern "C" the whole file).

Could the C-only function call a static local function? (to avoid `extern "C"` the whole file).
/* Custom flags for NanoSVG. */
#define NANOSVG_ALL_COLOR_KEYWORDS
#define NANOSVG_IMPLEMENTATION
#define NANOSVGRAST_IMPLEMENTATION
#include "../../../extern/nanosvg/nanosvgrast.h"
#include "nanosvg.h"
#include "nanosvgrast.h"
Harley marked this conversation as resolved Outdated

Also note here, that only thumbnails are supported and why.

Also note here, that only thumbnails are supported and why.

It's not so obvious where this kind of info should be included, I'd prefer the file header, as this comment isn't a doc-string for the function, e.g.

/* SPDX-FileCopyrightText: 2023 Blender Foundation
 *
 * SPDX-License-Identifier: GPL-2.0-or-later */

/** \file
 * \ingroup imbuf
 *
 * SVG vector graphics format support for the purpose of thumbnail-display.
 * While loading these as an #ImBuf is trivial to support, it would expose
 * limitations of NANOSVG and users may end up needing more advanced options
 * spesific to loading vector graphics (such as resolution control), see #109567 for details.
 */
It's not so obvious where this kind of info should be included, I'd prefer the file header, as this comment isn't a doc-string for the function, e.g. ``` /* SPDX-FileCopyrightText: 2023 Blender Foundation * * SPDX-License-Identifier: GPL-2.0-or-later */ /** \file * \ingroup imbuf * * SVG vector graphics format support for the purpose of thumbnail-display. * While loading these as an #ImBuf is trivial to support, it would expose * limitations of NANOSVG and users may end up needing more advanced options * spesific to loading vector graphics (such as resolution control), see #109567 for details. */ ```
ImBuf *imb_load_filepath_thumbnail_svg(const char *filepath,
const int /* flags */,

View File

@ -16,8 +16,7 @@ set(INC
../../windowmanager
../../../../intern/clog
../../../../intern/guardedalloc
../../../../intern/utfconv
../../../../extern/nanosvg
../../../../intern/utfconv
)
set(INC_SYS
@ -34,15 +33,13 @@ set(SRC
intern/gpencil_io_export_base.hh
intern/gpencil_io_import_base.hh
intern/gpencil_io_import_svg.hh
# Only so this file is known by CMake.
../../../../extern/nanosvg/nanosvg.h
)
set(LIB
bf_blenkernel
bf_blenlib
bf_io_common
PRIVATE bf::extern::nanosvg
)
if(WITH_PUGIXML)

View File

@ -25,7 +25,6 @@
/* Custom flags for NanoSVG. */
#define NANOSVG_ALL_COLOR_KEYWORDS
#define NANOSVG_IMPLEMENTATION
#include "nanosvg.h"