summaryrefslogtreecommitdiff
path: root/utils/themeeditor/graphics
diff options
context:
space:
mode:
authorRobert Bieber <robby@bieberphoto.com>2010-07-07 08:41:36 +0000
committerRobert Bieber <robby@bieberphoto.com>2010-07-07 08:41:36 +0000
commit6f06793f58f520ec7d44683f6447c0b540a265b3 (patch)
tree94b76580cfc13903a55c10dc92318551eebf9788 /utils/themeeditor/graphics
parent88145656fb9b3276893e617b21bc590bc49fe96a (diff)
downloadrockbox-6f06793f58f520ec7d44683f6447c0b540a265b3.zip
rockbox-6f06793f58f520ec7d44683f6447c0b540a265b3.tar.gz
rockbox-6f06793f58f520ec7d44683f6447c0b540a265b3.tar.bz2
rockbox-6f06793f58f520ec7d44683f6447c0b540a265b3.tar.xz
Theme Editor: Fixed rendering bug that caused text in sublines not to appear, implemented a global font cache
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27331 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/themeeditor/graphics')
-rw-r--r--utils/themeeditor/graphics/rbfont.cpp29
-rw-r--r--utils/themeeditor/graphics/rbfontcache.cpp24
-rw-r--r--utils/themeeditor/graphics/rbfontcache.h48
-rw-r--r--utils/themeeditor/graphics/rbviewport.h6
4 files changed, 101 insertions, 6 deletions
diff --git a/utils/themeeditor/graphics/rbfont.cpp b/utils/themeeditor/graphics/rbfont.cpp
index 07308fa..cd68af9 100644
--- a/utils/themeeditor/graphics/rbfont.cpp
+++ b/utils/themeeditor/graphics/rbfont.cpp
@@ -20,6 +20,7 @@
****************************************************************************/
#include "rbfont.h"
+#include "rbfontcache.h"
#include <QFont>
#include <QBrush>
@@ -29,6 +30,8 @@
#include <QImage>
#include <QSettings>
+#include <QDebug>
+
quint16 RBFont::maxFontSizeFor16BitOffsets = 0xFFDB;
RBFont::RBFont(QString file)
@@ -52,6 +55,18 @@ RBFont::RBFont(QString file)
}
header.insert("filename", file);
+ /* Checking for a cache entry */
+ RBFontCache::CacheInfo* cache = RBFontCache::lookup(file);
+ if(cache)
+ {
+ imageData = cache->imageData;
+ offsetData = cache->offsetData;
+ widthData = cache->widthData;
+ header = cache->header;
+
+ return;
+ }
+
/* Opening the file */
QFile fin(file);
fin.open(QFile::ReadOnly);
@@ -134,16 +149,18 @@ RBFont::RBFont(QString file)
fin.close();
+ /* Caching the font data */
+ cache = new RBFontCache::CacheInfo;
+ cache->imageData = imageData;
+ cache->offsetData = offsetData;
+ cache->widthData = widthData;
+ cache->header = header;
+ RBFontCache::insert(file, cache);
+
}
RBFont::~RBFont()
{
- if(imageData)
- delete[] imageData;
- if(offsetData)
- delete[] offsetData;
- if(widthData)
- delete[] widthData;
}
RBText* RBFont::renderText(QString text, QColor color, int viewWidth,
diff --git a/utils/themeeditor/graphics/rbfontcache.cpp b/utils/themeeditor/graphics/rbfontcache.cpp
new file mode 100644
index 0000000..3b6d56f
--- /dev/null
+++ b/utils/themeeditor/graphics/rbfontcache.cpp
@@ -0,0 +1,24 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2010 Robert Bieber
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include "rbfontcache.h"
+
+QHash<QString, RBFontCache::CacheInfo*> RBFontCache::cache;
diff --git a/utils/themeeditor/graphics/rbfontcache.h b/utils/themeeditor/graphics/rbfontcache.h
new file mode 100644
index 0000000..50a6d2e
--- /dev/null
+++ b/utils/themeeditor/graphics/rbfontcache.h
@@ -0,0 +1,48 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2010 Robert Bieber
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#ifndef RBFONTCACHE_H
+#define RBFONTCACHE_H
+
+#include <QHash>
+
+class RBFontCache
+{
+
+public:
+ struct CacheInfo
+ {
+ quint8* imageData;
+ quint16* offsetData;
+ quint8* widthData;
+
+ QHash<QString, QVariant> header;
+ };
+
+ static CacheInfo* lookup(QString key){ return cache.value(key, 0); }
+ static void insert(QString key, CacheInfo* data){ cache.insert(key, data); }
+
+private:
+ static QHash<QString, CacheInfo*> cache;
+
+};
+
+#endif // RBFONTCACHE_H
diff --git a/utils/themeeditor/graphics/rbviewport.h b/utils/themeeditor/graphics/rbviewport.h
index 81841d5..c557632 100644
--- a/utils/themeeditor/graphics/rbviewport.h
+++ b/utils/themeeditor/graphics/rbviewport.h
@@ -60,6 +60,12 @@ public:
void alignText(Alignment align){ textAlign = align; }
int getTextOffset(){ return textOffset.y(); }
void addTextOffset(int height){ textOffset.setY(textOffset.y() + height); }
+ void flushText()
+ {
+ alignLeft();
+ alignRight();
+ alignCenter();
+ }
void enableStatusBar(){ showStatusBar = true; }