Exemplo n.º 1
0
void glyph_cache_put(rdpGlyphCache* glyphCache, UINT32 id, UINT32 index, rdpGlyph* glyph)
{
	rdpGlyph* prevGlyph;

	if (id > 9)
	{
		WLog_ERR(TAG, "invalid glyph cache id: %d", id);
		return;
	}

	if (index > glyphCache->glyphCache[id].number)
	{
		WLog_ERR(TAG, "invalid glyph cache index: %d in cache id: %d", index, id);
		return;
	}

	WLog_DBG(TAG, "GlyphCachePut: id: %d index: %d", id, index);

	prevGlyph = glyphCache->glyphCache[id].entries[index];

	if (prevGlyph)
	{
		Glyph_Free(glyphCache->context, prevGlyph);
		free(prevGlyph->aj);
		free(prevGlyph);
	}

	glyphCache->glyphCache[id].entries[index] = glyph;
}
Exemplo n.º 2
0
BOOL update_gdi_cache_glyph(rdpContext* context, CACHE_GLYPH_ORDER* cacheGlyph)
{
	int i;
	rdpGlyph* glyph;
	GLYPH_DATA* glyph_data;
	rdpCache* cache = context->cache;

	for (i = 0; i < (int) cacheGlyph->cGlyphs; i++)
	{
		glyph_data = &cacheGlyph->glyphData[i];

		glyph = Glyph_Alloc(context);
		if (!glyph)
			return FALSE;

		glyph->x = glyph_data->x;
		glyph->y = glyph_data->y;
		glyph->cx = glyph_data->cx;
		glyph->cy = glyph_data->cy;
		glyph->cb = glyph_data->cb;
		glyph->aj = glyph_data->aj;
		if (!Glyph_New(context, glyph))
		{
			Glyph_Free(context, glyph);
			return FALSE;
		}

		glyph_cache_put(cache->glyph, cacheGlyph->cacheId, glyph_data->cacheIndex, glyph);
	}
	return TRUE;
}
Exemplo n.º 3
0
void glyph_cache_put(rdpGlyphCache* glyph_cache, UINT32 id, UINT32 index, rdpGlyph* glyph)
{
	rdpGlyph* prevGlyph;

	if (id > 9)
	{
		printf("invalid glyph cache id: %d\n", id);
		return;
	}

	if (index > glyph_cache->glyphCache[id].number)
	{
		printf("invalid glyph cache index: %d in cache id: %d\n", index, id);
		return;
	}

	prevGlyph = glyph_cache->glyphCache[id].entries[index];

	if (prevGlyph != NULL)
	{
		Glyph_Free(glyph_cache->context, prevGlyph);
		free(prevGlyph->aj);
		free(prevGlyph);
	}

	glyph_cache->glyphCache[id].entries[index] = glyph;
}
Exemplo n.º 4
0
void glyph_cache_free(rdpGlyphCache* glyphCache)
{
	if (glyphCache)
	{
		int i;
		void* fragment;

		for (i = 0; i < 10; i++)
		{
			int j;

			for (j = 0; j < (int) glyphCache->glyphCache[i].number; j++)
			{
				rdpGlyph* glyph;

				glyph = glyphCache->glyphCache[i].entries[j];

				if (glyph)
				{
					Glyph_Free(glyphCache->context, glyph);

					if (glyph->aj)
						free(glyph->aj);
					free(glyph);

					glyphCache->glyphCache[i].entries[j] = NULL;
				}
			}
			free(glyphCache->glyphCache[i].entries);
			glyphCache->glyphCache[i].entries = NULL;
		}

		for (i = 0; i < 255; i++)
		{
			fragment = glyphCache->fragCache.entries[i].fragment;
			free(fragment);
			glyphCache->fragCache.entries[i].fragment = NULL;
		}

		free(glyphCache->fragCache.entries);
		free(glyphCache);
	}
}
Exemplo n.º 5
0
BOOL update_gdi_fast_glyph(rdpContext* context, FAST_GLYPH_ORDER* fastGlyph)
{
	INT32 x, y;
	rdpGlyph* glyph;
	BYTE text_data[2];
	INT32 opLeft, opTop;
	INT32 opRight, opBottom;
	GLYPH_DATA_V2* glyphData;
	rdpCache* cache = context->cache;

	opLeft = fastGlyph->opLeft;
	opTop = fastGlyph->opTop;
	opRight = fastGlyph->opRight;
	opBottom = fastGlyph->opBottom;
	x = fastGlyph->x;
	y = fastGlyph->y;

	if (opBottom == -32768)
	{
		BYTE flags = (BYTE) (opTop & 0x0F);

		if (flags & 0x01)
			opBottom = fastGlyph->bkBottom;
		if (flags & 0x02)
			opRight = fastGlyph->bkRight;
		if (flags & 0x04)
			opTop = fastGlyph->bkTop;
		if (flags & 0x08)
			opLeft = fastGlyph->bkLeft;
	}

	if (opLeft == 0)
		opLeft = fastGlyph->bkLeft;

	if (opRight == 0)
		opRight = fastGlyph->bkRight;

	if (x == -32768)
		x = fastGlyph->bkLeft;

	if (y == -32768)
		y = fastGlyph->bkTop;

	if ((fastGlyph->cbData > 1) && (fastGlyph->glyphData.aj))
	{
		/* got option font that needs to go into cache */
		glyphData = &fastGlyph->glyphData;

		glyph = Glyph_Alloc(context);
		if (!glyph)
			return FALSE;
		glyph->x = glyphData->x;
		glyph->y = glyphData->y;
		glyph->cx = glyphData->cx;
		glyph->cy = glyphData->cy;
		glyph->cb = glyphData->cb;
		glyph->aj = malloc(glyphData->cb);
		if (!glyph->aj)
			goto error_aj;
		CopyMemory(glyph->aj, glyphData->aj, glyph->cb);

		if (!Glyph_New(context, glyph))
			goto error_glyph_new;

		glyph_cache_put(cache->glyph, fastGlyph->cacheId, fastGlyph->data[0], glyph);
	}

	text_data[0] = fastGlyph->data[0];
	text_data[1] = 0;

	return update_process_glyph_fragments(context, text_data, 1,
			fastGlyph->cacheId, fastGlyph->ulCharInc, fastGlyph->flAccel,
			fastGlyph->backColor, fastGlyph->foreColor, x, y,
			fastGlyph->bkLeft, fastGlyph->bkTop,
			fastGlyph->bkRight - fastGlyph->bkLeft, fastGlyph->bkBottom - fastGlyph->bkTop,
			opLeft, opTop,
			opRight - opLeft, opBottom - opTop,
			FALSE);

error_glyph_new:
	free(glyph->aj);
	glyph->aj = NULL;
error_aj:
	Glyph_Free(context, glyph);
	return FALSE;
}