Skip to content

Commit

Permalink
fix msvc build error
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangjipeng committed Feb 12, 2025
1 parent 932ee9d commit e540995
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 35 deletions.
1 change: 0 additions & 1 deletion android/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ LOCAL_SRC_FILES := \
$(SOURCE_PATH)/src/gfx/gfx_gradient_adapter.cpp \
$(SOURCE_PATH)/src/gfx/gfx_raster_adapter.cpp \
$(SOURCE_PATH)/src/gfx/gfx_rendering_buffer.cpp \
$(SOURCE_PATH)/src/gfx/gfx_sqrt_tables.cpp \
$(SOURCE_PATH)/src/picasso_api.cpp \
$(SOURCE_PATH)/src/picasso_canvas.cpp \
$(SOURCE_PATH)/src/picasso_font_api.cpp \
Expand Down
46 changes: 23 additions & 23 deletions src/gfx/gfx_gradient_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ class gradient_x
{
public:
void init(scalar, scalar, scalar) { }
static int calculate(int x, int, int) { return x; }
static int32_t calculate(int32_t x, int, int) { return x; }
};

// gradient_conic
class gradient_conic
{
public:
void init(scalar, scalar, scalar) { }
static int calculate(int x, int y, int d)
static int32_t calculate(int32_t x, int32_t y, int32_t d)
{
return uround(Fabs(Atan2(INT_TO_SCALAR(y), INT_TO_SCALAR(x))) * INT_TO_SCALAR(d) * _1divPI);
}
Expand All @@ -36,7 +36,7 @@ class gradient_conic_vg
{
public:
void init(scalar, scalar, scalar) { }
static int calculate(int x, int y, int d)
static int32_t calculate(int32_t x, int32_t y, int32_t d)
{
scalar a = Atan2(INT_TO_SCALAR(y), INT_TO_SCALAR(x));
if (a < 0) { a = _2PI + a; }
Expand All @@ -49,7 +49,7 @@ class gradient_radial
{
public:
void init(scalar, scalar, scalar) { }
static int calculate(int x, int y, int d)
static int32_t calculate(int32_t x, int32_t y, int32_t d)
{
return (int)Sqrt(x * x + y * y);
}
Expand All @@ -75,7 +75,7 @@ class gradient_radial_focus
update_values();
}

int calculate(int x, int y, int) const
int32_t calculate(int32_t x, int32_t y, int) const
{
scalar dx = INT_TO_SCALAR(x - m_fx);
scalar dy = INT_TO_SCALAR(y - m_fy);
Expand Down Expand Up @@ -122,9 +122,9 @@ class gradient_radial_focus
}

private:
int m_r;
int m_fx;
int m_fy;
int32_t m_r;
int32_t m_fx;
int32_t m_fy;
scalar m_r2;
scalar m_fx2;
scalar m_fy2;
Expand All @@ -143,9 +143,9 @@ class gradient_pad_adaptor
{
}

int calculate(int x, int y, int d) const
int32_t calculate(int32_t x, int32_t y, int32_t d) const
{
int ret = m_gradient->calculate(x, y, d);
int32_t ret = m_gradient->calculate(x, y, d);
if (ret < 0) { ret = 0; }
if (ret > d) { ret = d; }
return ret;
Expand All @@ -165,9 +165,9 @@ class gradient_repeat_adaptor
{
}

int calculate(int x, int y, int d) const
int32_t calculate(int32_t x, int32_t y, int32_t d) const
{
int ret = m_gradient->calculate(x, y, d) % d;
int32_t ret = m_gradient->calculate(x, y, d) % d;
if (ret < 0) { ret += d; }
return ret;
}
Expand All @@ -186,10 +186,10 @@ class gradient_reflect_adaptor
{
}

int calculate(int x, int y, int d) const
int32_t calculate(int32_t x, int32_t y, int32_t d) const
{
int d2 = d << 1;
int ret = m_gradient->calculate(x, y, d) % d2;
int32_t d2 = d << 1;
int32_t ret = m_gradient->calculate(x, y, d) % d2;
if (ret < 0) { ret += d2; }
if (ret >= d) { ret = d2 - ret; }
return ret;
Expand All @@ -215,7 +215,7 @@ class gfx_gradient : public gfx_gradient_wrapper
m_gradient.init(r, x, y);
}

virtual int calculate(int x, int y, int d) const
virtual int32_t calculate(int32_t x, int32_t y, int32_t d) const
{
return m_adaptor.calculate(x, y, d);
}
Expand All @@ -232,7 +232,7 @@ struct color_interpolator {
public:
typedef rgba8 color_type;

color_interpolator(const color_type& c1, const color_type& c2, unsigned len)
color_interpolator(const color_type& c1, const color_type& c2, uint32_t len)
: r(c1.r, c2.r, len)
, g(c1.g, c2.g, len)
, b(c1.b, c2.b, len)
Expand Down Expand Up @@ -266,9 +266,9 @@ void gfx_gradient_table::build_table(void)
m_color_profile.cut_at(remove_duplicates(m_color_profile, offset_equal));

if (m_color_profile.size() >= 2) {
unsigned int i;
unsigned int start = uround(m_color_profile[0].offset * color_table_size);
unsigned int end = 0;
uint32_t i;
uint32_t start = uround(m_color_profile[0].offset * color_table_size);
uint32_t end = 0;
color_type c = m_color_profile[0].color;

for (i = 0; i < start; i++) {
Expand All @@ -295,7 +295,7 @@ void gfx_gradient_table::build_table(void)
}

// gfx gradient adapter
void gfx_gradient_adapter::init_linear(int spread, scalar x1, scalar y1, scalar x2, scalar y2)
void gfx_gradient_adapter::init_linear(int32_t spread, scalar x1, scalar y1, scalar x2, scalar y2)
{
if (!m_wrapper) {
switch (spread) {
Expand Down Expand Up @@ -335,7 +335,7 @@ void gfx_gradient_adapter::init_linear(int spread, scalar x1, scalar y1, scalar
}
}

void gfx_gradient_adapter::init_radial(int spread, scalar x1, scalar y1, scalar radius1,
void gfx_gradient_adapter::init_radial(int32_t spread, scalar x1, scalar y1, scalar radius1,
scalar x2, scalar y2, scalar radius2)
{
if (!m_wrapper) {
Expand Down Expand Up @@ -395,7 +395,7 @@ void gfx_gradient_adapter::init_radial(int spread, scalar x1, scalar y1, scalar
}
}

void gfx_gradient_adapter::init_conic(int spread, scalar x, scalar y, scalar angle)
void gfx_gradient_adapter::init_conic(int32_t spread, scalar x, scalar y, scalar angle)
{
if (!m_wrapper) {
if (spread == SPREAD_REFLECT) {
Expand Down
22 changes: 11 additions & 11 deletions src/gfx/gfx_gradient_adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class gfx_gradient_wrapper
gfx_gradient_wrapper() { }
virtual ~gfx_gradient_wrapper() { }
virtual void init(scalar r, scalar x, scalar y) = 0;
virtual int calculate(int x, int y, int d) const = 0;
virtual int32_t calculate(int32_t x, int32_t y, int32_t d) const = 0;
};

// gradient table
Expand Down Expand Up @@ -84,12 +84,12 @@ class gfx_gradient_table
m_color_profile.add(color_point(offset, color));
}

static unsigned int size(void)
static uint32_t size(void)
{
return color_table_size;
}

const color_type& operator [] (unsigned int i) const
const color_type& operator [] (uint32_t i) const
{
return m_color_table[i];
}
Expand Down Expand Up @@ -131,9 +131,9 @@ class gfx_span_gradient
// do nothing, scanline raster needed.
}

void generate(color_type* span, int x, int y, unsigned int len)
void generate(color_type* span, int32_t x, int32_t y, uint32_t len)
{
int dd = m_d2 - m_d1;
int32_t dd = m_d2 - m_d1;
if (dd < 1) {
dd = 1;
}
Expand All @@ -142,7 +142,7 @@ class gfx_span_gradient
INT_TO_SCALAR(y) + FLT_TO_SCALAR(0.5f), len);
do {
m_interpolator->coordinates(&x, &y);
int d = m_gradient_function->calculate(x >> downscale_shift,
int32_t d = m_gradient_function->calculate(x >> downscale_shift,
y >> downscale_shift, m_d2);
d = ((d - m_d1) * (int)m_color_function->size()) / dd;

Expand All @@ -163,8 +163,8 @@ class gfx_span_gradient
interpolator_type* m_interpolator;
const gradient_type* m_gradient_function;
const color_func* m_color_function;
int m_d1;
int m_d2;
int32_t m_d1;
int32_t m_d2;
};

// gradient adaptor
Expand All @@ -186,12 +186,12 @@ class gfx_gradient_adapter : public abstract_gradient_adapter
}
}

virtual void init_linear(int spread, scalar x1, scalar y1, scalar x2, scalar y2);
virtual void init_linear(int32_t spread, scalar x1, scalar y1, scalar x2, scalar y2);

virtual void init_radial(int spread, scalar x1, scalar y1, scalar radius1,
virtual void init_radial(int32_t spread, scalar x1, scalar y1, scalar radius1,
scalar x2, scalar y2, scalar radius2);

virtual void init_conic(int spread, scalar x, scalar y, scalar angle);
virtual void init_conic(int32_t spread, scalar x, scalar y, scalar angle);

virtual void add_color_stop(scalar offset, const picasso::rgba& c)
{
Expand Down

0 comments on commit e540995

Please sign in to comment.