microvg  8.0.0
microvg
Macros | Functions
vg_helper.h File Reference

MicroEJ MicroVG library low level API: helper to implement library natives methods. More...

#include <stdio.h>
#include <sni.h>
#include "mej_log.h"

Go to the source code of this file.

Macros

#define MEJ_LOG_INFO_MICROVG(fmt, ...)
 
#define MEJ_LOG_ERROR_MICROVG(fmt, ...)   MEJ_LOG(ERROR, MICROVG, fmt, ## __VA_ARGS__)
 
#define VG_HELPER_NULL_GRADIENT   0
 Set this define to monitor freetype heap evolution. It needs MEJ_LOG_MICROVG and MEJ_LOG_INFO_LEVEL defines to print the heap logs. More...
 
#define FT_FACE_FLAG_COMPLEX_LAYOUT   (((uint32_t)1) << 31)
 Freetype supplementary flag for complex layout Uses a free bit in freetype face flags to convey the complex layout mode information with the freetype face. freetype.h must be checked on freetype update to ensure that this bit is still free.
 
#define M_PI   3.1415926535
 
#define RAD_TO_DEG(r)   ((r) * (180.0f / M_PI))
 
#define DEG_TO_RAD(d)   (((d) * M_PI) / 180.0f)
 
#define JFLOAT_TO_UINT32_t(f)   (*(uint32_t *)&(f))
 
#define UINT32_t_TO_JFLOAT(i)   (*(float *)&(i))
 
#define REGISTERDESC(desc, buf, buf_len)   if ((buf_len) >= sizeof(desc)) { (void)memcpy((buf), (desc), sizeof(desc)); }
 Registers the description of a SNI close function.
 

Functions

void LLUI_DISPLAY_waitAsynchronousDrawingEnd (void)
 Waits until the end of current asynchronous drawing. More...
 
int VG_HELPER_get_utf (const unsigned short *text, int length, int *offset)
 Gets the UTF character from a text buffer at the given offset and updates the offset to point to the next character. More...
 
void VG_HELPER_layout_configure (int faceHandle, const unsigned short *text, int length)
 
bool VG_HELPER_layout_load_glyph (uint32_t *glyph_idx, int *x_advance, int *y_advance, int *x_offset, int *y_offset)
 
const jfloat * VG_HELPER_check_matrix (const jfloat *matrix)
 
uint32_t VG_HELPER_apply_alpha (uint32_t color, uint32_t alpha)
 
void VG_HELPER_prepare_matrix (jfloat *dest, jfloat x, jfloat y, const jfloat *matrix)
 

Detailed Description

MicroEJ MicroVG library low level API: helper to implement library natives methods.

Author
MicroEJ Developer Team
Version
8.0.0

Definition in file vg_helper.h.

Macro Definition Documentation

◆ VG_HELPER_NULL_GRADIENT

#define VG_HELPER_NULL_GRADIENT   0

Set this define to monitor freetype heap evolution. It needs MEJ_LOG_MICROVG and MEJ_LOG_INFO_LEVEL defines to print the heap logs.

NULL Gradient value

Definition at line 57 of file vg_helper.h.

Function Documentation

◆ LLUI_DISPLAY_waitAsynchronousDrawingEnd()

void LLUI_DISPLAY_waitAsynchronousDrawingEnd ( void  )

Waits until the end of current asynchronous drawing.

To avoid potential side effects from the release of objects (images, fonts) retained by a feature during the killing of that feature, ensure that no third-party components (e.g., GPU) are using these objects at the time of the kill.

UI packs with versions higher than 14.5.1 provide the blocking API LLUI_DISPLAY_waitAsynchronousDrawingEnd(). This API is stubbed on the VG Pack for backward compatibility issues between VG Pack 1.8.0 and UI Packs [14.4.0, 14.5.1]. However, it is highly recommended to use a UI Pack version greater than 14.5.1.

Definition at line 150 of file vg_helper.c.

150  {
151  // cannot wait the end of drawing with UI packs [14.4.0-14.5.1]
152 }

◆ VG_HELPER_get_utf()

int VG_HELPER_get_utf ( const unsigned short *  text,
int  length,
int *  offset 
)

Gets the UTF character from a text buffer at the given offset and updates the offset to point to the next character.

Some characters have some special values; they are made up of two Unicode characters in two specific ranges such that the first Unicode character is in one range (for example 0xD800-0xD8FF) and the second Unicode character is in the second range (for example 0xDC00-0xDCFF). This is called a surrogate pair.

If a surrogate pair is incomplete (missing second character), this function returns "0" (error) and does not update the offset.

Parameters
[in]texttext buffer encoded in UTF16 where to read UTF character.
[in]lengthlenght of the text buffer.
[in/out]offset: offset in the text buffer where to read UTF character. Updated to the next character position.
Returns
The decoded UTF character.

Definition at line 159 of file vg_helper.c.

159  {
160  unsigned short highPart = GET_NEXT_CHARACTER(textCharRam, length, *offset);
161  int ret = 0; // means "error" (see doc)
162 
163  if ((highPart >= MIN_HIGH_SURROGATE) && (highPart <= MAX_HIGH_SURROGATE)) {
164  if (*offset < (length - 1)) {
165  unsigned short lowPart = GET_NEXT_CHARACTER(textCharRam, length, *(offset) + 1);
166 
167  if ((lowPart >= MIN_LOW_SURROGATE) && (lowPart <= MAX_LOW_SURROGATE)) {
168  *offset += 2;
169 
170  ret = 0;
171  ret += ((int)highPart - (int)MIN_HIGH_SURROGATE);
172  ret <<= (int)10;
173  ret += ((int)lowPart - (int)MIN_LOW_SURROGATE);
174  ret += (int)MIN_SUPPLEMENTARY_CODE_POINT;
175  }
176  // else: invalid surrogate pair
177  }
178  // else: missing second part of surrogate pair
179  } else {
180  *offset += 1;
181 
182  // standard character
183  ret = 0x0000FFFF & (int)highPart;
184  }
185 
186  return ret;
187 }