aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Herb Derby <herb@google.com>2018-07-27 15:36:49 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-07-27 20:55:16 +0000
commit46dbfbb528305fc7c7bd4f8cca56dc4321761511 (patch)
treec7332365407da6063f15a9e262e324a843be07c8
parent79f99f7bf22859f4cee31ee6652141b507ea7141 (diff)
Make regenerateGlyphRunList on use the iterator
Change-Id: Iba68c94a62b535031594dcff46fd73ed36613b95 Reviewed-on: https://skia-review.googlesource.com/144120 Commit-Queue: Herb Derby <herb@google.com> Auto-Submit: Herb Derby <herb@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
-rw-r--r--src/gpu/text/GrTextContext.cpp59
-rw-r--r--src/gpu/text/GrTextContext.h8
2 files changed, 54 insertions, 13 deletions
diff --git a/src/gpu/text/GrTextContext.cpp b/src/gpu/text/GrTextContext.cpp
index 4631991985..4a3c0baa10 100644
--- a/src/gpu/text/GrTextContext.cpp
+++ b/src/gpu/text/GrTextContext.cpp
@@ -185,26 +185,25 @@ void GrTextContext::regenerateGlyphRunList(GrTextBlob* cacheBlob,
cacheBlob->initReusableBlob(paint.luminanceColor(), viewMatrix, origin.x(), origin.y());
// Regenerate textblob
- SkGlyphRunListIterator it(glyphRunList);
GrTextUtils::RunPaint runPaint(&paint);
- for (int run = 0; !it.done(); it.next(), run++) {
- int glyphCount = it.glyphCount();
- size_t textLen = glyphCount * sizeof(uint16_t);
- cacheBlob->push_back_run(run);
- if (!runPaint.modifyForRun([it](SkPaint* p) { it.applyFontToPaint(p); })) {
+ int runNum = 0;
+ for (const auto& glyphRun : glyphRunList) {
+ cacheBlob->push_back_run(runNum);
+
+ if (!runPaint.modifyForRun([glyphRun](SkPaint* p) { *p = glyphRun.paint(); })) {
continue;
}
- cacheBlob->setRunPaintFlags(run, runPaint.skPaint().getFlags());
+ cacheBlob->setRunPaintFlags(runNum, runPaint.skPaint().getFlags());
if (CanDrawAsDistanceFields(runPaint, viewMatrix, props,
shaderCaps.supportsDistanceFieldText(), fOptions)) {
- this->drawDFGlyphRun(cacheBlob, run, glyphCache, props, runPaint,
- scalerContextFlags, viewMatrix, it.glyphRun(), origin);
+ this->drawDFGlyphRun(cacheBlob, runNum, glyphCache, props, runPaint,
+ scalerContextFlags, viewMatrix, glyphRun, origin);
} else {
- DrawBmpPosText(cacheBlob, run, glyphCache, props, runPaint, scalerContextFlags,
- viewMatrix, (const char*)it.glyphs(), textLen, it.pos(), 2,
- origin);
+ DrawBmpGlyphRun(cacheBlob, runNum, glyphCache, props, runPaint, scalerContextFlags,
+ viewMatrix, glyphRun, origin);
}
+ runNum += 1;
}
}
@@ -301,6 +300,42 @@ void GrTextContext::DrawBmpPosText(GrTextBlob* blob, int runIndex,
});
}
+void GrTextContext::DrawBmpGlyphRun(GrTextBlob* blob, int runIndex,
+ GrGlyphCache* glyphCache, const SkSurfaceProps& props,
+ const GrTextUtils::Paint& paint,
+ SkScalerContextFlags scalerContextFlags,
+ const SkMatrix& viewMatrix,
+ const SkGlyphRun& glyphRun, const SkPoint& offset) {
+
+ // Ensure the blob is set for bitmaptext
+ blob->setHasBitmap();
+
+ if (SkDraw::ShouldDrawTextAsPaths(paint, viewMatrix)) {
+ DrawBmpPosTextAsPaths(
+ blob, runIndex, glyphCache, props, paint, scalerContextFlags, viewMatrix,
+ (const char*)glyphRun.shuntGlyphsIDs().data(),
+ glyphRun.shuntGlyphsIDs().size() * sizeof(SkGlyphID),
+ (const SkScalar*)glyphRun.positions().data(), 2, offset);
+ return;
+ }
+
+ sk_sp<GrTextStrike> currStrike;
+ auto cache = blob->setupCache(runIndex, props, scalerContextFlags, paint, &viewMatrix);
+ SkFindAndPlaceGlyph::ProcessPosText(
+ SkPaint::kGlyphID_TextEncoding,
+ (const char*)glyphRun.shuntGlyphsIDs().data(),
+ glyphRun.shuntGlyphsIDs().size() * sizeof(SkGlyphID),
+ offset, viewMatrix, (const SkScalar*)glyphRun.positions().data(), 2, cache.get(),
+ [&](const SkGlyph& glyph, SkPoint position, SkPoint rounding) {
+ position += rounding;
+ BmpAppendGlyph(blob, runIndex, glyphCache, &currStrike, glyph,
+ SkScalarFloorToScalar(position.fX),
+ SkScalarFloorToScalar(position.fY),
+ paint.filteredPremulColor(), cache.get(), SK_Scalar1, false);
+ }
+ );
+}
+
void GrTextContext::DrawBmpPosTextAsPaths(GrTextBlob* blob, int runIndex,
GrGlyphCache* glyphCache,
const SkSurfaceProps& props,
diff --git a/src/gpu/text/GrTextContext.h b/src/gpu/text/GrTextContext.h
index 7c8c576041..21657469c5 100644
--- a/src/gpu/text/GrTextContext.h
+++ b/src/gpu/text/GrTextContext.h
@@ -8,10 +8,11 @@
#ifndef GrTextContext_DEFINED
#define GrTextContext_DEFINED
-#include "GrTextBlob.h"
#include "GrDistanceFieldAdjustTable.h"
#include "GrGeometryProcessor.h"
+#include "GrTextBlob.h"
#include "GrTextUtils.h"
+#include "SkGlyphRun.h"
#if GR_TEST_UTILS
#include "GrDrawOpTest.h"
@@ -177,6 +178,11 @@ private:
const char text[], size_t byteLength, const SkScalar pos[],
int scalarsPerPosition, const SkPoint& offset);
+ static void DrawBmpGlyphRun(GrTextBlob*, int runIndex, GrGlyphCache*,
+ const SkSurfaceProps&, const GrTextUtils::Paint& paint,
+ SkScalerContextFlags scalerContextFlags, const SkMatrix& viewMatrix,
+ const SkGlyphRun& glyphRun, const SkPoint& offset);
+
static void DrawBmpPosTextAsPaths(GrTextBlob*, int runIndex, GrGlyphCache*,
const SkSurfaceProps&, const GrTextUtils::Paint& paint,
SkScalerContextFlags scalerContextFlags,