2011-08-21 22:16:53 +04:00
|
|
|
/**
|
|
|
|
* FreeRDP: A Remote Desktop Protocol Client
|
|
|
|
* Glyph Cache
|
|
|
|
*
|
|
|
|
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2011-11-09 08:26:44 +04:00
|
|
|
#include <freerdp/freerdp.h>
|
2011-08-21 22:16:53 +04:00
|
|
|
#include <freerdp/utils/stream.h>
|
|
|
|
#include <freerdp/utils/memory.h>
|
|
|
|
|
|
|
|
#include <freerdp/cache/glyph.h>
|
|
|
|
|
2011-11-22 03:11:43 +04:00
|
|
|
void update_process_glyph(rdpContext* context, uint8* data, int* index,
|
2011-11-22 07:11:31 +04:00
|
|
|
int* x, int* y, uint32 cacheId, uint32 ulCharInc, uint32 flAccel)
|
2011-08-21 22:16:53 +04:00
|
|
|
{
|
2011-11-09 08:26:44 +04:00
|
|
|
int offset;
|
|
|
|
rdpGlyph* glyph;
|
2011-11-22 07:11:31 +04:00
|
|
|
uint32 cacheIndex;
|
2011-11-09 09:43:56 +04:00
|
|
|
rdpGraphics* graphics;
|
2011-11-09 08:26:44 +04:00
|
|
|
rdpGlyphCache* glyph_cache;
|
|
|
|
|
2011-11-22 03:11:43 +04:00
|
|
|
graphics = context->graphics;
|
|
|
|
glyph_cache = context->cache->glyph;
|
2011-11-09 08:26:44 +04:00
|
|
|
|
2011-11-09 21:16:09 +04:00
|
|
|
cacheIndex = data[(*index)++];
|
2011-11-09 08:26:44 +04:00
|
|
|
|
2011-11-09 21:16:09 +04:00
|
|
|
glyph = glyph_cache_get(glyph_cache, cacheId, cacheIndex);
|
2011-11-09 08:26:44 +04:00
|
|
|
|
2011-11-09 21:16:09 +04:00
|
|
|
if ((ulCharInc == 0) && (!(flAccel & SO_CHAR_INC_EQUAL_BM_BASE)))
|
2011-11-09 08:26:44 +04:00
|
|
|
{
|
2011-11-09 21:16:09 +04:00
|
|
|
offset = data[*index];
|
2011-11-09 08:26:44 +04:00
|
|
|
|
2011-11-09 21:16:09 +04:00
|
|
|
if (offset & 0x80)
|
|
|
|
{
|
|
|
|
offset = data[*index + 1] | (data[*index + 2] << 8);
|
|
|
|
(*index)++;
|
|
|
|
(*index)++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flAccel & SO_VERTICAL)
|
2011-11-09 08:26:44 +04:00
|
|
|
*y += offset;
|
|
|
|
else
|
|
|
|
*x += offset;
|
|
|
|
}
|
2011-11-09 21:16:09 +04:00
|
|
|
|
|
|
|
if (glyph != NULL)
|
2011-11-09 08:26:44 +04:00
|
|
|
{
|
2011-11-22 03:11:43 +04:00
|
|
|
Glyph_Draw(context, glyph, glyph->x + *x, glyph->y + *y);
|
2011-11-09 21:16:09 +04:00
|
|
|
|
|
|
|
if (flAccel & SO_CHAR_INC_EQUAL_BM_BASE)
|
|
|
|
*x += glyph->cx;
|
2011-11-09 08:26:44 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-22 07:11:31 +04:00
|
|
|
void update_process_glyph_fragments(rdpContext* context, uint8* data, uint32 length,
|
|
|
|
uint32 cacheId, uint32 ulCharInc, uint32 flAccel, uint32 bgcolor, uint32 fgcolor, int x, int y,
|
2011-11-09 08:26:44 +04:00
|
|
|
int bkX, int bkY, int bkWidth, int bkHeight, int opX, int opY, int opWidth, int opHeight)
|
|
|
|
{
|
|
|
|
int n;
|
2011-11-22 07:11:31 +04:00
|
|
|
uint32 id;
|
|
|
|
uint32 size;
|
2011-11-09 08:26:44 +04:00
|
|
|
int index = 0;
|
|
|
|
uint8* fragments;
|
2011-11-09 09:43:56 +04:00
|
|
|
rdpGraphics* graphics;
|
2011-11-09 08:26:44 +04:00
|
|
|
rdpGlyphCache* glyph_cache;
|
|
|
|
|
2011-11-22 03:11:43 +04:00
|
|
|
graphics = context->graphics;
|
|
|
|
glyph_cache = context->cache->glyph;
|
2011-11-09 08:26:44 +04:00
|
|
|
|
|
|
|
if (opWidth > 1)
|
2011-11-22 03:11:43 +04:00
|
|
|
Glyph_BeginDraw(context, opX, opY, opWidth, opHeight, bgcolor, fgcolor);
|
2011-11-09 21:57:31 +04:00
|
|
|
else
|
2011-11-22 03:11:43 +04:00
|
|
|
Glyph_BeginDraw(context, 0, 0, 0, 0, bgcolor, fgcolor);
|
2011-11-09 08:26:44 +04:00
|
|
|
|
|
|
|
while (index < length)
|
|
|
|
{
|
|
|
|
switch (data[index])
|
|
|
|
{
|
|
|
|
case GLYPH_FRAGMENT_USE:
|
|
|
|
|
2011-11-09 21:16:09 +04:00
|
|
|
printf("GLYPH_FRAGMENT_USE\n");
|
|
|
|
|
2011-11-09 08:26:44 +04:00
|
|
|
if (index + 2 > length)
|
|
|
|
{
|
2011-11-09 21:16:09 +04:00
|
|
|
/* at least one byte need to follow */
|
2011-11-09 08:26:44 +04:00
|
|
|
index = length = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
id = data[index + 1];
|
|
|
|
fragments = (uint8*) glyph_cache_fragment_get(glyph_cache, id, &size);
|
|
|
|
|
2011-11-09 21:16:09 +04:00
|
|
|
if (fragments != NULL)
|
2011-11-09 08:26:44 +04:00
|
|
|
{
|
2011-11-09 21:16:09 +04:00
|
|
|
if ((ulCharInc == 0) && (!(flAccel & SO_CHAR_INC_EQUAL_BM_BASE)))
|
|
|
|
{
|
|
|
|
if (flAccel & SO_VERTICAL)
|
|
|
|
y += data[index + 2];
|
|
|
|
else
|
|
|
|
x += data[index + 2];
|
|
|
|
}
|
|
|
|
|
2011-11-09 21:57:31 +04:00
|
|
|
for (n = 0; n < size; n++)
|
2011-11-09 21:16:09 +04:00
|
|
|
{
|
2011-11-22 03:11:43 +04:00
|
|
|
update_process_glyph(context, fragments, &n, &x, &y, cacheId, ulCharInc, flAccel);
|
2011-11-09 21:16:09 +04:00
|
|
|
}
|
2011-11-09 08:26:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
index += (index + 2 < length) ? 3 : 2;
|
|
|
|
length -= index;
|
|
|
|
data = &(data[index]);
|
|
|
|
index = 0;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GLYPH_FRAGMENT_ADD:
|
|
|
|
|
2011-11-09 21:16:09 +04:00
|
|
|
printf("GLYPH_FRAGMENT_ADD\n");
|
|
|
|
|
2011-11-09 08:26:44 +04:00
|
|
|
if (index + 3 > length)
|
|
|
|
{
|
2011-11-09 21:16:09 +04:00
|
|
|
/* at least two bytes need to follow */
|
2011-11-09 08:26:44 +04:00
|
|
|
index = length = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
id = data[index + 1];
|
|
|
|
size = data[index + 2];
|
2011-11-09 21:16:09 +04:00
|
|
|
|
|
|
|
fragments = (uint8*) xmalloc(size);
|
|
|
|
memcpy(fragments, data, size);
|
|
|
|
glyph_cache_fragment_put(glyph_cache, id, size, fragments);
|
2011-11-09 08:26:44 +04:00
|
|
|
|
|
|
|
index += 3;
|
|
|
|
length -= index;
|
|
|
|
data = &(data[index]);
|
|
|
|
index = 0;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2011-11-09 21:16:09 +04:00
|
|
|
printf("GLYPH_FRAGMENT_NOP\n");
|
|
|
|
|
2011-11-22 03:11:43 +04:00
|
|
|
update_process_glyph(context, data, &index, &x, &y, cacheId, ulCharInc, flAccel);
|
2011-11-09 21:16:09 +04:00
|
|
|
index++;
|
2011-11-09 08:26:44 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (opWidth > 1)
|
2011-11-22 03:11:43 +04:00
|
|
|
Glyph_EndDraw(context, opX, opY, opWidth, opHeight, bgcolor, fgcolor);
|
2011-11-09 08:26:44 +04:00
|
|
|
else
|
2011-11-22 03:11:43 +04:00
|
|
|
Glyph_EndDraw(context, bkX, bkY, bkWidth, bkHeight, bgcolor, fgcolor);
|
2011-11-09 08:26:44 +04:00
|
|
|
}
|
|
|
|
|
2011-11-22 03:11:43 +04:00
|
|
|
void update_gdi_glyph_index(rdpContext* context, GLYPH_INDEX_ORDER* glyph_index)
|
2011-11-09 08:26:44 +04:00
|
|
|
{
|
2011-11-24 01:11:28 +04:00
|
|
|
rdpGlyphCache* glyph_cache;
|
2011-11-09 08:26:44 +04:00
|
|
|
|
2011-11-24 01:11:28 +04:00
|
|
|
glyph_cache = context->cache->glyph;
|
|
|
|
update_process_glyph_fragments(context, glyph_index->data, glyph_index->cbData,
|
|
|
|
glyph_index->cacheId, glyph_index->ulCharInc, glyph_index->flAccel,
|
|
|
|
glyph_index->backColor, glyph_index->foreColor, glyph_index->x, glyph_index->y,
|
|
|
|
glyph_index->bkLeft, glyph_index->bkTop,
|
|
|
|
glyph_index->bkRight - glyph_index->bkLeft, glyph_index->bkBottom - glyph_index->bkTop,
|
|
|
|
glyph_index->opLeft, glyph_index->opTop,
|
|
|
|
glyph_index->opRight - glyph_index->opLeft, glyph_index->opBottom - glyph_index->opTop);
|
2011-11-09 08:26:44 +04:00
|
|
|
}
|
|
|
|
|
2011-11-22 03:11:43 +04:00
|
|
|
void update_gdi_fast_index(rdpContext* context, FAST_INDEX_ORDER* fast_index)
|
2011-11-09 08:26:44 +04:00
|
|
|
{
|
2011-11-25 03:32:49 +04:00
|
|
|
sint32 opLeft, opTop, opRight, opBottom;
|
|
|
|
sint32 x, y;
|
2011-11-09 08:26:44 +04:00
|
|
|
rdpGlyphCache* glyph_cache;
|
|
|
|
|
2011-11-22 03:11:43 +04:00
|
|
|
glyph_cache = context->cache->glyph;
|
2011-11-09 08:26:44 +04:00
|
|
|
|
2011-11-25 03:32:49 +04:00
|
|
|
opLeft = fast_index->opLeft;
|
|
|
|
opTop = fast_index->opTop;
|
|
|
|
opRight = fast_index->opRight;
|
|
|
|
opBottom = fast_index->opBottom;
|
|
|
|
x = fast_index->x;
|
|
|
|
y = fast_index->y;
|
|
|
|
|
|
|
|
if (opBottom == -32768)
|
|
|
|
{
|
|
|
|
uint8 flags = (uint8) (opTop & 0x0F);
|
|
|
|
|
|
|
|
if (flags & 0x01)
|
|
|
|
opBottom = fast_index->bkBottom;
|
|
|
|
if (flags & 0x02)
|
|
|
|
opRight = fast_index->bkRight;
|
|
|
|
if (flags & 0x04)
|
|
|
|
opTop = fast_index->bkTop;
|
|
|
|
if (flags & 0x08)
|
|
|
|
opLeft = fast_index->bkLeft;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (opLeft == 0)
|
|
|
|
opLeft = fast_index->bkLeft;
|
|
|
|
|
|
|
|
if (opRight == 0)
|
|
|
|
opRight = fast_index->bkRight;
|
|
|
|
|
|
|
|
if (x == -32768)
|
|
|
|
x = fast_index->bkLeft;
|
|
|
|
|
|
|
|
if (y == -32768)
|
|
|
|
y = fast_index->bkTop;
|
2011-11-09 08:26:44 +04:00
|
|
|
|
2011-11-22 03:11:43 +04:00
|
|
|
update_process_glyph_fragments(context, fast_index->data, fast_index->cbData,
|
2011-11-09 21:16:09 +04:00
|
|
|
fast_index->cacheId, fast_index->ulCharInc, fast_index->flAccel,
|
2011-11-25 03:32:49 +04:00
|
|
|
fast_index->backColor, fast_index->foreColor, x, y,
|
2011-11-09 08:26:44 +04:00
|
|
|
fast_index->bkLeft, fast_index->bkTop,
|
|
|
|
fast_index->bkRight - fast_index->bkLeft, fast_index->bkBottom - fast_index->bkTop,
|
2011-11-25 03:32:49 +04:00
|
|
|
opLeft, opTop,
|
|
|
|
opRight - opLeft, opBottom - opTop);
|
|
|
|
}
|
|
|
|
|
|
|
|
void update_gdi_fast_glyph(rdpContext* context, FAST_GLYPH_ORDER* fast_glyph)
|
|
|
|
{
|
|
|
|
sint32 opLeft, opTop, opRight, opBottom;
|
|
|
|
sint32 x, y;
|
|
|
|
GLYPH_DATA_V2* glyph_data;
|
|
|
|
rdpGlyph* glyph;
|
|
|
|
rdpCache* cache = context->cache;
|
|
|
|
uint8 text_data[2];
|
|
|
|
|
|
|
|
opLeft = fast_glyph->opLeft;
|
|
|
|
opTop = fast_glyph->opTop;
|
|
|
|
opRight = fast_glyph->opRight;
|
|
|
|
opBottom = fast_glyph->opBottom;
|
|
|
|
x = fast_glyph->x;
|
|
|
|
y = fast_glyph->y;
|
|
|
|
|
|
|
|
if (opBottom == -32768)
|
|
|
|
{
|
|
|
|
uint8 flags = (uint8) (opTop & 0x0F);
|
|
|
|
|
|
|
|
if (flags & 0x01)
|
|
|
|
opBottom = fast_glyph->bkBottom;
|
|
|
|
if (flags & 0x02)
|
|
|
|
opRight = fast_glyph->bkRight;
|
|
|
|
if (flags & 0x04)
|
|
|
|
opTop = fast_glyph->bkTop;
|
|
|
|
if (flags & 0x08)
|
|
|
|
opLeft = fast_glyph->bkLeft;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (opLeft == 0)
|
|
|
|
opLeft = fast_glyph->bkLeft;
|
|
|
|
|
|
|
|
if (opRight == 0)
|
|
|
|
opRight = fast_glyph->bkRight;
|
|
|
|
|
|
|
|
if (x == -32768)
|
|
|
|
x = fast_glyph->bkLeft;
|
|
|
|
|
|
|
|
if (y == -32768)
|
|
|
|
y = fast_glyph->bkTop;
|
|
|
|
|
|
|
|
if (fast_glyph->glyph_data != NULL)
|
|
|
|
{
|
|
|
|
/* got option font that needs to go into cache */
|
|
|
|
glyph_data = (GLYPH_DATA_V2*) (fast_glyph->glyph_data);
|
|
|
|
glyph = Glyph_Alloc(context);
|
|
|
|
glyph->x = glyph_data->x;
|
|
|
|
glyph->y = glyph_data->y;
|
|
|
|
glyph->cx = glyph_data->cx;
|
|
|
|
glyph->cy = glyph_data->cy;
|
|
|
|
glyph->aj = glyph_data->aj;
|
|
|
|
glyph->cb = glyph_data->cb;
|
|
|
|
Glyph_New(context, glyph);
|
|
|
|
glyph_cache_put(cache->glyph, fast_glyph->cacheId, fast_glyph->data[0], glyph);
|
|
|
|
xfree(fast_glyph->glyph_data);
|
|
|
|
fast_glyph->glyph_data = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
text_data[0] = fast_glyph->data[0];
|
|
|
|
text_data[1] = 0;
|
|
|
|
|
|
|
|
update_process_glyph_fragments(context, text_data, 2,
|
|
|
|
fast_glyph->cacheId, fast_glyph->ulCharInc, fast_glyph->flAccel,
|
|
|
|
fast_glyph->backColor, fast_glyph->foreColor, x, y,
|
|
|
|
fast_glyph->bkLeft, fast_glyph->bkTop,
|
|
|
|
fast_glyph->bkRight - fast_glyph->bkLeft, fast_glyph->bkBottom - fast_glyph->bkTop,
|
|
|
|
opLeft, opTop,
|
|
|
|
opRight - opLeft, opBottom - opTop);
|
2011-11-09 08:26:44 +04:00
|
|
|
}
|
|
|
|
|
2011-11-22 04:41:49 +04:00
|
|
|
void update_gdi_cache_glyph(rdpContext* context, CACHE_GLYPH_ORDER* cache_glyph)
|
2011-11-09 08:26:44 +04:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
rdpGlyph* glyph;
|
|
|
|
GLYPH_DATA* glyph_data;
|
2011-11-22 04:41:49 +04:00
|
|
|
rdpCache* cache = context->cache;
|
2011-11-09 08:26:44 +04:00
|
|
|
|
|
|
|
for (i = 0; i < cache_glyph->cGlyphs; i++)
|
|
|
|
{
|
|
|
|
glyph_data = cache_glyph->glyphData[i];
|
|
|
|
|
2011-11-22 04:41:49 +04:00
|
|
|
glyph = Glyph_Alloc(context);
|
2011-11-09 09:43:56 +04:00
|
|
|
|
2011-11-09 08:26:44 +04:00
|
|
|
glyph->x = glyph_data->x;
|
|
|
|
glyph->y = glyph_data->y;
|
|
|
|
glyph->cx = glyph_data->cx;
|
|
|
|
glyph->cy = glyph_data->cy;
|
|
|
|
glyph->aj = glyph_data->aj;
|
|
|
|
glyph->cb = glyph_data->cb;
|
2011-11-22 04:41:49 +04:00
|
|
|
Glyph_New(context, glyph);
|
2011-11-09 08:26:44 +04:00
|
|
|
|
|
|
|
glyph_cache_put(cache->glyph, cache_glyph->cacheId, glyph_data->cacheIndex, glyph);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-22 04:41:49 +04:00
|
|
|
void update_gdi_cache_glyph_v2(rdpContext* context, CACHE_GLYPH_V2_ORDER* cache_glyph_v2)
|
2011-11-09 08:26:44 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-11-22 07:11:31 +04:00
|
|
|
rdpGlyph* glyph_cache_get(rdpGlyphCache* glyph_cache, uint32 id, uint32 index)
|
2011-11-09 08:26:44 +04:00
|
|
|
{
|
2011-11-09 21:57:31 +04:00
|
|
|
rdpGlyph* glyph;
|
2011-08-21 22:16:53 +04:00
|
|
|
|
|
|
|
if (id > 9)
|
|
|
|
{
|
|
|
|
printf("invalid glyph cache id: %d\n", id);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-11-09 08:26:44 +04:00
|
|
|
if (index > glyph_cache->glyphCache[id].number)
|
2011-08-21 22:16:53 +04:00
|
|
|
{
|
|
|
|
printf("invalid glyph cache index: %d in cache id: %d\n", index, id);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-11-09 21:57:31 +04:00
|
|
|
glyph = glyph_cache->glyphCache[id].entries[index];
|
|
|
|
|
|
|
|
if (glyph == NULL)
|
|
|
|
{
|
|
|
|
printf("invalid glyph at cache index: %d in cache id: %d\n", index, id);
|
|
|
|
}
|
2011-08-21 22:54:08 +04:00
|
|
|
|
2011-11-09 21:57:31 +04:00
|
|
|
return glyph;
|
2011-08-21 22:16:53 +04:00
|
|
|
}
|
|
|
|
|
2011-11-22 07:11:31 +04:00
|
|
|
void glyph_cache_put(rdpGlyphCache* glyph_cache, uint32 id, uint32 index, rdpGlyph* glyph)
|
2011-08-21 22:16:53 +04:00
|
|
|
{
|
2011-11-09 09:43:56 +04:00
|
|
|
rdpGlyph* prevGlyph;
|
|
|
|
|
2011-08-21 22:16:53 +04:00
|
|
|
if (id > 9)
|
|
|
|
{
|
|
|
|
printf("invalid glyph cache id: %d\n", id);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-11-09 08:26:44 +04:00
|
|
|
if (index > glyph_cache->glyphCache[id].number)
|
2011-08-21 22:16:53 +04:00
|
|
|
{
|
|
|
|
printf("invalid glyph cache index: %d in cache id: %d\n", index, id);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-11-09 09:43:56 +04:00
|
|
|
prevGlyph = glyph_cache->glyphCache[id].entries[index];
|
|
|
|
|
|
|
|
if (prevGlyph != NULL)
|
|
|
|
{
|
|
|
|
xfree(prevGlyph->aj);
|
2011-11-24 01:11:28 +04:00
|
|
|
/* hack jsorg71 */
|
|
|
|
//Glyph_Free(glyph_cache->context, prevGlyph);
|
2011-11-09 09:43:56 +04:00
|
|
|
xfree(prevGlyph);
|
|
|
|
}
|
|
|
|
|
|
|
|
glyph_cache->glyphCache[id].entries[index] = glyph;
|
2011-08-21 22:16:53 +04:00
|
|
|
}
|
|
|
|
|
2011-11-22 07:11:31 +04:00
|
|
|
void* glyph_cache_fragment_get(rdpGlyphCache* glyph_cache, uint32 index, uint32* size)
|
2011-09-19 02:29:23 +04:00
|
|
|
{
|
2011-11-09 21:16:09 +04:00
|
|
|
void* fragment;
|
2011-09-19 02:29:23 +04:00
|
|
|
|
2011-11-09 21:16:09 +04:00
|
|
|
fragment = glyph_cache->fragCache.entries[index].fragment;
|
2011-11-12 09:51:41 +04:00
|
|
|
*size = (uint8) glyph_cache->fragCache.entries[index].size;
|
2011-09-19 02:29:23 +04:00
|
|
|
|
2011-11-09 21:57:31 +04:00
|
|
|
if (fragment == NULL)
|
|
|
|
{
|
|
|
|
printf("invalid glyph fragment at index:%d\n", index);
|
|
|
|
}
|
|
|
|
|
2011-11-09 21:16:09 +04:00
|
|
|
return fragment;
|
2011-09-19 02:29:23 +04:00
|
|
|
}
|
|
|
|
|
2011-11-22 07:11:31 +04:00
|
|
|
void glyph_cache_fragment_put(rdpGlyphCache* glyph_cache, uint32 index, uint32 size, void* fragment)
|
2011-11-09 08:26:44 +04:00
|
|
|
{
|
2011-11-09 21:57:31 +04:00
|
|
|
void* prevFragment;
|
|
|
|
|
|
|
|
prevFragment = glyph_cache->fragCache.entries[index].fragment;
|
|
|
|
|
2011-11-09 21:16:09 +04:00
|
|
|
glyph_cache->fragCache.entries[index].fragment = fragment;
|
2011-11-09 08:26:44 +04:00
|
|
|
glyph_cache->fragCache.entries[index].size = size;
|
2011-11-09 21:57:31 +04:00
|
|
|
|
|
|
|
if (prevFragment != NULL)
|
|
|
|
{
|
|
|
|
xfree(prevFragment);
|
|
|
|
}
|
2011-11-09 08:26:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void glyph_cache_register_callbacks(rdpUpdate* update)
|
2011-09-19 02:29:23 +04:00
|
|
|
{
|
2011-11-22 03:11:43 +04:00
|
|
|
update->primary->GlyphIndex = update_gdi_glyph_index;
|
|
|
|
update->primary->FastIndex = update_gdi_fast_index;
|
2011-11-25 03:32:49 +04:00
|
|
|
update->primary->FastGlyph = update_gdi_fast_glyph;
|
2011-11-22 04:41:49 +04:00
|
|
|
update->secondary->CacheGlyph = update_gdi_cache_glyph;
|
|
|
|
update->secondary->CacheGlyphV2 = update_gdi_cache_glyph_v2;
|
2011-09-19 02:29:23 +04:00
|
|
|
}
|
|
|
|
|
2011-10-12 02:51:45 +04:00
|
|
|
rdpGlyphCache* glyph_cache_new(rdpSettings* settings)
|
2011-08-21 22:16:53 +04:00
|
|
|
{
|
2011-10-12 02:51:45 +04:00
|
|
|
rdpGlyphCache* glyph;
|
2011-08-21 22:16:53 +04:00
|
|
|
|
2011-10-12 02:51:45 +04:00
|
|
|
glyph = (rdpGlyphCache*) xzalloc(sizeof(rdpGlyphCache));
|
2011-08-21 22:16:53 +04:00
|
|
|
|
|
|
|
if (glyph != NULL)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
glyph->settings = settings;
|
2011-11-09 09:43:56 +04:00
|
|
|
glyph->context = ((freerdp*) settings->instance)->update->context;
|
2011-08-21 22:16:53 +04:00
|
|
|
|
2011-11-09 21:57:31 +04:00
|
|
|
if (settings->glyph_cache)
|
|
|
|
settings->glyphSupportLevel = GLYPH_SUPPORT_FULL;
|
2011-08-21 22:16:53 +04:00
|
|
|
|
|
|
|
for (i = 0; i < 10; i++)
|
|
|
|
{
|
|
|
|
glyph->glyphCache[i].number = settings->glyphCache[i].cacheEntries;
|
|
|
|
glyph->glyphCache[i].maxCellSize = settings->glyphCache[i].cacheMaximumCellSize;
|
2011-11-09 21:57:31 +04:00
|
|
|
glyph->glyphCache[i].entries = (rdpGlyph**) xzalloc(sizeof(rdpGlyph*) * glyph->glyphCache[i].number);
|
2011-08-21 22:16:53 +04:00
|
|
|
}
|
|
|
|
|
2011-09-19 02:29:23 +04:00
|
|
|
glyph->fragCache.entries = xzalloc(sizeof(FRAGMENT_CACHE_ENTRY) * 256);
|
2011-08-21 22:16:53 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return glyph;
|
|
|
|
}
|
|
|
|
|
2011-10-12 02:51:45 +04:00
|
|
|
void glyph_cache_free(rdpGlyphCache* glyph)
|
2011-08-21 22:16:53 +04:00
|
|
|
{
|
|
|
|
if (glyph != NULL)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 10; i++)
|
|
|
|
{
|
|
|
|
xfree(glyph->glyphCache[i].entries);
|
|
|
|
}
|
|
|
|
|
|
|
|
xfree(glyph->fragCache.entries);
|
|
|
|
|
|
|
|
xfree(glyph);
|
|
|
|
}
|
|
|
|
}
|