accessors for RunBuffer as points or rsxforms

trying to reduce casts at call-sites

Bug: skia:
Change-Id: I7c74cfd89111f7a197cbb1d77b499e2adc193579
Reviewed-on: https://skia-review.googlesource.com/c/180363
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Mike Reed <reed@google.com>
diff --git a/gm/pdf_never_embed.cpp b/gm/pdf_never_embed.cpp
index e8e1f71..583ff3e 100644
--- a/gm/pdf_never_embed.cpp
+++ b/gm/pdf_never_embed.cpp
@@ -20,7 +20,7 @@
     SkTextBlobBuilder builder;
     auto rec = builder.allocRunPos(font, count);
     font.textToGlyphs(text, strlen(text), kUTF8_SkTextEncoding, rec.glyphs, count);
-    font.getPos(rec.glyphs, count, (SkPoint*)rec.pos);
+    font.getPos(rec.glyphs, count, rec.points());
     canvas->drawTextBlob(builder.make(), x, y, paint);
 }
 
diff --git a/gm/skbug_257.cpp b/gm/skbug_257.cpp
index 483d013..49f06dc 100644
--- a/gm/skbug_257.cpp
+++ b/gm/skbug_257.cpp
@@ -36,7 +36,7 @@
     SkTextBlobBuilder builder;
     auto rec = builder.allocRunPos(font, count);
     font.textToGlyphs(text, strlen(text), kUTF8_SkTextEncoding, rec.glyphs, count);
-    font.getPos(rec.glyphs, count, (SkPoint*)rec.pos, {x, y});
+    font.getPos(rec.glyphs, count, rec.points(), {x, y});
     canvas->drawTextBlob(builder.make(), 0, 0, paint);
 }
 
diff --git a/gm/typeface.cpp b/gm/typeface.cpp
index 0edeea0..ef0020a 100644
--- a/gm/typeface.cpp
+++ b/gm/typeface.cpp
@@ -67,8 +67,8 @@
     SkTextBlobBuilder builder;
     auto rec = builder.allocRunPos(font, glyphCount);
     memcpy(rec.glyphs, glyphs, glyphCount * sizeof(SkGlyphID));
-    getGlyphPositions(font, glyphs, glyphCount, x, y, (SkPoint*)rec.pos);
-    applyKerning((SkPoint*)rec.pos, adjustments, glyphCount, font);
+    getGlyphPositions(font, glyphs, glyphCount, x, y, rec.points());
+    applyKerning(rec.points(), adjustments, glyphCount, font);
 
     canvas->drawTextBlob(builder.make(), 0, 0, paint);
 }
diff --git a/include/core/SkTextBlob.h b/include/core/SkTextBlob.h
index 8a3129b..0e9dd58 100644
--- a/include/core/SkTextBlob.h
+++ b/include/core/SkTextBlob.h
@@ -267,6 +267,9 @@
         SkScalar*  pos;      //!< storage for positions in run
         char*      utf8text; //!< reserved for future use
         uint32_t*  clusters; //!< reserved for future use
