From b935cf8e12d7371246d318f20f4ebf88e321573a Mon Sep 17 00:00:00 2001 From: Herb Derby Date: Thu, 26 Jul 2018 16:54:18 -0400 Subject: const all the things Having the glyph run list be const as it passes through the stack means that future change can't be introduced in the device code that changes behavior. Try to force all text changes into the SkGylphRun system. Change-Id: I9412bc094c7adb8554887c725a6264af306e1d42 Reviewed-on: https://skia-review.googlesource.com/143702 Commit-Queue: Herb Derby Reviewed-by: Ben Wagner --- src/core/SkBitmapDevice.cpp | 10 +++--- src/core/SkBitmapDevice.h | 2 +- src/core/SkCanvas.cpp | 4 +-- src/core/SkDevice.cpp | 8 ++--- src/core/SkDevice.h | 2 +- src/core/SkDraw.cpp | 2 +- src/core/SkDraw.h | 3 +- src/core/SkGlyphRun.cpp | 65 ++++++++++++++++++--------------------- src/core/SkGlyphRun.h | 39 ++++++++++++----------- src/core/SkRemoteGlyphCache.cpp | 4 +-- src/core/SkTextBlob.cpp | 6 ++-- src/gpu/GrRenderTargetContext.cpp | 2 +- src/gpu/GrRenderTargetContext.h | 2 +- src/gpu/SkGpuDevice.cpp | 2 +- src/gpu/SkGpuDevice.h | 2 +- src/gpu/text/GrTextBlobCache.h | 8 ++--- src/gpu/text/GrTextContext.cpp | 24 +++++++-------- src/gpu/text/GrTextContext.h | 4 +-- src/pdf/SkPDFDevice.cpp | 6 ++-- src/pdf/SkPDFDevice.h | 2 +- 20 files changed, 96 insertions(+), 101 deletions(-) (limited to 'src') diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp index c789496557..767eff1437 100644 --- a/src/core/SkBitmapDevice.cpp +++ b/src/core/SkBitmapDevice.cpp @@ -585,15 +585,15 @@ void SkBitmapDevice::drawPosText(const void* text, size_t len, const SkScalar xp nullptr) } -void SkBitmapDevice::drawGlyphRunList(SkGlyphRunList* glyphRunList) { +void SkBitmapDevice::drawGlyphRunList(const SkGlyphRunList& glyphRunList) { #if defined(SK_SUPPORT_LEGACY_TEXT_BLOB) - auto blob = glyphRunList->blob(); + auto blob = glyphRunList.blob(); if (blob == nullptr) { - glyphRunList->temporaryShuntToDrawPosText(this, SkPoint::Make(0, 0)); + glyphRunList.temporaryShuntToDrawPosText(this, SkPoint::Make(0, 0)); } else { - auto origin = glyphRunList->origin(); - auto paint = glyphRunList->paint(); + auto origin = glyphRunList.origin(); + auto paint = glyphRunList.paint(); this->drawTextBlob(blob, origin.x(), origin.y(), paint); } #else diff --git a/src/core/SkBitmapDevice.h b/src/core/SkBitmapDevice.h index 127c09b83b..74b93494f8 100644 --- a/src/core/SkBitmapDevice.h +++ b/src/core/SkBitmapDevice.h @@ -107,7 +107,7 @@ protected: void drawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&, const SkPaint&, SkCanvas::SrcRectConstraint) override; - void drawGlyphRunList(SkGlyphRunList* glyphRunList) override; + void drawGlyphRunList(const SkGlyphRunList& glyphRunList) override; void drawVertices(const SkVertices*, const SkMatrix* bones, int boneCount, SkBlendMode, const SkPaint& paint) override; void drawDevice(SkBaseDevice*, int x, int y, const SkPaint&) override; diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp index 8fc431864d..1da6e28f1f 100644 --- a/src/core/SkCanvas.cpp +++ b/src/core/SkCanvas.cpp @@ -2489,8 +2489,8 @@ void SkCanvas::onDrawTextRSXform(const void* text, size_t len, const SkRSXform x while (iter.next()) { fScratchGlyphRunBuilder->drawTextAtOrigin(paint, text, len); auto list = fScratchGlyphRunBuilder->useGlyphRunList(); - if (!list->empty()) { - auto glyphRun = (*list)[0]; + if (!list.empty()) { + auto glyphRun = list[0]; iter.fDevice->drawGlyphRunRSXform(&glyphRun, xform); } } diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp index b94d7e97cf..f0829dc4da 100644 --- a/src/core/SkDevice.cpp +++ b/src/core/SkDevice.cpp @@ -158,7 +158,7 @@ void SkBaseDevice::drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, SkGlyphRunBuilder builder; builder.drawText(runPaint, (const char*) it.glyphs(), textLen, origin); auto glyphRunList = builder.useGlyphRunList(); - glyphRunList->temporaryShuntToDrawPosText(this, SkPoint::Make(0, 0)); + glyphRunList.temporaryShuntToDrawPosText(this, SkPoint::Make(0, 0)); } break; case SkTextBlob::kHorizontal_Positioning: @@ -239,8 +239,8 @@ void SkBaseDevice::drawImageLattice(const SkImage* image, } } -void SkBaseDevice::drawGlyphRunList(SkGlyphRunList* glyphRunList) { - glyphRunList->temporaryShuntToDrawPosText(this, SkPoint::Make(0, 0)); +void SkBaseDevice::drawGlyphRunList(const SkGlyphRunList& glyphRunList) { + glyphRunList.temporaryShuntToDrawPosText(this, SkPoint::Make(0, 0)); } void SkBaseDevice::drawBitmapLattice(const SkBitmap& bitmap, @@ -491,7 +491,7 @@ void SkBaseDevice::drawGlyphRunRSXform(SkGlyphRun* run, const SkRSXform* xform) ctm.setConcat(originalCTM, ctm); this->setCTM(ctm); SkGlyphRunList glyphRunList{glyphRun}; - this->drawGlyphRunList(&glyphRunList); + this->drawGlyphRunList(glyphRunList); }; run->eachGlyphToGlyphRun(perGlyph); run->mutablePaint()->setShader(shader); diff --git a/src/core/SkDevice.h b/src/core/SkDevice.h index bd327a65c3..d56d5078e1 100644 --- a/src/core/SkDevice.h +++ b/src/core/SkDevice.h @@ -223,7 +223,7 @@ protected: const SkPaint&) = 0; virtual void drawShadow(const SkPath&, const SkDrawShadowRec&); - virtual void drawGlyphRunList(SkGlyphRunList* glyphRunList); + virtual void drawGlyphRunList(const SkGlyphRunList& glyphRunList); // default implementation calls drawVertices virtual void drawPatch(const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4], SkBlendMode, const SkPaint& paint); diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp index c9f2e0ed2c..95942f76a8 100644 --- a/src/core/SkDraw.cpp +++ b/src/core/SkDraw.cpp @@ -1620,7 +1620,7 @@ SkGlyphRunListDrawer::PerMask SkDraw::drawOneMaskCreator( } void SkDraw::drawGlyphRunList( - SkGlyphRunList* glyphRunList, SkGlyphRunListDrawer* glyphDraw) const { + const SkGlyphRunList& glyphRunList, SkGlyphRunListDrawer* glyphDraw) const { SkDEBUGCODE(this->validate();) diff --git a/src/core/SkDraw.h b/src/core/SkDraw.h index a199215878..ca37c098ce 100644 --- a/src/core/SkDraw.h +++ b/src/core/SkDraw.h @@ -67,7 +67,8 @@ public: void drawPosText(const char text[], size_t byteLength, const SkScalar pos[], int scalarsPerPosition, const SkPoint& offset, const SkPaint&, const SkSurfaceProps*) const; - void drawGlyphRunList(SkGlyphRunList* glyphRunList, SkGlyphRunListDrawer* glyphDraw) const; + void drawGlyphRunList(const SkGlyphRunList& glyphRunList, + SkGlyphRunListDrawer* glyphDraw) const; void drawVertices(SkVertices::VertexMode mode, int vertexCount, const SkPoint vertices[], const SkPoint textures[], const SkColor colors[], const SkVertices::BoneIndices boneIndices[], diff --git a/src/core/SkGlyphRun.cpp b/src/core/SkGlyphRun.cpp index 4889482432..ca52289ea9 100644 --- a/src/core/SkGlyphRun.cpp +++ b/src/core/SkGlyphRun.cpp @@ -42,7 +42,7 @@ static SkTypeface::Encoding convert_encoding(SkPaint::TextEncoding encoding) { // -- SkGlyphRun ----------------------------------------------------------------------------------- SkGlyphRun::SkGlyphRun(SkPaint&& runPaint, SkSpan denseIndices, - SkSpan positions, + SkSpan positions, SkSpan glyphIDs, SkSpan uniqueGlyphIDs, SkSpan text, @@ -63,7 +63,7 @@ void SkGlyphRun::eachGlyphToGlyphRun(SkGlyphRun::PerGlyph perGlyph) { SkGlyphRun run{ std::move(paint), SkSpan{}, // No dense indices for now. - SkSpan{&point, 1}, + SkSpan{&point, 1}, SkSpan{&glyphID, 1}, SkSpan{}, SkSpan{}, @@ -79,11 +79,6 @@ void SkGlyphRun::eachGlyphToGlyphRun(SkGlyphRun::PerGlyph perGlyph) { } } -void SkGlyphRun::mapPositions(const SkMatrix& matrix) { - matrix.mapPoints(fPositions.data(), fPositions.data(), (int)fPositions.size()); -} - - void SkGlyphRun::temporaryShuntToDrawPosText(SkBaseDevice* device, SkPoint origin) { auto pos = (const SkScalar*) this->positions().data(); @@ -140,10 +135,11 @@ bool SkGlyphRunListDrawer::ensureBitmapBuffers(size_t runSize) { } void SkGlyphRunListDrawer::drawGlyphRunAsPaths( - SkGlyphRun* glyphRun, SkPoint origin, const SkSurfaceProps& props, PerPath perPath) const { + const SkGlyphRun& glyphRun, SkPoint origin, + const SkSurfaceProps& props, PerPath perPath) const { // setup our std paint, in hopes of getting hits in the cache - const SkPaint& origPaint = glyphRun->paint(); - SkPaint paint(glyphRun->paint()); + const SkPaint& origPaint = glyphRun.paint(); + SkPaint paint(glyphRun.paint()); SkScalar matrixScale = paint.setupForAsPaths(); SkMatrix matrix; @@ -174,7 +170,7 @@ void SkGlyphRunListDrawer::drawGlyphRunAsPaths( } }; - glyphRun->forEachGlyphAndPosition(eachGlyph); + glyphRun.forEachGlyphAndPosition(eachGlyph); } static bool prepare_mask( @@ -217,21 +213,21 @@ static bool prepare_mask( } void SkGlyphRunListDrawer::drawGlyphRunAsSubpixelMask( - SkGlyphCache* cache, SkGlyphRun* glyphRun, + SkGlyphCache* cache, const SkGlyphRun& glyphRun, SkPoint origin, const SkMatrix& deviceMatrix, PerMask perMask) { - auto runSize = glyphRun->runSize(); - if (this->ensureBitmapBuffers(glyphRun->runSize())) { + auto runSize = glyphRun.runSize(); + if (this->ensureBitmapBuffers(runSize)) { // Add rounding and origin. SkMatrix matrix = deviceMatrix; SkAxisAlignment axisAlignment = cache->getScalerContext()->computeAxisAlignmentForHText(); SkPoint rounding = SkFindAndPlaceGlyph::SubpixelPositionRounding(axisAlignment); matrix.preTranslate(origin.x(), origin.y()); matrix.postTranslate(rounding.x(), rounding.y()); - matrix.mapPoints(fPositions, glyphRun->positions().data(), runSize); + matrix.mapPoints(fPositions, glyphRun.positions().data(), runSize); const SkPoint* positionCursor = fPositions; - for (auto glyphID : glyphRun->shuntGlyphsIDs()) { + for (auto glyphID : glyphRun.shuntGlyphsIDs()) { auto position = *positionCursor++; if (SkScalarsAreFinite(position.fX, position.fY)) { SkFixed lookupX = SkScalarToFixed(SkScalarFraction(position.fX)), @@ -255,20 +251,20 @@ void SkGlyphRunListDrawer::drawGlyphRunAsSubpixelMask( } void SkGlyphRunListDrawer::drawGlyphRunAsFullpixelMask( - SkGlyphCache* cache, SkGlyphRun* glyphRun, + SkGlyphCache* cache, const SkGlyphRun& glyphRun, SkPoint origin, const SkMatrix& deviceMatrix, PerMask perMask) { - auto runSize = glyphRun->runSize(); - if (this->ensureBitmapBuffers(glyphRun->runSize())) { + auto runSize = glyphRun.runSize(); + if (this->ensureBitmapBuffers(runSize)) { // Add rounding and origin. SkMatrix matrix = deviceMatrix; matrix.preTranslate(origin.x(), origin.y()); matrix.postTranslate(SK_ScalarHalf, SK_ScalarHalf); - matrix.mapPoints(fPositions, glyphRun->positions().data(), runSize); + matrix.mapPoints(fPositions, glyphRun.positions().data(), runSize); const SkPoint* positionCursor = fPositions; - for (auto glyphID : glyphRun->shuntGlyphsIDs()) { + for (auto glyphID : glyphRun.shuntGlyphsIDs()) { auto position = *positionCursor++; if (SkScalarsAreFinite(position.fX, position.fY)) { const SkGlyph& glyph = cache->getGlyphIDMetrics(glyphID); @@ -282,11 +278,11 @@ void SkGlyphRunListDrawer::drawGlyphRunAsFullpixelMask( } void SkGlyphRunListDrawer::drawForBitmap( - SkGlyphRunList* glyphRunList, const SkMatrix& deviceMatrix, + const SkGlyphRunList& glyphRunList, const SkMatrix& deviceMatrix, PerMaskCreator perMaskCreator, PerPathCreator perPathCreator) { - SkPoint origin = glyphRunList->origin(); - for (auto& glyphRun : *glyphRunList) { + SkPoint origin = glyphRunList.origin(); + for (auto& glyphRun : glyphRunList) { SkSTArenaAlloc<3332> alloc; // The bitmap blitters can only draw lcd text to a N32 bitmap in srcOver. Otherwise, // convert the lcd text into A8 text. The props communicates this to the scaler. @@ -296,17 +292,17 @@ void SkGlyphRunListDrawer::drawForBitmap( auto paint = glyphRun.paint(); if (ShouldDrawAsPath(glyphRun.paint(), deviceMatrix)) { auto perPath = perPathCreator(paint, &alloc); - this->drawGlyphRunAsPaths(&glyphRun, origin, props, perPath); + this->drawGlyphRunAsPaths(glyphRun, origin, props, perPath); } else { auto cache = SkStrikeCache::FindOrCreateStrikeExclusive( paint, &props, fScalerContextFlags, &deviceMatrix); auto perMask = perMaskCreator(paint, &alloc); if (cache->isSubpixel()) { this->drawGlyphRunAsSubpixelMask( - cache.get(), &glyphRun, origin, deviceMatrix, perMask); + cache.get(), glyphRun, origin, deviceMatrix, perMask); } else { this->drawGlyphRunAsFullpixelMask( - cache.get(), &glyphRun, origin, deviceMatrix, perMask); + cache.get(), glyphRun, origin, deviceMatrix, perMask); } } } @@ -422,7 +418,7 @@ void SkGlyphRunBuilder::drawTextAtOrigin( this->initialize(glyphIDs.size()); } - auto positions = SkSpan{fPositions, glyphIDs.size()}; + auto positions = SkSpan{fPositions, glyphIDs.size()}; // Every glyph is at the origin. sk_bzero((void *)positions.data(), positions.size_bytes()); @@ -540,8 +536,8 @@ void SkGlyphRunBuilder::drawTextBlob(const SkPaint& paint, const SkTextBlob& blo this->makeGlyphRunList(paint, &blob, origin); } -SkGlyphRunList* SkGlyphRunBuilder::useGlyphRunList() { - return &fGlyphRunList; +const SkGlyphRunList& SkGlyphRunBuilder::useGlyphRunList() { + return fGlyphRunList; } void SkGlyphRunBuilder::initialize(size_t totalRunSize) { @@ -599,7 +595,7 @@ SkSpan SkGlyphRunBuilder::addDenseAndUnique( void SkGlyphRunBuilder::makeGlyphRun( const SkPaint& runPaint, SkSpan glyphIDs, - SkSpan positions, + SkSpan positions, SkSpan uniqueGlyphIDIndices, SkSpan uniqueGlyphIDs, SkSpan text, @@ -669,7 +665,7 @@ size_t SkGlyphRunBuilder::simplifyDrawText( this->makeGlyphRun( paint, glyphIDs, - SkSpan{positions, runSize}, + SkSpan{positions, runSize}, SkSpan{uniqueGlyphIDIndicesBuffer, runSize}, unqiueGlyphIDs, text, @@ -701,7 +697,7 @@ size_t SkGlyphRunBuilder::simplifyDrawPosTextH( this->makeGlyphRun( paint, glyphIDs, - SkSpan{positions, runSize}, + SkSpan{positions, runSize}, SkSpan{uniqueGlyphIDIndicesBuffer, runSize}, uniqueGlyphIDs, text, @@ -725,13 +721,12 @@ size_t SkGlyphRunBuilder::simplifyDrawPosText( memcpy(positions, pos, runSize * sizeof(SkPoint)); - // TODO: when using the unique glyph system have a guard that there are actually glyphs like // drawText above. this->makeGlyphRun( paint, glyphIDs, - SkSpan{positions, runSize}, + SkSpan{positions, runSize}, SkSpan{uniqueGlyphIDIndicesBuffer, runSize}, uniqueGlyphIDs, text, diff --git a/src/core/SkGlyphRun.h b/src/core/SkGlyphRun.h index 8348fe9013..b2d1aad265 100644 --- a/src/core/SkGlyphRun.h +++ b/src/core/SkGlyphRun.h @@ -56,7 +56,7 @@ public: SkGlyphRun() = default; SkGlyphRun(SkPaint&& runPaint, SkSpan denseIndices, - SkSpan positions, + SkSpan positions, SkSpan glyphIDs, SkSpan uniqueGlyphIDs, SkSpan text, @@ -65,7 +65,6 @@ public: // A function that turns an SkGlyphRun into an SkGlyphRun for each glyph. using PerGlyph = std::function; void eachGlyphToGlyphRun(PerGlyph perGlyph); - void mapPositions(const SkMatrix& matrix); // The following made a ~5% speed improvement over not using a template. //using PerGlyphPos = std::function; @@ -91,7 +90,7 @@ private: // const SkSpan fUniqueGlyphIDIndices; // - const SkSpan fPositions; + const SkSpan fPositions; // This is temporary while converting from the old per glyph code to the bulk code. const SkSpan fGlyphIDs; // The unique glyphs from fGlyphIDs. @@ -115,21 +114,21 @@ public: using PerPath = std::function; using PerPathCreator = std::function; void drawForBitmap( - SkGlyphRunList* glyphRunList, const SkMatrix& deviceMatrix, + const SkGlyphRunList& glyphRunList, const SkMatrix& deviceMatrix, PerMaskCreator perMaskCreator, PerPathCreator perPathCreator); private: static bool ShouldDrawAsPath(const SkPaint& paint, const SkMatrix& matrix); bool ensureBitmapBuffers(size_t runSize); void drawGlyphRunAsPaths( - SkGlyphRun* glyphRun, SkPoint origin, + const SkGlyphRun& glyphRun, SkPoint origin, const SkSurfaceProps& props, PerPath perPath) const; void drawGlyphRunAsSubpixelMask( - SkGlyphCache* cache, SkGlyphRun* glyphRun, + SkGlyphCache* cache, const SkGlyphRun& glyphRun, SkPoint origin, const SkMatrix& deviceMatrix, PerMask perMask); void drawGlyphRunAsFullpixelMask( - SkGlyphCache* cache, SkGlyphRun* glyphRun, + SkGlyphCache* cache, const SkGlyphRun& glyphRun, SkPoint origin, const SkMatrix& deviceMatrix, PerMask perMask); // The props as on the actual device. @@ -179,22 +178,23 @@ public: const SkPaint& paint() const { return *fOriginalPaint; } const SkTextBlob* blob() const { return fOriginalTextBlob; } - auto begin() -> decltype(fGlyphRuns.begin()) { return fGlyphRuns.begin(); } - auto end() -> decltype(fGlyphRuns.end()) { return fGlyphRuns.end(); } - auto size() -> decltype(fGlyphRuns.size()) { return fGlyphRuns.size(); } - auto empty() -> decltype(fGlyphRuns.empty()) { return fGlyphRuns.empty(); } - auto operator [] (size_t i) -> decltype(fGlyphRuns[i]) { return fGlyphRuns[i]; } - void temporaryShuntToDrawPosText(SkBaseDevice* device, SkPoint origin) { + auto begin() -> decltype(fGlyphRuns.begin()) { return fGlyphRuns.begin(); } + auto end() -> decltype(fGlyphRuns.end()) { return fGlyphRuns.end(); } + auto begin() const -> decltype(fGlyphRuns.cbegin()) { return fGlyphRuns.cbegin(); } + auto end() const -> decltype(fGlyphRuns.cend()) { return fGlyphRuns.cend(); } + auto size() const -> decltype(fGlyphRuns.size()) { return fGlyphRuns.size(); } + auto empty() const -> decltype(fGlyphRuns.empty()) { return fGlyphRuns.empty(); } + auto operator [] (size_t i) const -> decltype(fGlyphRuns[i]) { return fGlyphRuns[i]; } + void temporaryShuntToDrawPosText(SkBaseDevice* device, SkPoint origin) const { for (auto& run : fGlyphRuns) { run.temporaryShuntToDrawPosText(device, origin); } } - }; class SkGlyphRunListIterator { public: - explicit SkGlyphRunListIterator(SkGlyphRunList* list) : fList{*list} {} + explicit SkGlyphRunListIterator(const SkGlyphRunList& list) : fList{list} {} bool done() const { return fIndex == fList.size(); } void next() { fIndex += 1;} @@ -213,7 +213,7 @@ public: private: static constexpr SkPoint fZero{0, 0}; size_t fIndex{0}; - SkGlyphRunList& fList; + const SkGlyphRunList& fList; }; class SkGlyphIDSet { @@ -238,7 +238,7 @@ public: const SkPaint& paint, const void* bytes, size_t byteLength, const SkPoint* pos); void drawTextBlob(const SkPaint& paint, const SkTextBlob& blob, SkPoint origin); - SkGlyphRunList* useGlyphRunList(); + const SkGlyphRunList& useGlyphRunList(); private: void initialize(size_t totalRunSize); @@ -255,7 +255,7 @@ private: void makeGlyphRun( const SkPaint& runPaint, SkSpan glyphIDs, - SkSpan positions, + SkSpan positions, SkSpan uniqueGlyphIDIndices, SkSpan uniqueGlyphIDs, SkSpan text, @@ -280,7 +280,6 @@ private: SkSpan text = SkSpan{}, SkSpan clusters = SkSpan{}); - size_t fMaxTotalRunSize{0}; SkAutoTMalloc fUniqueGlyphIDIndices; SkAutoTMalloc fPositions; @@ -303,7 +302,7 @@ private: template inline void SkGlyphRun::forEachGlyphAndPosition(PerGlyphPos perGlyph) const { - SkPoint* ptCursor = fPositions.data(); + const SkPoint* ptCursor = fPositions.data(); for (auto glyphID : fGlyphIDs) { perGlyph(glyphID, *ptCursor++); } diff --git a/src/core/SkRemoteGlyphCache.cpp b/src/core/SkRemoteGlyphCache.cpp index 4b9239dc6b..58422627f5 100644 --- a/src/core/SkRemoteGlyphCache.cpp +++ b/src/core/SkRemoteGlyphCache.cpp @@ -239,14 +239,14 @@ public: } protected: - void drawGlyphRunList(SkGlyphRunList* glyphRunList) override { + void drawGlyphRunList(const SkGlyphRunList& glyphRunList) override { SkPaint runPaint; SkGlyphRunListIterator it(glyphRunList); for (; !it.done(); it.next()) { // applyFontToPaint() always overwrites the exact same attributes, // so it is safe to not re-seed the paint for this reason. it.applyFontToPaint(&runPaint); - this->processGlyphRun(glyphRunList->origin(), it, runPaint); + this->processGlyphRun(glyphRunList.origin(), it, runPaint); } } diff --git a/src/core/SkTextBlob.cpp b/src/core/SkTextBlob.cpp index 4528e64f15..fcaeec8613 100644 --- a/src/core/SkTextBlob.cpp +++ b/src/core/SkTextBlob.cpp @@ -893,10 +893,10 @@ sk_sp SkTextBlob::MakeAsDrawText( runBuilder.drawText(paint, text, byteLength, SkPoint::Make(0, 0)); - auto list = runBuilder.useGlyphRunList(); + auto glyphRunList = runBuilder.useGlyphRunList(); SkTextBlobBuilder blobBuilder; - if (!list->empty()) { - auto run = (*list)[0]; + if (!glyphRunList.empty()) { + auto run = glyphRunList[0]; SkPaint blobPaint(paint); blobPaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp index f2e1c08474..7d88bc4936 100644 --- a/src/gpu/GrRenderTargetContext.cpp +++ b/src/gpu/GrRenderTargetContext.cpp @@ -241,7 +241,7 @@ void GrRenderTargetContext::drawPosText(const GrClip& clip, const SkPaint& paint void GrRenderTargetContext::drawGlyphRunList( const GrClip& clip, const SkMatrix& viewMatrix, - SkGlyphRunList* blob, const SkIRect& clipBounds) { + const SkGlyphRunList& blob, const SkIRect& clipBounds) { ASSERT_SINGLE_OWNER RETURN_IF_ABANDONED SkDEBUGCODE(this->validate();) diff --git a/src/gpu/GrRenderTargetContext.h b/src/gpu/GrRenderTargetContext.h index 2d4bc49dcf..565a2b8c08 100644 --- a/src/gpu/GrRenderTargetContext.h +++ b/src/gpu/GrRenderTargetContext.h @@ -69,7 +69,7 @@ public: int scalarsPerPosition, const SkPoint& offset, const SkIRect& clipBounds); virtual void drawGlyphRunList(const GrClip&, - const SkMatrix& viewMatrix, SkGlyphRunList*, + const SkMatrix& viewMatrix, const SkGlyphRunList&, const SkIRect& clipBounds); /** diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 27eeda7902..39704e5174 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -1637,7 +1637,7 @@ void SkGpuDevice::drawPosText(const void* text, size_t byteLength, this->devClipBounds()); } -void SkGpuDevice::drawGlyphRunList(SkGlyphRunList* glyphRunList) { +void SkGpuDevice::drawGlyphRunList(const SkGlyphRunList& glyphRunList) { ASSERT_SINGLE_OWNER GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawGlyphRunList", fContext.get()); SkDEBUGCODE(this->validate();) diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/SkGpuDevice.h index 5d0fb708dc..6cd1ae60e4 100644 --- a/src/gpu/SkGpuDevice.h +++ b/src/gpu/SkGpuDevice.h @@ -89,7 +89,7 @@ public: const SkPaint& paint) override; void drawPosText(const void* text, size_t len, const SkScalar pos[], int scalarsPerPos, const SkPoint& offset, const SkPaint&) override; - void drawGlyphRunList(SkGlyphRunList* glyphRunList) override; + void drawGlyphRunList(const SkGlyphRunList& glyphRunList) override; void drawVertices(const SkVertices*, const SkMatrix bones[], int boneCount, SkBlendMode, const SkPaint&) override; void drawShadow(const SkPath&, const SkDrawShadowRec&) override; diff --git a/src/gpu/text/GrTextBlobCache.h b/src/gpu/text/GrTextBlobCache.h index 72743f84ba..110e0ad7fc 100644 --- a/src/gpu/text/GrTextBlobCache.h +++ b/src/gpu/text/GrTextBlobCache.h @@ -56,18 +56,18 @@ public: return cacheBlob; } - sk_sp makeBlob(SkGlyphRunList* glyphRunList) { - return GrTextBlob::Make(glyphRunList->totalGlyphCount(), glyphRunList->size()); + sk_sp makeBlob(const SkGlyphRunList& glyphRunList) { + return GrTextBlob::Make(glyphRunList.totalGlyphCount(), glyphRunList.size()); } - sk_sp makeCachedBlob(SkGlyphRunList* glyphRunList, + sk_sp makeCachedBlob(const SkGlyphRunList& glyphRunList, const GrTextBlob::Key& key, const SkMaskFilterBase::BlurRec& blurRec, const SkPaint& paint) { sk_sp cacheBlob(makeBlob(glyphRunList)); cacheBlob->setupKey(key, blurRec, paint); this->add(cacheBlob); - glyphRunList->temporaryShuntBlobNotifyAddedToCache(fUniqueID); + glyphRunList.temporaryShuntBlobNotifyAddedToCache(fUniqueID); return cacheBlob; } diff --git a/src/gpu/text/GrTextContext.cpp b/src/gpu/text/GrTextContext.cpp index 6a3489554b..aeb99f1548 100644 --- a/src/gpu/text/GrTextContext.cpp +++ b/src/gpu/text/GrTextContext.cpp @@ -86,12 +86,12 @@ SkScalerContextFlags GrTextContext::ComputeScalerContextFlags( void GrTextContext::drawGlyphRunList( GrContext* context, GrTextUtils::Target* target, const GrClip& clip, - const SkMatrix& viewMatrix, const SkSurfaceProps& props, SkGlyphRunList* glyphRunList, + const SkMatrix& viewMatrix, const SkSurfaceProps& props, const SkGlyphRunList& glyphRunList, const SkIRect& clipBounds) { - SkPoint origin = glyphRunList->origin(); + SkPoint origin = glyphRunList.origin(); // Get the first paint to use as the key paint. - const SkPaint& skPaint = glyphRunList->paint(); + const SkPaint& skPaint = glyphRunList.paint(); // If we have been abandoned, then don't draw if (context->abandoned()) { @@ -102,7 +102,7 @@ void GrTextContext::drawGlyphRunList( // It might be worth caching these things, but its not clear at this time // TODO for animated mask filters, this will fill up our cache. We need a safeguard here const SkMaskFilter* mf = skPaint.getMaskFilter(); - bool canCache = glyphRunList->canCache() && !(skPaint.getPathEffect() || + bool canCache = glyphRunList.canCache() && !(skPaint.getPathEffect() || (mf && !as_MFB(mf)->asABlur(&blurRec))); SkScalerContextFlags scalerContextFlags = ComputeScalerContextFlags(target->colorSpaceInfo()); @@ -112,7 +112,7 @@ void GrTextContext::drawGlyphRunList( sk_sp cacheBlob; GrTextBlob::Key key; if (canCache) { - bool hasLCD = glyphRunList->anyRunsLCD(); + bool hasLCD = glyphRunList.anyRunsLCD(); // We canonicalize all non-lcd draws to use kUnknown_SkPixelGeometry SkPixelGeometry pixelGeometry = hasLCD ? props.pixelGeometry() : @@ -125,7 +125,7 @@ void GrTextContext::drawGlyphRunList( ComputeCanonicalColor(skPaint, hasLCD); key.fPixelGeometry = pixelGeometry; - key.fUniqueID = glyphRunList->uniqueID(); + key.fUniqueID = glyphRunList.uniqueID(); key.fStyle = skPaint.getStyle(); key.fHasBlur = SkToBool(mf); key.fCanonicalColor = canonicalColor; @@ -148,8 +148,8 @@ void GrTextContext::drawGlyphRunList( textBlobCache->makeMRU(cacheBlob.get()); if (CACHE_SANITY_CHECK) { - int glyphCount = glyphRunList->totalGlyphCount(); - int runCount = glyphRunList->runCount(); + int glyphCount = glyphRunList.totalGlyphCount(); + int runCount = glyphRunList.runCount(); sk_sp sanityBlob(textBlobCache->makeBlob(glyphCount, runCount)); sanityBlob->setupKey(key, blurRec, skPaint); this->regenerateGlyphRunList( @@ -180,8 +180,8 @@ void GrTextContext::regenerateGlyphRunList(GrTextBlob* cacheBlob, SkScalerContextFlags scalerContextFlags, const SkMatrix& viewMatrix, const SkSurfaceProps& props, - SkGlyphRunList* glyphRunList) const { - SkPoint origin = glyphRunList->origin(); + const SkGlyphRunList& glyphRunList) const { + SkPoint origin = glyphRunList.origin(); cacheBlob->initReusableBlob(paint.luminanceColor(), viewMatrix, origin.x(), origin.y()); // Regenerate textblob @@ -718,8 +718,8 @@ std::unique_ptr GrTextContext::createOp_TestingOnly(GrContext* context sk_sp blob; auto glyphRunList = builder.useGlyphRunList(); - if (!glyphRunList->empty()) { - auto glyphRun = (*glyphRunList)[0]; + if (!glyphRunList.empty()) { + auto glyphRun = glyphRunList[0]; // Use the text and textLen below, because we don't want to mess with the paint. glyphRun.temporaryShuntToCallback( [&](size_t runSize, const char* glyphIDs, const SkScalar* pos) { diff --git a/src/gpu/text/GrTextContext.h b/src/gpu/text/GrTextContext.h index 25aeea0c7a..aa4626e411 100644 --- a/src/gpu/text/GrTextContext.h +++ b/src/gpu/text/GrTextContext.h @@ -49,7 +49,7 @@ public: size_t byteLength, const SkScalar pos[], int scalarsPerPosition, const SkPoint& offset, const SkIRect& regionClipBounds); void drawGlyphRunList(GrContext*, GrTextUtils::Target*, const GrClip&, - const SkMatrix& viewMatrix, const SkSurfaceProps&, SkGlyphRunList*, + const SkMatrix& viewMatrix, const SkSurfaceProps&, const SkGlyphRunList&, const SkIRect& clipBounds); std::unique_ptr createOp_TestingOnly(GrContext*, @@ -123,7 +123,7 @@ private: SkScalerContextFlags scalerContextFlags, const SkMatrix& viewMatrix, const SkSurfaceProps&, - SkGlyphRunList* glyphRunList) const; + const SkGlyphRunList& glyphRunList) const; sk_sp makeDrawPosTextBlob(GrTextBlobCache*, GrGlyphCache*, const GrShaderCaps&, diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp index 88955a1b9c..cdaeef0418 100644 --- a/src/pdf/SkPDFDevice.cpp +++ b/src/pdf/SkPDFDevice.cpp @@ -1386,9 +1386,9 @@ void SkPDFDevice::internalDrawGlyphRun(const SkGlyphRun& glyphRun, SkPoint offse } } -void SkPDFDevice::drawGlyphRunList(SkGlyphRunList* glyphRunList) { - for (const SkGlyphRun& glyphRun : *glyphRunList) { - this->internalDrawGlyphRun(glyphRun, glyphRunList->origin()); +void SkPDFDevice::drawGlyphRunList(const SkGlyphRunList& glyphRunList) { + for (const SkGlyphRun& glyphRun : glyphRunList) { + this->internalDrawGlyphRun(glyphRun, glyphRunList.origin()); } } diff --git a/src/pdf/SkPDFDevice.h b/src/pdf/SkPDFDevice.h index 1ef4a20ed6..2075202cb9 100644 --- a/src/pdf/SkPDFDevice.h +++ b/src/pdf/SkPDFDevice.h @@ -98,7 +98,7 @@ public: void drawPosText(const void* text, size_t len, const SkScalar pos[], int scalarsPerPos, const SkPoint& offset, const SkPaint&) override { SkASSERT(false); } - void drawGlyphRunList(SkGlyphRunList* glyphRunList) override; + void drawGlyphRunList(const SkGlyphRunList& glyphRunList) override; void drawVertices(const SkVertices*, const SkMatrix* bones, int boneCount, SkBlendMode, const SkPaint&) override; void drawDevice(SkBaseDevice*, int x, int y, -- cgit v1.2.3