21 #ifdef VG_FEATURE_GRADIENT
30 #include <LLVG_GRADIENT_impl.h>
36 #if defined (VG_FEATURE_GRADIENT) && defined (VG_FEATURE_GRADIENT_FULL) && (VG_FEATURE_GRADIENT == VG_FEATURE_GRADIENT_FULL)
43 BSP_DECLARE_WEAK_FCNT uint32_t MICROVG_GRADIENT_get_gradient_header_size(
void) {
52 jint LLVG_GRADIENT_IMPL_initializeGradient(jint* jgradient, jint length, jint* colors, jint count,
53 jfloat* positions, jfloat xStart, jfloat yStart, jfloat xEnd, jfloat yEnd) {
55 uint32_t expectedLength = MICROVG_GRADIENT_get_gradient_header_size() + (count * 2 );
57 if (length >= expectedLength) {
60 float angle = RAD_TO_DEG(atan2f(yEnd - yStart, xEnd - xStart));
61 float l = sqrtf(powf(xEnd - xStart, 2) + powf(yEnd - yStart, 2));
65 gradient->angle = angle;
74 gradient->colors_offset = MICROVG_GRADIENT_get_gradient_header_size();
75 gradient->positions_offset = MICROVG_GRADIENT_get_gradient_header_size() + (jint)2;
77 uint32_t* colors_addr = &((uint32_t*)gradient)[gradient->colors_offset];
78 *colors_addr = *colors;
79 colors_addr[1] = colors[count - 1];
81 uint32_t* positions_addr = &((uint32_t*)gradient)[gradient->positions_offset];
82 *positions_addr = (uint32_t) (MICROVG_GRADIENT_get_gradient_scale_size() / 2);
83 positions_addr[1] = (*positions_addr) + 1;
87 gradient->count = (uint32_t)count;
90 gradient->colors_offset = MICROVG_GRADIENT_get_gradient_header_size();
91 gradient->positions_offset = MICROVG_GRADIENT_get_gradient_header_size() + count;
94 void* colors_addr = (
void*)&((uint32_t*)gradient)[gradient->colors_offset];
95 (
void)memcpy(colors_addr, colors, count *
sizeof(uint32_t));
98 uint32_t max_position = (uint32_t) (MICROVG_GRADIENT_get_gradient_scale_size() - 1);
99 uint32_t* positions_addr = &((uint32_t*)gradient)[gradient->positions_offset];
100 if (NULL == positions) {
101 float step = (float) (max_position / (count - 1));
102 float currentStep = 0.f;
103 for (uint32_t i = 0; i < count; i++) {
104 *positions_addr = (uint32_t) currentStep;
111 for (uint32_t i = 0; i < count; i++) {
112 *positions_addr = (uint32_t) (positions[i] * max_position);
121 ret = expectedLength;
126 #else // #if (VG_FEATURE_GRADIENT == VG_FEATURE_GRADIENT_FULL) => VG_FEATURE_GRADIENT_FIRST_COLOR
129 jint LLVG_GRADIENT_IMPL_initializeGradient(jint* gradient, jint length, jint* colors, jint count,
130 jfloat* positions, jfloat xStart, jfloat yStart, jfloat xEnd, jfloat yEnd) {
147 gradient[0] = colors[0];
154 #endif // #if (VG_FEATURE_GRADIENT == VG_FEATURE_GRADIENT_FULL)
160 #endif // VG_FEATURE_GRADIENT
MicroEJ MicroVG library low level API: helper to implement library natives methods.
MicroEJ MicroVG library low level API: implementation of LinearGradient.
MicroEJ MicroVG library low level API: enable some features according to the hardware capacities...