aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench/TextBench.cpp
diff options
context:
space:
mode:
authorGravatar reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2009-04-08 05:03:52 +0000
committerGravatar reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2009-04-08 05:03:52 +0000
commitd6638e644e430a721ea2dc2372e1880e16a3ff5d (patch)
tree193a8ec896667b1aa9721cd877b79a5f4a94f2d1 /bench/TextBench.cpp
parent16690af1c21dead3eedb25ebd0a4b9a091684ed4 (diff)
add Table apis to SkFontHost
need to implement in _win backend git-svn-id: http://skia.googlecode.com/svn/trunk@149 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'bench/TextBench.cpp')
-rw-r--r--bench/TextBench.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/bench/TextBench.cpp b/bench/TextBench.cpp
index 799a3c852c..adbd96281b 100644
--- a/bench/TextBench.cpp
+++ b/bench/TextBench.cpp
@@ -1,10 +1,50 @@
#include "SkBenchmark.h"
#include "SkCanvas.h"
+#include "SkFontHost.h"
#include "SkPaint.h"
#include "SkRandom.h"
#include "SkString.h"
#include "SkTemplates.h"
+static void dump_font(const char name[], SkFontID fontID) {
+ SkDebugf("Font \"%s\" %x\n", name, fontID);
+ int count = SkFontHost::CountTables(fontID);
+ SkAutoTArray<SkFontTableTag> storage(count);
+ SkFontTableTag* tags = storage.get();
+ SkFontHost::GetTableTags(fontID, tags);
+ for (int i = 0; i < count; i++) {
+ uint32_t tag = tags[i];
+ uint8_t data[4];
+ size_t size = SkFontHost::GetTableSize(fontID, tag);
+ size_t bytes = SkFontHost::GetTableData(fontID, tag,
+ 0, sizeof(data), data);
+ SkDebugf(" tag=%c%c%c%c size=%d bytes=%d %x %x %x %x\n",
+ uint8_t(tag>>24), uint8_t(tag>>16), uint8_t(tag>>8), uint8_t(tag),
+ size, bytes, data[0], data[1], data[2], data[3]);
+ }
+}
+
+static void test_tables() {
+ static bool gOnce;
+ if (gOnce) {
+ return;
+ }
+ gOnce = true;
+
+ static const char* gNames[] = {
+ "Arial", "Times", "Courier"
+ };
+
+ for (size_t i = 0; i < SK_ARRAY_COUNT(gNames); i++) {
+ SkTypeface* tf = SkTypeface::CreateFromName(gNames[i], SkTypeface::kNormal);
+ if (tf) {
+ SkFontID fontID = tf->uniqueID();
+ dump_font(gNames[i], fontID);
+ tf->unref();
+ }
+ }
+}
+
/* Some considerations for performance:
short -vs- long strings (measuring overhead)
tiny -vs- large pointsize (measure blit -vs- overhead)
@@ -23,6 +63,8 @@ class TextBench : public SkBenchmark {
enum { N = 300 };
public:
TextBench(const char text[], int ps, bool linearText, bool posText) {
+ test_tables();
+
fText.set(text);
fPaint.setAntiAlias(true);