+
+        SkPoint*    points() const { return reinterpret_cast<SkPoint*>(pos); }
+        SkRSXform*  xforms() const { return reinterpret_cast<SkRSXform*>(pos); }
     };
 
     /** Returns run with storage for glyphs. Caller must write count glyphs to
diff --git a/modules/skshaper/src/SkShaper.cpp b/modules/skshaper/src/SkShaper.cpp
index 35dafed..78f973c 100644
--- a/modules/skshaper/src/SkShaper.cpp
+++ b/modules/skshaper/src/SkShaper.cpp
@@ -15,7 +15,7 @@
     const auto& runBuffer = SkTextBlobBuilderPriv::AllocRunTextPos(&fBuilder, font, glyphCount,
                                                                    textCount, SkString());
     return { runBuffer.glyphs,
-             reinterpret_cast<SkPoint*>(runBuffer.pos),
+             runBuffer.points(),
              runBuffer.utf8text,
              runBuffer.clusters };
 }
diff --git a/src/core/SkTextBlob.cpp b/src/core/SkTextBlob.cpp
index 5697cd3..63949dd 100644
--- a/src/core/SkTextBlob.cpp
+++ b/src/core/SkTextBlob.cpp
@@ -335,13 +335,13 @@
         bounds.setLTRB(minX, 0, maxX, 0);
     } break;
     case SkTextBlob::kFull_Positioning: {
-        const SkPoint* glyphPosPts = reinterpret_cast<const SkPoint*>(run.posBuffer());
+        const SkPoint* glyphPosPts = run.pointBuffer();
         SkASSERT((void*)(glyphPosPts + run.glyphCount()) <= SkTextBlob::RunRecord::Next(&run));
 
         bounds.setBounds(glyphPosPts, run.glyphCount());
     } break;
     case SkTextBlob::kRSXform_Positioning: {
-        const SkRSXform* xform = reinterpret_cast<const SkRSXform*>(run.posBuffer());
+        const SkRSXform* xform = run.xformBuffer();
         SkASSERT((void*)(xform + run.glyphCount()) <= SkTextBlob::RunRecord::Next(&run));
         bounds = map_quad_to_rect(xform[0], fontBounds);
         for (unsigned i = 1; i < run.glyphCount(); ++i) {
@@ -834,7 +834,7 @@
     SkTextBlobBuilder builder;
     auto buffer = builder.allocRunPos(font, count);
     font.textToGlyphs(text, byteLength, encoding, buffer.glyphs, count);
-    font.getPos(buffer.glyphs, count, reinterpret_cast<SkPoint*>(buffer.pos), {0, 0});
+    font.getPos(buffer.glyphs, count, buffer.points(), {0, 0});
     return builder.make();
 }
 
@@ -845,7 +845,7 @@
     SkTextBlobBuilder builder;
     auto buffer = builder.allocRunPos(font, count);
     font.textToGlyphs(text, byteLength, encoding, buffer.glyphs, count);
-    memcpy(buffer.pos, pos, count * sizeof(SkPoint));
+    memcpy(buffer.points(), pos, count * sizeof(SkPoint));
     return builder.make();
 }
 
@@ -867,7 +867,7 @@
     SkTextBlobBuilder builder;
     auto buffer = builder.allocRunRSXform(font, count);
     font.textToGlyphs(text, byteLength, encoding, buffer.glyphs, count);
-    memcpy(buffer.pos, xform, count * sizeof(SkRSXform));
+    memcpy(buffer.xforms(), xform, count * sizeof(SkRSXform));
     return builder.make();
 }
 
diff --git a/src/core/SkTextBlobPriv.h b/src/core/SkTextBlobPriv.h
index 499086d..5cb69b9 100644
--- a/src/core/SkTextBlobPriv.h
+++ b/src/core/SkTextBlobPriv.h
@@ -119,12 +119,25 @@
         return reinterpret_cast<uint16_t*>(const_cast<RunRecord*>(this) + 1);
     }
 
+    // can be aliased with pointBuffer() or xformBuffer()
     SkScalar* posBuffer() const {
         // Position scalars follow the (aligned) glyph buffer.
         return reinterpret_cast<SkScalar*>(reinterpret_cast<uint8_t*>(this->glyphBuffer()) +
                                            SkAlign4(fCount * sizeof(uint16_t)));
     }
 
+    // alias for posBuffer()
+    SkPoint* pointBuffer() const {
+        SkASSERT(this->positioning() == (GlyphPositioning)2);
+        return reinterpret_cast<SkPoint*>(this->posBuffer());
+    }
+
+    // alias for posBuffer()
+    SkRSXform* xformBuffer() const {
+        SkASSERT(this->positioning() == (GlyphPositioning)3);
+        return reinterpret_cast<SkRSXform*>(this->posBuffer());
+    }
+
     uint32_t textSize() const { return isExtended() ? *this->textSizePtr() : 0; }
 
     uint32_t* clusterBuffer() const {
@@ -213,6 +226,14 @@
         SkASSERT(!this->done());
         return fCurrentRun->posBuffer();
     }
+    // alias for pos()
+    const SkPoint* points() const {
+        return fCurrentRun->pointBuffer();
+    }
+    // alias for pos()
+    const SkRSXform* xforms() const {
+        return fCurrentRun->xformBuffer();
+    }
     const SkPoint& offset() const {
         SkASSERT(!this->done());
         return fCurrentRun->offset();