diff options
| author | Robert Bieber <robby@bieberphoto.com> | 2010-07-07 09:33:47 +0000 |
|---|---|---|
| committer | Robert Bieber <robby@bieberphoto.com> | 2010-07-07 09:33:47 +0000 |
| commit | 6d609e009f4836418bbe5b404be8ae03d29ef8cb (patch) | |
| tree | 708bc7ba7bce2c7fc01cb719b594b296e51b17d0 /utils/themeeditor/graphics/rbfont.cpp | |
| parent | 6f06793f58f520ec7d44683f6447c0b540a265b3 (diff) | |
| download | rockbox-6d609e009f4836418bbe5b404be8ae03d29ef8cb.zip rockbox-6d609e009f4836418bbe5b404be8ae03d29ef8cb.tar.gz rockbox-6d609e009f4836418bbe5b404be8ae03d29ef8cb.tar.bz2 rockbox-6d609e009f4836418bbe5b404be8ae03d29ef8cb.tar.xz | |
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
Diffstat (limited to 'utils/themeeditor/graphics/rbfont.cpp')
| -rw-r--r-- | utils/themeeditor/graphics/rbfont.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/utils/themeeditor/graphics/rbfont.cpp b/utils/themeeditor/graphics/rbfont.cpp index cd68af9..3b73972 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 <QFont> #include <QBrush> @@ -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); } |