aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Cary Clark <caryclark@skia.org>2018-07-17 08:59:34 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-07-17 17:01:20 +0000
commit53c876900247ad700ce28f7b33031047a6cff402 (patch)
treed3dbf21cb7c6b7b2af6a718ce0a431b0f5404b2a /src
parent462417d3d8683a8efe3b4d5813b972e478655ac3 (diff)
remove unused untested parts of text blob
SkTextBlob has a number of untested entry points to serialize and deserialize. Privitize ones only used by Skia, and remove ones suspected to be unused and untested. R=fmalita@chromium.org TBR=reed@google.com,bsalomon@google.com Bug: skia:6818 Change-Id: I6a9982a26a883982af3592f3302029a1bcdf5aa3 Reviewed-on: https://skia-review.googlesource.com/141820 Reviewed-by: Florin Malita <fmalita@chromium.org> Reviewed-by: Cary Clark <caryclark@skia.org> Commit-Queue: Cary Clark <caryclark@skia.org>
Diffstat (limited to 'src')
-rw-r--r--src/core/SkPictureData.cpp6
-rw-r--r--src/core/SkTextBlob.cpp39
-rw-r--r--src/core/SkTextBlobPriv.h33
-rw-r--r--src/pipe/SkPipeCanvas.cpp4
-rw-r--r--src/pipe/SkPipeReader.cpp4
5 files changed, 57 insertions, 29 deletions
diff --git a/src/core/SkPictureData.cpp b/src/core/SkPictureData.cpp
index 92234f9ce9..14a6d94c88 100644
--- a/src/core/SkPictureData.cpp
+++ b/src/core/SkPictureData.cpp
@@ -13,7 +13,7 @@
#include "SkPictureRecord.h"
#include "SkPicturePriv.h"
#include "SkReadBuffer.h"
-#include "SkTextBlob.h"
+#include "SkTextBlobPriv.h"
#include "SkTypeface.h"
#include "SkWriteBuffer.h"
#include "SkTo.h"
@@ -156,7 +156,7 @@ void SkPictureData::flattenToBuffer(SkWriteBuffer& buffer) const {
if (!fTextBlobs.empty()) {
write_tag_size(buffer, SK_PICT_TEXTBLOB_BUFFER_TAG, fTextBlobs.count());
for (const auto& blob : fTextBlobs) {
- blob->flatten(buffer);
+ SkTextBlobPriv::Flatten(*blob, buffer);
}
}
@@ -405,7 +405,7 @@ void SkPictureData::parseBufferTag(SkReadBuffer& buffer, uint32_t tag, uint32_t
}
} break;
case SK_PICT_TEXTBLOB_BUFFER_TAG:
- new_array_from_buffer(buffer, size, fTextBlobs, SkTextBlob::MakeFromBuffer);
+ new_array_from_buffer(buffer, size, fTextBlobs, SkTextBlobPriv::MakeFromBuffer);
break;
case SK_PICT_VERTICES_BUFFER_TAG:
new_array_from_buffer(buffer, size, fVertices, create_vertices_from_buffer);
diff --git a/src/core/SkTextBlob.cpp b/src/core/SkTextBlob.cpp
index 6d636ce4b6..dd2f7bd1dd 100644
--- a/src/core/SkTextBlob.cpp
+++ b/src/core/SkTextBlob.cpp
@@ -10,6 +10,7 @@
#include "SkPaintPriv.h"
#include "SkReadBuffer.h"
#include "SkSafeMath.h"
+#include "SkTextBlobPriv.h"
#include "SkTypeface.h"
#include "SkWriteBuffer.h"
@@ -762,11 +763,11 @@ sk_sp<SkTextBlob> SkTextBlobBuilder::make() {
///////////////////////////////////////////////////////////////////////////////////////////////////
-void SkTextBlob::flatten(SkWriteBuffer& buffer) const {
- buffer.writeRect(fBounds);
+void SkTextBlobPriv::Flatten(const SkTextBlob& blob, SkWriteBuffer& buffer) {
+ buffer.writeRect(blob.fBounds);
SkPaint runPaint;
- SkTextBlobRunIterator it(this);
+ SkTextBlobRunIterator it(&blob);
while (!it.done()) {
SkASSERT(it.glyphCount() > 0);
@@ -789,7 +790,8 @@ void SkTextBlob::flatten(SkWriteBuffer& buffer) const {
buffer.writeByteArray(it.glyphs(), it.glyphCount() * sizeof(uint16_t));
buffer.writeByteArray(it.pos(),
- it.glyphCount() * sizeof(SkScalar) * ScalarsPerGlyph(it.positioning()));
+ it.glyphCount() * sizeof(SkScalar) *
+ SkTextBlob::ScalarsPerGlyph(it.positioning()));
if (pe.extended) {
buffer.writeByteArray(it.clusters(), sizeof(uint32_t) * it.glyphCount());
buffer.writeByteArray(it.text(), it.textSize());
@@ -802,7 +804,7 @@ void SkTextBlob::flatten(SkWriteBuffer& buffer) const {
buffer.write32(0);
}
-sk_sp<SkTextBlob> SkTextBlob::MakeFromBuffer(SkReadBuffer& reader) {
+sk_sp<SkTextBlob> SkTextBlobPriv::MakeFromBuffer(SkReadBuffer& reader) {
SkRect bounds;
reader.readRect(&bounds);
@@ -817,8 +819,8 @@ sk_sp<SkTextBlob> SkTextBlob::MakeFromBuffer(SkReadBuffer& reader) {
PositioningAndExtended pe;
pe.intValue = reader.read32();
- GlyphPositioning pos = pe.positioning;
- if (glyphCount <= 0 || pos > kFull_Positioning) {
+ SkTextBlob::GlyphPositioning pos = pe.positioning;
+ if (glyphCount <= 0 || pos > SkTextBlob::kFull_Positioning) {
return nullptr;
}
int textSize = pe.extended ? reader.read32() : 0;
@@ -835,7 +837,8 @@ sk_sp<SkTextBlob> SkTextBlob::MakeFromBuffer(SkReadBuffer& reader) {
// a run before allocating it.
const size_t glyphSize = safe.mul(glyphCount, sizeof(uint16_t)),
posSize =
- safe.mul(glyphCount, safe.mul(sizeof(SkScalar), ScalarsPerGlyph(pos))),
+ safe.mul(glyphCount, safe.mul(sizeof(SkScalar),
+ SkTextBlob::ScalarsPerGlyph(pos))),
clusterSize = pe.extended ? safe.mul(glyphCount, sizeof(uint32_t)) : 0;
const size_t totalSize =
safe.add(safe.add(glyphSize, posSize), safe.add(clusterSize, textSize));
@@ -846,15 +849,15 @@ sk_sp<SkTextBlob> SkTextBlob::MakeFromBuffer(SkReadBuffer& reader) {
const SkTextBlobBuilder::RunBuffer* buf = nullptr;
switch (pos) {
- case kDefault_Positioning:
+ case SkTextBlob::kDefault_Positioning:
buf = &blobBuilder.allocRunText(font, glyphCount, offset.x(), offset.y(),
textSize, SkString(), &bounds);
break;
- case kHorizontal_Positioning:
+ case SkTextBlob::kHorizontal_Positioning:
buf = &blobBuilder.allocRunTextPosH(font, glyphCount, offset.y(),
textSize, SkString(), &bounds);
break;
- case kFull_Positioning:
+ case SkTextBlob::kFull_Positioning:
buf = &blobBuilder.allocRunTextPos(font, glyphCount, textSize, SkString(), &bounds);
break;
default:
@@ -886,7 +889,7 @@ sk_sp<SkTextBlob> SkTextBlob::MakeFromBuffer(SkReadBuffer& reader) {
sk_sp<SkData> SkTextBlob::serialize(const SkSerialProcs& procs) const {
SkBinaryWriteBuffer buffer;
buffer.setSerialProcs(procs);
- this->flatten(buffer);
+ SkTextBlobPriv::Flatten(*this, buffer);
size_t total = buffer.bytesWritten();
sk_sp<SkData> data = SkData::MakeUninitialized(total);
@@ -894,19 +897,11 @@ sk_sp<SkData> SkTextBlob::serialize(const SkSerialProcs& procs) const {
return data;
}
-sk_sp<SkData> SkTextBlob::serialize() const {
- return this->serialize(SkSerialProcs());
-}
-
sk_sp<SkTextBlob> SkTextBlob::Deserialize(const void* data, size_t length,
const SkDeserialProcs& procs) {
SkReadBuffer buffer(data, length);
buffer.setDeserialProcs(procs);
- return SkTextBlob::MakeFromBuffer(buffer);
-}
-
-sk_sp<SkTextBlob> SkTextBlob::Deserialize(const void* data, size_t length) {
- return SkTextBlob::Deserialize(data, length, SkDeserialProcs());
+ return SkTextBlobPriv::MakeFromBuffer(buffer);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -936,7 +931,7 @@ sk_sp<SkData> SkTextBlob::serialize(SkTypefaceCatalogerProc proc, void* ctx) con
size_t SkTextBlob::serialize(const SkSerialProcs& procs, void* memory, size_t memory_size) const {
SkBinaryWriteBuffer buffer(memory, memory_size);
buffer.setSerialProcs(procs);
- this->flatten(buffer);
+ SkTextBlobPriv::Flatten(*this, buffer);
return buffer.usingInitialStorage() ? buffer.bytesWritten() : 0u;
}
diff --git a/src/core/SkTextBlobPriv.h b/src/core/SkTextBlobPriv.h
new file mode 100644
index 0000000000..70fdf5a57e
--- /dev/null
+++ b/src/core/SkTextBlobPriv.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2018 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkTextBlobPriv_DEFINED
+#define SkTextBlobPriv_DEFINED
+
+#include "SkTextBlob.h"
+
+class SkReadBuffer;
+class SkWriteBuffer;
+
+class SkTextBlobPriv {
+public:
+ /**
+ * Serialize to a buffer.
+ */
+ static void Flatten(const SkTextBlob& , SkWriteBuffer&);
+
+ /**
+ * Recreate an SkTextBlob that was serialized into a buffer.
+ *
+ * @param SkReadBuffer Serialized blob data.
+ * @return A new SkTextBlob representing the serialized data, or NULL if the buffer is
+ * invalid.
+ */
+ static sk_sp<SkTextBlob> MakeFromBuffer(SkReadBuffer&);
+};
+
+#endif // SkTextBlobPriv_DEFINED
diff --git a/src/pipe/SkPipeCanvas.cpp b/src/pipe/SkPipeCanvas.cpp
index aabff5bfae..258160c4fe 100644
--- a/src/pipe/SkPipeCanvas.cpp
+++ b/src/pipe/SkPipeCanvas.cpp
@@ -20,7 +20,7 @@
#include "SkRSXform.h"
#include "SkShader.h"
#include "SkStream.h"
-#include "SkTextBlob.h"
+#include "SkTextBlobPriv.h"
#include "SkTo.h"
#include "SkTypeface.h"
@@ -680,7 +680,7 @@ void SkPipeCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y
const SkPaint &paint) {
SkPipeWriter writer(this);
writer.write32(pack_verb(SkPipeVerb::kDrawTextBlob, 0));
- blob->flatten(writer);
+ SkTextBlobPriv::Flatten(*blob, writer);
writer.writeScalar(x);
writer.writeScalar(y);
write_paint(writer, paint, kTextBlob_PaintUsage);
diff --git a/src/pipe/SkPipeReader.cpp b/src/pipe/SkPipeReader.cpp
index a37af5532a..909276f41b 100644
--- a/src/pipe/SkPipeReader.cpp
+++ b/src/pipe/SkPipeReader.cpp
@@ -16,7 +16,7 @@
#include "SkReadBuffer.h"
#include "SkRefSet.h"
#include "SkRSXform.h"
-#include "SkTextBlob.h"
+#include "SkTextBlobPriv.h"
#include "SkTypeface.h"
#include "SkVertices.h"
@@ -401,7 +401,7 @@ static void drawTextOnPath_handler(SkPipeReader& reader, uint32_t packedVerb, Sk
}
static void drawTextBlob_handler(SkPipeReader& reader, uint32_t packedVerb, SkCanvas* canvas) {
- sk_sp<SkTextBlob> tb = SkTextBlob::MakeFromBuffer(reader);
+ sk_sp<SkTextBlob> tb = SkTextBlobPriv::MakeFromBuffer(reader);
SkScalar x = reader.readScalar();
SkScalar y = reader.readScalar();
canvas->drawTextBlob(tb, x, y, read_paint(reader));