From 6d609e009f4836418bbe5b404be8ae03d29ef8cb Mon Sep 17 00:00:00 2001 From: Robert Bieber Date: Wed, 7 Jul 2010 09:33:47 +0000 Subject: Theme Editor: Implemented caching for rendered text, added profiling info to debug build, added a 500msec delay when rendering after code changes to prevent editor from hanging on large themes git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27332 a1c6a512-1295-4272-9138-f99709370657 --- utils/themeeditor/graphics/rbfont.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'utils/themeeditor/graphics/rbfont.cpp') diff --git a/utils/themeeditor/graphics/rbfont.cpp b/utils/themeeditor/graphics/rbfont.cpp index cd68af99fe..3b7397283c 100644 --- a/utils/themeeditor/graphics/rbfont.cpp +++ b/utils/themeeditor/graphics/rbfont.cpp @@ -21,6 +21,7 @@ #include "rbfont.h" #include "rbfontcache.h" +#include "rbtextcache.h" #include #include @@ -166,6 +167,13 @@ RBFont::~RBFont() RBText* RBFont::renderText(QString text, QColor color, int viewWidth, QGraphicsItem *parent) { + + /* Checking for a cache hit first */ + QImage* image = RBTextCache::lookup(header.value("filename").toString() + + text); + if(image) + return new RBText(image, viewWidth, parent); + int firstChar = header.value("firstchar").toInt(); int height = header.value("height").toInt(); int maxWidth = header.value("maxwidth").toInt(); @@ -184,10 +192,10 @@ RBText* RBFont::renderText(QString text, QColor color, int viewWidth, for(int i = 0; i < widths.count(); i++) totalWidth += widths[i]; - QImage image(totalWidth, height, QImage::Format_Indexed8); + image = new QImage(totalWidth, height, QImage::Format_Indexed8); - image.setColor(0, qRgba(0,0,0,0)); - image.setColor(1, color.rgb()); + image->setColor(0, qRgba(0,0,0,0)); + image->setColor(1, color.rgb()); /* Drawing the text */ int startX = 0; @@ -214,9 +222,9 @@ RBText* RBFont::renderText(QString text, QColor color, int viewWidth, for(int bit = 0; bit < 8; bit++) { if(mask & data) - image.setPixel(x, y, 1); + image->setPixel(x, y, 1); else - image.setPixel(x, y, 0); + image->setPixel(x, y, 0); y++; mask <<= 1; @@ -230,6 +238,7 @@ RBText* RBFont::renderText(QString text, QColor color, int viewWidth, startX += widths[i]; } + RBTextCache::insert(header.value("filename").toString() + text, image); return new RBText(image, viewWidth, parent); } -- cgit v1.2.3