Change 'char' type to 'signed char' 97/68897/4
authorSeoyeon Kim <seoyeon2.kim@samsung.com>
Tue, 10 May 2016 07:43:11 +0000 (16:43 +0900)
committerSeoyeon Kim <seoyeon2.kim@samsung.com>
Fri, 13 May 2016 06:52:03 +0000 (15:52 +0900)
- 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 <seoyeon2.kim@samsung.com>
dali-toolkit/internal/controls/renderers/svg/nanosvg/nanosvg.cc
dali-toolkit/internal/controls/renderers/svg/nanosvg/nanosvg.h
dali-toolkit/internal/controls/renderers/svg/nanosvg/nanosvgrast.cc

index e52cb15..9643567 100644 (file)
@@ -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;
index 608bcd6..2634297 100644 (file)
@@ -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;
index 73bfd2c..a3f3bdb 100644 (file)
@@ -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;