Remove SkSpan class template deduction guides
This effectively reverts a80ce1a36d
,
and goes back to using SkMakeSpan (which works in C++14).
Change-Id: Iaa63c86b5acaadbdd60588b0a5c703820e810770
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/406938
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
543fd5f279
commit
ae87bf1e49
@ -32,7 +32,7 @@ public:
|
||||
|
||||
fPositions.append(fGlyphCount);
|
||||
fFont.getPos(fGlyphs.begin(), fGlyphCount, fPositions.begin());
|
||||
auto positions = SkSpan(fPositions.begin(), fGlyphCount);
|
||||
auto positions = SkMakeSpan(fPositions.begin(), fGlyphCount);
|
||||
|
||||
fLength = positions.back().x() - positions.front().x();
|
||||
fRadius = fLength / SK_FloatPI;
|
||||
|
@ -186,7 +186,7 @@ void SkParticleEffectParams::prepare(const skresources::ResourceProvider* resour
|
||||
for (int i = 0; i < uniformInfo->fUniformSlotCount; ++i) {
|
||||
uniformIDs.push_back(b.uniform32(skslUniformPtr, i * sizeof(int)).id);
|
||||
}
|
||||
SkSL::ProgramToSkVM(*program, *fn, &b, uniformIDs);
|
||||
SkSL::ProgramToSkVM(*program, *fn, &b, SkMakeSpan(uniformIDs));
|
||||
return b.done();
|
||||
};
|
||||
|
||||
|
@ -2292,10 +2292,10 @@ void SkCanvas::drawGlyphs(int count, const SkGlyphID* glyphs, const SkPoint* pos
|
||||
|
||||
SkGlyphRun glyphRun {
|
||||
font,
|
||||
SkSpan(positions, count),
|
||||
SkSpan(glyphs, count),
|
||||
SkSpan(utf8text, textByteCount),
|
||||
SkSpan(clusters, count),
|
||||
SkMakeSpan(positions, count),
|
||||
SkMakeSpan(glyphs, count),
|
||||
SkMakeSpan(utf8text, textByteCount),
|
||||
SkMakeSpan(clusters, count),
|
||||
SkSpan<SkVector>()
|
||||
};
|
||||
SkGlyphRunList glyphRunList {
|
||||
@ -2312,8 +2312,8 @@ void SkCanvas::drawGlyphs(int count, const SkGlyphID glyphs[], const SkPoint pos
|
||||
|
||||
SkGlyphRun glyphRun {
|
||||
font,
|
||||
SkSpan(positions, count),
|
||||
SkSpan(glyphs, count),
|
||||
SkMakeSpan(positions, count),
|
||||
SkMakeSpan(glyphs, count),
|
||||
SkSpan<const char>(),
|
||||
SkSpan<const uint32_t>(),
|
||||
SkSpan<SkVector>()
|
||||
@ -2330,12 +2330,13 @@ void SkCanvas::drawGlyphs(int count, const SkGlyphID glyphs[], const SkRSXform x
|
||||
SkPoint origin, const SkFont& font, const SkPaint& paint) {
|
||||
if (count <= 0) { return; }
|
||||
|
||||
auto [positions, rotateScales] = fScratchGlyphRunBuilder->convertRSXForm(SkSpan(xforms, count));
|
||||
auto [positions, rotateScales] =
|
||||
fScratchGlyphRunBuilder->convertRSXForm(SkMakeSpan(xforms, count));
|
||||
|
||||
SkGlyphRun glyphRun {
|
||||
font,
|
||||
positions,
|
||||
SkSpan(glyphs, count),
|
||||
SkMakeSpan(glyphs, count),
|
||||
SkSpan<const char>(),
|
||||
SkSpan<const uint32_t>(),
|
||||
rotateScales
|
||||
|
@ -226,7 +226,7 @@ SkScalar SkFont::measureText(const void* text, size_t length, SkTextEncoding enc
|
||||
|
||||
SkStrikeSpec strikeSpec = SkStrikeSpec::MakeCanonicalized(*this, paint);
|
||||
SkBulkGlyphMetrics metrics{strikeSpec};
|
||||
SkSpan<const SkGlyph*> glyphs = metrics.glyphs(SkSpan(glyphIDs, glyphCount));
|
||||
SkSpan<const SkGlyph*> glyphs = metrics.glyphs(SkMakeSpan(glyphIDs, glyphCount));
|
||||
|
||||
SkScalar width = 0;
|
||||
if (bounds) {
|
||||
@ -265,7 +265,7 @@ void SkFont::getWidthsBounds(const SkGlyphID glyphIDs[],
|
||||
const SkPaint* paint) const {
|
||||
SkStrikeSpec strikeSpec = SkStrikeSpec::MakeCanonicalized(*this, paint);
|
||||
SkBulkGlyphMetrics metrics{strikeSpec};
|
||||
SkSpan<const SkGlyph*> glyphs = metrics.glyphs(SkSpan(glyphIDs, count));
|
||||
SkSpan<const SkGlyph*> glyphs = metrics.glyphs(SkMakeSpan(glyphIDs, count));
|
||||
|
||||
SkScalar scale = strikeSpec.strikeToSourceRatio();
|
||||
|
||||
@ -288,7 +288,7 @@ void SkFont::getWidthsBounds(const SkGlyphID glyphIDs[],
|
||||
void SkFont::getPos(const SkGlyphID glyphIDs[], int count, SkPoint pos[], SkPoint origin) const {
|
||||
SkStrikeSpec strikeSpec = SkStrikeSpec::MakeCanonicalized(*this);
|
||||
SkBulkGlyphMetrics metrics{strikeSpec};
|
||||
SkSpan<const SkGlyph*> glyphs = metrics.glyphs(SkSpan(glyphIDs, count));
|
||||
SkSpan<const SkGlyph*> glyphs = metrics.glyphs(SkMakeSpan(glyphIDs, count));
|
||||
|
||||
SkPoint sum = origin;
|
||||
for (auto glyph : glyphs) {
|
||||
@ -302,7 +302,7 @@ void SkFont::getXPos(
|
||||
|
||||
SkStrikeSpec strikeSpec = SkStrikeSpec::MakeCanonicalized(*this);
|
||||
SkBulkGlyphMetrics metrics{strikeSpec};
|
||||
SkSpan<const SkGlyph*> glyphs = metrics.glyphs(SkSpan(glyphIDs, count));
|
||||
SkSpan<const SkGlyph*> glyphs = metrics.glyphs(SkMakeSpan(glyphIDs, count));
|
||||
|
||||
SkScalar loc = origin;
|
||||
SkScalar* cursor = xpos;
|
||||
@ -320,7 +320,7 @@ void SkFont::getPaths(const SkGlyphID glyphIDs[], int count,
|
||||
|
||||
SkStrikeSpec strikeSpec = SkStrikeSpec::MakeWithNoDevice(font);
|
||||
SkBulkGlyphMetricsAndPaths paths{strikeSpec};
|
||||
SkSpan<const SkGlyph*> glyphs = paths.glyphs(SkSpan(glyphIDs, count));
|
||||
SkSpan<const SkGlyph*> glyphs = paths.glyphs(SkMakeSpan(glyphIDs, count));
|
||||
|
||||
for (auto glyph : glyphs) {
|
||||
proc(glyph->path(), mx, ctx);
|
||||
|
@ -184,7 +184,7 @@ static SkSpan<const SkPoint> draw_text_positions(
|
||||
*positionCursor++ = endOfLastGlyph;
|
||||
endOfLastGlyph += glyph->advanceVector();
|
||||
}
|
||||
return SkSpan(buffer, glyphIDs.size());
|
||||
return SkMakeSpan(buffer, glyphIDs.size());
|
||||
}
|
||||
|
||||
const SkGlyphRunList& SkGlyphRunBuilder::textToGlyphRunList(
|
||||
@ -234,20 +234,20 @@ const SkGlyphRunList& SkGlyphRunBuilder::blobToGlyphRunList(
|
||||
break;
|
||||
}
|
||||
case SkTextBlobRunIterator::kHorizontal_Positioning: {
|
||||
positions = SkSpan(positionCursor, runSize);
|
||||
positions = SkMakeSpan(positionCursor, runSize);
|
||||
for (auto x : SkSpan<const SkScalar>{it.pos(), glyphIDs.size()}) {
|
||||
*positionCursor++ = SkPoint::Make(x, it.offset().y());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SkTextBlobRunIterator::kFull_Positioning: {
|
||||
positions = SkSpan(it.points(), runSize);
|
||||
positions = SkMakeSpan(it.points(), runSize);
|
||||
break;
|
||||
}
|
||||
case SkTextBlobRunIterator::kRSXform_Positioning: {
|
||||
positions = SkSpan(positionCursor, runSize);
|
||||
scaledRotations = SkSpan(scaledRotationsCursor, runSize);
|
||||
for (const SkRSXform& xform : SkSpan(it.xforms(), runSize)) {
|
||||
positions = SkMakeSpan(positionCursor, runSize);
|
||||
scaledRotations = SkMakeSpan(scaledRotationsCursor, runSize);
|
||||
for (const SkRSXform& xform : SkMakeSpan(it.xforms(), runSize)) {
|
||||
*positionCursor++ = {xform.fTx, xform.fTy};
|
||||
*scaledRotationsCursor++ = {xform.fSCos, xform.fSSin};
|
||||
}
|
||||
@ -271,8 +271,8 @@ std::tuple<SkSpan<const SkPoint>, SkSpan<const SkVector>>
|
||||
SkGlyphRunBuilder::convertRSXForm(SkSpan<const SkRSXform> xforms) {
|
||||
const int count = SkCount(xforms);
|
||||
this->prepareBuffers(count, count);
|
||||
auto positions = SkSpan(fPositions.get(), count);
|
||||
auto scaledRotations = SkSpan(fScaledRotations.get(), count);
|
||||
auto positions = SkMakeSpan(fPositions.get(), count);
|
||||
auto scaledRotations = SkMakeSpan(fScaledRotations.get(), count);
|
||||
for (auto [pos, sr, xform] : SkMakeZip(positions, scaledRotations, xforms)) {
|
||||
auto [scos, ssin, tx, ty] = xform;
|
||||
pos = {tx, ty};
|
||||
@ -317,7 +317,7 @@ SkSpan<const SkGlyphID> SkGlyphRunBuilder::textToGlyphIDs(
|
||||
if (count > 0) {
|
||||
fScratchGlyphIDs.resize(count);
|
||||
font.textToGlyphs(bytes, byteLength, encoding, fScratchGlyphIDs.data(), count);
|
||||
return SkSpan(fScratchGlyphIDs);
|
||||
return SkMakeSpan(fScratchGlyphIDs);
|
||||
} else {
|
||||
return SkSpan<const SkGlyphID>();
|
||||
}
|
||||
@ -349,5 +349,6 @@ void SkGlyphRunBuilder::makeGlyphRun(
|
||||
const SkGlyphRunList& SkGlyphRunBuilder::makeGlyphRunList(
|
||||
const SkTextBlob* blob, const SkRect& bounds, SkPoint origin) {
|
||||
fGlyphRunList.~SkGlyphRunList();
|
||||
return *new (&fGlyphRunList) SkGlyphRunList{blob, bounds, origin, SkSpan(fGlyphRunListStorage)};
|
||||
return *new (&fGlyphRunList)
|
||||
SkGlyphRunList{blob, bounds, origin, SkMakeSpan(fGlyphRunListStorage)};
|
||||
}
|
||||
|
@ -464,7 +464,7 @@ void SkRuntimeEffect::initFilterColorInfo() {
|
||||
skvm::Color result = SkSL::ProgramToSkVM(*fBaseProgram,
|
||||
fMain,
|
||||
&p,
|
||||
uniform,
|
||||
SkMakeSpan(uniform),
|
||||
/*device=*/zeroCoord,
|
||||
/*local=*/zeroCoord,
|
||||
inputColor,
|
||||
@ -607,7 +607,7 @@ public:
|
||||
uniform.push_back(p->uniform32(uniforms->push(bits)).id);
|
||||
}
|
||||
|
||||
return SkSL::ProgramToSkVM(*fEffect->fBaseProgram, fEffect->fMain, p, uniform,
|
||||
return SkSL::ProgramToSkVM(*fEffect->fBaseProgram, fEffect->fMain, p, SkMakeSpan(uniform),
|
||||
/*device=*/zeroCoord, /*local=*/zeroCoord, c, sampleChild);
|
||||
}
|
||||
|
||||
@ -782,7 +782,7 @@ public:
|
||||
uniform.push_back(p->uniform32(uniforms->push(bits)).id);
|
||||
}
|
||||
|
||||
return SkSL::ProgramToSkVM(*fEffect->fBaseProgram, fEffect->fMain, p, uniform,
|
||||
return SkSL::ProgramToSkVM(*fEffect->fBaseProgram, fEffect->fMain, p, SkMakeSpan(uniform),
|
||||
device, local, paint, sampleChild);
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,10 @@
|
||||
#include <utility>
|
||||
#include "include/private/SkTLogic.h"
|
||||
|
||||
/**
|
||||
* With C++17, we could add template deduction guides that eliminate the need for SkMakeSpan:
|
||||
* https://skia-review.googlesource.com/c/skia/+/320264
|
||||
*/
|
||||
template <typename T>
|
||||
class SkSpan {
|
||||
public:
|
||||
@ -22,9 +26,6 @@ public:
|
||||
template <typename U, typename = typename std::enable_if<std::is_same<const U, T>::value>::type>
|
||||
constexpr SkSpan(const SkSpan<U>& that) : fPtr(that.data()), fSize{that.size()} {}
|
||||
constexpr SkSpan(const SkSpan& o) = default;
|
||||
template<size_t N> constexpr SkSpan(T(&a)[N]) : SkSpan{a, N} { }
|
||||
template<typename Container>
|
||||
constexpr SkSpan(Container& c) : SkSpan{skstd::data(c), skstd::size(c)} { }
|
||||
|
||||
constexpr SkSpan& operator=(const SkSpan& that) {
|
||||
fPtr = that.fPtr;
|
||||
@ -64,8 +65,18 @@ private:
|
||||
size_t fSize;
|
||||
};
|
||||
|
||||
template<typename Container>
|
||||
SkSpan(Container&) -> SkSpan<std::remove_pointer_t<decltype(
|
||||
skstd::data(std::declval<Container&>()))>>;
|
||||
template <typename T, typename S> inline constexpr SkSpan<T> SkMakeSpan(T* p, S s) {
|
||||
return SkSpan<T>{p, SkTo<size_t>(s)};
|
||||
}
|
||||
|
||||
template <size_t N, typename T> inline constexpr SkSpan<T> SkMakeSpan(T (&a)[N]) {
|
||||
return SkSpan<T>{a, N};
|
||||
}
|
||||
|
||||
template <typename Container>
|
||||
inline auto SkMakeSpan(Container& c)
|
||||
-> SkSpan<typename std::remove_reference<decltype(*(c.data()))>::type> {
|
||||
return {c.data(), c.size()};
|
||||
}
|
||||
|
||||
#endif // SkSpan_DEFINED
|
||||
|
@ -78,7 +78,7 @@ public:
|
||||
constexpr Iterator begin() const { return Iterator{this, 0}; }
|
||||
constexpr Iterator end() const { return Iterator{this, this->size()}; }
|
||||
template<size_t I> constexpr auto get() const {
|
||||
return SkSpan(std::get<I>(fPointers), fSize);
|
||||
return SkMakeSpan(std::get<I>(fPointers), fSize);
|
||||
}
|
||||
constexpr std::tuple<Ts*...> data() const { return fPointers; }
|
||||
constexpr SkZip first(size_t n) const {
|
||||
|
@ -161,7 +161,7 @@ bool GrDrawingManager::flush(
|
||||
}
|
||||
|
||||
for (GrOnFlushCallbackObject* onFlushCBObject : fOnFlushCBObjects) {
|
||||
onFlushCBObject->preFlush(&onFlushProvider, fFlushingRenderTaskIDs);
|
||||
onFlushCBObject->preFlush(&onFlushProvider, SkMakeSpan(fFlushingRenderTaskIDs));
|
||||
}
|
||||
for (const auto& onFlushRenderTask : fOnFlushRenderTasks) {
|
||||
onFlushRenderTask->makeClosed(*fContext->priv().caps());
|
||||
@ -229,7 +229,8 @@ bool GrDrawingManager::flush(
|
||||
flushed = false;
|
||||
}
|
||||
for (GrOnFlushCallbackObject* onFlushCBObject : fOnFlushCBObjects) {
|
||||
onFlushCBObject->postFlush(fTokenTracker.nextTokenToFlush(), fFlushingRenderTaskIDs);
|
||||
onFlushCBObject->postFlush(fTokenTracker.nextTokenToFlush(),
|
||||
SkMakeSpan(fFlushingRenderTaskIDs));
|
||||
flushed = true;
|
||||
}
|
||||
if (flushed) {
|
||||
@ -391,7 +392,7 @@ static void reorder_array_by_llist(const SkTInternalLList<T>& llist, SkTArray<sk
|
||||
bool GrDrawingManager::reorderTasks(GrResourceAllocator* resourceAllocator) {
|
||||
SkASSERT(fReduceOpsTaskSplitting);
|
||||
SkTInternalLList<GrRenderTask> llist;
|
||||
bool clustered = GrClusterRenderTasks(fDAG, &llist);
|
||||
bool clustered = GrClusterRenderTasks(SkMakeSpan(fDAG), &llist);
|
||||
if (!clustered) {
|
||||
return false;
|
||||
}
|
||||
|
@ -78,8 +78,8 @@ public:
|
||||
*/
|
||||
void addDependenciesFromOtherTask(GrRenderTask* otherTask);
|
||||
|
||||
SkSpan<GrRenderTask*> dependencies() { return SkSpan<GrRenderTask*>(fDependencies); }
|
||||
SkSpan<GrRenderTask*> dependents() { return SkSpan<GrRenderTask*>(fDependents); }
|
||||
SkSpan<GrRenderTask*> dependencies() { return SkMakeSpan(fDependencies); }
|
||||
SkSpan<GrRenderTask*> dependents() { return SkMakeSpan(fDependents); }
|
||||
|
||||
void replaceDependency(const GrRenderTask* toReplace, GrRenderTask* replaceWith);
|
||||
void replaceDependent(const GrRenderTask* toReplace, GrRenderTask* replaceWith);
|
||||
|
@ -347,11 +347,11 @@ GlyphVector GlyphVector::Make(
|
||||
variants[i] = gv.glyph()->getPackedID();
|
||||
}
|
||||
|
||||
return GlyphVector{spec, SkSpan(variants, glyphs.size())};
|
||||
return GlyphVector{spec, SkMakeSpan(variants, glyphs.size())};
|
||||
}
|
||||
|
||||
SkSpan<const GrGlyph*> GlyphVector::glyphs() const {
|
||||
return SkSpan(reinterpret_cast<const GrGlyph**>(fGlyphs.data()), fGlyphs.size());
|
||||
return SkMakeSpan(reinterpret_cast<const GrGlyph**>(fGlyphs.data()), fGlyphs.size());
|
||||
}
|
||||
|
||||
void GlyphVector::packedGlyphIDToGrGlyph(GrStrikeCache* cache) {
|
||||
|
@ -768,7 +768,7 @@ sk_sp<SkImage> SkImage::MakeFromAHardwareBufferWithData(GrDirectContext* dContex
|
||||
surfaceContext.writePixels(dContext, pixmap, {0, 0});
|
||||
|
||||
GrSurfaceProxy* p[1] = {surfaceContext.asSurfaceProxy()};
|
||||
drawingManager->flush(p, SkSurface::BackendSurfaceAccess::kNoAccess, {}, nullptr);
|
||||
drawingManager->flush(SkMakeSpan(p), SkSurface::BackendSurfaceAccess::kNoAccess, {}, nullptr);
|
||||
|
||||
return image;
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ std::unique_ptr<SkPDFArray> SkPDFMakeCIDGlyphWidthsArray(const SkTypeface& typef
|
||||
subset.getSetValues([&](unsigned index) {
|
||||
glyphIDs.push_back(SkToU16(index));
|
||||
});
|
||||
auto glyphs = paths.glyphs(SkSpan(glyphIDs));
|
||||
auto glyphs = paths.glyphs(SkMakeSpan(glyphIDs));
|
||||
|
||||
#if defined(SK_PDF_CAN_USE_DW)
|
||||
std::vector<int16_t> advances;
|
||||
|
@ -310,7 +310,7 @@ void SkPDFEmitType1Font(const SkPDFFont& pdfFont, SkPDFDocument* doc) {
|
||||
}
|
||||
SkStrikeSpec strikeSpec = SkStrikeSpec::MakePDFVector(*typeface, &emSize);
|
||||
SkBulkGlyphMetrics metrics{strikeSpec};
|
||||
auto glyphs = metrics.glyphs(SkSpan(glyphIDs.get(), glyphRangeSize));
|
||||
auto glyphs = metrics.glyphs(SkMakeSpan(glyphIDs.get(), glyphRangeSize));
|
||||
for (int i = 0; i < glyphRangeSize; ++i) {
|
||||
widths->appendScalar(from_font_units(glyphs[i]->advanceX(), SkToU16(emSize)));
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ struct Value {
|
||||
return fVals[i];
|
||||
}
|
||||
|
||||
SkSpan<skvm::Val> asSpan() { return fVals; }
|
||||
SkSpan<skvm::Val> asSpan() { return SkMakeSpan(fVals); }
|
||||
|
||||
private:
|
||||
SkSTArray<4, skvm::Val, true> fVals;
|
||||
@ -1218,7 +1218,7 @@ Value SkVMGenerator::writeFunctionCall(const FunctionCall& f) {
|
||||
ScopedCondition m(this, ~currentFunction().fReturned);
|
||||
SkASSERTF(f.function().definition(), "no definition for function '%s'",
|
||||
f.function().description().c_str());
|
||||
this->writeFunction(*f.function().definition(), argVals, result.asSpan());
|
||||
this->writeFunction(*f.function().definition(), SkMakeSpan(argVals), result.asSpan());
|
||||
}
|
||||
|
||||
// Propagate new values of any 'out' params back to the original arguments
|
||||
@ -1645,7 +1645,7 @@ skvm::Color ProgramToSkVM(const Program& program,
|
||||
|
||||
SkVMGenerator generator(
|
||||
program, builder, uniforms, device, local, inputColor, std::move(sampleChild));
|
||||
generator.writeFunction(function, {args, argSlots}, result);
|
||||
generator.writeFunction(function, {args, argSlots}, SkMakeSpan(result));
|
||||
|
||||
return skvm::Color{{builder, result[0]},
|
||||
{builder, result[1]},
|
||||
@ -1687,7 +1687,7 @@ bool ProgramToSkVM(const Program& program,
|
||||
skvm::Color zeroColor = {zero, zero, zero, zero};
|
||||
SkVMGenerator generator(program, b, uniforms, /*device=*/zeroCoord, /*local=*/zeroCoord,
|
||||
/*inputColor=*/zeroColor, /*sampleChild=*/{});
|
||||
generator.writeFunction(function, argVals, returnVals);
|
||||
generator.writeFunction(function, SkMakeSpan(argVals), SkMakeSpan(returnVals));
|
||||
|
||||
// generateCode has updated the contents of 'argVals' for any 'out' or 'inout' parameters.
|
||||
// Propagate those changes back to our varying buffers:
|
||||
@ -1818,7 +1818,7 @@ bool testingOnly_ProgramToSkVMShader(const Program& program, skvm::Builder* buil
|
||||
skvm::Color inColor = builder->uniformColor(SkColors::kWhite, &uniforms);
|
||||
|
||||
skvm::Color result = SkSL::ProgramToSkVM(
|
||||
program, *main, builder, uniformVals, device, local, inColor, sampleChild);
|
||||
program, *main, builder, SkMakeSpan(uniformVals), device, local, inColor, sampleChild);
|
||||
|
||||
storeF(builder->varying<float>(), result.r);
|
||||
storeF(builder->varying<float>(), result.g);
|
||||
|
@ -100,8 +100,8 @@ void SkShaperJSONWriter::commitRunBuffer(const SkShaper::RunHandler::RunInfo& in
|
||||
} else {
|
||||
VisualizeClusters(fUTF8.c_str(),
|
||||
info.utf8Range.begin(), info.utf8Range.end(),
|
||||
SkSpan(fGlyphs),
|
||||
SkSpan(fClusters),
|
||||
SkMakeSpan(fGlyphs),
|
||||
SkMakeSpan(fClusters),
|
||||
[this](size_t codePointCount, SkSpan<const char> utf1to1,
|
||||
SkSpan<const SkGlyphID> glyph1to1) {
|
||||
this->displayMToN(codePointCount, utf1to1, glyph1to1);
|
||||
|
@ -532,7 +532,7 @@ DEF_TEST(SkSLInterpreterCompound, r) {
|
||||
for (int i = 0; i < 16; ++i) {
|
||||
uniforms[i] = b.uniform32(uniformPtr, i * sizeof(int)).id;
|
||||
}
|
||||
SkSL::ProgramToSkVM(*program, *fn, &b, uniforms);
|
||||
SkSL::ProgramToSkVM(*program, *fn, &b, SkMakeSpan(uniforms));
|
||||
return b.done();
|
||||
};
|
||||
|
||||
|
@ -65,7 +65,7 @@ DEF_TEST(SkShaperTest_cluster, reporter) {
|
||||
};
|
||||
|
||||
SkShaperJSONWriter::BreakupClusters(
|
||||
0, oneCase.utf8Len, SkSpan(oneCase.clusters), checker);
|
||||
0, oneCase.utf8Len, SkMakeSpan(oneCase.clusters), checker);
|
||||
REPORTER_ASSERT(reporter, answerCount == oneCase.answers.size());
|
||||
}
|
||||
}
|
||||
@ -114,8 +114,8 @@ DEF_TEST(SkShaperTest_VisualizeCluster, reporter) {
|
||||
|
||||
SkShaperJSONWriter::VisualizeClusters(oneCase.utf8.c_str(),
|
||||
0, oneCase.utf8.size(),
|
||||
SkSpan(oneCase.glyphIDs),
|
||||
SkSpan(oneCase.clusters),
|
||||
SkMakeSpan(oneCase.glyphIDs),
|
||||
SkMakeSpan(oneCase.clusters),
|
||||
checker);
|
||||
}
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ DEF_TEST(SkSpan, reporter) {
|
||||
// Test constness preservation for SkMakeSpan.
|
||||
{
|
||||
std::vector<int> v = {{1, 2, 3, 4, 5}};
|
||||
auto s = SkSpan(v);
|
||||
auto s = SkMakeSpan(v);
|
||||
REPORTER_ASSERT(reporter, s[3] == 4);
|
||||
s[3] = 100;
|
||||
REPORTER_ASSERT(reporter, s[3] == 100);
|
||||
@ -188,7 +188,7 @@ DEF_TEST(SkSpan, reporter) {
|
||||
{
|
||||
std::vector<int> t = {{1, 2, 3, 4, 5}};
|
||||
const std::vector<int>& v = t;
|
||||
auto s = SkSpan(v);
|
||||
auto s = SkMakeSpan(v);
|
||||
//s[3] = 100; // Should fail to compile
|
||||
REPORTER_ASSERT(reporter, s[3] == 4);
|
||||
REPORTER_ASSERT(reporter, t[3] == 4);
|
||||
@ -198,7 +198,7 @@ DEF_TEST(SkSpan, reporter) {
|
||||
|
||||
{
|
||||
std::array<int, 5> v = {{1, 2, 3, 4, 5}};
|
||||
auto s = SkSpan(v);
|
||||
auto s = SkMakeSpan(v);
|
||||
REPORTER_ASSERT(reporter, s[3] == 4);
|
||||
s[3] = 100;
|
||||
REPORTER_ASSERT(reporter, s[3] == 100);
|
||||
@ -211,7 +211,7 @@ DEF_TEST(SkSpan, reporter) {
|
||||
{
|
||||
std::array<int, 5> t = {{1, 2, 3, 4, 5}};
|
||||
const std::array<int, 5>& v = t;
|
||||
auto s = SkSpan(v);
|
||||
auto s = SkMakeSpan(v);
|
||||
//s[3] = 100; // Should fail to compile
|
||||
REPORTER_ASSERT(reporter, s[3] == 4);
|
||||
REPORTER_ASSERT(reporter, t[3] == 4);
|
||||
@ -221,7 +221,7 @@ DEF_TEST(SkSpan, reporter) {
|
||||
|
||||
{
|
||||
std::vector<int> v;
|
||||
auto s = SkSpan(v);
|
||||
auto s = SkMakeSpan(v);
|
||||
REPORTER_ASSERT(reporter, s.empty());
|
||||
}
|
||||
}
|
||||
@ -257,14 +257,14 @@ DEF_TEST(SkEnumerate, reporter) {
|
||||
REPORTER_ASSERT(reporter, check == 4);
|
||||
|
||||
check = 0;
|
||||
for (auto [i, v] : SkMakeEnumerate(SkSpan(vec))) {
|
||||
for (auto [i, v] : SkMakeEnumerate(SkMakeSpan(vec))) {
|
||||
REPORTER_ASSERT(reporter, i == check);
|
||||
REPORTER_ASSERT(reporter, v == (int)check+1);
|
||||
check++;
|
||||
}
|
||||
|
||||
{
|
||||
auto e = SkMakeEnumerate(SkSpan(vec)).first(2);
|
||||
auto e = SkMakeEnumerate(SkMakeSpan(vec)).first(2);
|
||||
for (auto[i, v] : e) {
|
||||
REPORTER_ASSERT(reporter, v == (int) i + 1);
|
||||
}
|
||||
@ -272,7 +272,7 @@ DEF_TEST(SkEnumerate, reporter) {
|
||||
}
|
||||
|
||||
{
|
||||
auto e = SkMakeEnumerate(SkSpan(vec)).last(2);
|
||||
auto e = SkMakeEnumerate(SkMakeSpan(vec)).last(2);
|
||||
for (auto[i, v] : e) {
|
||||
REPORTER_ASSERT(reporter, v == (int) i + 1);
|
||||
}
|
||||
@ -280,7 +280,7 @@ DEF_TEST(SkEnumerate, reporter) {
|
||||
}
|
||||
|
||||
{
|
||||
auto e = SkMakeEnumerate(SkSpan(vec)).subspan(1, 2);
|
||||
auto e = SkMakeEnumerate(SkMakeSpan(vec)).subspan(1, 2);
|
||||
for (auto[i, v] : e) {
|
||||
REPORTER_ASSERT(reporter, v == (int) i + 1);
|
||||
}
|
||||
@ -297,7 +297,7 @@ DEF_TEST(SkEnumerate, reporter) {
|
||||
};
|
||||
|
||||
I is[10];
|
||||
SkSpan s{is};
|
||||
auto s = SkMakeSpan(is);
|
||||
for (auto [i, v] : SkMakeEnumerate(s)) {
|
||||
new (&v) I(i);
|
||||
}
|
||||
@ -311,12 +311,12 @@ DEF_TEST(SkEnumerate, reporter) {
|
||||
{
|
||||
std::unique_ptr<int> is[10];
|
||||
std::unique_ptr<int> os[10];
|
||||
SkSpan s{is};
|
||||
auto s = SkMakeSpan(is);
|
||||
for (auto [i, v] : SkMakeEnumerate(s)) {
|
||||
v = std::make_unique<int>(i);
|
||||
}
|
||||
|
||||
for (auto [i, v] : SkMakeEnumerate(SkSpan(os))) {
|
||||
for (auto [i, v] : SkMakeEnumerate(SkMakeSpan(os))) {
|
||||
v = std::move(s[i]);
|
||||
}
|
||||
|
||||
@ -329,7 +329,7 @@ DEF_TEST(SkEnumerate, reporter) {
|
||||
{
|
||||
std::unique_ptr<int> is[10];
|
||||
std::unique_ptr<int> os[10];
|
||||
SkSpan s{is};
|
||||
auto s = SkMakeSpan(is);
|
||||
for (auto [i, v] : SkMakeEnumerate(s)) {
|
||||
v = std::make_unique<int>(i);
|
||||
}
|
||||
@ -350,7 +350,7 @@ DEF_TEST(SkZip, reporter) {
|
||||
const float B[] = {10.f, 20.f, 30.f, 40.f};
|
||||
std::vector<int> C = {{20, 30, 40, 50}};
|
||||
std::array<int, 4> D = {{100, 200, 300, 400}};
|
||||
SkSpan<int> S = SkSpan(C);
|
||||
SkSpan<int> S = SkMakeSpan(C);
|
||||
|
||||
// Check SkZip calls
|
||||
SkZip<uint16_t, const float, int, int, int>
|
||||
@ -523,7 +523,7 @@ DEF_TEST(SkMakeZip, reporter) {
|
||||
const float B[] = {10.f, 20.f, 30.f, 40.f};
|
||||
const std::vector<int> C = {{20, 30, 40, 50}};
|
||||
std::array<int, 4> D = {{100, 200, 300, 400}};
|
||||
SkSpan<const int> S = SkSpan(C);
|
||||
SkSpan<const int> S = SkMakeSpan(C);
|
||||
uint16_t* P = &A[0];
|
||||
{
|
||||
// Check make zip
|
||||
|
@ -311,7 +311,7 @@ sk_sp<TestSVGTypeface> TestSVGTypeface::Default() {
|
||||
return sk_make_sp<DefaultTypeface>("Emoji",
|
||||
1000,
|
||||
metrics,
|
||||
SkSpan(glyphs),
|
||||
SkMakeSpan(glyphs),
|
||||
SkFontStyle::Normal());
|
||||
}
|
||||
|
||||
@ -361,7 +361,7 @@ sk_sp<TestSVGTypeface> TestSVGTypeface::Planets() {
|
||||
return sk_make_sp<PlanetTypeface>("Planets",
|
||||
200,
|
||||
metrics,
|
||||
SkSpan(glyphs),
|
||||
SkMakeSpan(glyphs),
|
||||
SkFontStyle::Normal());
|
||||
}
|
||||
|
||||
|
@ -403,12 +403,12 @@ int main(int , char * const []) {
|
||||
};
|
||||
|
||||
static constexpr FontFamilyDesc kFamiliesData[] = {
|
||||
{"monospace", "Liberation Mono", "LiberationMono", SkSpan(kMonoFonts)},
|
||||
{"sans-serif", "Liberation Sans", "LiberationSans", SkSpan(kSansFonts)},
|
||||
{"serif", "Liberation Serif", "LiberationSerif", SkSpan(kSerifFonts)},
|
||||
{"monospace", "Liberation Mono", "LiberationMono", SkMakeSpan(kMonoFonts)},
|
||||
{"sans-serif", "Liberation Sans", "LiberationSans", SkMakeSpan(kSansFonts)},
|
||||
{"serif", "Liberation Serif", "LiberationSerif", SkMakeSpan(kSerifFonts)},
|
||||
};
|
||||
|
||||
static constexpr SkSpan kFamilies(kFamiliesData);
|
||||
static constexpr SkSpan<const FontFamilyDesc> kFamilies(SkMakeSpan(kFamiliesData));
|
||||
|
||||
#ifdef SK_BUILD_FOR_UNIX
|
||||
generate_fonts("/usr/share/fonts/truetype/liberation/", kFamilies);
|
||||
|
@ -43,8 +43,9 @@ int main(int argc, char** argv) {
|
||||
// But the planet font cannot get very big in the size limited cbdt format.
|
||||
unsigned small[] = { 8, 16 };
|
||||
|
||||
export_ttx(TestSVGTypeface::Default(), SkString(), SkSpan(usual), SkSpan(usual));
|
||||
export_ttx(TestSVGTypeface::Planets(), SkString("planet"), SkSpan(small), SkSpan(usual));
|
||||
export_ttx(TestSVGTypeface::Default(), SkString(), SkMakeSpan(usual), SkMakeSpan(usual));
|
||||
export_ttx(
|
||||
TestSVGTypeface::Planets(), SkString("planet"), SkMakeSpan(small), SkMakeSpan(usual));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user