2011-08-06 00:56:40 +04:00
|
|
|
/**
|
2012-10-09 07:02:04 +04:00
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
2011-08-06 00:56:40 +04:00
|
|
|
* Bitmap Cache V2
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2012-08-15 01:09:01 +04:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2012-09-24 02:41:07 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2012-11-20 08:49:08 +04:00
|
|
|
#include <winpr/crt.h>
|
|
|
|
|
2011-10-21 01:28:59 +04:00
|
|
|
#include <freerdp/freerdp.h>
|
2012-07-24 23:05:22 +04:00
|
|
|
#include <freerdp/constants.h>
|
2013-03-22 00:45:25 +04:00
|
|
|
#include <winpr/stream.h>
|
2011-08-06 00:56:40 +04:00
|
|
|
|
2014-09-15 11:01:05 +04:00
|
|
|
#include <freerdp/log.h>
|
2011-10-12 02:51:45 +04:00
|
|
|
#include <freerdp/cache/bitmap.h>
|
2011-08-06 00:56:40 +04:00
|
|
|
|
2014-09-15 11:01:05 +04:00
|
|
|
#define TAG FREERDP_TAG("cache.bitmap")
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
BOOL update_gdi_memblt(rdpContext* context, MEMBLT_ORDER* memblt)
|
2011-10-13 23:51:07 +04:00
|
|
|
{
|
|
|
|
rdpBitmap* bitmap;
|
2011-11-22 03:11:43 +04:00
|
|
|
rdpCache* cache = context->cache;
|
2011-10-13 23:51:07 +04:00
|
|
|
|
2011-10-14 03:32:18 +04:00
|
|
|
if (memblt->cacheId == 0xFF)
|
2011-10-13 23:51:07 +04:00
|
|
|
bitmap = offscreen_cache_get(cache->offscreen, memblt->cacheIndex);
|
|
|
|
else
|
2012-10-09 11:01:37 +04:00
|
|
|
bitmap = bitmap_cache_get(cache->bitmap, (BYTE) memblt->cacheId, memblt->cacheIndex);
|
2014-09-12 16:36:29 +04:00
|
|
|
/* XP-SP2 servers sometimes ask for cached bitmaps they've never defined. */
|
2015-04-14 11:14:23 +03:00
|
|
|
if (bitmap == NULL)
|
|
|
|
return TRUE;
|
2011-10-13 23:51:07 +04:00
|
|
|
|
|
|
|
memblt->bitmap = bitmap;
|
2015-04-17 17:21:55 +03:00
|
|
|
return IFCALLRESULT(TRUE, cache->bitmap->MemBlt, context, memblt);
|
2011-10-13 23:51:07 +04:00
|
|
|
}
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
BOOL update_gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt)
|
2011-10-13 23:51:07 +04:00
|
|
|
{
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE style;
|
2011-10-13 23:51:07 +04:00
|
|
|
rdpBitmap* bitmap;
|
2011-11-22 03:11:43 +04:00
|
|
|
rdpCache* cache = context->cache;
|
2012-02-13 03:12:28 +04:00
|
|
|
rdpBrush* brush = &mem3blt->brush;
|
2015-04-14 11:14:23 +03:00
|
|
|
BOOL ret = TRUE;
|
2011-10-13 23:51:07 +04:00
|
|
|
|
2011-10-14 03:32:18 +04:00
|
|
|
if (mem3blt->cacheId == 0xFF)
|
2011-10-13 23:51:07 +04:00
|
|
|
bitmap = offscreen_cache_get(cache->offscreen, mem3blt->cacheIndex);
|
|
|
|
else
|
2012-10-09 11:01:37 +04:00
|
|
|
bitmap = bitmap_cache_get(cache->bitmap, (BYTE) mem3blt->cacheId, mem3blt->cacheIndex);
|
2013-11-03 22:51:41 +04:00
|
|
|
|
2014-09-12 16:36:29 +04:00
|
|
|
/* XP-SP2 servers sometimes ask for cached bitmaps they've never defined. */
|
2013-11-03 22:51:41 +04:00
|
|
|
if (!bitmap)
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2011-10-13 23:51:07 +04:00
|
|
|
|
2012-02-13 03:12:28 +04:00
|
|
|
style = brush->style;
|
|
|
|
|
|
|
|
if (brush->style & CACHED_BRUSH)
|
|
|
|
{
|
|
|
|
brush->data = brush_cache_get(cache->brush, brush->index, &brush->bpp);
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!brush->data)
|
|
|
|
return FALSE;
|
2012-02-13 03:12:28 +04:00
|
|
|
brush->style = 0x03;
|
|
|
|
}
|
|
|
|
|
2011-10-13 23:51:07 +04:00
|
|
|
mem3blt->bitmap = bitmap;
|
2015-04-14 11:14:23 +03:00
|
|
|
IFCALLRET(cache->bitmap->Mem3Blt, ret, context, mem3blt);
|
2012-02-13 03:12:28 +04:00
|
|
|
brush->style = style;
|
2015-04-14 11:14:23 +03:00
|
|
|
return ret;
|
2011-10-13 23:51:07 +04:00
|
|
|
}
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
BOOL update_gdi_cache_bitmap(rdpContext* context, CACHE_BITMAP_ORDER* cacheBitmap)
|
2011-11-11 10:48:31 +04:00
|
|
|
{
|
2012-01-05 05:17:11 +04:00
|
|
|
rdpBitmap* bitmap;
|
|
|
|
rdpBitmap* prevBitmap;
|
|
|
|
rdpCache* cache = context->cache;
|
|
|
|
|
|
|
|
bitmap = Bitmap_Alloc(context);
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!bitmap)
|
|
|
|
return FALSE;
|
|
|
|
|
2012-01-05 05:17:11 +04:00
|
|
|
|
2013-11-03 22:51:41 +04:00
|
|
|
Bitmap_SetDimensions(context, bitmap, cacheBitmap->bitmapWidth, cacheBitmap->bitmapHeight);
|
2012-01-05 05:17:11 +04:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!bitmap->Decompress(context, bitmap,
|
2013-11-03 22:51:41 +04:00
|
|
|
cacheBitmap->bitmapDataStream, cacheBitmap->bitmapWidth, cacheBitmap->bitmapHeight,
|
|
|
|
cacheBitmap->bitmapBpp, cacheBitmap->bitmapLength,
|
2015-04-14 11:14:23 +03:00
|
|
|
cacheBitmap->compressed, RDP_CODEC_ID_NONE))
|
|
|
|
{
|
|
|
|
Bitmap_Free(context, bitmap);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2012-01-05 05:17:11 +04:00
|
|
|
|
|
|
|
bitmap->New(context, bitmap);
|
|
|
|
|
2013-11-03 22:51:41 +04:00
|
|
|
prevBitmap = bitmap_cache_get(cache->bitmap, cacheBitmap->cacheId, cacheBitmap->cacheIndex);
|
2012-01-05 05:17:11 +04:00
|
|
|
|
2014-09-12 16:36:29 +04:00
|
|
|
if (prevBitmap != NULL)
|
2012-01-05 05:17:11 +04:00
|
|
|
Bitmap_Free(context, prevBitmap);
|
|
|
|
|
2013-11-03 22:51:41 +04:00
|
|
|
bitmap_cache_put(cache->bitmap, cacheBitmap->cacheId, cacheBitmap->cacheIndex, bitmap);
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2011-11-11 10:48:31 +04:00
|
|
|
}
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
BOOL update_gdi_cache_bitmap_v2(rdpContext* context, CACHE_BITMAP_V2_ORDER* cacheBitmapV2)
|
|
|
|
|
2011-10-13 23:51:07 +04:00
|
|
|
{
|
|
|
|
rdpBitmap* bitmap;
|
|
|
|
rdpBitmap* prevBitmap;
|
2011-11-22 04:41:49 +04:00
|
|
|
rdpCache* cache = context->cache;
|
2014-09-12 09:11:40 +04:00
|
|
|
rdpSettings* settings = context->settings;
|
2011-10-13 23:51:07 +04:00
|
|
|
|
2011-11-22 04:41:49 +04:00
|
|
|
bitmap = Bitmap_Alloc(context);
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!bitmap)
|
|
|
|
return FALSE;
|
2011-10-13 23:51:07 +04:00
|
|
|
|
2013-11-03 22:51:41 +04:00
|
|
|
Bitmap_SetDimensions(context, bitmap, cacheBitmapV2->bitmapWidth, cacheBitmapV2->bitmapHeight);
|
2011-10-21 05:34:55 +04:00
|
|
|
|
2014-09-12 04:12:32 +04:00
|
|
|
if (!cacheBitmapV2->bitmapBpp)
|
2014-09-12 09:11:40 +04:00
|
|
|
cacheBitmapV2->bitmapBpp = settings->ColorDepth;
|
|
|
|
|
|
|
|
if ((settings->ColorDepth == 15) && (cacheBitmapV2->bitmapBpp == 16))
|
|
|
|
cacheBitmapV2->bitmapBpp = settings->ColorDepth;
|
2012-01-03 11:09:14 +04:00
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!bitmap->Decompress(context, bitmap,
|
2013-11-03 22:51:41 +04:00
|
|
|
cacheBitmapV2->bitmapDataStream, cacheBitmapV2->bitmapWidth, cacheBitmapV2->bitmapHeight,
|
|
|
|
cacheBitmapV2->bitmapBpp, cacheBitmapV2->bitmapLength,
|
2015-04-14 11:14:23 +03:00
|
|
|
cacheBitmapV2->compressed, RDP_CODEC_ID_NONE))
|
|
|
|
{
|
|
|
|
Bitmap_Free(context, bitmap);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-10-21 01:28:59 +04:00
|
|
|
|
2011-11-22 04:41:49 +04:00
|
|
|
bitmap->New(context, bitmap);
|
2011-10-13 23:51:07 +04:00
|
|
|
|
2013-11-03 22:51:41 +04:00
|
|
|
prevBitmap = bitmap_cache_get(cache->bitmap, cacheBitmapV2->cacheId, cacheBitmapV2->cacheIndex);
|
2011-10-13 23:51:07 +04:00
|
|
|
|
2014-07-08 23:07:19 +04:00
|
|
|
if (prevBitmap)
|
2011-11-22 04:41:49 +04:00
|
|
|
Bitmap_Free(context, prevBitmap);
|
2011-10-13 23:51:07 +04:00
|
|
|
|
2013-11-03 22:51:41 +04:00
|
|
|
bitmap_cache_put(cache->bitmap, cacheBitmapV2->cacheId, cacheBitmapV2->cacheIndex, bitmap);
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2011-10-13 23:51:07 +04:00
|
|
|
}
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
BOOL update_gdi_cache_bitmap_v3(rdpContext* context, CACHE_BITMAP_V3_ORDER* cacheBitmapV3)
|
2012-07-24 23:05:22 +04:00
|
|
|
{
|
|
|
|
rdpBitmap* bitmap;
|
|
|
|
rdpBitmap* prevBitmap;
|
2014-09-12 09:11:40 +04:00
|
|
|
BOOL compressed = TRUE;
|
2012-07-24 23:05:22 +04:00
|
|
|
rdpCache* cache = context->cache;
|
2014-09-12 09:11:40 +04:00
|
|
|
rdpSettings* settings = context->settings;
|
2013-11-03 22:51:41 +04:00
|
|
|
BITMAP_DATA_EX* bitmapData = &cacheBitmapV3->bitmapData;
|
2012-07-24 23:05:22 +04:00
|
|
|
|
|
|
|
bitmap = Bitmap_Alloc(context);
|
2015-04-14 11:14:23 +03:00
|
|
|
if (!bitmap)
|
|
|
|
return FALSE;
|
2012-07-24 23:05:22 +04:00
|
|
|
|
|
|
|
Bitmap_SetDimensions(context, bitmap, bitmapData->width, bitmapData->height);
|
|
|
|
|
2014-09-12 04:12:32 +04:00
|
|
|
if (!cacheBitmapV3->bpp)
|
2014-09-12 09:11:40 +04:00
|
|
|
cacheBitmapV3->bpp = settings->ColorDepth;
|
2012-07-24 23:05:22 +04:00
|
|
|
|
2014-09-12 09:11:40 +04:00
|
|
|
compressed = (bitmapData->codecID != RDP_CODEC_ID_NONE);
|
2014-06-20 20:33:30 +04:00
|
|
|
|
2012-07-24 23:05:22 +04:00
|
|
|
bitmap->Decompress(context, bitmap,
|
|
|
|
bitmapData->data, bitmap->width, bitmap->height,
|
2014-09-12 09:11:40 +04:00
|
|
|
bitmapData->bpp, bitmapData->length, compressed,
|
2012-07-25 03:54:29 +04:00
|
|
|
bitmapData->codecID);
|
2012-07-24 23:05:22 +04:00
|
|
|
|
|
|
|
bitmap->New(context, bitmap);
|
|
|
|
|
2013-11-03 22:51:41 +04:00
|
|
|
prevBitmap = bitmap_cache_get(cache->bitmap, cacheBitmapV3->cacheId, cacheBitmapV3->cacheIndex);
|
2012-07-24 23:05:22 +04:00
|
|
|
|
2014-07-08 23:07:19 +04:00
|
|
|
if (prevBitmap)
|
2012-07-24 23:05:22 +04:00
|
|
|
Bitmap_Free(context, prevBitmap);
|
|
|
|
|
2013-11-03 22:51:41 +04:00
|
|
|
bitmap_cache_put(cache->bitmap, cacheBitmapV3->cacheId, cacheBitmapV3->cacheIndex, bitmap);
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2012-07-24 23:05:22 +04:00
|
|
|
}
|
|
|
|
|
2015-04-14 11:14:23 +03:00
|
|
|
BOOL update_gdi_bitmap_update(rdpContext* context, BITMAP_UPDATE* bitmapUpdate)
|
2011-10-21 01:28:59 +04:00
|
|
|
{
|
|
|
|
int i;
|
2012-10-09 10:38:39 +04:00
|
|
|
BOOL reused = TRUE;
|
2014-09-12 04:12:32 +04:00
|
|
|
rdpBitmap* bitmap;
|
|
|
|
BITMAP_DATA* bitmapData;
|
2011-11-22 04:41:49 +04:00
|
|
|
rdpCache* cache = context->cache;
|
2011-10-21 01:28:59 +04:00
|
|
|
|
2013-11-03 22:51:41 +04:00
|
|
|
if (!cache->bitmap->bitmap)
|
2011-10-21 05:34:55 +04:00
|
|
|
{
|
2011-11-22 04:41:49 +04:00
|
|
|
cache->bitmap->bitmap = Bitmap_Alloc(context);
|
2012-10-09 10:31:28 +04:00
|
|
|
cache->bitmap->bitmap->ephemeral = TRUE;
|
|
|
|
reused = FALSE;
|
2011-10-21 05:34:55 +04:00
|
|
|
}
|
2011-10-21 01:28:59 +04:00
|
|
|
|
|
|
|
bitmap = cache->bitmap->bitmap;
|
|
|
|
|
2013-11-03 22:51:41 +04:00
|
|
|
for (i = 0; i < (int) bitmapUpdate->number; i++)
|
2011-10-21 01:28:59 +04:00
|
|
|
{
|
2014-09-12 04:12:32 +04:00
|
|
|
bitmapData = &bitmapUpdate->rectangles[i];
|
2011-10-21 05:34:55 +04:00
|
|
|
|
2014-09-12 04:12:32 +04:00
|
|
|
bitmap->bpp = bitmapData->bitsPerPixel;
|
|
|
|
bitmap->length = bitmapData->bitmapLength;
|
|
|
|
bitmap->compressed = bitmapData->compressed;
|
2011-10-21 05:34:55 +04:00
|
|
|
|
2011-11-22 04:41:49 +04:00
|
|
|
Bitmap_SetRectangle(context, bitmap,
|
2014-09-12 04:12:32 +04:00
|
|
|
bitmapData->destLeft, bitmapData->destTop,
|
|
|
|
bitmapData->destRight, bitmapData->destBottom);
|
2011-10-21 05:34:55 +04:00
|
|
|
|
2014-09-12 04:12:32 +04:00
|
|
|
Bitmap_SetDimensions(context, bitmap, bitmapData->width, bitmapData->height);
|
2011-10-21 01:28:59 +04:00
|
|
|
|
2011-11-22 04:41:49 +04:00
|
|
|
bitmap->Decompress(context, bitmap,
|
2014-09-12 04:12:32 +04:00
|
|
|
bitmapData->bitmapDataStream, bitmapData->width, bitmapData->height,
|
|
|
|
bitmapData->bitsPerPixel, bitmapData->bitmapLength,
|
|
|
|
bitmapData->compressed, RDP_CODEC_ID_NONE);
|
2011-10-21 01:28:59 +04:00
|
|
|
|
2011-10-26 20:34:18 +04:00
|
|
|
if (reused)
|
2011-11-22 04:41:49 +04:00
|
|
|
bitmap->Free(context, bitmap);
|
2011-10-26 20:34:18 +04:00
|
|
|
else
|
2012-10-09 10:31:28 +04:00
|
|
|
reused = TRUE;
|
2011-10-26 20:34:18 +04:00
|
|
|
|
2011-11-22 04:41:49 +04:00
|
|
|
bitmap->New(context, bitmap);
|
2011-10-21 01:28:59 +04:00
|
|
|
|
2011-11-22 04:41:49 +04:00
|
|
|
bitmap->Paint(context, bitmap);
|
2011-10-21 01:28:59 +04:00
|
|
|
}
|
2015-04-14 11:14:23 +03:00
|
|
|
return TRUE;
|
2011-10-21 01:28:59 +04:00
|
|
|
}
|
|
|
|
|
2013-11-03 22:51:41 +04:00
|
|
|
rdpBitmap* bitmap_cache_get(rdpBitmapCache* bitmapCache, UINT32 id, UINT32 index)
|
2011-10-13 23:51:07 +04:00
|
|
|
{
|
|
|
|
rdpBitmap* bitmap;
|
2011-08-06 00:56:40 +04:00
|
|
|
|
2013-11-03 22:51:41 +04:00
|
|
|
if (id > bitmapCache->maxCells)
|
2011-08-06 00:56:40 +04:00
|
|
|
{
|
2014-09-12 16:36:29 +04:00
|
|
|
WLog_ERR(TAG, "get invalid bitmap cell id: %d", id);
|
2011-08-06 00:56:40 +04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-01-04 03:22:42 +04:00
|
|
|
if (index == BITMAP_CACHE_WAITING_LIST_INDEX)
|
2012-03-27 23:44:03 +04:00
|
|
|
{
|
2013-11-03 22:51:41 +04:00
|
|
|
index = bitmapCache->cells[id].number;
|
2012-03-27 23:44:03 +04:00
|
|
|
}
|
2013-11-03 22:51:41 +04:00
|
|
|
else if (index > bitmapCache->cells[id].number)
|
2011-08-06 00:56:40 +04:00
|
|
|
{
|
2014-09-12 16:36:29 +04:00
|
|
|
WLog_ERR(TAG, "get invalid bitmap index %d in cell id: %d", index, id);
|
2011-08-06 00:56:40 +04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-11-03 22:51:41 +04:00
|
|
|
bitmap = bitmapCache->cells[id].entries[index];
|
2011-08-06 00:56:40 +04:00
|
|
|
|
2011-10-13 23:51:07 +04:00
|
|
|
return bitmap;
|
2011-08-06 00:56:40 +04:00
|
|
|
}
|
|
|
|
|
2013-11-03 22:51:41 +04:00
|
|
|
void bitmap_cache_put(rdpBitmapCache* bitmapCache, UINT32 id, UINT32 index, rdpBitmap* bitmap)
|
2011-08-06 00:56:40 +04:00
|
|
|
{
|
2013-11-03 22:51:41 +04:00
|
|
|
if (id > bitmapCache->maxCells)
|
2011-08-06 00:56:40 +04:00
|
|
|
{
|
2014-09-12 16:36:29 +04:00
|
|
|
WLog_ERR(TAG, "put invalid bitmap cell id: %d", id);
|
2011-08-06 00:56:40 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-01-04 03:22:42 +04:00
|
|
|
if (index == BITMAP_CACHE_WAITING_LIST_INDEX)
|
2012-03-27 23:44:03 +04:00
|
|
|
{
|
2013-11-03 22:51:41 +04:00
|
|
|
index = bitmapCache->cells[id].number;
|
2012-03-27 23:44:03 +04:00
|
|
|
}
|
2013-11-03 22:51:41 +04:00
|
|
|
else if (index > bitmapCache->cells[id].number)
|
2011-08-06 00:56:40 +04:00
|
|
|
{
|
2014-09-12 16:36:29 +04:00
|
|
|
WLog_ERR(TAG, "put invalid bitmap index %d in cell id: %d", index, id);
|
2011-08-06 00:56:40 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-11-03 22:51:41 +04:00
|
|
|
bitmapCache->cells[id].entries[index] = bitmap;
|
2011-10-13 23:51:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void bitmap_cache_register_callbacks(rdpUpdate* update)
|
|
|
|
{
|
2011-10-16 08:50:10 +04:00
|
|
|
rdpCache* cache = update->context->cache;
|
2011-10-13 23:51:07 +04:00
|
|
|
|
2011-11-22 03:11:43 +04:00
|
|
|
cache->bitmap->MemBlt = update->primary->MemBlt;
|
|
|
|
cache->bitmap->Mem3Blt = update->primary->Mem3Blt;
|
2011-10-13 23:51:07 +04:00
|
|
|
|
2011-11-22 03:11:43 +04:00
|
|
|
update->primary->MemBlt = update_gdi_memblt;
|
|
|
|
update->primary->Mem3Blt = update_gdi_mem3blt;
|
2011-11-22 04:41:49 +04:00
|
|
|
|
|
|
|
update->secondary->CacheBitmap = update_gdi_cache_bitmap;
|
|
|
|
update->secondary->CacheBitmapV2 = update_gdi_cache_bitmap_v2;
|
2012-07-24 23:05:22 +04:00
|
|
|
update->secondary->CacheBitmapV3 = update_gdi_cache_bitmap_v3;
|
2011-11-22 04:41:49 +04:00
|
|
|
|
2011-10-21 01:28:59 +04:00
|
|
|
update->BitmapUpdate = update_gdi_bitmap_update;
|
2011-08-06 00:56:40 +04:00
|
|
|
}
|
|
|
|
|
2011-10-12 02:51:45 +04:00
|
|
|
rdpBitmapCache* bitmap_cache_new(rdpSettings* settings)
|
2011-08-06 00:56:40 +04:00
|
|
|
{
|
|
|
|
int i;
|
2013-11-03 22:51:41 +04:00
|
|
|
rdpBitmapCache* bitmapCache;
|
2011-08-06 00:56:40 +04:00
|
|
|
|
2014-07-08 23:07:19 +04:00
|
|
|
bitmapCache = (rdpBitmapCache*) calloc(1, sizeof(rdpBitmapCache));
|
2011-08-06 00:56:40 +04:00
|
|
|
|
2013-11-03 22:51:41 +04:00
|
|
|
if (bitmapCache)
|
2011-08-06 00:56:40 +04:00
|
|
|
{
|
2013-11-03 22:51:41 +04:00
|
|
|
bitmapCache->settings = settings;
|
|
|
|
bitmapCache->update = ((freerdp*) settings->instance)->update;
|
|
|
|
bitmapCache->context = bitmapCache->update->context;
|
2011-08-06 00:56:40 +04:00
|
|
|
|
2013-11-03 22:51:41 +04:00
|
|
|
bitmapCache->maxCells = settings->BitmapCacheV2NumCells;
|
2011-08-06 00:56:40 +04:00
|
|
|
|
2014-07-08 23:07:19 +04:00
|
|
|
bitmapCache->cells = (BITMAP_V2_CELL*) calloc(bitmapCache->maxCells, sizeof(BITMAP_V2_CELL));
|
|
|
|
|
|
|
|
if (!bitmapCache->cells)
|
2014-11-16 17:54:37 +03:00
|
|
|
{
|
|
|
|
free(bitmapCache);
|
2014-07-08 23:07:19 +04:00
|
|
|
return NULL;
|
2014-11-16 17:54:37 +03:00
|
|
|
}
|
2011-08-06 00:56:40 +04:00
|
|
|
|
2013-11-03 22:51:41 +04:00
|
|
|
for (i = 0; i < (int) bitmapCache->maxCells; i++)
|
2011-08-06 00:56:40 +04:00
|
|
|
{
|
2013-11-03 22:51:41 +04:00
|
|
|
bitmapCache->cells[i].number = settings->BitmapCacheV2CellInfo[i].numEntries;
|
2012-03-27 23:44:03 +04:00
|
|
|
/* allocate an extra entry for BITMAP_CACHE_WAITING_LIST_INDEX */
|
2014-07-08 23:07:19 +04:00
|
|
|
bitmapCache->cells[i].entries = (rdpBitmap**) calloc((bitmapCache->cells[i].number + 1), sizeof(rdpBitmap*));
|
2011-08-06 00:56:40 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-03 22:51:41 +04:00
|
|
|
return bitmapCache;
|
2011-08-06 00:56:40 +04:00
|
|
|
}
|
|
|
|
|
2013-11-03 22:51:41 +04:00
|
|
|
void bitmap_cache_free(rdpBitmapCache* bitmapCache)
|
2011-08-06 00:56:40 +04:00
|
|
|
{
|
|
|
|
int i, j;
|
2011-10-13 23:51:07 +04:00
|
|
|
rdpBitmap* bitmap;
|
2011-08-06 00:56:40 +04:00
|
|
|
|
2014-07-08 23:07:19 +04:00
|
|
|
if (bitmapCache)
|
2011-08-06 00:56:40 +04:00
|
|
|
{
|
2013-11-03 22:51:41 +04:00
|
|
|
for (i = 0; i < (int) bitmapCache->maxCells; i++)
|
2011-08-06 00:56:40 +04:00
|
|
|
{
|
2013-11-03 22:51:41 +04:00
|
|
|
for (j = 0; j < (int) bitmapCache->cells[i].number + 1; j++)
|
2011-08-06 00:56:40 +04:00
|
|
|
{
|
2013-11-03 22:51:41 +04:00
|
|
|
bitmap = bitmapCache->cells[i].entries[j];
|
2011-10-13 23:51:07 +04:00
|
|
|
|
2014-09-12 04:12:32 +04:00
|
|
|
if (bitmap)
|
2013-11-03 22:51:41 +04:00
|
|
|
Bitmap_Free(bitmapCache->context, bitmap);
|
2011-08-06 00:56:40 +04:00
|
|
|
}
|
|
|
|
|
2013-11-03 22:51:41 +04:00
|
|
|
free(bitmapCache->cells[i].entries);
|
2011-08-06 00:56:40 +04:00
|
|
|
}
|
|
|
|
|
2013-11-03 22:51:41 +04:00
|
|
|
if (bitmapCache->bitmap)
|
|
|
|
Bitmap_Free(bitmapCache->context, bitmapCache->bitmap);
|
2011-10-21 01:28:59 +04:00
|
|
|
|
2013-11-03 22:51:41 +04:00
|
|
|
free(bitmapCache->cells);
|
|
|
|
free(bitmapCache);
|
2011-08-06 00:56:40 +04:00
|
|
|
}
|
|
|
|
}
|