OSDN Git Service

vega: add some casts to silence MSVC warnings
authorBrian Paul <brianp@vmware.com>
Wed, 26 Jun 2013 15:27:34 +0000 (09:27 -0600)
committerBrian Paul <brianp@vmware.com>
Wed, 26 Jun 2013 16:42:59 +0000 (10:42 -0600)
src/gallium/state_trackers/vega/api_filters.c
src/gallium/state_trackers/vega/matrix.h

index f5856db..480ced1 100644 (file)
@@ -273,7 +273,7 @@ void vegaColorMatrix(VGImage dst, VGImage src,
 
 static VGfloat texture_offset(VGfloat width, VGint kernelSize, VGint current, VGint shift)
 {
-   VGfloat diff = current - shift;
+   VGfloat diff = (VGfloat) (current - shift);
 
    return diff / width;
 }
@@ -336,7 +336,7 @@ void vegaConvolve(VGImage dst, VGImage src,
    buffer[2] = 2.f; /*unused*/
    buffer[3] = 4.f; /*unused*/
 
-   buffer[4] = kernelWidth * kernelHeight;
+   buffer[4] = (VGfloat) (kernelWidth * kernelHeight);
    buffer[5] = scale;
    buffer[6] = bias;
    buffer[7] = 0.f;
@@ -347,8 +347,8 @@ void vegaConvolve(VGImage dst, VGImage src,
          VGint index = j * kernelWidth + i;
          VGfloat x, y;
 
-         x = texture_offset(s->width, kernelWidth, i, shiftX);
-         y = texture_offset(s->height, kernelHeight, j, shiftY);
+         x = (VGfloat) texture_offset(s->width, kernelWidth, i, shiftX);
+         y = (VGfloat) texture_offset(s->height, kernelHeight, j, shiftY);
 
          buffer[idx + index*4 + 0] = x;
          buffer[idx + index*4 + 1] = y;
index bed2b31..794c7e7 100644 (file)
@@ -221,9 +221,9 @@ static INLINE void matrix_rotate(struct matrix *dst,
    else if (floatsEqual(angle, 180))
       cos_val = -1.f;
    else {
-      float radians = DEGREES_TO_RADIANS(angle);
-      sin_val = sin(radians);
-      cos_val = cos(radians);
+      double radians = DEGREES_TO_RADIANS(angle);
+      sin_val = (float) sin(radians);
+      cos_val = (float) cos(radians);
    }
 
    if (!matrix_is_affine(dst)) {
@@ -410,7 +410,7 @@ static INLINE void line_normalize(float *l)
 {
    float x = l[2] - l[0];
    float y = l[3] - l[1];
-   float len = sqrt(x*x + y*y);
+   float len = (float) sqrt(x*x + y*y);
    l[2] = l[0] + x/len;
    l[3] = l[1] + y/len;
 }
@@ -420,14 +420,14 @@ static INLINE VGfloat line_length(VGfloat x1, VGfloat y1,
 {
    VGfloat x = x2 - x1;
    VGfloat y = y2 - y1;
-   return sqrt(x*x + y*y);
+   return (VGfloat) sqrt(x*x + y*y);
 }
 
 static INLINE VGfloat line_lengthv(const VGfloat *l)
 {
    VGfloat x = l[2] - l[0];
    VGfloat y = l[3] - l[1];
-   return sqrt(x*x + y*y);
+   return (VGfloat) sqrt(x*x + y*y);
 }
 
 
@@ -442,7 +442,7 @@ static INLINE void line_point_at(float *l, float t, float *pt)
 
 static INLINE void vector_unit(float *vec)
 {
-   float len = sqrt(vec[0] * vec[0] + vec[1] * vec[1]);
+   float len = (float) sqrt(vec[0] * vec[0] + vec[1] * vec[1]);
    vec[0] /= len;
    vec[1] /= len;
 }