From fb452ce6ba2f4781e7a029d922cfaa5b8db2f17c Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Tue, 9 Oct 2012 14:28:23 +0200 Subject: [PATCH] Add const qualifiers --- os/include/nitpicker_gfx/chunky_canvas.h | 12 +++++----- os/include/nitpicker_gfx/font.h | 28 +++++++++++++----------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/os/include/nitpicker_gfx/chunky_canvas.h b/os/include/nitpicker_gfx/chunky_canvas.h index fc412c2ee..447b0eef9 100644 --- a/os/include/nitpicker_gfx/chunky_canvas.h +++ b/os/include/nitpicker_gfx/chunky_canvas.h @@ -82,7 +82,7 @@ class Chunky_canvas : public Canvas if (!str || !font) return; - unsigned char *src = font->img; + unsigned char const *src = font->img; int d, h = font->img_h; /* check top clipping */ @@ -110,11 +110,11 @@ class Chunky_canvas : public Canvas /* draw glyphs */ for ( ; *str && (x <= _clip.x2()); str++) { - int w = font->wtab[*str]; - int start = max(0, _clip.x1() - x); - int end = min(w - 1, _clip.x2() - x); - PT *d = dst + x; - unsigned char *s = src + font->otab[*str]; + int w = font->wtab[*str]; + int start = max(0, _clip.x1() - x); + int end = min(w - 1, _clip.x2() - x); + PT *d = dst + x; + unsigned char const *s = src + font->otab[*str]; for (int j = 0; j < h; j++, s += font->img_w, d += _size.w()) for (int i = start; i <= end; i++) diff --git a/os/include/nitpicker_gfx/font.h b/os/include/nitpicker_gfx/font.h index 81e1959a3..28a1144da 100644 --- a/os/include/nitpicker_gfx/font.h +++ b/os/include/nitpicker_gfx/font.h @@ -24,27 +24,29 @@ class Font public: - unsigned char *img; /* font image */ - int img_w, img_h; /* size of font image */ - int32_t *wtab; /* width table */ - int32_t *otab; /* offset table */ + unsigned char const *img; /* font image */ + int const img_w, img_h; /* size of font image */ + int32_t const *otab; /* offset table */ + int32_t const *wtab; /* width table */ /** * Construct font from a TFF data block */ Font(const char *tff) - { - otab = (int32_t *)(tff); - wtab = (int32_t *)(tff + 1024); - img_w = *((int32_t *)(tff + 2048)); - img_h = *((int32_t *)(tff + 2052)); - img = (unsigned char *)(tff + 2056); - } + : + img((unsigned char *)(tff + 2056)), + + img_w(*((int32_t *)(tff + 2048))), + img_h(*((int32_t *)(tff + 2052))), + + otab((int32_t *)(tff)), + wtab((int32_t *)(tff + 1024)) + { } /** * Calculate width of string when printed with the font */ - int str_w(const char *sstr) + int str_w(const char *sstr) const { const unsigned char *str = (const unsigned char *)sstr; int res = 0; @@ -55,7 +57,7 @@ class Font /** * Calculate height of string when printed with the font */ - int str_h(const char *str) { return img_h; } + int str_h(const char *str) const { return img_h; } }; #endif /* _INCLUDE__NITPICKER_GFX__FONT_H_ */