Hide SkTextBlob::GlyphPositioning from public API
Make private, add corresponding SkTextBlobRunIterator enum. Also move SkTextBlobRunIterator to SkTextBlobPriv.h. Change-Id: If3e0beabb0e8484b1ac73c6fc0827e920ca1f93b Reviewed-on: https://skia-review.googlesource.com/142501 Commit-Queue: Florin Malita <fmalita@chromium.org> Reviewed-by: Mike Reed <reed@google.com> Reviewed-by: Herb Derby <herb@google.com> Reviewed-by: Cary Clark <caryclark@google.com>
This commit is contained in:
parent
504dd052b9
commit
ab54e7394d
@ -36,12 +36,6 @@ public:
|
||||
static sk_sp<SkTextBlob> MakeAsDrawText(
|
||||
const void* text, size_t byteLength, const SkPaint& paint);
|
||||
|
||||
enum GlyphPositioning : uint8_t {
|
||||
kDefault_Positioning = 0, // Default glyph advances -- zero scalars per glyph.
|
||||
kHorizontal_Positioning = 1, // Horizontal positioning -- one scalar per glyph.
|
||||
kFull_Positioning = 2 // Point positioning -- two scalars per glyph.
|
||||
};
|
||||
|
||||
/**
|
||||
* Similar to serialize above, but writes directly into |memory|. Returns bytes written or 0u
|
||||
* if serialization failed due to insufficient size.
|
||||
@ -57,6 +51,8 @@ private:
|
||||
friend class SkNVRefCnt<SkTextBlob>;
|
||||
class RunRecord;
|
||||
|
||||
enum GlyphPositioning : uint8_t;
|
||||
|
||||
explicit SkTextBlob(const SkRect& bounds);
|
||||
|
||||
~SkTextBlob();
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include "SkShader.h"
|
||||
#include "SkSpecialImage.h"
|
||||
#include "SkTLazy.h"
|
||||
#include "SkTextBlobRunIterator.h"
|
||||
#include "SkTextBlobPriv.h"
|
||||
#include "SkTextToPathIter.h"
|
||||
#include "SkTo.h"
|
||||
#include "SkUtils.h"
|
||||
@ -153,7 +153,7 @@ void SkBaseDevice::drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
|
||||
it.applyFontToPaint(&runPaint);
|
||||
|
||||
switch (it.positioning()) {
|
||||
case SkTextBlob::kDefault_Positioning: {
|
||||
case SkTextBlobRunIterator::kDefault_Positioning: {
|
||||
auto origin = SkPoint::Make(x + offset.x(), y + offset.y());
|
||||
SkGlyphRunBuilder builder;
|
||||
builder.drawText(runPaint, (const char*) it.glyphs(), textLen, origin);
|
||||
@ -161,16 +161,14 @@ void SkBaseDevice::drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
|
||||
glyphRunList.temporaryShuntToDrawPosText(this, SkPoint::Make(0, 0));
|
||||
}
|
||||
break;
|
||||
case SkTextBlob::kHorizontal_Positioning:
|
||||
case SkTextBlobRunIterator::kHorizontal_Positioning:
|
||||
this->drawPosText(it.glyphs(), textLen, it.pos(), 1,
|
||||
SkPoint::Make(x, y + offset.y()), runPaint);
|
||||
break;
|
||||
case SkTextBlob::kFull_Positioning:
|
||||
case SkTextBlobRunIterator::kFull_Positioning:
|
||||
this->drawPosText(it.glyphs(), textLen, it.pos(), 2,
|
||||
SkPoint::Make(x, y), runPaint);
|
||||
break;
|
||||
default:
|
||||
SK_ABORT("unhandled positioning mode");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "SkRasterClip.h"
|
||||
#include "SkStrikeCache.h"
|
||||
#include "SkTextBlob.h"
|
||||
#include "SkTextBlobRunIterator.h"
|
||||
#include "SkTextBlobPriv.h"
|
||||
#include "SkTo.h"
|
||||
#include "SkUtils.h"
|
||||
|
||||
@ -503,14 +503,14 @@ void SkGlyphRunBuilder::drawTextBlob(const SkPaint& paint, const SkTextBlob& blo
|
||||
|
||||
size_t uniqueGlyphIDsSize = 0;
|
||||
switch (it.positioning()) {
|
||||
case SkTextBlob::kDefault_Positioning: {
|
||||
case SkTextBlobRunIterator::kDefault_Positioning: {
|
||||
uniqueGlyphIDsSize = this->simplifyDrawText(
|
||||
runPaint, glyphIDs, offset,
|
||||
currentDenseIndices, currentUniqueGlyphIDs, currentPositions,
|
||||
text, clusters);
|
||||
}
|
||||
break;
|
||||
case SkTextBlob::kHorizontal_Positioning: {
|
||||
case SkTextBlobRunIterator::kHorizontal_Positioning: {
|
||||
auto constY = offset.y();
|
||||
uniqueGlyphIDsSize = this->simplifyDrawPosTextH(
|
||||
runPaint, glyphIDs, it.pos(), constY,
|
||||
@ -518,14 +518,12 @@ void SkGlyphRunBuilder::drawTextBlob(const SkPaint& paint, const SkTextBlob& blo
|
||||
text, clusters);
|
||||
}
|
||||
break;
|
||||
case SkTextBlob::kFull_Positioning:
|
||||
case SkTextBlobRunIterator::kFull_Positioning:
|
||||
uniqueGlyphIDsSize = this->simplifyDrawPosText(
|
||||
runPaint, glyphIDs, (const SkPoint*)it.pos(),
|
||||
currentDenseIndices, currentUniqueGlyphIDs, currentPositions,
|
||||
text, clusters);
|
||||
break;
|
||||
default:
|
||||
SK_ABORT("unhandled positioning mode");
|
||||
}
|
||||
|
||||
currentDenseIndices += runSize;
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include "SkPoint.h"
|
||||
#include "SkSurfaceProps.h"
|
||||
#include "SkTemplates.h"
|
||||
#include "SkTextBlob.h"
|
||||
#include "SkTextBlobPriv.h"
|
||||
#include "SkTypes.h"
|
||||
|
||||
class SkBaseDevice;
|
||||
@ -203,7 +203,9 @@ public:
|
||||
const SkScalar* pos() const { return (const SkScalar*)fList[fIndex].positions().data(); }
|
||||
const SkPoint& offset() const { return fZero; }
|
||||
void applyFontToPaint(SkPaint* paint) const { *paint = fList[fIndex].paint(); }
|
||||
SkTextBlob::GlyphPositioning positioning() const { return SkTextBlob::kFull_Positioning; }
|
||||
SkTextBlobRunIterator::GlyphPositioning positioning() const {
|
||||
return SkTextBlobRunIterator::kFull_Positioning;
|
||||
}
|
||||
const uint32_t* clusters() const { return fList[fIndex].clusters().data(); }
|
||||
uint32_t textSize() const { return fList[fIndex].text().size(); }
|
||||
const char* text() const { return fList[fIndex].text().data(); }
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include "SkRSXform.h"
|
||||
#include "SkStrikeCache.h"
|
||||
#include "SkTextBlob.h"
|
||||
#include "SkTextBlobRunIterator.h"
|
||||
#include "SkTextBlobPriv.h"
|
||||
#include "SkTo.h"
|
||||
|
||||
namespace {
|
||||
@ -154,20 +154,17 @@ void SkOverdrawCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScal
|
||||
const SkPoint& offset = it.offset();
|
||||
it.applyFontToPaint(&runPaint);
|
||||
switch (it.positioning()) {
|
||||
case SkTextBlob::kDefault_Positioning:
|
||||
case SkTextBlobRunIterator::kDefault_Positioning:
|
||||
this->onDrawText(it.glyphs(), textLen, x + offset.x(), y + offset.y(), runPaint);
|
||||
break;
|
||||
case SkTextBlob::kHorizontal_Positioning:
|
||||
case SkTextBlobRunIterator::kHorizontal_Positioning:
|
||||
this->drawPosTextCommon(it.glyphs(), textLen, it.pos(), 1,
|
||||
SkPoint::Make(x, y + offset.y()), runPaint);
|
||||
break;
|
||||
case SkTextBlob::kFull_Positioning:
|
||||
case SkTextBlobRunIterator::kFull_Positioning:
|
||||
this->drawPosTextCommon(it.glyphs(), textLen, it.pos(), 2, SkPoint::Make(x, y),
|
||||
runPaint);
|
||||
break;
|
||||
default:
|
||||
SkASSERT(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include "SkSurfacePriv.h"
|
||||
#include "SkTLazy.h"
|
||||
#include "SkTextBlob.h"
|
||||
#include "SkTextBlobRunIterator.h"
|
||||
#include "SkTextBlobPriv.h"
|
||||
#include "SkTextFormatParams.h"
|
||||
#include "SkTextToPathIter.h"
|
||||
#include "SkTo.h"
|
||||
@ -1095,15 +1095,15 @@ int SkPaint::getTextBlobIntercepts(const SkTextBlob* blob, const SkScalar bounds
|
||||
SkScalar* runIntervals = intervals ? intervals + count : nullptr;
|
||||
|
||||
switch (it.positioning()) {
|
||||
case SkTextBlob::kDefault_Positioning:
|
||||
case SkTextBlobRunIterator::kDefault_Positioning:
|
||||
count += runPaint.getTextIntercepts(it.glyphs(), runByteCount, it.offset().x(),
|
||||
it.offset().y(), bounds, runIntervals);
|
||||
break;
|
||||
case SkTextBlob::kHorizontal_Positioning:
|
||||
case SkTextBlobRunIterator::kHorizontal_Positioning:
|
||||
count += runPaint.getPosTextHIntercepts(it.glyphs(), runByteCount, it.pos(),
|
||||
it.offset().y(), bounds, runIntervals);
|
||||
break;
|
||||
case SkTextBlob::kFull_Positioning:
|
||||
case SkTextBlobRunIterator::kFull_Positioning:
|
||||
count += runPaint.getPosTextIntercepts(it.glyphs(), runByteCount,
|
||||
reinterpret_cast<const SkPoint*>(it.pos()),
|
||||
bounds, runIntervals);
|
||||
|
@ -267,7 +267,7 @@ private:
|
||||
FAIL_AND_RETURN
|
||||
}
|
||||
|
||||
if (it.positioning() == SkTextBlob::kDefault_Positioning) {
|
||||
if (it.positioning() == SkTextBlobRunIterator::kDefault_Positioning) {
|
||||
// Default positioning needs advances. Can't do that.
|
||||
TRACE_EVENT0("skia", "kDefault_Positioning");
|
||||
FAIL_AND_RETURN
|
||||
@ -291,13 +291,13 @@ private:
|
||||
SkSTArenaAlloc<120> arena;
|
||||
SkFindAndPlaceGlyph::MapperInterface* mapper = nullptr;
|
||||
switch (it.positioning()) {
|
||||
case SkTextBlob::kHorizontal_Positioning:
|
||||
case SkTextBlobRunIterator::kHorizontal_Positioning:
|
||||
posFn = [](int index, const SkScalar* pos) { return SkPoint{pos[index], 0}; };
|
||||
mapper = SkFindAndPlaceGlyph::CreateMapper(
|
||||
runMatrix, SkPoint::Make(position.x(), position.y() + it.offset().y()), 1,
|
||||
&arena);
|
||||
break;
|
||||
case SkTextBlob::kFull_Positioning:
|
||||
case SkTextBlobRunIterator::kFull_Positioning:
|
||||
posFn = [](int index, const SkScalar* pos) {
|
||||
return SkPoint{pos[2 * index], pos[2 * index + 1]};
|
||||
};
|
||||
|
@ -5,7 +5,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SkTextBlobRunIterator.h"
|
||||
#include "SkTextBlob.h"
|
||||
|
||||
#include "SkGlyphRun.h"
|
||||
#include "SkPaintPriv.h"
|
||||
@ -333,7 +333,7 @@ namespace {
|
||||
union PositioningAndExtended {
|
||||
int32_t intValue;
|
||||
struct {
|
||||
SkTextBlob::GlyphPositioning positioning;
|
||||
uint8_t positioning;
|
||||
uint8_t extended;
|
||||
uint16_t padding;
|
||||
};
|
||||
@ -343,6 +343,12 @@ static_assert(sizeof(PositioningAndExtended) == sizeof(int32_t), "");
|
||||
|
||||
} // namespace
|
||||
|
||||
enum SkTextBlob::GlyphPositioning : uint8_t {
|
||||
kDefault_Positioning = 0, // Default glyph advances -- zero scalars per glyph.
|
||||
kHorizontal_Positioning = 1, // Horizontal positioning -- one scalar per glyph.
|
||||
kFull_Positioning = 2 // Point positioning -- two scalars per glyph.
|
||||
};
|
||||
|
||||
unsigned SkTextBlob::ScalarsPerGlyph(GlyphPositioning pos) {
|
||||
// GlyphPositioning values are directly mapped to scalars-per-glyph.
|
||||
SkASSERT(pos <= 2);
|
||||
@ -400,9 +406,16 @@ const SkPoint& SkTextBlobRunIterator::offset() const {
|
||||
return fCurrentRun->offset();
|
||||
}
|
||||
|
||||
SkTextBlob::GlyphPositioning SkTextBlobRunIterator::positioning() const {
|
||||
SkTextBlobRunIterator::GlyphPositioning SkTextBlobRunIterator::positioning() const {
|
||||
SkASSERT(!this->done());
|
||||
return fCurrentRun->positioning();
|
||||
static_assert(static_cast<GlyphPositioning>(SkTextBlob::kDefault_Positioning) ==
|
||||
kDefault_Positioning, "");
|
||||
static_assert(static_cast<GlyphPositioning>(SkTextBlob::kHorizontal_Positioning) ==
|
||||
kHorizontal_Positioning, "");
|
||||
static_assert(static_cast<GlyphPositioning>(SkTextBlob::kFull_Positioning) ==
|
||||
kFull_Positioning, "");
|
||||
|
||||
return SkTo<GlyphPositioning>(fCurrentRun->positioning());
|
||||
}
|
||||
|
||||
void SkTextBlobRunIterator::applyFontToPaint(SkPaint* paint) const {
|
||||
@ -792,7 +805,8 @@ void SkTextBlobPriv::Flatten(const SkTextBlob& blob, SkWriteBuffer& buffer) {
|
||||
buffer.writeByteArray(it.glyphs(), it.glyphCount() * sizeof(uint16_t));
|
||||
buffer.writeByteArray(it.pos(),
|
||||
it.glyphCount() * sizeof(SkScalar) *
|
||||
SkTextBlob::ScalarsPerGlyph(it.positioning()));
|
||||
SkTextBlob::ScalarsPerGlyph(
|
||||
SkTo<SkTextBlob::GlyphPositioning>(it.positioning())));
|
||||
if (pe.extended) {
|
||||
buffer.writeByteArray(it.clusters(), sizeof(uint32_t) * it.glyphCount());
|
||||
buffer.writeByteArray(it.text(), it.textSize());
|
||||
@ -820,7 +834,7 @@ sk_sp<SkTextBlob> SkTextBlobPriv::MakeFromBuffer(SkReadBuffer& reader) {
|
||||
|
||||
PositioningAndExtended pe;
|
||||
pe.intValue = reader.read32();
|
||||
SkTextBlob::GlyphPositioning pos = pe.positioning;
|
||||
const auto pos = SkTo<SkTextBlob::GlyphPositioning>(pe.positioning);
|
||||
if (glyphCount <= 0 || pos > SkTextBlob::kFull_Positioning) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -30,4 +30,41 @@ public:
|
||||
static sk_sp<SkTextBlob> MakeFromBuffer(SkReadBuffer&);
|
||||
};
|
||||
|
||||
/**
|
||||
* Iterate through all of the text runs of the text blob. For example:
|
||||
* for (SkTextBlobRunIterator it(blob); !it.done(); it.next()) {
|
||||
* .....
|
||||
* }
|
||||
*/
|
||||
class SkTextBlobRunIterator {
|
||||
public:
|
||||
SkTextBlobRunIterator(const SkTextBlob* blob);
|
||||
|
||||
enum GlyphPositioning : uint8_t {
|
||||
kDefault_Positioning = 0, // Default glyph advances -- zero scalars per glyph.
|
||||
kHorizontal_Positioning = 1, // Horizontal positioning -- one scalar per glyph.
|
||||
kFull_Positioning = 2 // Point positioning -- two scalars per glyph.
|
||||
};
|
||||
|
||||
bool done() const;
|
||||
void next();
|
||||
|
||||
uint32_t glyphCount() const;
|
||||
const uint16_t* glyphs() const;
|
||||
const SkScalar* pos() const;
|
||||
const SkPoint& offset() const;
|
||||
void applyFontToPaint(SkPaint*) const;
|
||||
GlyphPositioning positioning() const;
|
||||
uint32_t* clusters() const;
|
||||
uint32_t textSize() const;
|
||||
char* text() const;
|
||||
|
||||
bool isLCD() const;
|
||||
|
||||
private:
|
||||
const SkTextBlob::RunRecord* fCurrentRun;
|
||||
|
||||
SkDEBUGCODE(uint8_t* fStorageTop;)
|
||||
};
|
||||
|
||||
#endif // SkTextBlobPriv_DEFINED
|
||||
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#ifndef SkTextBlobRunIterator_DEFINED
|
||||
#define SkTextBlobRunIterator_DEFINED
|
||||
|
||||
#include "SkTextBlob.h"
|
||||
|
||||
/**
|
||||
* Iterate through all of the text runs of the text blob. For example:
|
||||
* for (SkTextBlobRunIterator it(blob); !it.done(); it.next()) {
|
||||
* .....
|
||||
* }
|
||||
*/
|
||||
class SkTextBlobRunIterator {
|
||||
public:
|
||||
SkTextBlobRunIterator(const SkTextBlob* blob);
|
||||
|
||||
bool done() const;
|
||||
void next();
|
||||
|
||||
uint32_t glyphCount() const;
|
||||
const uint16_t* glyphs() const;
|
||||
const SkScalar* pos() const;
|
||||
const SkPoint& offset() const;
|
||||
void applyFontToPaint(SkPaint*) const;
|
||||
SkTextBlob::GlyphPositioning positioning() const;
|
||||
uint32_t* clusters() const;
|
||||
uint32_t textSize() const;
|
||||
char* text() const;
|
||||
|
||||
bool isLCD() const;
|
||||
|
||||
private:
|
||||
const SkTextBlob::RunRecord* fCurrentRun;
|
||||
|
||||
SkDEBUGCODE(uint8_t* fStorageTop;)
|
||||
};
|
||||
|
||||
#endif // SkTextBlobRunIterator_DEFINED
|
@ -14,7 +14,6 @@
|
||||
#include "SkGlyphCache.h"
|
||||
#include "SkMaskFilterBase.h"
|
||||
#include "SkPaintPriv.h"
|
||||
#include "SkTextBlobRunIterator.h"
|
||||
#include "SkTextToPathIter.h"
|
||||
#include "ops/GrAtlasTextOp.h"
|
||||
#include <new>
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include "SkMessageBus.h"
|
||||
#include "SkRefCnt.h"
|
||||
#include "SkTArray.h"
|
||||
#include "SkTextBlobRunIterator.h"
|
||||
#include "SkTextBlobPriv.h"
|
||||
#include "SkTHash.h"
|
||||
|
||||
class GrTextBlobCache {
|
||||
|
@ -196,7 +196,7 @@ void GrTextContext::regenerateGlyphRunList(GrTextBlob* cacheBlob,
|
||||
}
|
||||
cacheBlob->setRunPaintFlags(run, runPaint.skPaint().getFlags());
|
||||
|
||||
SkASSERT(it.positioning() == SkTextBlob::kFull_Positioning);
|
||||
SkASSERT(it.positioning() == SkTextBlobRunIterator::kFull_Positioning);
|
||||
if (CanDrawAsDistanceFields(runPaint, viewMatrix, props,
|
||||
shaderCaps.supportsDistanceFieldText(), fOptions)) {
|
||||
this->drawDFPosText(cacheBlob, run, glyphCache, props, runPaint,
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "GrDistanceFieldAdjustTable.h"
|
||||
#include "GrGeometryProcessor.h"
|
||||
#include "GrTextUtils.h"
|
||||
#include "SkTextBlobRunIterator.h"
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
#include "GrDrawOpTest.h"
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "SkGlyphCache.h"
|
||||
#include "SkGr.h"
|
||||
#include "SkPaint.h"
|
||||
#include "SkTextBlobRunIterator.h"
|
||||
|
||||
void GrTextUtils::Paint::initFilteredColor() {
|
||||
GrColor4f filteredColor = SkColorToUnpremulGrColor4f(fPaint->getColor(), *fDstColorSpaceInfo);
|
||||
|
@ -43,7 +43,7 @@
|
||||
#include "SkString.h"
|
||||
#include "SkSurface.h"
|
||||
#include "SkTemplates.h"
|
||||
#include "SkTextBlobRunIterator.h"
|
||||
#include "SkTextBlob.h"
|
||||
#include "SkTextFormatParams.h"
|
||||
#include "SkTo.h"
|
||||
#include "SkUtils.h"
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include "SkSinglyLinkedList.h"
|
||||
#include "SkStream.h"
|
||||
#include "SkTDArray.h"
|
||||
#include "SkTextBlob.h"
|
||||
#include "SkTextBlobPriv.h"
|
||||
#include "SkKeyedImage.h"
|
||||
|
||||
class SkGlyphRunList;
|
||||
@ -241,7 +241,6 @@ private:
|
||||
|
||||
int getFontResourceIndex(SkTypeface* typeface, uint16_t glyphID);
|
||||
|
||||
|
||||
void internalDrawGlyphRun(const SkGlyphRun& glyphRun, SkPoint offset);
|
||||
|
||||
void internalDrawPaint(const SkPaint& paint, ContentEntry* contentEntry);
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "SkPaint.h"
|
||||
#include "SkPoint.h"
|
||||
#include "SkSerialProcs.h"
|
||||
#include "SkTextBlobRunIterator.h"
|
||||
#include "SkTextBlobPriv.h"
|
||||
#include "SkTo.h"
|
||||
#include "SkTypeface.h"
|
||||
|
||||
@ -26,74 +26,74 @@ public:
|
||||
RunBuilderTest(reporter, builder, nullptr, 0, nullptr, 0);
|
||||
|
||||
RunDef set1[] = {
|
||||
{ 128, SkTextBlob::kDefault_Positioning, 100, 100 },
|
||||
{ 128, SkTextBlobRunIterator::kDefault_Positioning, 100, 100 },
|
||||
};
|
||||
RunBuilderTest(reporter, builder, set1, SK_ARRAY_COUNT(set1), set1, SK_ARRAY_COUNT(set1));
|
||||
|
||||
RunDef set2[] = {
|
||||
{ 128, SkTextBlob::kHorizontal_Positioning, 100, 100 },
|
||||
{ 128, SkTextBlobRunIterator::kHorizontal_Positioning, 100, 100 },
|
||||
};
|
||||
RunBuilderTest(reporter, builder, set2, SK_ARRAY_COUNT(set2), set2, SK_ARRAY_COUNT(set2));
|
||||
|
||||
RunDef set3[] = {
|
||||
{ 128, SkTextBlob::kFull_Positioning, 100, 100 },
|
||||
{ 128, SkTextBlobRunIterator::kFull_Positioning, 100, 100 },
|
||||
};
|
||||
RunBuilderTest(reporter, builder, set3, SK_ARRAY_COUNT(set3), set3, SK_ARRAY_COUNT(set3));
|
||||
|
||||
RunDef set4[] = {
|
||||
{ 128, SkTextBlob::kDefault_Positioning, 100, 150 },
|
||||
{ 128, SkTextBlob::kDefault_Positioning, 100, 150 },
|
||||
{ 128, SkTextBlob::kDefault_Positioning, 100, 150 },
|
||||
{ 128, SkTextBlobRunIterator::kDefault_Positioning, 100, 150 },
|
||||
{ 128, SkTextBlobRunIterator::kDefault_Positioning, 100, 150 },
|
||||
{ 128, SkTextBlobRunIterator::kDefault_Positioning, 100, 150 },
|
||||
};
|
||||
RunBuilderTest(reporter, builder, set4, SK_ARRAY_COUNT(set4), set4, SK_ARRAY_COUNT(set4));
|
||||
|
||||
RunDef set5[] = {
|
||||
{ 128, SkTextBlob::kHorizontal_Positioning, 100, 150 },
|
||||
{ 128, SkTextBlob::kHorizontal_Positioning, 200, 150 },
|
||||
{ 128, SkTextBlob::kHorizontal_Positioning, 300, 250 },
|
||||
{ 128, SkTextBlobRunIterator::kHorizontal_Positioning, 100, 150 },
|
||||
{ 128, SkTextBlobRunIterator::kHorizontal_Positioning, 200, 150 },
|
||||
{ 128, SkTextBlobRunIterator::kHorizontal_Positioning, 300, 250 },
|
||||
};
|
||||
RunDef mergedSet5[] = {
|
||||
{ 256, SkTextBlob::kHorizontal_Positioning, 0, 150 },
|
||||
{ 128, SkTextBlob::kHorizontal_Positioning, 0, 250 },
|
||||
{ 256, SkTextBlobRunIterator::kHorizontal_Positioning, 0, 150 },
|
||||
{ 128, SkTextBlobRunIterator::kHorizontal_Positioning, 0, 250 },
|
||||
};
|
||||
RunBuilderTest(reporter, builder, set5, SK_ARRAY_COUNT(set5), mergedSet5,
|
||||
SK_ARRAY_COUNT(mergedSet5));
|
||||
|
||||
RunDef set6[] = {
|
||||
{ 128, SkTextBlob::kFull_Positioning, 100, 100 },
|
||||
{ 128, SkTextBlob::kFull_Positioning, 200, 200 },
|
||||
{ 128, SkTextBlob::kFull_Positioning, 300, 300 },
|
||||
{ 128, SkTextBlobRunIterator::kFull_Positioning, 100, 100 },
|
||||
{ 128, SkTextBlobRunIterator::kFull_Positioning, 200, 200 },
|
||||
{ 128, SkTextBlobRunIterator::kFull_Positioning, 300, 300 },
|
||||
};
|
||||
RunDef mergedSet6[] = {
|
||||
{ 384, SkTextBlob::kFull_Positioning, 0, 0 },
|
||||
{ 384, SkTextBlobRunIterator::kFull_Positioning, 0, 0 },
|
||||
};
|
||||
RunBuilderTest(reporter, builder, set6, SK_ARRAY_COUNT(set6), mergedSet6,
|
||||
SK_ARRAY_COUNT(mergedSet6));
|
||||
|
||||
RunDef set7[] = {
|
||||
{ 128, SkTextBlob::kDefault_Positioning, 100, 150 },
|
||||
{ 128, SkTextBlob::kDefault_Positioning, 100, 150 },
|
||||
{ 128, SkTextBlob::kHorizontal_Positioning, 100, 150 },
|
||||
{ 128, SkTextBlob::kHorizontal_Positioning, 200, 150 },
|
||||
{ 128, SkTextBlob::kFull_Positioning, 400, 350 },
|
||||
{ 128, SkTextBlob::kFull_Positioning, 400, 350 },
|
||||
{ 128, SkTextBlob::kDefault_Positioning, 100, 450 },
|
||||
{ 128, SkTextBlob::kDefault_Positioning, 100, 450 },
|
||||
{ 128, SkTextBlob::kHorizontal_Positioning, 100, 550 },
|
||||
{ 128, SkTextBlob::kHorizontal_Positioning, 200, 650 },
|
||||
{ 128, SkTextBlob::kFull_Positioning, 400, 750 },
|
||||
{ 128, SkTextBlob::kFull_Positioning, 400, 850 },
|
||||
{ 128, SkTextBlobRunIterator::kDefault_Positioning, 100, 150 },
|
||||
{ 128, SkTextBlobRunIterator::kDefault_Positioning, 100, 150 },
|
||||
{ 128, SkTextBlobRunIterator::kHorizontal_Positioning, 100, 150 },
|
||||
{ 128, SkTextBlobRunIterator::kHorizontal_Positioning, 200, 150 },
|
||||
{ 128, SkTextBlobRunIterator::kFull_Positioning, 400, 350 },
|
||||
{ 128, SkTextBlobRunIterator::kFull_Positioning, 400, 350 },
|
||||
{ 128, SkTextBlobRunIterator::kDefault_Positioning, 100, 450 },
|
||||
{ 128, SkTextBlobRunIterator::kDefault_Positioning, 100, 450 },
|
||||
{ 128, SkTextBlobRunIterator::kHorizontal_Positioning, 100, 550 },
|
||||
{ 128, SkTextBlobRunIterator::kHorizontal_Positioning, 200, 650 },
|
||||
{ 128, SkTextBlobRunIterator::kFull_Positioning, 400, 750 },
|
||||
{ 128, SkTextBlobRunIterator::kFull_Positioning, 400, 850 },
|
||||
};
|
||||
RunDef mergedSet7[] = {
|
||||
{ 128, SkTextBlob::kDefault_Positioning, 100, 150 },
|
||||
{ 128, SkTextBlob::kDefault_Positioning, 100, 150 },
|
||||
{ 256, SkTextBlob::kHorizontal_Positioning, 0, 150 },
|
||||
{ 256, SkTextBlob::kFull_Positioning, 0, 0 },
|
||||
{ 128, SkTextBlob::kDefault_Positioning, 100, 450 },
|
||||
{ 128, SkTextBlob::kDefault_Positioning, 100, 450 },
|
||||
{ 128, SkTextBlob::kHorizontal_Positioning, 0, 550 },
|
||||
{ 128, SkTextBlob::kHorizontal_Positioning, 0, 650 },
|
||||
{ 256, SkTextBlob::kFull_Positioning, 0, 0 },
|
||||
{ 128, SkTextBlobRunIterator::kDefault_Positioning, 100, 150 },
|
||||
{ 128, SkTextBlobRunIterator::kDefault_Positioning, 100, 150 },
|
||||
{ 256, SkTextBlobRunIterator::kHorizontal_Positioning, 0, 150 },
|
||||
{ 256, SkTextBlobRunIterator::kFull_Positioning, 0, 0 },
|
||||
{ 128, SkTextBlobRunIterator::kDefault_Positioning, 100, 450 },
|
||||
{ 128, SkTextBlobRunIterator::kDefault_Positioning, 100, 450 },
|
||||
{ 128, SkTextBlobRunIterator::kHorizontal_Positioning, 0, 550 },
|
||||
{ 128, SkTextBlobRunIterator::kHorizontal_Positioning, 0, 650 },
|
||||
{ 256, SkTextBlobRunIterator::kFull_Positioning, 0, 0 },
|
||||
};
|
||||
RunBuilderTest(reporter, builder, set7, SK_ARRAY_COUNT(set7), mergedSet7,
|
||||
SK_ARRAY_COUNT(mergedSet7));
|
||||
@ -210,14 +210,16 @@ public:
|
||||
REPORTER_ASSERT(reporter, defaultPaint.isLinearText() != font.isLinearText());
|
||||
REPORTER_ASSERT(reporter, defaultPaint.isSubpixelText() != font.isSubpixelText());
|
||||
REPORTER_ASSERT(reporter, defaultPaint.isLCDRenderText() != font.isLCDRenderText());
|
||||
REPORTER_ASSERT(reporter, defaultPaint.isEmbeddedBitmapText() != font.isEmbeddedBitmapText());
|
||||
REPORTER_ASSERT(reporter,
|
||||
defaultPaint.isEmbeddedBitmapText() != font.isEmbeddedBitmapText());
|
||||
REPORTER_ASSERT(reporter, defaultPaint.isAutohinted() != font.isAutohinted());
|
||||
REPORTER_ASSERT(reporter, defaultPaint.isVerticalText() != font.isVerticalText());
|
||||
|
||||
SkTextBlobBuilder builder;
|
||||
AddRun(font, 1, SkTextBlob::kDefault_Positioning, SkPoint::Make(0, 0), builder);
|
||||
AddRun(font, 1, SkTextBlob::kHorizontal_Positioning, SkPoint::Make(0, 0), builder);
|
||||
AddRun(font, 1, SkTextBlob::kFull_Positioning, SkPoint::Make(0, 0), builder);
|
||||
AddRun(font, 1, SkTextBlobRunIterator::kDefault_Positioning, SkPoint::Make(0, 0), builder);
|
||||
AddRun(font, 1, SkTextBlobRunIterator::kHorizontal_Positioning, SkPoint::Make(0, 0),
|
||||
builder);
|
||||
AddRun(font, 1, SkTextBlobRunIterator::kFull_Positioning, SkPoint::Make(0, 0), builder);
|
||||
sk_sp<SkTextBlob> blob(builder.make());
|
||||
|
||||
SkTextBlobRunIterator it(blob.get());
|
||||
@ -248,7 +250,7 @@ public:
|
||||
private:
|
||||
struct RunDef {
|
||||
unsigned count;
|
||||
SkTextBlob::GlyphPositioning pos;
|
||||
SkTextBlobRunIterator::GlyphPositioning pos;
|
||||
SkScalar x, y;
|
||||
};
|
||||
|
||||
@ -278,18 +280,18 @@ private:
|
||||
REPORTER_ASSERT(reporter, !it.done());
|
||||
REPORTER_ASSERT(reporter, out[i].pos == it.positioning());
|
||||
REPORTER_ASSERT(reporter, out[i].count == it.glyphCount());
|
||||
if (SkTextBlob::kDefault_Positioning == out[i].pos) {
|
||||
if (SkTextBlobRunIterator::kDefault_Positioning == out[i].pos) {
|
||||
REPORTER_ASSERT(reporter, out[i].x == it.offset().x());
|
||||
REPORTER_ASSERT(reporter, out[i].y == it.offset().y());
|
||||
} else if (SkTextBlob::kHorizontal_Positioning == out[i].pos) {
|
||||
} else if (SkTextBlobRunIterator::kHorizontal_Positioning == out[i].pos) {
|
||||
REPORTER_ASSERT(reporter, out[i].y == it.offset().y());
|
||||
}
|
||||
|
||||
for (unsigned k = 0; k < it.glyphCount(); ++k) {
|
||||
REPORTER_ASSERT(reporter, k % 128 == it.glyphs()[k]);
|
||||
if (SkTextBlob::kHorizontal_Positioning == it.positioning()) {
|
||||
if (SkTextBlobRunIterator::kHorizontal_Positioning == it.positioning()) {
|
||||
REPORTER_ASSERT(reporter, SkIntToScalar(k % 128) == it.pos()[k]);
|
||||
} else if (SkTextBlob::kFull_Positioning == it.positioning()) {
|
||||
} else if (SkTextBlobRunIterator::kFull_Positioning == it.positioning()) {
|
||||
REPORTER_ASSERT(reporter, SkIntToScalar(k % 128) == it.pos()[k * 2]);
|
||||
REPORTER_ASSERT(reporter, -SkIntToScalar(k % 128) == it.pos()[k * 2 + 1]);
|
||||
}
|
||||
@ -301,18 +303,18 @@ private:
|
||||
REPORTER_ASSERT(reporter, it.done());
|
||||
}
|
||||
|
||||
static void AddRun(const SkPaint& font, int count, SkTextBlob::GlyphPositioning pos,
|
||||
static void AddRun(const SkPaint& font, int count, SkTextBlobRunIterator::GlyphPositioning pos,
|
||||
const SkPoint& offset, SkTextBlobBuilder& builder,
|
||||
const SkRect* bounds = nullptr) {
|
||||
switch (pos) {
|
||||
case SkTextBlob::kDefault_Positioning: {
|
||||
case SkTextBlobRunIterator::kDefault_Positioning: {
|
||||
const SkTextBlobBuilder::RunBuffer& rb = builder.allocRun(font, count, offset.x(),
|
||||
offset.y(), bounds);
|
||||
for (int i = 0; i < count; ++i) {
|
||||
rb.glyphs[i] = i;
|
||||
}
|
||||
} break;
|
||||
case SkTextBlob::kHorizontal_Positioning: {
|
||||
case SkTextBlobRunIterator::kHorizontal_Positioning: {
|
||||
const SkTextBlobBuilder::RunBuffer& rb = builder.allocRunPosH(font, count, offset.y(),
|
||||
bounds);
|
||||
for (int i = 0; i < count; ++i) {
|
||||
@ -320,7 +322,7 @@ private:
|
||||
rb.pos[i] = SkIntToScalar(i);
|
||||
}
|
||||
} break;
|
||||
case SkTextBlob::kFull_Positioning: {
|
||||
case SkTextBlobRunIterator::kFull_Positioning: {
|
||||
const SkTextBlobBuilder::RunBuffer& rb = builder.allocRunPos(font, count, bounds);
|
||||
for (int i = 0; i < count; ++i) {
|
||||
rb.glyphs[i] = i;
|
||||
@ -369,7 +371,7 @@ DEF_TEST(TextBlob_extended, reporter) {
|
||||
for (uint32_t i = 0; i < it.glyphCount(); ++i) {
|
||||
REPORTER_ASSERT(reporter, it.glyphs()[i] == glyphs[i]);
|
||||
}
|
||||
REPORTER_ASSERT(reporter, SkTextBlob::kDefault_Positioning == it.positioning());
|
||||
REPORTER_ASSERT(reporter, SkTextBlobRunIterator::kDefault_Positioning == it.positioning());
|
||||
REPORTER_ASSERT(reporter, (SkPoint{0.0f, 0.0f}) == it.offset());
|
||||
REPORTER_ASSERT(reporter, it.textSize() > 0);
|
||||
REPORTER_ASSERT(reporter, it.clusters());
|
||||
@ -475,7 +477,7 @@ DEF_TEST(TextBlob_MakeAsDrawText, reporter) {
|
||||
int runs = 0;
|
||||
for(SkTextBlobRunIterator it(blob.get()); !it.done(); it.next()) {
|
||||
REPORTER_ASSERT(reporter, it.glyphCount() == strlen(text));
|
||||
REPORTER_ASSERT(reporter, it.positioning() == SkTextBlob::kFull_Positioning);
|
||||
REPORTER_ASSERT(reporter, it.positioning() == SkTextBlobRunIterator::kFull_Positioning);
|
||||
runs += 1;
|
||||
}
|
||||
REPORTER_ASSERT(reporter, runs == 1);
|
||||
|
@ -21,8 +21,7 @@
|
||||
#include "SkPicture.h"
|
||||
#include "SkReadBuffer.h"
|
||||
#include "SkRectPriv.h"
|
||||
#include "SkTextBlob.h"
|
||||
#include "SkTextBlobRunIterator.h"
|
||||
#include "SkTextBlobPriv.h"
|
||||
#include "SkTHash.h"
|
||||
#include "SkTypeface.h"
|
||||
#include "SkWriteBuffer.h"
|
||||
@ -1950,19 +1949,19 @@ Json::Value SkDrawTextBlobCommand::toJSON(UrlDataManager& urlDataManager) const
|
||||
const uint16_t* iterGlyphs = iter.glyphs();
|
||||
for (uint32_t i = 0; i < iter.glyphCount(); i++) {
|
||||
switch (iter.positioning()) {
|
||||
case SkTextBlob::kFull_Positioning:
|
||||
case SkTextBlobRunIterator::kFull_Positioning:
|
||||
jsonPositions.append(MakeJsonPoint(iterPositions[i * 2],
|
||||
iterPositions[i * 2 + 1]));
|
||||
break;
|
||||
case SkTextBlob::kHorizontal_Positioning:
|
||||
case SkTextBlobRunIterator::kHorizontal_Positioning:
|
||||
jsonPositions.append(Json::Value(iterPositions[i]));
|
||||
break;
|
||||
case SkTextBlob::kDefault_Positioning:
|
||||
case SkTextBlobRunIterator::kDefault_Positioning:
|
||||
break;
|
||||
}
|
||||
jsonGlyphs.append(Json::Value(iterGlyphs[i]));
|
||||
}
|
||||
if (iter.positioning() != SkTextBlob::kDefault_Positioning) {
|
||||
if (iter.positioning() != SkTextBlobRunIterator::kDefault_Positioning) {
|
||||
run[SKDEBUGCANVAS_ATTRIBUTE_POSITIONS] = jsonPositions;
|
||||
}
|
||||
run[SKDEBUGCANVAS_ATTRIBUTE_GLYPHS] = jsonGlyphs;
|
||||
|
Loading…
Reference in New Issue
Block a user