summaryrefslogtreecommitdiff
path: root/utils/themeeditor/graphics/rbfont.cpp
diff options
context:
space:
mode:
authorRobert Bieber <robby@bieberphoto.com>2010-07-07 09:33:47 +0000
committerRobert Bieber <robby@bieberphoto.com>2010-07-07 09:33:47 +0000
commit6d609e009f4836418bbe5b404be8ae03d29ef8cb (patch)
tree708bc7ba7bce2c7fc01cb719b594b296e51b17d0 /utils/themeeditor/graphics/rbfont.cpp
parent6f06793f58f520ec7d44683f6447c0b540a265b3 (diff)
downloadrockbox-6d609e009f4836418bbe5b404be8ae03d29ef8cb.tar.gz
rockbox-6d609e009f4836418bbe5b404be8ae03d29ef8cb.zip
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.cpp19
1 files changed, 14 insertions, 5 deletions
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 @@
21 21
22#include "rbfont.h" 22#include "rbfont.h"
23#include "rbfontcache.h" 23#include "rbfontcache.h"
24#include "rbtextcache.h"
24 25
25#include <QFont> 26#include <QFont>
26#include <QBrush> 27#include <QBrush>
@@ -166,6 +167,13 @@ RBFont::~RBFont()
166RBText* RBFont::renderText(QString text, QColor color, int viewWidth, 167RBText* RBFont::renderText(QString text, QColor color, int viewWidth,
167 QGraphicsItem *parent) 168 QGraphicsItem *parent)
168{ 169{
170
171 /* Checking for a cache hit first */
172 QImage* image = RBTextCache::lookup(header.value("filename").toString()
173 + text);
174 if(image)
175 return new RBText(image, viewWidth, parent);
176
169 int firstChar = header.value("firstchar").toInt(); 177 int firstChar = header.value("firstchar").toInt();
170 int height = header.value("height").toInt(); 178 int height = header.value("height").toInt();
171 int maxWidth = header.value("maxwidth").toInt(); 179 int maxWidth = header.value("maxwidth").toInt();
@@ -184,10 +192,10 @@ RBText* RBFont::renderText(QString text, QColor color, int viewWidth,
184 for(int i = 0; i < widths.count(); i++) 192 for(int i = 0; i < widths.count(); i++)
185 totalWidth += widths[i]; 193 totalWidth += widths[i];
186 194
187 QImage image(totalWidth, height, QImage::Format_Indexed8); 195 image = new QImage(totalWidth, height, QImage::Format_Indexed8);
188 196
189 image.setColor(0, qRgba(0,0,0,0)); 197 image->setColor(0, qRgba(0,0,0,0));
190 image.setColor(1, color.rgb()); 198 image->setColor(1, color.rgb());
191 199
192 /* Drawing the text */ 200 /* Drawing the text */
193 int startX = 0; 201 int startX = 0;
@@ -214,9 +222,9 @@ RBText* RBFont::renderText(QString text, QColor color, int viewWidth,
214 for(int bit = 0; bit < 8; bit++) 222 for(int bit = 0; bit < 8; bit++)
215 { 223 {
216 if(mask & data) 224 if(mask & data)
217 image.setPixel(x, y, 1); 225 image->setPixel(x, y, 1);
218 else 226 else
219 image.setPixel(x, y, 0); 227 image->setPixel(x, y, 0);
220 228
221 y++; 229 y++;
222 mask <<= 1; 230 mask <<= 1;
@@ -230,6 +238,7 @@ RBText* RBFont::renderText(QString text, QColor color, int viewWidth,
230 startX += widths[i]; 238 startX += widths[i];
231 } 239 }
232 240
241 RBTextCache::insert(header.value("filename").toString() + text, image);
233 return new RBText(image, viewWidth, parent); 242 return new RBText(image, viewWidth, parent);
234 243
235} 244}