Skip to content

Commit 68302d6

Browse files
committed
Avoid warnings during compilation
1 parent e0174bc commit 68302d6

16 files changed

+81
-79
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* `agg_capture()` now reports the current "page number" as well as whether any
77
drawing has occured since the last time the capture was taken as attributes
88
in the return value (but only if you request native raster) (#204)
9+
* Avoid compile time warnings from implicit casting during enum arithmetic
10+
* `agg_capture()` and `agg_record()` no longer advance the RNG (#212)
911

1012
# ragg 1.5.0
1113

src/agg/include/agg_basics.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,8 @@ namespace agg
446446
//----------------------------------------------------------------is_close
447447
inline bool is_close(unsigned c)
448448
{
449-
return (c & ~(path_flags_cw | path_flags_ccw)) ==
450-
(path_cmd_end_poly | path_flags_close);
449+
return (c & ~((unsigned)path_flags_cw | (unsigned)path_flags_ccw)) ==
450+
((unsigned)path_cmd_end_poly | (unsigned)path_flags_close);
451451
}
452452

453453
//------------------------------------------------------------is_next_poly

src/agg/include/agg_color_gray.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ namespace agg
5656
static value_type luminance(const rgba& c)
5757
{
5858
// Calculate grayscale value as per ITU-R BT.709.
59-
return value_type(uround((0.2126 * c.r + 0.7152 * c.g + 0.0722 * c.b) * base_mask));
59+
return value_type(uround((0.2126 * c.r + 0.7152 * c.g + 0.0722 * c.b) * double(base_mask)));
6060
}
6161

6262
static value_type luminance(const rgba8& c)
@@ -215,13 +215,13 @@ namespace agg
215215
//--------------------------------------------------------------------
216216
static AGG_INLINE double to_double(value_type a)
217217
{
218-
return double(a) / base_mask;
218+
return double(a) / double(base_mask);
219219
}
220220

221221
//--------------------------------------------------------------------
222222
static AGG_INLINE value_type from_double(double a)
223223
{
224-
return value_type(uround(a * base_mask));
224+
return value_type(uround(a * double(base_mask)));
225225
}
226226

227227
//--------------------------------------------------------------------
@@ -375,7 +375,7 @@ namespace agg
375375
self_type gradient(self_type c, double k) const
376376
{
377377
self_type ret;
378-
calc_type ik = uround(k * base_scale);
378+
calc_type ik = uround(k * double(base_scale));
379379
ret.v = lerp(v, c.v, ik);
380380
ret.a = lerp(a, c.a, ik);
381381
return ret;
@@ -436,7 +436,7 @@ namespace agg
436436
static value_type luminance(const rgba& c)
437437
{
438438
// Calculate grayscale value as per ITU-R BT.709.
439-
return value_type(uround((0.2126 * c.r + 0.7152 * c.g + 0.0722 * c.b) * base_mask));
439+
return value_type(uround((0.2126 * c.r + 0.7152 * c.g + 0.0722 * c.b) * double(base_mask)));
440440
}
441441

442442
static value_type luminance(const rgba16& c)
@@ -544,13 +544,13 @@ namespace agg
544544
//--------------------------------------------------------------------
545545
static AGG_INLINE double to_double(value_type a)
546546
{
547-
return double(a) / base_mask;
547+
return double(a) / double(base_mask);
548548
}
549549

550550
//--------------------------------------------------------------------
551551
static AGG_INLINE value_type from_double(double a)
552552
{
553-
return value_type(uround(a * base_mask));
553+
return value_type(uround(a * double(base_mask)));
554554
}
555555

556556
//--------------------------------------------------------------------
@@ -705,7 +705,7 @@ namespace agg
705705
self_type gradient(self_type c, double k) const
706706
{
707707
self_type ret;
708-
calc_type ik = uround(k * base_scale);
708+
calc_type ik = uround(k * double(base_scale));
709709
ret.v = lerp(v, c.v, ik);
710710
ret.a = lerp(a, c.a, ik);
711711
return ret;
@@ -953,9 +953,9 @@ namespace agg
953953
}
954954

955955
//--------------------------------------------------------------------
956-
static AGG_INLINE value_type mult_cover(value_type a, cover_type b)
956+
static AGG_INLINE value_type mult_cover(value_type a, cover_type b)
957957
{
958-
return value_type(a * b / cover_mask);
958+
return value_type(a * b / float(cover_mask));
959959
}
960960

961961
//--------------------------------------------------------------------

src/agg/include/agg_color_rgba.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -351,13 +351,13 @@ namespace agg
351351
//--------------------------------------------------------------------
352352
static AGG_INLINE double to_double(value_type a)
353353
{
354-
return double(a) / base_mask;
354+
return double(a) / double(base_mask);
355355
}
356356

357357
//--------------------------------------------------------------------
358358
static AGG_INLINE value_type from_double(double a)
359359
{
360-
return value_type(uround(a * base_mask));
360+
return value_type(uround(a * double(base_mask)));
361361
}
362362

363363
//--------------------------------------------------------------------
@@ -552,7 +552,7 @@ namespace agg
552552
AGG_INLINE self_type gradient(const self_type& c, double k) const
553553
{
554554
self_type ret;
555-
calc_type ik = uround(k * base_mask);
555+
calc_type ik = uround(k * double(base_mask));
556556
ret.r = lerp(r, c.r, ik);
557557
ret.g = lerp(g, c.g, ik);
558558
ret.b = lerp(b, c.b, ik);
@@ -743,13 +743,13 @@ namespace agg
743743
//--------------------------------------------------------------------
744744
static AGG_INLINE double to_double(value_type a)
745745
{
746-
return double(a) / base_mask;
746+
return double(a) / double(base_mask);
747747
}
748748

749749
//--------------------------------------------------------------------
750750
static AGG_INLINE value_type from_double(double a)
751751
{
752-
return value_type(uround(a * base_mask));
752+
return value_type(uround(a * double(base_mask)));
753753
}
754754

755755
//--------------------------------------------------------------------
@@ -944,7 +944,7 @@ namespace agg
944944
AGG_INLINE self_type gradient(const self_type& c, double k) const
945945
{
946946
self_type ret;
947-
calc_type ik = uround(k * base_mask);
947+
calc_type ik = uround(k * double(base_mask));
948948
ret.r = lerp(r, c.r, ik);
949949
ret.g = lerp(g, c.g, ik);
950950
ret.b = lerp(b, c.b, ik);
@@ -1181,9 +1181,9 @@ namespace agg
11811181
}
11821182

11831183
//--------------------------------------------------------------------
1184-
static AGG_INLINE value_type mult_cover(value_type a, cover_type b)
1184+
static AGG_INLINE value_type mult_cover(value_type a, cover_type b)
11851185
{
1186-
return value_type(a * b / cover_mask);
1186+
return value_type(a * b / float(cover_mask));
11871187
}
11881188

11891189
//--------------------------------------------------------------------

src/agg/include/agg_ellipse.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ namespace agg
103103
if(m_step == m_num)
104104
{
105105
++m_step;
106-
return path_cmd_end_poly | path_flags_close | path_flags_ccw;
106+
return (unsigned)path_cmd_end_poly | (unsigned)path_flags_close | (unsigned)path_flags_ccw;
107107
}
108108
if(m_step > m_num) return path_cmd_stop;
109109
double angle = double(m_step) / double(m_num) * 2.0 * pi;

src/agg/include/agg_gradient_lut.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ namespace agg
209209
if(m_color_profile.size() >= 2)
210210
{
211211
unsigned i;
212-
unsigned start = uround(m_color_profile[0].offset * color_lut_size);
212+
unsigned start = uround(m_color_profile[0].offset * double(color_lut_size));
213213
unsigned end;
214214
color_type c = m_color_profile[0].color;
215215
for(i = 0; i < start; i++)
@@ -218,7 +218,7 @@ namespace agg
218218
}
219219
for(i = 1; i < m_color_profile.size(); i++)
220220
{
221-
end = uround(m_color_profile[i].offset * color_lut_size);
221+
end = uround(m_color_profile[i].offset * double(color_lut_size));
222222
interpolator_type ci(m_color_profile[i-1].color,
223223
m_color_profile[i ].color,
224224
end - start + 1);

src/agg/include/agg_image_filters.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ namespace agg
5757
unsigned pivot = diameter() << (image_subpixel_shift - 1);
5858
for(i = 0; i < pivot; i++)
5959
{
60-
double x = double(i) / double(image_subpixel_scale);
60+
double x = double(i) / double(int(image_subpixel_scale));
6161
double y = filter.calc_weight(x);
6262
m_weight_array[pivot + i] =
6363
m_weight_array[pivot - i] = (int16)iround(y * image_filter_scale);

src/agg/include/agg_path_storage.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ namespace agg
397397
if(m_closed && !m_stop)
398398
{
399399
m_stop = true;
400-
return path_cmd_end_poly | path_flags_close;
400+
return (unsigned)path_cmd_end_poly | (unsigned)path_flags_close;
401401
}
402402
return path_cmd_stop;
403403
}
@@ -462,7 +462,7 @@ namespace agg
462462
if(m_closed && !m_stop)
463463
{
464464
m_stop = true;
465-
return path_cmd_end_poly | path_flags_close;
465+
return (unsigned)path_cmd_end_poly | (unsigned)path_flags_close;
466466
}
467467
return path_cmd_stop;
468468
}
@@ -524,7 +524,7 @@ namespace agg
524524
if(m_closed && !m_stop)
525525
{
526526
m_stop = true;
527-
return path_cmd_end_poly | path_flags_close;
527+
return (unsigned)path_cmd_end_poly | (unsigned)path_flags_close;
528528
}
529529
return path_cmd_stop;
530530
}

src/agg/include/agg_path_storage_integer.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ namespace agg
5050
double dx=0, double dy=0,
5151
double scale=1.0) const
5252
{
53-
*x_ = dx + (double(x >> 1) / coord_scale) * scale;
54-
*y_ = dy + (double(y >> 1) / coord_scale) * scale;
53+
*x_ = dx + (double(x >> 1) / double(coord_scale)) * scale;
54+
*y_ = dy + (double(y >> 1) / double(coord_scale)) * scale;
5555
switch(((y & 1) << 1) | (x & 1))
5656
{
5757
case cmd_move_to: return path_cmd_move_to;
@@ -150,15 +150,15 @@ namespace agg
150150
*x = 0;
151151
*y = 0;
152152
++m_vertex_idx;
153-
return path_cmd_end_poly | path_flags_close;
153+
return (unsigned)path_cmd_end_poly | (unsigned)path_flags_close;
154154
}
155155
unsigned cmd = m_storage[m_vertex_idx].vertex(x, y);
156156
if(is_move_to(cmd) && !m_closed)
157157
{
158158
*x = 0;
159159
*y = 0;
160160
m_closed = true;
161-
return path_cmd_end_poly | path_flags_close;
161+
return (unsigned)path_cmd_end_poly | (unsigned)path_flags_close;
162162
}
163163
m_closed = false;
164164
++m_vertex_idx;
@@ -262,7 +262,7 @@ namespace agg
262262
*x = 0;
263263
*y = 0;
264264
m_ptr += sizeof(vertex_integer_type);
265-
return path_cmd_end_poly | path_flags_close;
265+
return (unsigned)path_cmd_end_poly | (unsigned)path_flags_close;
266266
}
267267

268268
vertex_integer_type v;
@@ -273,7 +273,7 @@ namespace agg
273273
*x = 0;
274274
*y = 0;
275275
m_vertices = 0;
276-
return path_cmd_end_poly | path_flags_close;
276+
return (unsigned)path_cmd_end_poly | (unsigned)path_flags_close;
277277
}
278278
++m_vertices;
279279
m_ptr += sizeof(vertex_integer_type);

src/agg/include/agg_pixfmt_base.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ namespace agg
5454

5555
if (cover < cover_full)
5656
{
57-
double x = double(cover) / cover_full;
57+
double x = double(cover) / double(cover_full);
5858
c.r *= x;
5959
c.g *= x;
6060
c.b *= x;

0 commit comments

Comments
 (0)