aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar djsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-03-26 17:34:39 +0000
committerGravatar djsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-03-26 17:34:39 +0000
commitd43b0a87f85ca26ec771e094c62df33b0537b563 (patch)
tree765ed47a6b880ed037f73a80f4c00bc9abe1ef9a /src
parent39d4f3a02c21a32b766b13068d5bb65d4c332846 (diff)
Make use of the functions in the flattenable reader/writer
Review URL: https://codereview.appspot.com/5905066 git-svn-id: http://skia.googlecode.com/svn/trunk@3493 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r--src/core/SkBitmap.cpp20
1 files changed, 3 insertions, 17 deletions
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index 0a96e9e597..e292f39a73 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -1379,21 +1379,6 @@ enum {
SERIALIZE_PIXELTYPE_REF_PTR,
};
-static void writeString(SkFlattenableWriteBuffer& buffer, const char str[]) {
- size_t len = strlen(str);
- buffer.write32(len);
- buffer.writePad(str, len);
-}
-
-static SkPixelRef::Factory deserialize_factory(SkFlattenableReadBuffer& buffer) {
- size_t len = buffer.readInt();
- SkAutoSMalloc<256> storage(len + 1);
- char* str = (char*)storage.get();
- buffer.read(str, len);
- str[len] = 0;
- return SkPixelRef::NameToFactory(str);
-}
-
/*
It is tricky to know how much to flatten. If we don't have a pixelref (i.e.
we just have pixels, then we can only flatten the pixels, or write out an
@@ -1439,7 +1424,7 @@ void SkBitmap::flatten(SkFlattenableWriteBuffer& buffer) const {
if (name && *name) {
buffer.write8(SERIALIZE_PIXELTYPE_REF_DATA);
buffer.write32(fPixelRefOffset);
- writeString(buffer, name);
+ buffer.writeString(name);
fPixelRef->flatten(buffer);
return;
}
@@ -1487,7 +1472,8 @@ void SkBitmap::unflatten(SkFlattenableReadBuffer& buffer) {
}
case SERIALIZE_PIXELTYPE_REF_DATA: {
size_t offset = buffer.readU32();
- SkPixelRef::Factory fact = deserialize_factory(buffer);
+ const char* factoryName = buffer.readString();
+ SkPixelRef::Factory fact = SkPixelRef::NameToFactory(factoryName);
SkPixelRef* pr = fact(buffer);
SkSafeUnref(this->setPixelRef(pr, offset));
break;