Allow filtering RSXForm text in viewer.

Prior to this change Viewer would crash in debug or act quite strangely
in release when attempting to filter any RSXForm blobs. This adds the
ability to allocate an RSXForm run and directly query the number of
positioning scalers per glyph it contains.

Change-Id: I90e118102a0f4d535e97026eecad9ac2f70e448f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/367957
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp
index 9c2e6e6..2b54be1 100644
--- a/tools/viewer/Viewer.cpp
+++ b/tools/viewer/Viewer.cpp
@@ -1285,6 +1285,9 @@
                 : it.positioning() == SkTextBlobRunIterator::kFull_Positioning
                     ? SkTextBlobBuilderPriv::AllocRunTextPos(&builder, font,
                         it.glyphCount(), it.textSize(), SkString())
+                : it.positioning() == SkTextBlobRunIterator::kRSXform_Positioning
+                    ? SkTextBlobBuilderPriv::AllocRunRSXForm(&builder, font,
+                        it.glyphCount(), it.textSize(), SkString())
                 : (SkASSERT_RELEASE(false), SkTextBlobBuilder::RunBuffer());
             uint32_t glyphCount = it.glyphCount();
             if (it.glyphs()) {
@@ -1293,8 +1296,8 @@
             }
             if (it.pos()) {
                 size_t posSize = sizeof(decltype(*it.pos()));
-                uint8_t positioning = it.positioning();
-                memcpy(runBuffer.pos, it.pos(), glyphCount * positioning * posSize);
+                unsigned posPerGlyph = it.scalarsPerGlyph();
+                memcpy(runBuffer.pos, it.pos(), glyphCount * posPerGlyph * posSize);
             }
             if (it.text()) {
                 size_t textSize = sizeof(decltype(*it.text()));