From 7ce445025e10bf4eb0c4066907e588039c09f1ad Mon Sep 17 00:00:00 2001 From: louis Date: Wed, 3 Dec 2014 18:12:37 +0100 Subject: drawing ellipses antialiased with Cairo --- libcore/imagecache.c | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) (limited to 'libcore/imagecache.c') diff --git a/libcore/imagecache.c b/libcore/imagecache.c index cfaf255..4d68722 100644 --- a/libcore/imagecache.c +++ b/libcore/imagecache.c @@ -3,9 +3,10 @@ #include #include #include -#include "imagecache.h" +#include "imagecreator.h" #include "../config.h" #include "helpers.h" +#include "imagecache.h" cMutex cImageCache::mutex; @@ -300,6 +301,37 @@ cImage *cImageCache::GetSkinpart(string name, int width, int height) { return NULL; } +void cImageCache::CacheEllipse(int id, int width, int height, tColor color, int quadrant) { + esyslog("skindesigner: caching ellipse %d, w %d, h %d, color %x, quadrant %d", id, width, height, color, quadrant); + GetEllipse(id, width, height, color, quadrant); +} + +cImage *cImageCache::GetEllipse(int id, int width, int height, tColor color, int quadrant) { + if (width < 1 || width > 1920 || height < 1 || height > 1080) + return NULL; + cMutexLock MutexLock(&mutex); + map::iterator hit = cairoImageCache.find(id); + if (hit != cairoImageCache.end()) { + return (cImage*)hit->second; + } else { + cImageCreator ic; + if (!ic.InitCairoImage(width, height)) + return NULL; + ic.DrawEllipse(color, quadrant); + cImage *ellipse = ic.GetImage(); + cairoImageCache.insert(pair(id, ellipse)); + hit = cairoImageCache.find(id); + if (hit != cairoImageCache.end()) { + return (cImage*)hit->second; + } + } + return NULL; +} + +/**************************************************************************************** +* PRIVATE FUNCTIONS +****************************************************************************************/ + bool cImageCache::LoadIcon(eImageType type, string name) { cString subdir(""); if (type == itMenuIcon) @@ -361,11 +393,17 @@ void cImageCache::Clear(void) { } channelLogoCache.clear(); - for(map::const_iterator it = skinPartsCache.begin(); it != skinPartsCache.end(); it++) { + for(map::const_iterator it = skinPartsCache.begin(); it != skinPartsCache.end(); it++) { cImage *img = (cImage*)it->second; delete img; } skinPartsCache.clear(); + + for(map::const_iterator it = cairoImageCache.begin(); it != cairoImageCache.end(); it++) { + cImage *img = (cImage*)it->second; + delete img; + } + cairoImageCache.clear(); } void cImageCache::Debug(bool full) { -- cgit v1.2.3