summaryrefslogtreecommitdiffstats
path: root/server/red_client_shared_cache.h
diff options
context:
space:
mode:
authorYonit Halperin <yhalperi@redhat.com>2010-06-01 10:30:51 +0300
committerAlexander Larsson <alexl@redhat.com>2010-06-09 11:41:01 +0200
commit5d2ae66f5022187e0028a1d7ccf67fe48fdaa94b (patch)
tree0458ad257a08447d5edc21c6391225ac8b738717 /server/red_client_shared_cache.h
parent263646a1f7e705766f7d46017679812d4b1406b8 (diff)
downloadspice-5d2ae66f5022187e0028a1d7ccf67fe48fdaa94b.tar.gz
spice-5d2ae66f5022187e0028a1d7ccf67fe48fdaa94b.tar.xz
spice-5d2ae66f5022187e0028a1d7ccf67fe48fdaa94b.zip
support for lossy images in the pixmap cache and fill bits
1) add an option to determine if a bitmap can be sent lossy to the client 2) when required, replacing lossy cache items with their correspending lossless bitmaps
Diffstat (limited to 'server/red_client_shared_cache.h')
-rw-r--r--server/red_client_shared_cache.h24
1 files changed, 22 insertions, 2 deletions
diff --git a/server/red_client_shared_cache.h b/server/red_client_shared_cache.h
index 4d1989dd..716b8122 100644
--- a/server/red_client_shared_cache.h
+++ b/server/red_client_shared_cache.h
@@ -35,7 +35,7 @@
#endif
-static int FUNC_NAME(hit)(CACHE *cache, uint64_t id, CHANNEL *channel)
+static int FUNC_NAME(hit)(CACHE *cache, uint64_t id, int *lossy, CHANNEL *channel)
{
NewCacheItem *item;
uint64_t serial;
@@ -51,6 +51,7 @@ static int FUNC_NAME(hit)(CACHE *cache, uint64_t id, CHANNEL *channel)
ASSERT(channel->base.id < MAX_CACHE_CLIENTS)
item->sync[channel->base.id] = serial;
cache->sync[channel->base.id] = serial;
+ *lossy = item->lossy;
break;
}
item = item->next;
@@ -60,7 +61,25 @@ static int FUNC_NAME(hit)(CACHE *cache, uint64_t id, CHANNEL *channel)
return !!item;
}
-static int FUNC_NAME(add)(CACHE *cache, uint64_t id, uint32_t size, CHANNEL *channel)
+static int FUNC_NAME(set_lossy)(CACHE *cache, uint64_t id, int lossy)
+{
+ NewCacheItem *item;
+ pthread_mutex_lock(&cache->lock);
+
+ item = cache->hash_table[CACHE_HASH_KEY(id)];
+
+ while (item) {
+ if (item->id == id) {
+ item->lossy = lossy;
+ break;
+ }
+ item = item->next;
+ }
+ pthread_mutex_unlock(&cache->lock);
+ return !!item;
+}
+
+static int FUNC_NAME(add)(CACHE *cache, uint64_t id, uint32_t size, int lossy, CHANNEL *channel)
{
NewCacheItem *item;
uint64_t serial;
@@ -119,6 +138,7 @@ static int FUNC_NAME(add)(CACHE *cache, uint64_t id, uint32_t size, CHANNEL *cha
ring_add(&cache->lru, &item->lru_link);
item->id = id;
item->size = size;
+ item->lossy = lossy;
memset(item->sync, 0, sizeof(item->sync));
item->sync[channel->base.id] = serial;
cache->sync[channel->base.id] = serial;