Exemple #1
0
uint64_t s_ld_pk_u64(const uint8_t **buf0, size_t bs)
{
	size_t hdr_bytes;
	const uint8_t *buf;
	RETURN_IF(!buf0 || !bs, 0);
	buf = *buf0;
	RETURN_IF(!buf, 0);
	hdr_bytes = s_pk_u64_size(buf);
	(*buf0) += hdr_bytes;
	RETURN_IF(hdr_bytes > bs, 0);
	switch (hdr_bytes) {
	case D8_LE_SZ:
		return buf[0] >> D8_LE_SHIFT;
	case D16_LE_SZ:
		return S_LD_LE_U16(buf) >> D16_LE_SHIFT;
	case D24_LE_SZ:
		return D24_LE_MASK & (S_LD_LE_U32(buf) >> D24_LE_SHIFT);
	case D32_LE_SZ:
		return S_LD_LE_U32(buf) >> D32_LE_SHIFT;
	case D40_LE_SZ:
		return D40_LE_MASK & (S_LD_LE_U64(buf) >> D40_LE_SHIFT);
	case D48_LE_SZ:
		return D48_LE_MASK & (S_LD_LE_U64(buf) >> D48_LE_SHIFT);
	case D56_LE_SZ:
		return D56_LE_MASK & (S_LD_LE_U64(buf) >> D56_LE_SHIFT);
	case D72_LE_SZ:
		return S_LD_LE_U64(buf + 1);
	}
	return 0;
}
Exemple #2
0
const srt_string *sso1_get(const srt_stringo1 *s)
{
	RETURN_IF(!s, ss_void);
	RETURN_IF(s->t == OptStr_D, (const srt_string *)s->d.s_raw);
	RETURN_IF(s->t == OptStr_I, s->i.s);
	return ss_void;
}
Exemple #3
0
sbool_t sm_i_delete(sm_t *m, const sint_t k)
{
	struct SMapIx ix;
	struct SMapii ii;
	struct SMapuu uu;
	const stn_t *n;
	stn_callback_t callback = NULL;
	switch (m->f.type) {
	case SM_I32I32:
		RETURN_IF(k > SINT32_MAX || k < SINT32_MIN, S_FALSE);
		ii.k = (sint32_t)k;
		n = (const stn_t *)&ii;
		break;
	case SM_U32U32:
		RETURN_IF(k > SUINT32_MAX, S_FALSE);
		uu.k = (suint32_t)k;
		n = (const stn_t *)&uu;
		break;
	case SM_IntStr:
		callback = aux_is_delete;
		/* don't break */
	case SM_IntInt: case SM_IntPtr:
		ix.k = k;
		n = (const stn_t *)&ix;
		break;
	default:
		return S_FALSE;
	}
	return st_delete(m, n, callback);
}
Exemple #4
0
static size_t ppm2rgb(ss_t **rgb, struct RGB_Info *ri, const ss_t *ppm)
{
	RETURN_IF(!ppm || !ri, 0);
	const char *p = ss_get_buffer_r(ppm);
	size_t ps = ss_size(ppm);
	ri->chn = p[1] == '5' ? 1 : p[1] == '6' ? 3 : 0;
	RETURN_IF(ps < 16 || p[0] != 'P' || !ri->chn, 0);
	size_t off = 2, nf = 0, nl, nl2, i = 0;
	int f[PPM_NFIELDS];
	for (; i != S_NPOS && nf < PPM_NFIELDS && off < ps; off = nl + 1) {
		nl = ss_findc(ppm, off, '\n');
		if (nl == S_NPOS)
			break;
		nl2 = ss_findrc(ppm, off, nl, '#'); /* skip comments */
		nl2 = nl2 == S_NPOS ? nl : nl2;
		for (i = off; i < nl2;) { /* get fields */
			i = ss_findrbm(ppm, i, nl2, 0x30, 0xc0); /* digits */
			if (i == S_NPOS)
				break;
			f[nf++] = atoi(p + i);
			if (nf == PPM_NFIELDS)
				break;
			i = ss_findrb(ppm, i + 1, nl2);
		}
	}
	RETURN_IF(nf != PPM_NFIELDS, 0);
	ri->bpp = ri->chn * (f[2] <= 255 ? 1 : f[2] <= 65535 ? 2 : 0) * 8;
	set_rgbi(ri, f[0], f[1], ri->bpp, ri->chn);
	RETURN_IF(!valid_rgbi(ri), 0);
	ss_cpy_cn(rgb, p + off, ps - off); /* Copy pixel data */
	return ss_size(*rgb);
}
Exemple #5
0
static size_t rgb2jpg(ss_t **jpg, const ss_t *rgb, const struct RGB_Info *ri)
{
	RETURN_IF(!valid_rgbi_for_jpg(ri) ||!rgb, 0);
	struct jpeg_error_mgr je;
	struct jpeg_compress_struct jc;
	struct aux_jpeg jaux;
	jc.err = jpeg_std_error(&je);
	RETURN_IF(!aux_jpeg_enc_init(&jc, &jaux, ri, rgb, jpg), 0);
	jpeg_start_compress(&jc, TRUE);
	jc.next_scanline = 0;
	size_t i = 0, i_max = ri->height * ri->row_size;
	const char *rgbp = ss_get_buffer_r(rgb);
	JSAMPROW r;
	for (; i < i_max && jaux.errors == S_FALSE; i += ri->row_size) {
		r = (JSAMPROW)(rgbp + i);
		jpeg_write_scanlines(&jc, &r, 1);
	}
	if (jaux.errors == S_FALSE) {
		jpeg_finish_compress(&jc);
		ss_set_size(*jpg, jaux.out_size);
		ss_shrink(jpg);
	} else {
		jaux.out_size = 0;
	}
	jpeg_destroy_compress(&jc);
	return jaux.out_size;
}
Exemple #6
0
void ITimelineModel::Precompute(float fps)
{
	RETURN_IF_FALSE(SupportPrecompute());
	RETURN_IF_TRUE(mIsPrecomputed);
	RETURN_IF(fps < 0.f);
	RETURN_IF_EMPTY(mFrames);

	mIsPrecomputed = true;
	mFPS = fps;
	int preCalculatedframeCount = (int)Math::Ceil(mDuration * fps);
	RETURN_IF(preCalculatedframeCount <= 0);
	mFrameCount = (uint)preCalculatedframeCount;

	OnPrecomputeBegin();
	float firstTime = mFrames.First().Time;
	AddPrecomputedItem(Math::IsZero(firstTime), 0U, 0U, 0.f);	//add zero frame


	const float frameInterval = 1.f / mFPS;
	float time = 0.f;
	uint outPrevFrameIndex;
	uint outNextFrameIndex;
	float outPercent;

	uint prevIndex = 0;
	FOR_EACH_SIZE(i, mFrameCount)
	{
		time += frameInterval;
		bool isFound = TryGetFrameHelper(time, outPrevFrameIndex, outNextFrameIndex, outPercent, prevIndex);
		if (isFound)
		{
			prevIndex = outPrevFrameIndex;
		}
		AddPrecomputedItem(isFound, outPrevFrameIndex, outNextFrameIndex, outPercent);
	}
Exemple #7
0
sbool_t valid_rgbi_for_ppm(const struct RGB_Info *ri)
{
	RETURN_IF(!valid_rgbi(ri), S_FALSE);
	RETURN_IF(ri->chn == 3 && ri->bpp != 24 && ri->bpp != 48, S_FALSE);
	RETURN_IF(ri->chn == 1 && ri->bpp != 8 && ri->bpp != 16, S_FALSE);
	return S_TRUE;
}
Exemple #8
0
static size_t tga2rgb(ss_t **rgb, struct RGB_Info *ri, const ss_t *tga)
{
	const char *t = ss_get_buffer_r(tga);
	const size_t ts = ss_size(tga);
	RETURN_IF(ts < TGA_RGBHDR || !valid_tga(t), 0);
	set_rgbi(ri, S_LD_LE_U16(t + TGA_W), S_LD_LE_U16(t + TGA_H),
		 t[TGA_BPP], t[TGA_TYPE] == TGA_RAW_GRAY ? 1 : t[TGA_BPP]/8);
	RETURN_IF(!valid_rgbi(ri), 0);
	size_t rgb_bytes = ri->row_size * ri->height;
	RETURN_IF(ts < rgb_bytes + TGA_RGBHDR, 0);
	RETURN_IF(ss_reserve(rgb, rgb_bytes) < rgb_bytes, 0);
	if ((t[TGA_DESC] & TGA_TOP_LEFT) != 0) {
		if (ri->chn == 1)
			ss_cpy_cn(rgb, t + TGA_RGBHDR, rgb_bytes);
		else
			tga_rgb_swap(ri->bpp, rgb_bytes,
				     ss_get_buffer_r(tga) + TGA_RGBHDR,
				     ss_get_buffer(*rgb));
	} else {
		ss_set_size(*rgb, 0);
		ssize_t i = (ssize_t)(ri->height - 1) * ri->row_size;
		for (; i >= 0; i -= ri->row_size)
			if (ri->chn == 1)
				ss_cat_cn(rgb, t + TGA_RGBHDR + i,
					  ri->row_size);
			else
				tga_rgb_swap(ri->bpp, ri->row_size,
					     t + TGA_RGBHDR + i,
					     ss_get_buffer(*rgb) + i);
	}
	ss_set_size(*rgb, rgb_bytes);
	return rgb_bytes;
}
Exemple #9
0
sbool_t aux_jpeg_dec_init(struct jpeg_decompress_struct *jd,
			  struct aux_jpeg *ja, struct RGB_Info *ri,
			  const ss_t *jpg_in, ss_t **rgb_out)
{
	RETURN_IF(!ja || !ri || !jpg_in || !rgb_out, S_FALSE);
	jpeg_create_decompress(jd);
	jd->err->trace_level = 0;
	jd->err->error_exit = jpg_error_exit;
	ja->in = jpg_in;
	ja->out = rgb_out;
	jd->src = &ja->jsrc;
	aux_jpeg_common_init(ja);
	ja->jsrc.init_source = aux_jpegd_init;
	ja->jsrc.fill_input_buffer = aux_jpegd_fill_input_buffer;
	ja->jsrc.skip_input_data = aux_jpegd_skip_input_data;
	ja->jsrc.resync_to_restart = jpeg_resync_to_restart;
	ja->jsrc.term_source = aux_jpegd_term_source;
	ja->jsrc.next_input_byte = (JOCTET *)ss_get_buffer_r(jpg_in);
	ja->jsrc.bytes_in_buffer = ss_size(jpg_in);
	RETURN_IF(jpeg_read_header(jd, TRUE) != JPEG_HEADER_OK, 0);
	jpeg_start_decompress(jd);
	set_rgbi(ri, jd->output_width, jd->output_height,
		 jd->out_color_components * 8, jd->out_color_components);
	RETURN_IF(!valid_rgbi(ri), S_FALSE);
	size_t rgb_size = ri->row_size * ri->height;
	if (ss_reserve(rgb_out, rgb_size) >= rgb_size)
		return S_TRUE;
	jpeg_destroy_decompress(jd);
	return S_FALSE;
}
Exemple #10
0
const srt_string *sso_get_s2(const srt_stringo *s)
{
	RETURN_IF(!s || (s->t & OptStr_2) == 0, ss_void);
	RETURN_IF(s->t == OptStr_ID, (const srt_string *)s->kv.di.s_raw);
	RETURN_IF(s->t == OptStr_DI, (const srt_string *)s->kv.di.si);
	RETURN_IF(s->t == OptStr_II, s->kv.ii.s2);
	return sso_dd_get_s2(s); /* OptStr_DD */
}
Exemple #11
0
sbool_t valid_rgbi_for_jpg(const struct RGB_Info *ri)
{
	RETURN_IF(!valid_rgbi(ri), S_FALSE);
	RETURN_IF(ri->chn == 2 || ri->chn > 3, S_FALSE);
	RETURN_IF(ri->chn == 3 && ri->bpp != 24, S_FALSE);
	RETURN_IF(ri->chn == 1 && ri->bpp != 8, S_FALSE);
	return S_TRUE;
}
Exemple #12
0
static sbool_t aux_png_read_set_rows(png_bytep *rows, const png_info *pi,
				     ss_t **rgb)
{
	RETURN_IF(!rows || !pi || !rgb, S_FALSE);
	size_t rs = aux_png_row_size(pi), rgb_size = rs * pi->height;
	RETURN_IF(ss_reserve(rgb, rgb_size) < rgb_size, S_FALSE);
	ss_set_size(*rgb, rgb_size);
	return aux_png_set_rows(rows, pi, ss_get_buffer(*rgb));
}
Exemple #13
0
ss_t *ss_cpy(ss_t **s, const ss_t *src)
{
	ASSERT_RETURN_IF(!s, ss_void);
	RETURN_IF(*s == src && ss_check(s), *s); /* aliasing, same string */
	RETURN_IF(!src, ss_clear(s)); /* BEHAVIOR: empty */
	if (*s)
		ss_clear(s);
	return ss_cat(s, src);
}
Exemple #14
0
sm_t *sm_cpy(sm_t **m, const sm_t *src)
{
	RETURN_IF(!m || !src, NULL); /* BEHAVIOR */
	size_t i;
	const enum eSM_Type t = (enum eSM_Type)src->f.type;
	size_t ss = sm_size(src),
	       src_buf_size = ST_SIZE_TO_ALLOC_SIZE(ss, sm_elem_size(t));
	if (*m) {
		if (sd_is_using_ext_buffer((const sd_t *)src))
		{	/* If using ext buffer, we'll have grow limits */
			sm_reset(*m);
			size_t oe = st_capacity(*m),
			       os = ST_SIZE_TO_ALLOC_SIZE(oe, sm_elem_size(t));
			RETURN_IF(os < src_buf_size, NULL); /* BEHAVIOR */
			*m = sm_alloc_raw(t, S_TRUE, *m, os);
		} else {
			if ((*m)->f.type == t) {
				st_reserve(m, ss);
			} else {
				sm_free(m);
				*m = NULL;
			}
		}
	}
	if (!*m)
		*m = sm_alloc(t, ss);
	RETURN_IF(!*m || st_capacity(*m) < ss, NULL); /* BEHAVIOR */
	switch (t) {
	/*
	 * Fast copy: compact structure (without strings)
	 */
	case SM_I32I32: case SM_U32U32: case SM_IntInt: case SM_IntPtr:
		memcpy(*m, src, src_buf_size);
		break;
	/*
	 * Slow map copy for types having strings as key or value:
	 */
#define case_SM_CPY_InsertLoop(SM_xy, ST, INSERTF)			\
	case SM_xy:							\
		for (i = 0; i < ss; i++) {				\
			const ST *s = (const ST *)sm_enum_r(*m, i);	\
			INSERTF(m, s->x.k, s->v);			\
		}							\
		break;
	case_SM_CPY_InsertLoop(SM_IntStr, struct SMapIS, sm_is_insert);
	case_SM_CPY_InsertLoop(SM_StrInt, struct SMapSI, sm_si_insert);
	case_SM_CPY_InsertLoop(SM_StrStr, struct SMapSS, sm_ss_insert);
	case_SM_CPY_InsertLoop(SM_StrPtr, struct SMapSP, sm_sp_insert);
#undef case_SM_CPY_InsertLoop
	default:
		break;
	}
	return *m;
}
Exemple #15
0
void IButton::SetIsSelected(bool selected /*= true*/)
{
	if (selected)
	{
		RETURN_IF(IsSelected());
		SetButtonState(mButtonState == ButtonState::Normal ? ButtonState::Selected : ButtonState::DisabledSelected);
	}
	else
	{
		RETURN_IF(!IsSelected());
		SetButtonState(mButtonState == ButtonState::Selected ? ButtonState::Normal : ButtonState::Disabled);
	}
}
Exemple #16
0
void IButton::EnableButton(bool enable /*= true*/)
{
	if (enable)
	{
		RETURN_IF(!IsDisabled());
		SetButtonState(mButtonState == ButtonState::Disabled ? ButtonState::Normal : ButtonState::Selected);
	}
	else
	{
		RETURN_IF(IsDisabled());
		SetButtonState(mButtonState == ButtonState::Normal ? ButtonState::Disabled : ButtonState::DisabledSelected);
	}
}
Exemple #17
0
sbool_t aux_jpeg_enc_init(struct jpeg_compress_struct *jc,
			  struct aux_jpeg *ja, const struct RGB_Info *ri,
			  const ss_t *rgb, ss_t **jpg_out)
{
	RETURN_IF(!ja || !valid_rgbi(ri) || !rgb || !jpg_out, S_FALSE);
	ss_set_size(*jpg_out, 0);
	jpeg_create_compress(jc);
	jc->in_color_space = ri->chn == 1 ? JCS_GRAYSCALE : JCS_RGB;
	jpeg_set_defaults(jc);
	jc->input_components = ri->chn;
	jc->data_precision = ri->bpp / ri->chn;
	jc->image_width = ri->width;
	jc->image_height = ri->height;
	jpeg_default_colorspace(jc);
	jc->smoothing_factor = JPG_SMOOTH;
	jc->arith_code = FALSE;
	if (ri->chn == 1)
		jpeg_set_colorspace(jc, JCS_GRAYSCALE);
	jc->mem->max_memory_to_use = JPG_TMP_MAX_MEM;
	jc->restart_in_rows = 0;
	jc->optimize_coding = TRUE;
	jc->err->trace_level = 0;
	jc->err->error_exit = jpg_error_exit;
#ifdef S_HW_FPU
	jc->dct_method = JDCT_FLOAT;
#else
	jc->dct_method = JDCT_ISLOW;
#endif
#ifdef JPG_SUBS_HQ /* No chroma subsampling (better quality, +30% size) */
	jc->comp_info[0].h_samp_factor = jc->comp_info[0].v_samp_factor =
	jc->comp_info[1].h_samp_factor = jc->comp_info[1].v_samp_factor =
	jc->comp_info[2].h_samp_factor = jc->comp_info[2].v_samp_factor = 1;
#endif
	jpeg_set_quality(jc, JPG_QUALITY, TRUE);
	aux_jpeg_common_init(ja);
	/* Max out size: this is an heuristic (adjusted afterwards) */
	ja->max_out_size = (ri->width * ri->height * ri->bpp) / 8;
	RETURN_IF(ss_reserve(jpg_out, ja->max_out_size) < ja->max_out_size,
		  S_FALSE);
	ja->in = rgb;
	ja->out = jpg_out;
	ja->ri_enc = ri;
	ja->errors = S_FALSE;
	ja->jdest.init_destination = aux_jpege_init;
	ja->jdest.empty_output_buffer = aux_jpege_empty_output_buffer;
	ja->jdest.term_destination = aux_jpege_term_destination;
	jc->client_data = ja;
	jc->dest = &ja->jdest;
	return S_TRUE;
}
Exemple #18
0
static size_t png2rgb(ss_t **rgb, struct RGB_Info *ri, const ss_t *png)
{
	RETURN_IF(!png || !ss_size(png), 0);
	size_t out_size = 0;
	struct aux_png_rio pio = { 0, png };
	png_structp s = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);
	png_infop pi = png_create_info_struct(s);
	png_set_read_fn(s, (png_voidp)&pio, aux_png_read);
	png_read_info(s, pi);
	if (!aux_png2rbi(pi, ri)) {
		png_destroy_info_struct(s, &pi);
		png_destroy_read_struct(&s, NULL, NULL);
		return 0;
	}
	if ((pi->color_type & PNG_COLOR_MASK_PALETTE) != 0)
		png_set_expand(s); /* pal: expand to RGB */
	png_bytep *rows = (png_bytep *)alloca(sizeof(png_bytep) * pi->height);
	if (aux_png_read_set_rows(rows, pi, rgb)) {
		size_t i = png_set_interlace_handling(s);
		for (; i > 0; i--)
			png_read_rows(s, rows, NULL, pi->height);
		png_read_end(s, pi);
		out_size = ss_size(*rgb);
	}
	png_destroy_info_struct(s, &pi);
	png_destroy_read_struct(&s, NULL, NULL);
	return out_size;
}
Exemple #19
0
int LibThreadMgr_BatchCreate(THREAD_HANDLE_t *hdlAry, ThreadEntryFunc *funcAry, u32 len)
{
    int retVal;
    u32 i = 0;
    for (i = 0; i < len; i++) {
        retVal = LibThread_NewHandle(&hdlAry[i]);
        RETURN_IF(retVal);
    }

    for (i = 0; i < len; i++) {
        retVal = LibThread_Create(hdlAry[i], funcAry[i]);
        RETURN_IF(retVal);
    }

    return 0;
}
Exemple #20
0
static size_t get_unicode_size(const ss_t *s)
{
	RETURN_IF(!s, 0);
	return s->is_full ? ((const struct SSTR_Full *)s)->unicode_size :
			    ((get_unicode_size_h(s) << 8) |
			     ((const struct SSTR_Small *)s)->unicode_size_l);
}
Exemple #21
0
static sbool_t aux_png2rbi(const png_info *pi, struct RGB_Info *ri)
{
	RETURN_IF(!pi || !ri, S_FALSE);
	size_t depth = aux_png_get_depth(pi), chn = aux_png_get_chn(pi);
	set_rgbi(ri, pi->width, pi->height, depth * chn, chn);
	return valid_rgbi(ri);
}
Exemple #22
0
static size_t rgb2png(ss_t **png, const ss_t *rgb, const struct RGB_Info *ri)
{
	RETURN_IF(!valid_rgbi(ri) ||!rgb, 0);
	size_t out_size = 0;
	png_structp s = png_create_write_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);
	png_infop pi = png_create_info_struct(s);
	if (png)
		ss_set_size(*png, 0);
	png_set_write_fn(s, (png_voidp)png, aux_png_write, NULL);
	int ctype = (ri->chn > 1 ? PNG_COLOR_MASK_COLOR : 0) |
		    (ri->chn == 2 || ri->chn == 4 ? PNG_COLOR_MASK_ALPHA : 0);
	png_set_IHDR(s, pi, (png_uint_32)ri->width, (png_uint_32)ri->height,
		     ri->bpc, ctype, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE,
		     PNG_FILTER_TYPE_BASE);
	png_set_filter(s, PNG_FILTER_TYPE_BASE, PNG_ALL_FILTERS);
	png_set_compression_level(s, Z_BEST_COMPRESSION);
	png_write_info(s, pi);
	png_bytep *rows = (png_bytep *)alloca(sizeof(png_bytep) * pi->height);
	if (aux_png_set_rows(rows, pi, ss_get_buffer_r(rgb))) {
		png_write_image(s, rows);
		png_write_end(s, pi);
		out_size = ss_size(*png);
	}
	png_destroy_info_struct(s, &pi);
	png_destroy_write_struct(&s, &pi);
	return out_size;
}
Exemple #23
0
	bool ServerSession::connect(void)
	{
		RETURN_IF( m_isConnected, false );

		mqsFactory::SharedMemoryAccessFactory l_shmFactory;
		m_shmAccess		= l_shmFactory.create();
		if( !m_shmAccess->bind() ){
			appCore::safeDelete(m_shmAccess);
			return false;
		}
		mqsFactory::MutualExclusionClientFactory l_mtxFactory;
		m_mtxClient		= l_mtxFactory.create();
		if( !m_mtxClient->open() ){
			appCore::safeDelete(m_shmAccess);
			appCore::safeDelete(m_mtxClient);
			return false;
		}
		appCore::safeNew(m_mqsClient);
		m_mqsClient->setSharedMemoryAccess( m_shmAccess );
		if( !m_mqsClient->open() ){
			appCore::safeDelete(m_shmAccess);
			appCore::safeDelete(m_mtxClient);
			appCore::safeDelete(m_mqsClient);
			return false;
		}

		m_isConnected = true;

		return m_isConnected;
	}
