#include <freerdp/gdi/bitmap.h>
#include "../gdi/gdi.h"
+#include "../core/graphics.h"
#define TAG FREERDP_TAG("cache.bitmap")
static rdpBitmap* bitmap_cache_get(rdpBitmapCache* bitmapCache, UINT32 id,
UINT32 index);
-static void bitmap_cache_put(rdpBitmapCache* bitmap_cache, UINT32 id,
+static BOOL bitmap_cache_put(rdpBitmapCache* bitmap_cache, UINT32 id,
UINT32 index, rdpBitmap* bitmap);
+static void bitmap_free(rdpContext* context, rdpBitmap* bitmap)
+{
+}
+
static BOOL update_gdi_memblt(rdpContext* context,
MEMBLT_ORDER* memblt)
{
cacheBitmap->bitmapBpp, cacheBitmap->bitmapLength,
cacheBitmap->compressed, RDP_CODEC_ID_NONE))
{
- bitmap->Free(context, bitmap);
+ Bitmap_Free(context, bitmap);
return FALSE;
}
if (!bitmap->New(context, bitmap))
{
- bitmap->Free(context, bitmap);
+ Bitmap_Free(context, bitmap);
return FALSE;
}
prevBitmap = bitmap_cache_get(cache->bitmap, cacheBitmap->cacheId,
cacheBitmap->cacheIndex);
-
- if (prevBitmap != NULL)
- prevBitmap->Free(context, prevBitmap);
-
- bitmap_cache_put(cache->bitmap, cacheBitmap->cacheId, cacheBitmap->cacheIndex,
- bitmap);
- return TRUE;
+ Bitmap_Free(context, prevBitmap);
+ return bitmap_cache_put(cache->bitmap, cacheBitmap->cacheId,
+ cacheBitmap->cacheIndex,
+ bitmap);
}
static BOOL update_gdi_cache_bitmap_v2(rdpContext* context,
cacheBitmapV2->compressed,
RDP_CODEC_ID_NONE))
{
- bitmap->Free(context, bitmap);
+ Bitmap_Free(context, bitmap);
return FALSE;
}
if (!bitmap->New(context, bitmap))
{
- bitmap->Free(context, bitmap);
+ Bitmap_Free(context, bitmap);
return FALSE;
}
- if (prevBitmap)
- prevBitmap->Free(context, prevBitmap);
-
- bitmap_cache_put(cache->bitmap, cacheBitmapV2->cacheId,
- cacheBitmapV2->cacheIndex, bitmap);
- return TRUE;
+ Bitmap_Free(context, prevBitmap);
+ return bitmap_cache_put(cache->bitmap, cacheBitmapV2->cacheId,
+ cacheBitmapV2->cacheIndex, bitmap);
}
static BOOL update_gdi_cache_bitmap_v3(rdpContext* context,
bitmapData->bpp, bitmapData->length, compressed,
bitmapData->codecID))
{
- bitmap->Free(context, bitmap);
+ Bitmap_Free(context, bitmap);
return FALSE;
}
if (!bitmap->New(context, bitmap))
{
- bitmap->Free(context, bitmap);
+ Bitmap_Free(context, bitmap);
return FALSE;
}
prevBitmap = bitmap_cache_get(cache->bitmap, cacheBitmapV3->cacheId,
cacheBitmapV3->cacheIndex);
-
- if (prevBitmap)
- prevBitmap->Free(context, prevBitmap);
-
- bitmap_cache_put(cache->bitmap, cacheBitmapV3->cacheId,
- cacheBitmapV3->cacheIndex, bitmap);
- return TRUE;
+ Bitmap_Free(context, prevBitmap);
+ return bitmap_cache_put(cache->bitmap, cacheBitmapV3->cacheId,
+ cacheBitmapV3->cacheIndex, bitmap);
}
rdpBitmap* bitmap_cache_get(rdpBitmapCache* bitmapCache, UINT32 id,
return bitmap;
}
-void bitmap_cache_put(rdpBitmapCache* bitmapCache, UINT32 id, UINT32 index,
+BOOL bitmap_cache_put(rdpBitmapCache* bitmapCache, UINT32 id, UINT32 index,
rdpBitmap* bitmap)
{
if (id > bitmapCache->maxCells)
{
WLog_ERR(TAG, "put invalid bitmap cell id: %d", id);
- return;
+ return FALSE;
}
if (index == BITMAP_CACHE_WAITING_LIST_INDEX)
else if (index > bitmapCache->cells[id].number)
{
WLog_ERR(TAG, "put invalid bitmap index %d in cell id: %d", index, id);
- return;
+ return FALSE;
}
bitmapCache->cells[id].entries[index] = bitmap;
+ return TRUE;
}
void bitmap_cache_register_callbacks(rdpUpdate* update)
{
for (i = 0; i < (int) bitmapCache->maxCells; i++)
free(bitmapCache->cells[i].entries);
- }
+ }
free(bitmapCache);
return NULL;
for (j = 0; j < (int) bitmapCache->cells[i].number + 1; j++)
{
bitmap = bitmapCache->cells[i].entries[j];
-
- if (bitmap)
- bitmap->Free(bitmapCache->context, bitmap);
+ Bitmap_Free(bitmapCache->context, bitmap);
}
free(bitmapCache->cells[i].entries);
--- /dev/null
+/**
+ * FreeRDP: A Remote Desktop Protocol Implementation
+ * Client Channels
+ *
+ * Copyright 2016 Armin Novak <armin.novak@thincast.com>
+ * Copyright 2016 Thinast Technologies GmbH
+ *
+ * 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.
+ */
+
+#ifndef FREERDP_CORE_GRAPHICS_H
+#define FREERDP_CORE_GRAPHICS_H
+
+#include <freerdp/api.h>
+#include <freerdp/freerdp.h>
+#include <freerdp/graphics.h>
+
+FREERDP_LOCAL void Bitmap_Free(rdpContext* context, rdpBitmap* bitmap);
+
+#endif /* FREERDP_CORE_GRAPHICS_H */