aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-09 11:52:12 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-09 11:52:12 -0700
commit4b86a58dcecc030f2220cb91f4744f8099e7dfe6 (patch)
tree538ed3311bd62a090220953cf138e0e96352d8d4
parent3298d565d8a70b84f28b455f6289293883c85494 (diff)
downloadexternal_skia-4b86a58dcecc030f2220cb91f4744f8099e7dfe6.zip
external_skia-4b86a58dcecc030f2220cb91f4744f8099e7dfe6.tar.gz
external_skia-4b86a58dcecc030f2220cb91f4744f8099e7dfe6.tar.bz2
auto import from //branches/cupcake/...@137197
-rw-r--r--include/core/SkTypeface.h14
-rw-r--r--src/core/SkTypeface.cpp28
-rw-r--r--src/ports/SkFontHost_android.cpp2
3 files changed, 37 insertions, 7 deletions
diff --git a/include/core/SkTypeface.h b/include/core/SkTypeface.h
index 7487071..ed45c03 100644
--- a/include/core/SkTypeface.h
+++ b/include/core/SkTypeface.h
@@ -106,15 +106,23 @@ public:
*/
static SkTypeface* CreateFromStream(SkStream* stream);
- // Serialization
+ /** Write a unique signature to a stream, sufficient to reconstruct a
+ typeface referencing the same font when Deserialize is called.
+ */
void serialize(SkWStream*) const;
+
+ /** Given the data previously written by serialize(), return a new instance
+ to a typeface referring to the same font. If that font is not available,
+ return null. If an instance is returned, the caller is responsible for
+ calling unref() when they are done with it.
+ */
static SkTypeface* Deserialize(SkStream*);
protected:
/** uniqueID must be unique (please!) and non-zero
*/
- SkTypeface(Style style, uint32_t uniqueID)
- : fUniqueID(uniqueID), fStyle(style) {}
+ SkTypeface(Style style, uint32_t uniqueID);
+ virtual ~SkTypeface();
private:
uint32_t fUniqueID;
diff --git a/src/core/SkTypeface.cpp b/src/core/SkTypeface.cpp
index 38d0e01..b87db6b 100644
--- a/src/core/SkTypeface.cpp
+++ b/src/core/SkTypeface.cpp
@@ -1,6 +1,30 @@
#include "SkTypeface.h"
#include "SkFontHost.h"
+//#define TRACK_TYPEFACE_ALLOCS
+
+#ifdef TRACK_TYPEFACE_ALLOCS
+ static int32_t gTypefaceAllocCount;
+#endif
+
+SkTypeface::SkTypeface(Style style, uint32_t uniqueID)
+ : fUniqueID(uniqueID), fStyle(style) {
+#ifdef TRACK_TYPEFACE_ALLOCS
+ sk_atomic_inc(&gTypefaceAllocCount);
+ SkDebugf("+++ [%d] typeface %p [style=%d uniqueID=%d]\n",
+ gTypefaceAllocCount, this, style, uniqueID);
+#endif
+}
+
+SkTypeface::~SkTypeface() {
+#ifdef TRACK_TYPEFACE_ALLOCS
+ SkDebugf("--- [%d] typeface %p\n", gTypefaceAllocCount, this);
+ sk_atomic_inc(&gTypefaceAllocCount);
+#endif
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
uint32_t SkTypeface::UniqueID(const SkTypeface* face) {
if (face) {
return face->uniqueID();
@@ -50,9 +74,7 @@ void SkTypeface::serialize(SkWStream* stream) const {
}
SkTypeface* SkTypeface::Deserialize(SkStream* stream) {
- SkTypeface* face = SkFontHost::Deserialize(stream);
- face->ref();
- return face;
+ return SkFontHost::Deserialize(stream);
}
diff --git a/src/ports/SkFontHost_android.cpp b/src/ports/SkFontHost_android.cpp
index 67c78fb..43bbde3 100644
--- a/src/ports/SkFontHost_android.cpp
+++ b/src/ports/SkFontHost_android.cpp
@@ -535,7 +535,7 @@ SkTypeface* SkFontHost::Deserialize(SkStream* stream) {
}
}
}
- return SkFontHost::CreateTypeface(NULL, NULL, (SkTypeface::Style)style);
+ return NULL;
}
///////////////////////////////////////////////////////////////////////////////