From 57a562d0bcf8565327e0bad1750f1628d551fe0d Mon Sep 17 00:00:00 2001 From: Seoyeon Kim Date: Tue, 10 May 2016 16:43:11 +0900 Subject: [PATCH] Change 'char' type to 'signed char' - In some build environments, like ARM architecture, 'char' without a signedness qualifier can be interpreted as 'unsigned char', and it may result in unexpected behavior. Change-Id: Ib362f914f853638a954dc0f39e9b6fb19f7043a0 Signed-off-by: Seoyeon Kim --- .../controls/renderers/svg/nanosvg/nanosvg.cc | 23 +++++++++++++++++++--- .../controls/renderers/svg/nanosvg/nanosvg.h | 7 ++++++- .../controls/renderers/svg/nanosvg/nanosvgrast.cc | 15 ++++++++++++-- 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/dali-toolkit/internal/controls/renderers/svg/nanosvg/nanosvg.cc b/dali-toolkit/internal/controls/renderers/svg/nanosvg/nanosvg.cc index e52cb15..9643567 100644 --- a/dali-toolkit/internal/controls/renderers/svg/nanosvg/nanosvg.cc +++ b/dali-toolkit/internal/controls/renderers/svg/nanosvg/nanosvg.cc @@ -230,13 +230,25 @@ typedef struct NSVGgradientData { char id[64]; char ref[64]; - char type; + + /** + * In the original file, using char type (without signed or unsigned) can be interpreted + * as 'unsigned char' in some build environments, like ARM architecture. + * To prevent the unexpected behavior, we replace 'char type' with 'signed char type' here. + */ + signed char type; union { NSVGlinearData linear; NSVGradialData radial; }; char spread; - char units; + + /** + * In the original file, using char type (without signed or unsigned) can be interpreted + * as 'unsigned char' in some build environments, like ARM architecture. + * To prevent the unexpected behavior, we replace 'char units' with 'signed char units' here. + */ + signed char units; float xform[6]; int nstops; NSVGgradientStop* stops; @@ -643,7 +655,12 @@ static NSVGgradientData* nsvg__findGradientData(NSVGparser* p, const char* id) return NULL; } -static NSVGgradient* nsvg__createGradient(NSVGparser* p, const char* id, const float* localBounds, char* paintType) +/** + * In the original file, using char type (without signed or unsigned) can be interpreted + * as 'unsigned char' in some build environments, like ARM architecture. + * To prevent the unexpected behavior, we replace 'char paintType' with 'signed char paintType' here. + */ +static NSVGgradient* nsvg__createGradient(NSVGparser* p, const char* id, const float* localBounds, signed char* paintType) { NSVGattrib* attr = nsvg__getAttr(p); NSVGgradientData* data = NULL; diff --git a/dali-toolkit/internal/controls/renderers/svg/nanosvg/nanosvg.h b/dali-toolkit/internal/controls/renderers/svg/nanosvg/nanosvg.h index 608bcd6..2634297 100644 --- a/dali-toolkit/internal/controls/renderers/svg/nanosvg/nanosvg.h +++ b/dali-toolkit/internal/controls/renderers/svg/nanosvg/nanosvg.h @@ -113,7 +113,12 @@ typedef struct NSVGgradient { } NSVGgradient; typedef struct NSVGpaint { - char type; + /** + * In the original file, using char type (without signed or unsigned) can be interpreted + * as 'unsigned char' in some build environments, like ARM architecture. + * To prevent the unexpected behavior, we replace 'char type' with 'signed char type' here. + */ + signed char type; union { unsigned int color; NSVGgradient* gradient; diff --git a/dali-toolkit/internal/controls/renderers/svg/nanosvg/nanosvgrast.cc b/dali-toolkit/internal/controls/renderers/svg/nanosvg/nanosvgrast.cc index 73bfd2c..a3f3bdb 100644 --- a/dali-toolkit/internal/controls/renderers/svg/nanosvg/nanosvgrast.cc +++ b/dali-toolkit/internal/controls/renderers/svg/nanosvg/nanosvgrast.cc @@ -68,7 +68,12 @@ typedef struct NSVGmemPage { } NSVGmemPage; typedef struct NSVGcachedPaint { - char type; + /** + * In the original file, using char type (without signed or unsigned) can be interpreted + * as 'unsigned char' in some build environments, like ARM architecture. + * To prevent the unexpected behavior, we replace 'char type' with 'signed char type' here. + */ + signed char type; char spread; float xform[6]; unsigned int colors[256]; @@ -873,7 +878,13 @@ static void nsvg__fillScanline(unsigned char* scanline, int len, int x0, int x1, // note: this routine clips fills that extend off the edges... ideally this // wouldn't happen, but it could happen if the truetype glyph bounding boxes // are wrong, or if the user supplies a too-small bitmap -static void nsvg__fillActiveEdges(unsigned char* scanline, int len, NSVGactiveEdge* e, int maxWeight, int* xmin, int* xmax, char fillRule) + + /** + * In the original file, using char type (without signed or unsigned) can be interpreted + * as 'unsigned char' in some build environments, like ARM architecture. + * To prevent the unexpected behavior, we replace 'char fillRule' with 'signed char fillRule' here. + */ +static void nsvg__fillActiveEdges(unsigned char* scanline, int len, NSVGactiveEdge* e, int maxWeight, int* xmin, int* xmax, signed char fillRule) { // non-zero winding fill int x0 = 0, w = 0; -- 2.7.4