Exemple #24
0
void* _cmemory_pool_alloc(size_t size) {
    /* if _mempools not init, alloc it */
    if (_mempools == NULL) {
        _mempools = _create_mempools();
    }

    /* find which pool should use */
    int ind = 0;
    while (size > (1 << ind)) ind++;
    RETURN_IF(ind > _CMMP_MAX_SIZE_EXP, NULL);
    ind = (ind >= _CMMP_MIN_SIZE_EXP ? ind - _CMMP_MIN_SIZE_EXP : 0);

    _cmempool_t *upool = &_mempools[ind];

    /* alloc new block if no space in this pool */
    if (upool->idleunit == NULL) {
        _append_memblock(upool);
    }

    /* get free unit */
    _cmemunit_t *uunit   = upool->idleunit;
    _cmemblock_t *ublock = uunit->block;
    upool->idleunit = uunit->nextunit;
    ublock->idlenum--;

   return (void*)(uunit->data);
}
Exemple #25
0
STATUS drawCursor(pSurface suf)
{
	BOOL isEnabled = FALSE;
	cursorProp* prop = NULL;

	RETURN_IF(settingManager_getBool("cursor", &isEnabled));
	if (isEnabled)
	{
		RETURN_IF(settingManager_getProperty("cursor", (void**)(&prop)));
		cursorTheme = prop->ThemeColor;
		shape = prop->shape;
		paintCursor(suf);
	}

	return OK;
}
Exemple #26
0
static size_t aux_png_get_chn(const png_info *pi)
{
	RETURN_IF(!pi, S_FALSE);
	int ct = pi->color_type;
	sbool_t alpha = (ct & PNG_COLOR_MASK_ALPHA) != 0 ? S_TRUE : S_FALSE;
	sbool_t gray = (ct & PNG_COLOR_MASK_COLOR) == 0 ? S_TRUE : S_FALSE;
	return (gray ? 1 : 3) + (alpha ? 1 : 0);
}
Exemple #27
0
static size_t rgb2ppm(ss_t **ppm, const ss_t *rgb, const struct RGB_Info *ri)
{
	RETURN_IF(!ppm || !rgb || !valid_rgbi_for_ppm(ri), 0);
	int colors_per_channel = (1 << (ri->bpp / ri->chn)) - 1;
	ss_printf(ppm, 512, "P%i %i %i %i\n", (ri->chn == 1 ? 5 : 6),
		  (int)ri->width, (int)ri->height, colors_per_channel);
	ss_cat(ppm, rgb);
	return ss_size(*ppm);
}
Exemple #28
0
static sbool_t aux_png_set_rows(png_bytep *rows, const png_info *pi,
				const char *rgb)
{
	RETURN_IF(!rows || !pi || !rgb, S_FALSE);
	size_t i = 0, rs = aux_png_row_size(pi);
	for (; i < pi->height; i++)
		rows[i] = (png_bytep)(rgb + i * rs);
	return S_TRUE;
}
Exemple #29
0
int LibThreadMgr_BatchDestroy(THREAD_HANDLE_t *hdlAry, u32 len)
{
    int retVal;
    u32 i = 0;
    for (i = 0; i < len; i++) {
        retVal = LibThread_DestroyHandle(hdlAry[i]);
        RETURN_IF(retVal);
    }

    return 0;
}
Exemple #30
0
int LibIPC_Event_BatchDestroy(EVENT_HANDLE_t *eventHdlAry, u32 len)
{
    int retVal;
    u32 i = 0;
    for (i = 0; i < len; i++) {
        retVal = LibIPC_Event_Destroy(eventHdlAry[i]);
        RETURN_IF(retVal);
    }

    return 0;
}