aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Domke <tmbinc@elitedvb.net>2008-03-15 10:50:29 +0000
committerFelix Domke <tmbinc@elitedvb.net>2008-03-15 10:50:29 +0000
commit72089a1844b6b6e820601d00c028b774dc0cbf75 (patch)
tree0d4555b1496075d836c44f37d1df0c09c1a26397
parent792d7967cd9a719a8cdd577a5d1c177db46c8630 (diff)
downloadenigma2-72089a1844b6b6e820601d00c028b774dc0cbf75.tar.gz
enigma2-72089a1844b6b6e820601d00c028b774dc0cbf75.zip
optional pixmap caching
-rw-r--r--lib/python/Tools/LoadPixmap.py11
-rw-r--r--skin.py8
2 files changed, 17 insertions, 2 deletions
diff --git a/lib/python/Tools/LoadPixmap.py b/lib/python/Tools/LoadPixmap.py
index b7838a39..53e04e54 100644
--- a/lib/python/Tools/LoadPixmap.py
+++ b/lib/python/Tools/LoadPixmap.py
@@ -1,6 +1,11 @@
from enigma import loadPNG, loadJPG
-def LoadPixmap(path, desktop = None):
+pixmap_cache = {}
+
+def LoadPixmap(path, desktop = None, cached = False):
+ if path in pixmap_cache:
+ return pixmap_cache[path]
+
if path[-4:] == ".png":
ptr = loadPNG(path)
elif path[-4:] == ".jpg":
@@ -12,4 +17,8 @@ def LoadPixmap(path, desktop = None):
raise "neither .png nor .jpg, please fix file extension"
if ptr and desktop:
desktop.makeCompatiblePixmap(ptr)
+
+ if cached:
+ pixmap_cache[path] = ptr
+
return ptr
diff --git a/skin.py b/skin.py
index 21ec62ae..26c08207 100644
--- a/skin.py
+++ b/skin.py
@@ -106,7 +106,13 @@ def collectAttributes(skinAttributes, node, skin_path_prefix=None, ignore=[]):
skinAttributes.append((attrib, value))
def loadPixmap(path, desktop):
- ptr = LoadPixmap(path, desktop)
+ cached = False
+ option = path.find("#")
+ if option != -1:
+ options = path[option+1:].split(',')
+ path = path[:option]
+ cached = "cached" in options
+ ptr = LoadPixmap(path, desktop, cached)
if ptr is None:
raise SkinError("pixmap file %s not found!" % (path))
return ptr