Cleanup: Various clang-tidy warnings in blenfont
Pull Request: https://projects.blender.org/blender/blender/pulls/133734
This commit is contained in:
@@ -191,10 +191,10 @@ blender::Array<uchar> BLF_svg_icon_bitmap(
|
||||
bool multicolor = false,
|
||||
blender::FunctionRef<void(std::string &)> edit_source_cb = nullptr);
|
||||
|
||||
typedef bool (*BLF_GlyphBoundsFn)(const char *str,
|
||||
size_t str_step_ofs,
|
||||
const rcti *bounds,
|
||||
void *user_data);
|
||||
using BLF_GlyphBoundsFn = bool (*)(const char *str,
|
||||
size_t str_step_ofs,
|
||||
const rcti *bounds,
|
||||
void *user_dataconst);
|
||||
|
||||
/**
|
||||
* Run \a user_fn for each character, with the bound-box that would be used for drawing.
|
||||
|
||||
@@ -21,8 +21,6 @@
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_GLYPH_H
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLI_fileops.h"
|
||||
#include "BLI_math_rotation.h"
|
||||
#include "BLI_path_utils.hh"
|
||||
@@ -33,7 +31,7 @@
|
||||
#include "IMB_colormanagement.hh"
|
||||
|
||||
#include "GPU_matrix.hh"
|
||||
#include "GPU_shader.hh"
|
||||
#include "GPU_state.hh"
|
||||
|
||||
#include "blf_internal.hh"
|
||||
#include "blf_internal_types.hh"
|
||||
|
||||
@@ -11,12 +11,9 @@
|
||||
#include "DNA_userdef_types.h"
|
||||
|
||||
#include "BLI_assert.h"
|
||||
#include "BLI_math_vector_types.hh"
|
||||
|
||||
#include "BLF_api.hh"
|
||||
|
||||
#include "blf_internal.hh"
|
||||
|
||||
/* call BLF_default_set first! */
|
||||
#define ASSERT_DEFAULT_SET BLI_assert(global_font_default != -1)
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
* Manage search paths for font files.
|
||||
*/
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
@@ -19,12 +18,9 @@
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "DNA_vec_types.h"
|
||||
|
||||
#include "BLI_fileops.h"
|
||||
#include "BLI_string.h"
|
||||
|
||||
#include "BLF_api.hh"
|
||||
#include "blf_internal.hh"
|
||||
|
||||
char *blf_dir_metrics_search(const char *filepath)
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
* Also low level functions for managing \a FontBLF.
|
||||
*/
|
||||
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
@@ -28,7 +28,6 @@
|
||||
|
||||
#include "DNA_vec_types.h"
|
||||
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_math_bits.h"
|
||||
#include "BLI_math_color_blend.h"
|
||||
#include "BLI_math_matrix.h"
|
||||
@@ -44,11 +43,12 @@
|
||||
|
||||
#include "GPU_batch.hh"
|
||||
#include "GPU_matrix.hh"
|
||||
#include "GPU_state.hh"
|
||||
|
||||
#include "blf_internal.hh"
|
||||
#include "blf_internal_types.hh"
|
||||
|
||||
#include "BLI_strict_flags.h" /* Keep last. */
|
||||
#include "BLI_strict_flags.h" /* IWYU pragma: keep. Keep last. */
|
||||
|
||||
#ifdef WIN32
|
||||
# define FT_New_Face FT_New_Face__win32_compat
|
||||
@@ -824,7 +824,7 @@ size_t blf_font_width_to_strlen(
|
||||
size_t i, i_prev;
|
||||
|
||||
GlyphCacheBLF *gc = blf_glyph_cache_acquire(font);
|
||||
const int width_i = int(width);
|
||||
const int width_i = width;
|
||||
|
||||
for (i_prev = i = 0, width_new = pen_x = 0, g_prev = nullptr; (i < str_len) && str[i];
|
||||
i_prev = i, width_new = pen_x, g_prev = g)
|
||||
@@ -923,19 +923,11 @@ static void blf_font_boundbox_ex(FontBLF *font,
|
||||
const ft_pix gbox_ymin = g->box_ymin + pen_y;
|
||||
const ft_pix gbox_ymax = g->box_ymax + pen_y;
|
||||
|
||||
if (gbox_xmin < box_xmin) {
|
||||
box_xmin = gbox_xmin;
|
||||
}
|
||||
if (gbox_ymin < box_ymin) {
|
||||
box_ymin = gbox_ymin;
|
||||
}
|
||||
box_xmin = std::min(gbox_xmin, box_xmin);
|
||||
box_ymin = std::min(gbox_ymin, box_ymin);
|
||||
|
||||
if (gbox_xmax > box_xmax) {
|
||||
box_xmax = gbox_xmax;
|
||||
}
|
||||
if (gbox_ymax > box_ymax) {
|
||||
box_ymax = gbox_ymax;
|
||||
}
|
||||
box_xmax = std::max(gbox_xmax, box_xmax);
|
||||
box_ymax = std::max(gbox_ymax, box_ymax);
|
||||
|
||||
pen_x = pen_x_next;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
* Glyph rendering, texturing and caching. Wraps Freetype and OpenGL functions.
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
@@ -26,9 +27,8 @@
|
||||
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_math_color.h"
|
||||
#include "BLI_math_geom.h"
|
||||
#include "BLI_rect.h"
|
||||
#include "BLI_string.h"
|
||||
#include "BLI_threads.h"
|
||||
|
||||
#include "BLF_api.hh"
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
# include "svg_icons.h"
|
||||
#endif /* WITH_HEADLESS */
|
||||
|
||||
#include "BLI_strict_flags.h" /* Keep last. */
|
||||
#include "BLI_strict_flags.h" /* IWYU pragma: keep. Keep last. */
|
||||
|
||||
/**
|
||||
* Convert glyph coverage amounts to lightness values. Uses a LUT that perceptually improves
|
||||
@@ -123,9 +123,7 @@ static GlyphCacheBLF *blf_glyph_cache_new(FontBLF *font)
|
||||
/* Font does not have a face or does not contain "0" so use CSS fallback of 1/2 of em. */
|
||||
gc->fixed_width = int((font->ft_size->metrics.height / 2) >> 6);
|
||||
}
|
||||
if (gc->fixed_width < 1) {
|
||||
gc->fixed_width = 1;
|
||||
}
|
||||
gc->fixed_width = std::max(gc->fixed_width, 1);
|
||||
|
||||
font->cache.append(std::move(gc));
|
||||
|
||||
@@ -429,7 +427,7 @@ static GlyphBLF *blf_glyph_cache_add_svg(
|
||||
for (int64_t x = 0; x < int64_t(g->dims[0]); x++) {
|
||||
int64_t offs_in = (y * int64_t(dest_w) * 4) + (x * 4);
|
||||
int64_t offs_out = (y * int64_t(g->dims[0]) + x);
|
||||
g->bitmap[offs_out] = uchar(float(srgb_to_grayscale_byte(&render_bmp[int64_t(offs_in)])) *
|
||||
g->bitmap[offs_out] = uchar(float(srgb_to_grayscale_byte(&render_bmp[offs_in])) *
|
||||
(float(render_bmp[int64_t(offs_in + 3)]) / 255.0f));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ struct GPUVertBufRaw;
|
||||
* This is an internal type that represents sub-pixel positioning,
|
||||
* users of this type are to use `ft_pix_*` functions to keep scaling/rounding in one place.
|
||||
*/
|
||||
typedef int32_t ft_pix;
|
||||
using ft_pix = int32_t;
|
||||
|
||||
/* Macros copied from `include/freetype/internal/ftobjs.h`. */
|
||||
|
||||
@@ -79,7 +79,7 @@ inline int ft_pix_to_int_floor(ft_pix v)
|
||||
|
||||
inline int ft_pix_to_int_ceil(ft_pix v)
|
||||
{
|
||||
return int(FT_PIX_CEIL(v) >> 6);
|
||||
return (FT_PIX_CEIL(v) >> 6);
|
||||
}
|
||||
|
||||
inline ft_pix ft_pix_from_int(int v)
|
||||
|
||||
@@ -20,20 +20,14 @@
|
||||
#include FT_TRUETYPE_IDS_H /* Code-point coverage constants. */
|
||||
#include FT_TRUETYPE_TABLES_H /* For TT_OS2 */
|
||||
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_math_bits.h"
|
||||
#include "BLI_rect.h"
|
||||
#include "BLI_string.h"
|
||||
#include "BLI_string_utf8.h"
|
||||
#include "BLI_threads.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "blf_internal.hh"
|
||||
#include "blf_internal_types.hh"
|
||||
|
||||
#include "BLF_api.hh"
|
||||
|
||||
#include "BLI_strict_flags.h" /* Keep last. */
|
||||
#include "BLI_strict_flags.h" /* IWYU pragma: keep. Keep last. */
|
||||
|
||||
/* Maximum length of text sample in char32_t, including nullptr terminator. */
|
||||
#define BLF_SAMPLE_LEN 5
|
||||
|
||||
Reference in New Issue
Block a user