From 785586af7dc72c23d0ab30204ab2975a1451dc16 Mon Sep 17 00:00:00 2001 From: Cary Clark Date: Thu, 19 Jul 2018 10:07:01 -0400 Subject: remove unused serialization in textblob The SKTextBlob serialization code that is tested by Skia is unused by Chrome. The serialization code that is used by Chrome is untested by Skia. Remove the unused code; test the used code. The code path introduced nearly a year ago, likely for slimming paint, attempts to make text blobs smarter by allowing the reuse of typefaces. Maybe there needs to be a Chrome bug / feature request to use this? If if turns out there is no interest to do so, This CL aligns used interfaces with tests. R=reed@google.com,fmalita@google.com,bungeman@google.com Bug: skia:6818 Change-Id: I9b3ec0c326495322986ba26f20f901bcb208be73 Reviewed-on: https://skia-review.googlesource.com/141542 Reviewed-by: Cary Clark Reviewed-by: Florin Malita Reviewed-by: Ben Wagner Reviewed-by: Mike Reed Commit-Queue: Cary Clark Auto-Submit: Cary Clark --- src/core/SkTextBlob.cpp | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) (limited to 'src/core') diff --git a/src/core/SkTextBlob.cpp b/src/core/SkTextBlob.cpp index fec7c527a2..4528e64f15 100644 --- a/src/core/SkTextBlob.cpp +++ b/src/core/SkTextBlob.cpp @@ -927,58 +927,9 @@ sk_sp SkTextBlob::Deserialize(const void* data, size_t length, /////////////////////////////////////////////////////////////////////////////////////////////////// -namespace { - struct CatalogState { - SkTypefaceCatalogerProc fProc; - void* fCtx; - }; - - sk_sp catalog_typeface_proc(SkTypeface* face, void* ctx) { - CatalogState* state = static_cast(ctx); - state->fProc(face, state->fCtx); - uint32_t id = face->uniqueID(); - return SkData::MakeWithCopy(&id, sizeof(uint32_t)); - } -} - -sk_sp SkTextBlob::serialize(SkTypefaceCatalogerProc proc, void* ctx) const { - CatalogState state = { proc, ctx }; - SkSerialProcs procs; - procs.fTypefaceProc = catalog_typeface_proc; - procs.fTypefaceCtx = &state; - return this->serialize(procs); -} - size_t SkTextBlob::serialize(const SkSerialProcs& procs, void* memory, size_t memory_size) const { SkBinaryWriteBuffer buffer(memory, memory_size); buffer.setSerialProcs(procs); SkTextBlobPriv::Flatten(*this, buffer); return buffer.usingInitialStorage() ? buffer.bytesWritten() : 0u; } - -namespace { - struct ResolverState { - SkTypefaceResolverProc fProc; - void* fCtx; - }; - - sk_sp resolver_typeface_proc(const void* data, size_t length, void* ctx) { - if (length != 4) { - return nullptr; - } - - ResolverState* state = static_cast(ctx); - uint32_t id; - memcpy(&id, data, length); - return state->fProc(id, state->fCtx); - } -} - -sk_sp SkTextBlob::Deserialize(const void* data, size_t length, - SkTypefaceResolverProc proc, void* ctx) { - ResolverState state = { proc, ctx }; - SkDeserialProcs procs; - procs.fTypefaceProc = resolver_typeface_proc; - procs.fTypefaceCtx = &state; - return Deserialize(data, length, procs); -} -- cgit v1.2.3