remove paint from SkGlyphRunList

Change-Id: I0f9027f1a360d90d2c91680d414a6591bc8192cc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/387956
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
This commit is contained in:
Herb Derby 2021-03-22 15:28:23 -04:00 committed by Skia Commit-Bot
parent 5625ef5043
commit 0da2c146fd
30 changed files with 149 additions and 126 deletions

View File

@ -39,7 +39,7 @@ class DirectMaskGlyphVertexFillBenchmark : public Benchmark {
size_t len = strlen(gText);
SkGlyphRunBuilder builder;
SkPaint paint;
builder.drawTextUTF8(paint, font, gText, len, {100, 100});
builder.drawTextUTF8(font, gText, len, {100, 100});
auto glyphRunList = builder.useGlyphRunList();
SkASSERT(!glyphRunList.empty());
SkSurfaceProps props;
@ -52,7 +52,7 @@ class DirectMaskGlyphVertexFillBenchmark : public Benchmark {
const SkPoint drawOrigin = glyphRunList.origin();
drawMatrix.preTranslate(drawOrigin.x(), drawOrigin.y());
GrSDFTControl control{false, props.isUseDeviceIndependentFonts(), 256, 256};
fBlob = GrTextBlob::Make(glyphRunList, drawMatrix, control, &painter);
fBlob = GrTextBlob::Make(glyphRunList, paint, drawMatrix, control, &painter);
SkASSERT(!fBlob->subRunList().isEmpty());
GrAtlasSubRun* subRun = fBlob->subRunList().front().testingOnly_atlasSubRun();

View File

@ -543,8 +543,8 @@ void SkBitmapDevice::drawImageRect(const SkImage* image, const SkRect* src, cons
this->drawRect(*dstPtr, paintWithShader);
}
void SkBitmapDevice::drawGlyphRunList(const SkGlyphRunList& glyphRunList) {
LOOP_TILER( drawGlyphRunList(glyphRunList, &fGlyphPainter), nullptr )
void SkBitmapDevice::drawGlyphRunList(const SkGlyphRunList& glyphRunList, const SkPaint& paint) {
LOOP_TILER( drawGlyphRunList(glyphRunList, paint, &fGlyphPainter), nullptr )
}
void SkBitmapDevice::drawVertices(const SkVertices* vertices, SkBlendMode bmode,

View File

@ -94,7 +94,7 @@ protected:
const SkSamplingOptions&, const SkPaint&,
SkCanvas::SrcRectConstraint) override;
void drawGlyphRunList(const SkGlyphRunList& glyphRunList) override;
void drawGlyphRunList(const SkGlyphRunList& glyphRunList, const SkPaint& paint) override;
void drawVertices(const SkVertices*, SkBlendMode, const SkPaint&) override;
void drawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int count,
SkBlendMode, const SkSamplingOptions&, const SkPaint&) override;

View File

@ -2284,6 +2284,7 @@ void SkCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
}
AutoLayerForImageFilter layer(this, paint, &bounds);
// We can't hoist building the glyph run list because some of the text blob runs may be RSXform.
fScratchGlyphRunBuilder->drawTextBlob(layer.paint(), *blob, {x, y}, this->topDevice());
}

View File

@ -467,7 +467,7 @@ void SkBaseDevice::drawGlyphRunRSXform(const SkFont& font, const SkGlyphID glyph
this->setLocalToDevice(originalLocalToDevice * SkM44(glyphToDevice));
this->drawGlyphRunList(SkGlyphRunList{glyphRun, transformingPaint});
this->drawGlyphRunList(SkGlyphRunList{glyphRun}, transformingPaint);
}
this->setLocalToDevice(originalLocalToDevice);
}

View File

@ -277,7 +277,8 @@ protected:
virtual void drawVertices(const SkVertices*, SkBlendMode, const SkPaint&) = 0;
virtual void drawShadow(const SkPath&, const SkDrawShadowRec&);
virtual void drawGlyphRunList(const SkGlyphRunList& glyphRunList) = 0;
virtual void drawGlyphRunList(const SkGlyphRunList& glyphRunList, const SkPaint& paint) = 0;
// default implementation calls drawVertices
virtual void drawPatch(const SkPoint cubics[12], const SkColor colors[4],
const SkPoint texCoords[4], SkBlendMode, const SkPaint& paint);
@ -528,7 +529,7 @@ protected:
void drawRRect(const SkRRect&, const SkPaint&) override {}
void drawPath(const SkPath&, const SkPaint&, bool) override {}
void drawDevice(SkBaseDevice*, const SkSamplingOptions&, const SkPaint&) override {}
void drawGlyphRunList(const SkGlyphRunList& glyphRunList) override {}
void drawGlyphRunList(const SkGlyphRunList& glyphRunList, const SkPaint& paint) override {}
void drawVertices(const SkVertices*, SkBlendMode, const SkPaint&) override {}
void drawFilteredImage(const skif::Mapping&, SkSpecialImage* src, const SkImageFilter*,

View File

@ -62,6 +62,7 @@ public:
const SkSamplingOptions&, const SkPaint&) const;
void drawSprite(const SkBitmap&, int x, int y, const SkPaint&) const;
void drawGlyphRunList(const SkGlyphRunList& glyphRunList,
const SkPaint& paint,
SkGlyphRunListPainter* glyphPainter) const;
void drawVertices(const SkVertices*, SkBlendMode, const SkPaint&) const;
void drawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int count,

View File

@ -125,6 +125,7 @@ void SkDraw::paintPaths(SkDrawableGlyphBuffer* drawables,
}
void SkDraw::drawGlyphRunList(const SkGlyphRunList& glyphRunList,
const SkPaint& paint,
SkGlyphRunListPainter* glyphPainter) const {
SkDEBUGCODE(this->validate();)
@ -133,7 +134,7 @@ void SkDraw::drawGlyphRunList(const SkGlyphRunList& glyphRunList,
return;
}
glyphPainter->drawForBitmapDevice(glyphRunList, fMatrixProvider->localToDevice(), this);
glyphPainter->drawForBitmapDevice(glyphRunList, paint, fMatrixProvider->localToDevice(), this);
}
#if defined _WIN32

View File

@ -39,18 +39,15 @@ SkGlyphRun::SkGlyphRun(const SkGlyphRun& that, const SkFont& font)
// -- SkGlyphRunList -------------------------------------------------------------------------------
SkGlyphRunList::SkGlyphRunList() = default;
SkGlyphRunList::SkGlyphRunList(
const SkPaint& paint,
const SkTextBlob* blob,
SkPoint origin,
SkSpan<const SkGlyphRun> glyphRunList)
: fGlyphRuns{glyphRunList}
, fOriginalPaint{&paint}
, fOriginalTextBlob{blob}
, fOrigin{origin} { }
SkGlyphRunList::SkGlyphRunList(const SkGlyphRun& glyphRun, const SkPaint& paint)
SkGlyphRunList::SkGlyphRunList(const SkGlyphRun& glyphRun)
: fGlyphRuns{SkSpan<const SkGlyphRun>{&glyphRun, 1}}
, fOriginalPaint{&paint}
, fOriginalTextBlob{nullptr}
, fOrigin{SkPoint::Make(0, 0)} {}
@ -92,7 +89,7 @@ void SkGlyphRunList::temporaryShuntBlobNotifyAddedToCache(uint32_t cacheID) cons
}
// -- SkGlyphRunBuilder ----------------------------------------------------------------------------
void SkGlyphRunBuilder::drawTextUTF8(const SkPaint& paint, const SkFont& font, const void* bytes,
void SkGlyphRunBuilder::drawTextUTF8(const SkFont& font, const void* bytes,
size_t byteLength, SkPoint origin) {
auto glyphIDs = textToGlyphIDs(font, bytes, byteLength, SkTextEncoding::kUTF8);
if (!glyphIDs.empty()) {
@ -100,7 +97,7 @@ void SkGlyphRunBuilder::drawTextUTF8(const SkPaint& paint, const SkFont& font, c
this->simplifyDrawText(font, glyphIDs, origin, fPositions);
}
this->makeGlyphRunList(paint, nullptr, SkPoint::Make(0, 0));
this->makeGlyphRunList(nullptr, SkPoint::Make(0, 0));
}
void SkGlyphRunBuilder::drawTextBlob(const SkPaint& paint, const SkTextBlob& blob, SkPoint origin,
@ -122,27 +119,28 @@ void SkGlyphRunBuilder::drawTextBlob(const SkPaint& paint, const SkTextBlob& blo
} else {
// Handle kRSXform_Positioning
if (!this->empty()) {
this->makeGlyphRunList(paint, &blob, origin);
device->drawGlyphRunList(this->useGlyphRunList());
// Draw the things we have accumulated so far before drawing the RSX form.
this->makeGlyphRunList(&blob, origin);
device->drawGlyphRunList(this->useGlyphRunList(), paint);
// re-init in case we keep looping and need the builder again
this->initialize(totalGlyphs);
}
device->drawGlyphRunRSXform(it.font(), it.glyphs(), (const SkRSXform*)it.pos(),
it.glyphCount(), origin, paint);
// re-init in case we keep looping and need the builder again
this->initialize(totalGlyphs);
}
positions += it.glyphCount();
}
if (!this->empty()) {
this->makeGlyphRunList(paint, &blob, origin);
device->drawGlyphRunList(this->useGlyphRunList());
this->makeGlyphRunList(&blob, origin);
device->drawGlyphRunList(this->useGlyphRunList(), paint);
}
}
void SkGlyphRunBuilder::textBlobToGlyphRunListIgnoringRSXForm(
const SkPaint& paint, const SkTextBlob& blob, SkPoint origin) {
const SkTextBlob& blob, SkPoint origin) {
// Figure out all the storage needed to pre-size everything below.
size_t totalGlyphs = 0;
for (SkTextBlobRunIterator it(&blob); !it.done(); it.next()) {
@ -160,7 +158,7 @@ void SkGlyphRunBuilder::textBlobToGlyphRunListIgnoringRSXForm(
}
if (!this->empty()) {
this->makeGlyphRunList(paint, &blob, origin);
this->makeGlyphRunList(&blob, origin);
}
}
@ -194,12 +192,12 @@ void SkGlyphRunBuilder::simplifyTextBlobIgnoringRSXForm(const SkTextBlobRunItera
}
}
void SkGlyphRunBuilder::drawGlyphsWithPositions(const SkPaint& paint, const SkFont& font,
void SkGlyphRunBuilder::drawGlyphsWithPositions(const SkFont& font,
SkSpan<const SkGlyphID> glyphIDs, const SkPoint* pos) {
if (!glyphIDs.empty()) {
this->initialize(glyphIDs.size());
this->simplifyDrawPosText(font, glyphIDs, pos);
this->makeGlyphRunList(paint, nullptr, SkPoint::Make(0, 0));
this->makeGlyphRunList(nullptr, SkPoint::Make(0, 0));
}
}
@ -251,11 +249,10 @@ void SkGlyphRunBuilder::makeGlyphRun(
}
}
void SkGlyphRunBuilder::makeGlyphRunList(
const SkPaint& paint, const SkTextBlob* blob, SkPoint origin) {
void SkGlyphRunBuilder::makeGlyphRunList(const SkTextBlob* blob, SkPoint origin) {
fGlyphRunList.~SkGlyphRunList();
new (&fGlyphRunList) SkGlyphRunList{paint, blob, origin, SkSpan(fGlyphRunListStorage)};
new (&fGlyphRunList) SkGlyphRunList{blob, origin, SkSpan(fGlyphRunListStorage)};
}
void SkGlyphRunBuilder::simplifyDrawText(

View File

@ -60,12 +60,11 @@ public:
SkGlyphRunList();
// Blob maybe null.
SkGlyphRunList(
const SkPaint& paint,
const SkTextBlob* blob,
SkPoint origin,
SkSpan<const SkGlyphRun> glyphRunList);
SkGlyphRunList(const SkGlyphRun& glyphRun, const SkPaint& paint);
SkGlyphRunList(const SkGlyphRun& glyphRun);
uint64_t uniqueID() const;
bool anyRunsLCD() const;
@ -84,7 +83,6 @@ public:
bool allFontsFinite() const;
SkPoint origin() const { return fOrigin; }
const SkPaint& paint() const { return *fOriginalPaint; }
const SkTextBlob* blob() const { return fOriginalTextBlob; }
auto begin() -> decltype(fGlyphRuns.begin()) { return fGlyphRuns.begin(); }
@ -96,7 +94,6 @@ public:
auto operator [] (size_t i) const -> decltype(fGlyphRuns[i]) { return fGlyphRuns[i]; }
private:
const SkPaint* fOriginalPaint{nullptr}; // This should be deleted soon.
// The text blob is needed to hookup the call back that the SkTextBlob destructor calls. It
// should be used for nothing else
const SkTextBlob* fOriginalTextBlob{nullptr};
@ -105,14 +102,12 @@ private:
class SkGlyphRunBuilder {
public:
void drawTextUTF8(
const SkPaint& paint, const SkFont&, const void* bytes, size_t byteLength, SkPoint origin);
void drawTextUTF8(const SkFont&, const void* bytes, size_t byteLength, SkPoint origin);
void drawGlyphsWithPositions(
const SkPaint&, const SkFont&, SkSpan<const SkGlyphID> glyphIDs, const SkPoint* pos);
const SkFont&, SkSpan<const SkGlyphID> glyphIDs, const SkPoint* pos);
void drawTextBlob(const SkPaint& paint, const SkTextBlob& blob, SkPoint origin, SkBaseDevice*);
void textBlobToGlyphRunListIgnoringRSXForm(
const SkPaint& paint, const SkTextBlob& blob, SkPoint origin);
void textBlobToGlyphRunListIgnoringRSXForm(const SkTextBlob& blob, SkPoint origin);
const SkGlyphRunList& useGlyphRunList();
@ -130,7 +125,7 @@ private:
SkSpan<const char> text,
SkSpan<const uint32_t> clusters);
void makeGlyphRunList(const SkPaint& paint, const SkTextBlob* blob, SkPoint origin);
void makeGlyphRunList(const SkTextBlob* blob, SkPoint origin);
void simplifyDrawText(
const SkFont& font, SkSpan<const SkGlyphID> glyphIDs,

View File

@ -79,7 +79,7 @@ SkGlyphRunListPainter::SkGlyphRunListPainter(const GrSurfaceDrawContext& rtc)
#endif
void SkGlyphRunListPainter::drawForBitmapDevice(
const SkGlyphRunList& glyphRunList, const SkMatrix& deviceMatrix,
const SkGlyphRunList& glyphRunList, const SkPaint& paint, const SkMatrix& deviceMatrix,
const BitmapDevicePainter* bitmapDevice) {
ScopedBuffers _ = this->ensureBuffers(glyphRunList);
@ -87,10 +87,9 @@ void SkGlyphRunListPainter::drawForBitmapDevice(
// gpu build. Remove when SkGlyphRunListPainter is split into GPU and CPU version.
(void)fStrikeCache;
const SkPaint& runPaint = glyphRunList.paint();
// 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.
auto& props = (kN32_SkColorType == fColorType && runPaint.isSrcOver())
auto& props = (kN32_SkColorType == fColorType && paint.isSrcOver())
? fDeviceProps
: fBitmapFallbackProps;
@ -100,10 +99,10 @@ void SkGlyphRunListPainter::drawForBitmapDevice(
fRejects.setSource(glyphRun.source());
if (SkStrikeSpec::ShouldDrawAsPath(runPaint, runFont, deviceMatrix)) {
if (SkStrikeSpec::ShouldDrawAsPath(paint, runFont, deviceMatrix)) {
SkStrikeSpec strikeSpec = SkStrikeSpec::MakePath(
runFont, runPaint, props, fScalerContextFlags);
runFont, paint, props, fScalerContextFlags);
auto strike = strikeSpec.findOrCreateStrike();
@ -113,7 +112,7 @@ void SkGlyphRunListPainter::drawForBitmapDevice(
// The paint we draw paths with must have the same anti-aliasing state as the runFont
// allowing the paths to have the same edging as the glyph masks.
SkPaint pathPaint = runPaint;
SkPaint pathPaint = paint;
pathPaint.setAntiAlias(runFont.hasSomeAntiAliasing());
bitmapDevice->paintPaths(
@ -121,14 +120,14 @@ void SkGlyphRunListPainter::drawForBitmapDevice(
}
if (!fRejects.source().empty()) {
SkStrikeSpec strikeSpec = SkStrikeSpec::MakeMask(
runFont, runPaint, props, fScalerContextFlags, deviceMatrix);
runFont, paint, props, fScalerContextFlags, deviceMatrix);
auto strike = strikeSpec.findOrCreateStrike();
fDrawable.startBitmapDevice(
fRejects.source(), drawOrigin, deviceMatrix, strike->roundingSpec());
strike->prepareForDrawingMasksCPU(&fDrawable);
bitmapDevice->paintMasks(&fDrawable, runPaint);
bitmapDevice->paintMasks(&fDrawable, paint);
}
// TODO: have the mask stage above reject the glyphs that are too big, and handle the

View File

@ -77,7 +77,7 @@ public:
};
void drawForBitmapDevice(
const SkGlyphRunList& glyphRunList, const SkMatrix& deviceMatrix,
const SkGlyphRunList& glyphRunList, const SkPaint& paint, const SkMatrix& deviceMatrix,
const BitmapDevicePainter* bitmapDevice);
#if SK_SUPPORT_GPU

View File

@ -62,8 +62,8 @@ public:
}
protected:
void drawGlyphRunList(const SkGlyphRunList& glyphRunList) override {
fPainter.drawForBitmapDevice(glyphRunList, fOverdrawCanvas->getTotalMatrix(), this);
void drawGlyphRunList(const SkGlyphRunList& glyphRunList, const SkPaint& paint) override {
fPainter.drawForBitmapDevice(glyphRunList, paint, fOverdrawCanvas->getTotalMatrix(), this);
}
private:

View File

@ -829,7 +829,7 @@ public:
}
protected:
void drawGlyphRunList(const SkGlyphRunList& glyphRunList) override {
void drawGlyphRunList(const SkGlyphRunList& glyphRunList, const SkPaint& paint) override {
#if SK_SUPPORT_GPU
GrContextOptions ctxOptions;
GrSDFTControl control =
@ -843,7 +843,7 @@ protected:
for (auto& glyphRun : glyphRunList) {
fPainter.processGlyphRun(glyphRun,
drawMatrix,
glyphRunList.paint(),
paint,
control,
nullptr,
"Cache Diff");

View File

@ -930,7 +930,7 @@ int SkTextBlob::getIntercepts(const SkScalar bounds[2], SkScalar intervals[],
}
SkGlyphRunBuilder builder;
builder.textBlobToGlyphRunListIgnoringRSXForm(*paint, *this, SkPoint{0, 0});
builder.textBlobToGlyphRunListIgnoringRSXForm(*this, SkPoint{0, 0});
auto glyphRunList = builder.useGlyphRunList();
int intervalCount = 0;

View File

@ -83,11 +83,11 @@ SkTextBlobTrace::Capture::Capture() : fTypefaceSet(new SkRefCntSet) {
SkTextBlobTrace::Capture::~Capture() = default;
void SkTextBlobTrace::Capture::capture(const SkGlyphRunList& glyphRunList) {
void SkTextBlobTrace::Capture::capture(const SkGlyphRunList& glyphRunList, const SkPaint& paint) {
const SkTextBlob* blob = glyphRunList.blob();
if (blob != nullptr) {
fWriteBuffer.writeUInt(blob->uniqueID());
fWriteBuffer.writePaint(glyphRunList.paint());
fWriteBuffer.writePaint(paint);
fWriteBuffer.writePoint(glyphRunList.origin());
SkTextBlobPriv::Flatten(*blob, fWriteBuffer);
fBlobCount++;

View File

@ -32,7 +32,7 @@ class Capture {
public:
Capture();
~Capture();
void capture(const SkGlyphRunList&);
void capture(const SkGlyphRunList&, const SkPaint&);
// If `dst` is nullptr, write to a file.
void dump(SkWStream* dst = nullptr) const;

View File

@ -327,7 +327,8 @@ GrMipmapped GrSurfaceDrawContext::mipmapped() const {
void GrSurfaceDrawContext::drawGlyphRunListNoCache(const GrClip* clip,
const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList) {
const SkGlyphRunList& glyphRunList,
const SkPaint& paint) {
GrSDFTControl control =
fContext->priv().getSDFTControl(fSurfaceProps.isUseDeviceIndependentFonts());
const SkPoint drawOrigin = glyphRunList.origin();
@ -336,12 +337,12 @@ void GrSurfaceDrawContext::drawGlyphRunListNoCache(const GrClip* clip,
GrSubRunAllocator* const alloc = this->recordingContext()->priv().recordTimeSubRunAllocator();
for (auto& glyphRun : glyphRunList) {
GrSubRunNoCachePainter painter{this, alloc, clip, viewMatrix, glyphRunList};
GrSubRunNoCachePainter painter{this, alloc, clip, viewMatrix, glyphRunList, paint};
// Make and add the text ops.
fGlyphPainter.processGlyphRun(glyphRun,
drawMatrix,
glyphRunList.paint(),
paint,
control,
&painter);
}
@ -349,7 +350,8 @@ void GrSurfaceDrawContext::drawGlyphRunListNoCache(const GrClip* clip,
void GrSurfaceDrawContext::drawGlyphRunListWithCache(const GrClip* clip,
const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList) {
const SkGlyphRunList& glyphRunList,
const SkPaint& paint) {
SkMatrix drawMatrix(viewMatrix.localToDevice());
drawMatrix.preTranslate(glyphRunList.origin().x(), glyphRunList.origin().y());
@ -358,6 +360,7 @@ void GrSurfaceDrawContext::drawGlyphRunListWithCache(const GrClip* clip,
this->surfaceProps().isUseDeviceIndependentFonts());
auto [canCache, key] = GrTextBlob::Key::Make(glyphRunList,
paint,
fSurfaceProps,
this->colorInfo(),
drawMatrix,
@ -369,7 +372,7 @@ void GrSurfaceDrawContext::drawGlyphRunListWithCache(const GrClip* clip,
blob = textBlobCache->find(key);
}
if (blob == nullptr || !blob->canReuse(glyphRunList.paint(), drawMatrix)) {
if (blob == nullptr || !blob->canReuse(paint, drawMatrix)) {
if (blob != nullptr) {
SkASSERT(!drawMatrix.hasPerspective());
// We have to remake the blob because changes may invalidate our masks.
@ -378,7 +381,7 @@ void GrSurfaceDrawContext::drawGlyphRunListWithCache(const GrClip* clip,
textBlobCache->remove(blob.get());
}
blob = GrTextBlob::Make(glyphRunList, drawMatrix, control, &fGlyphPainter);
blob = GrTextBlob::Make(glyphRunList, paint, drawMatrix, control, &fGlyphPainter);
if (canCache) {
blob->addKey(key);
@ -389,7 +392,7 @@ void GrSurfaceDrawContext::drawGlyphRunListWithCache(const GrClip* clip,
}
for (const GrSubRun& subRun : blob->subRunList()) {
subRun.draw(clip, viewMatrix, glyphRunList, this);
subRun.draw(clip, viewMatrix, glyphRunList, paint, this);
}
}
@ -397,7 +400,8 @@ void GrSurfaceDrawContext::drawGlyphRunListWithCache(const GrClip* clip,
bool gGrDrawTextNoCache = false;
void GrSurfaceDrawContext::drawGlyphRunList(const GrClip* clip,
const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList) {
const SkGlyphRunList& glyphRunList,
const SkPaint& paint) {
ASSERT_SINGLE_OWNER
RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
@ -412,9 +416,9 @@ void GrSurfaceDrawContext::drawGlyphRunList(const GrClip* clip,
if (gGrDrawTextNoCache) {
// drawGlyphRunListNoCache lives in GrTextBlob.cpp to share sub run implementation code.
this->drawGlyphRunListNoCache(clip, viewMatrix, glyphRunList);
this->drawGlyphRunListNoCache(clip, viewMatrix, glyphRunList, paint);
} else {
this->drawGlyphRunListWithCache(clip, viewMatrix, glyphRunList);
this->drawGlyphRunListWithCache(clip, viewMatrix, glyphRunList, paint);
}
}

View File

@ -508,7 +508,8 @@ public:
*/
void drawGlyphRunList(const GrClip*,
const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList);
const SkGlyphRunList& glyphRunList,
const SkPaint& paint);
/**
* Draw the text specified by the SkGlyphRunList.
@ -518,7 +519,8 @@ public:
*/
void drawGlyphRunListWithCache(const GrClip*,
const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList);
const SkGlyphRunList& glyphRunList,
const SkPaint& paint);
/**
* Draw the text specified by the SkGlyphRunList.
@ -528,7 +530,8 @@ public:
*/
void drawGlyphRunListNoCache(const GrClip*,
const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList);
const SkGlyphRunList& glyphRunList,
const SkPaint& paint);
/**
* Adds the necessary signal and wait semaphores and adds the passed in SkDrawable to the

View File

@ -927,7 +927,7 @@ void SkGpuDevice::drawAtlas(const SkImage* atlas, const SkRSXform xform[],
///////////////////////////////////////////////////////////////////////////////
void SkGpuDevice::drawGlyphRunList(const SkGlyphRunList& glyphRunList) {
void SkGpuDevice::drawGlyphRunList(const SkGlyphRunList& glyphRunList, const SkPaint& paint) {
ASSERT_SINGLE_OWNER
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawGlyphRunList", fContext.get());
@ -936,7 +936,8 @@ void SkGpuDevice::drawGlyphRunList(const SkGlyphRunList& glyphRunList) {
return;
}
fSurfaceDrawContext->drawGlyphRunList(this->clip(), this->asMatrixProvider(), glyphRunList);
fSurfaceDrawContext->drawGlyphRunList(
this->clip(), this->asMatrixProvider(), glyphRunList, paint);
}
///////////////////////////////////////////////////////////////////////////////

View File

@ -102,7 +102,7 @@ public:
bool useCenter, const SkPaint& paint) override;
void drawPath(const SkPath& path, const SkPaint& paint, bool pathIsMutable) override;
void drawGlyphRunList(const SkGlyphRunList& glyphRunList) override;
void drawGlyphRunList(const SkGlyphRunList& glyphRunList, const SkPaint& paint) override;
void drawVertices(const SkVertices*, SkBlendMode, const SkPaint&) override;
void drawShadow(const SkPath&, const SkDrawShadowRec&) override;
void drawAtlas(const SkImage* atlas, const SkRSXform[], const SkRect[], const SkColor[],

View File

@ -502,7 +502,7 @@ GrOp::Owner GrAtlasTextOp::CreateOpTestingOnly(GrSurfaceDrawContext* rtc,
drawMatrix.preTranslate(x, y);
auto drawOrigin = SkPoint::Make(x, y);
SkGlyphRunBuilder builder;
builder.drawTextUTF8(skPaint, font, text, textLen, drawOrigin);
builder.drawTextUTF8(font, text, textLen, drawOrigin);
auto glyphRunList = builder.useGlyphRunList();
if (glyphRunList.empty()) {
@ -514,7 +514,7 @@ GrOp::Owner GrAtlasTextOp::CreateOpTestingOnly(GrSurfaceDrawContext* rtc,
rContext->priv().getSDFTControl(rtc->surfaceProps().isUseDeviceIndependentFonts());
SkGlyphRunListPainter* painter = rtc->glyphRunPainter();
sk_sp<GrTextBlob> blob = GrTextBlob::Make(glyphRunList, drawMatrix, control, painter);
sk_sp<GrTextBlob> blob = GrTextBlob::Make(glyphRunList, skPaint, drawMatrix, control, painter);
if (blob->subRunList().isEmpty()) {
return nullptr;
@ -524,7 +524,7 @@ GrOp::Owner GrAtlasTextOp::CreateOpTestingOnly(GrSurfaceDrawContext* rtc,
SkASSERT(subRun);
GrOp::Owner op;
std::tie(std::ignore, op) = subRun->makeAtlasTextOp(
nullptr, mtxProvider, glyphRunList, rtc, nullptr);
nullptr, mtxProvider, glyphRunList, skPaint, rtc, nullptr);
return op;
}

View File

@ -177,6 +177,7 @@ public:
void draw(const GrClip* clip,
const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList,
const SkPaint& paint,
GrSurfaceDrawContext* sdc) const override;
bool canReuse(const SkPaint& paint, const SkMatrix& drawMatrix) const override;
@ -215,11 +216,11 @@ PathSubRun::PathSubRun(bool isAntiAliased,
void PathSubRun::draw(const GrClip* clip,
const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList,
const SkPaint& paint,
GrSurfaceDrawContext* sdc) const {
SkASSERT(!fPaths.empty());
SkPoint drawOrigin = glyphRunList.origin();
const SkPaint& drawPaint = glyphRunList.paint();
SkPaint runPaint{drawPaint};
SkPaint runPaint{paint};
runPaint.setAntiAlias(fIsAntiAliased);
// If there are shaders, blurs or styles, the path must be scaled into source
// space independently of the CTM. This allows the CTM to be correct for the
@ -243,7 +244,7 @@ void PathSubRun::draw(const GrClip* clip,
pathMatrix.postTranslate(pos.x(), pos.y());
SkPreConcatMatrixProvider strikeToDevice(viewMatrix, pathMatrix);
GrStyledShape shape(path, drawPaint);
GrStyledShape shape(path, paint);
GrBlurUtils::drawShapeWithMaskFilter(sdc->recordingContext(), sdc, clip, runPaint,
strikeToDevice, shape);
}
@ -260,7 +261,7 @@ void PathSubRun::draw(const GrClip* clip,
SkPath deviceOutline;
path.transform(pathMatrix, &deviceOutline);
deviceOutline.setIsVolatile(true);
GrStyledShape shape(deviceOutline, drawPaint);
GrStyledShape shape(deviceOutline, paint);
GrBlurUtils::drawShapeWithMaskFilter(sdc->recordingContext(), sdc, clip, runPaint,
viewMatrix, shape);
}
@ -453,6 +454,7 @@ public:
void draw(const GrClip* clip,
const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList,
const SkPaint& paint,
GrSurfaceDrawContext* sdc) const override;
bool canReuse(const SkPaint& paint, const SkMatrix& drawMatrix) const override;
@ -467,6 +469,7 @@ public:
makeAtlasTextOp(const GrClip* clip,
const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList,
const SkPaint& paint,
GrSurfaceDrawContext* sdc,
GrAtlasSubRunOwner) const override;
@ -554,8 +557,10 @@ GrSubRunOwner DirectMaskSubRun::Make(const SkZip<SkGlyphVariant, SkPoint>& drawa
void DirectMaskSubRun::draw(const GrClip* clip, const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList,
const SkPaint& paint,
GrSurfaceDrawContext* sdc) const{
auto[drawingClip, op] = this->makeAtlasTextOp(clip, viewMatrix, glyphRunList, sdc, nullptr);
auto[drawingClip, op] = this->makeAtlasTextOp(
clip, viewMatrix, glyphRunList, paint, sdc, nullptr);
if (op != nullptr) {
sdc->addDrawOp(drawingClip, std::move(op));
}
@ -631,6 +636,7 @@ calculate_clip(const GrClip* clip, SkRect deviceBounds, SkRect glyphBounds) {
std::tuple<const GrClip*, GrOp::Owner>
DirectMaskSubRun::makeAtlasTextOp(const GrClip* clip, const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList,
const SkPaint& paint,
GrSurfaceDrawContext* sdc,
GrAtlasSubRunOwner) const {
SkASSERT(this->glyphCount() != 0);
@ -662,9 +668,8 @@ DirectMaskSubRun::makeAtlasTextOp(const GrClip* clip, const SkMatrixProvider& vi
if (!clipRect.isEmpty()) { SkASSERT(clip == nullptr); }
GrPaint grPaint;
const SkPaint& drawPaint = glyphRunList.paint();
const SkPMColor4f drawingColor =
calculate_colors(sdc, drawPaint, viewMatrix, fMaskFormat, &grPaint);
calculate_colors(sdc, paint, viewMatrix, fMaskFormat, &grPaint);
GrRecordingContext* const rContext = sdc->recordingContext();
GrAtlasTextOp::Geometry* geometry = GrAtlasTextOp::Geometry::MakeForBlob(
@ -841,6 +846,7 @@ public:
void draw(const GrClip* clip,
const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList,
const SkPaint& paint,
GrSurfaceDrawContext* sdc) const override;
bool canReuse(const SkPaint& paint, const SkMatrix& drawMatrix) const override;
@ -851,6 +857,7 @@ public:
makeAtlasTextOp(const GrClip* clip,
const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList,
const SkPaint& paint,
GrSurfaceDrawContext* sdc,
GrAtlasSubRunOwner) const override;
@ -925,8 +932,10 @@ GrSubRunOwner TransformedMaskSubRun::Make(const SkZip<SkGlyphVariant, SkPoint>&
void TransformedMaskSubRun::draw(const GrClip* clip,
const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList,
const SkPaint& paint,
GrSurfaceDrawContext* sdc) const {
auto[drawingClip, op] = this->makeAtlasTextOp(clip, viewMatrix, glyphRunList, sdc, nullptr);
auto[drawingClip, op] = this->makeAtlasTextOp(
clip, viewMatrix, glyphRunList, paint, sdc, nullptr);
if (op != nullptr) {
sdc->addDrawOp(drawingClip, std::move(op));
}
@ -945,16 +954,16 @@ std::tuple<const GrClip*, GrOp::Owner>
TransformedMaskSubRun::makeAtlasTextOp(const GrClip* clip,
const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList,
const SkPaint& paint,
GrSurfaceDrawContext* sdc,
GrAtlasSubRunOwner) const {
SkASSERT(this->glyphCount() != 0);
SkPoint drawOrigin = glyphRunList.origin();
const SkPaint& drawPaint = glyphRunList.paint();
const SkMatrix& drawMatrix = viewMatrix.localToDevice();
GrPaint grPaint;
SkPMColor4f drawingColor = calculate_colors(sdc, drawPaint, viewMatrix, fMaskFormat, &grPaint);
SkPMColor4f drawingColor = calculate_colors(sdc, paint, viewMatrix, fMaskFormat, &grPaint);
GrRecordingContext* const rContext = sdc->recordingContext();
GrAtlasTextOp::Geometry* geometry = GrAtlasTextOp::Geometry::MakeForBlob(
@ -1093,6 +1102,7 @@ public:
void draw(const GrClip* clip,
const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList,
const SkPaint& paint,
GrSurfaceDrawContext* sdc) const override;
bool canReuse(const SkPaint& paint, const SkMatrix& drawMatrix) const override;
@ -1103,6 +1113,7 @@ public:
makeAtlasTextOp(const GrClip* clip,
const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList,
const SkPaint& paint,
GrSurfaceDrawContext* sdc,
GrAtlasSubRunOwner) const override;
@ -1222,17 +1233,17 @@ std::tuple<const GrClip*, GrOp::Owner >
SDFTSubRun::makeAtlasTextOp(const GrClip* clip,
const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList,
const SkPaint& paint,
GrSurfaceDrawContext* sdc,
GrAtlasSubRunOwner) const {
SkASSERT(this->glyphCount() != 0);
SkASSERT(!viewMatrix.localToDevice().hasPerspective());
SkPoint drawOrigin = glyphRunList.origin();
const SkPaint& drawPaint = glyphRunList.paint();
const SkMatrix& drawMatrix = viewMatrix.localToDevice();
GrPaint grPaint;
SkPMColor4f drawingColor = calculate_colors(sdc, drawPaint, viewMatrix, fMaskFormat, &grPaint);
SkPMColor4f drawingColor = calculate_colors(sdc, paint, viewMatrix, fMaskFormat, &grPaint);
auto [maskType, DFGPFlags, useGammaCorrectDistanceTable] =
calculate_sdf_parameters(*sdc, drawMatrix, fUseLCDText, fAntiAliased);
@ -1253,7 +1264,7 @@ SDFTSubRun::makeAtlasTextOp(const GrClip* clip,
true,
this->glyphCount(),
this->deviceRect(drawMatrix, drawOrigin),
SkPaintPriv::ComputeLuminanceColor(drawPaint),
SkPaintPriv::ComputeLuminanceColor(paint),
useGammaCorrectDistanceTable,
DFGPFlags,
geometry,
@ -1265,8 +1276,10 @@ SDFTSubRun::makeAtlasTextOp(const GrClip* clip,
void SDFTSubRun::draw(const GrClip* clip,
const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList,
const SkPaint& paint,
GrSurfaceDrawContext* sdc) const {
auto[drawingClip, op] = this->makeAtlasTextOp(clip, viewMatrix, glyphRunList, sdc, nullptr);
auto[drawingClip, op] = this->makeAtlasTextOp(
clip, viewMatrix, glyphRunList, paint, sdc, nullptr);
if (op != nullptr) {
sdc->addDrawOp(drawingClip, std::move(op));
}
@ -1360,20 +1373,17 @@ static SkColor compute_canonical_color(const SkPaint& paint, bool lcd) {
}
auto GrTextBlob::Key::Make(const SkGlyphRunList& glyphRunList,
const SkPaint& paint,
const SkSurfaceProps& surfaceProps,
const GrColorInfo& colorInfo,
const SkMatrix& drawMatrix,
const GrSDFTControl& control) -> std::tuple<bool, Key> {
// Get the first paint to use as the key paint.
const SkPaint& drawPaint = glyphRunList.paint();
SkMaskFilterBase::BlurRec blurRec;
// 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* maskFilter = drawPaint.getMaskFilter();
const SkMaskFilter* maskFilter = paint.getMaskFilter();
bool canCache = glyphRunList.canCache() &&
!(drawPaint.getPathEffect() ||
!(paint.getPathEffect() ||
(maskFilter && !as_MFB(maskFilter)->asABlur(&blurRec)));
// If we're doing linear blending, then we can disable the gamma hacks.
@ -1391,15 +1401,15 @@ auto GrTextBlob::Key::Make(const SkGlyphRunList& glyphRunList,
SkPixelGeometry pixelGeometry =
hasLCD ? surfaceProps.pixelGeometry() : kUnknown_SkPixelGeometry;
GrColor canonicalColor = compute_canonical_color(drawPaint, hasLCD);
GrColor canonicalColor = compute_canonical_color(paint, hasLCD);
key.fPixelGeometry = pixelGeometry;
key.fUniqueID = glyphRunList.uniqueID();
key.fStyle = drawPaint.getStyle();
key.fStyle = paint.getStyle();
if (key.fStyle != SkPaint::kFill_Style) {
key.fFrameWidth = drawPaint.getStrokeWidth();
key.fMiterLimit = drawPaint.getStrokeMiter();
key.fJoin = drawPaint.getStrokeJoin();
key.fFrameWidth = paint.getStrokeWidth();
key.fMiterLimit = paint.getStrokeMiter();
key.fJoin = paint.getStrokeJoin();
}
key.fHasBlur = maskFilter != nullptr;
if (key.fHasBlur) {
@ -1411,7 +1421,7 @@ auto GrTextBlob::Key::Make(const SkGlyphRunList& glyphRunList,
// Calculate the set of drawing types.
key.fSetOfDrawingTypes = 0;
for (auto& run : glyphRunList) {
key.fSetOfDrawingTypes |= control.drawingType(run.font(), drawPaint, drawMatrix);
key.fSetOfDrawingTypes |= control.drawingType(run.font(), paint, drawMatrix);
}
if (key.fSetOfDrawingTypes & GrSDFTControl::kDirect) {
@ -1477,6 +1487,7 @@ void* GrTextBlob::operator new(size_t, void* p) { return p; }
GrTextBlob::~GrTextBlob() = default;
sk_sp<GrTextBlob> GrTextBlob::Make(const SkGlyphRunList& glyphRunList,
const SkPaint& paint,
const SkMatrix& drawMatrix,
const GrSDFTControl& control,
SkGlyphRunListPainter* painter) {
@ -1497,14 +1508,14 @@ sk_sp<GrTextBlob> GrTextBlob::Make(const SkGlyphRunList& glyphRunList,
void* allocation = ::operator new (allocationSize);
SkColor initialLuminance = SkPaintPriv::ComputeLuminanceColor(glyphRunList.paint());
SkColor initialLuminance = SkPaintPriv::ComputeLuminanceColor(paint);
sk_sp<GrTextBlob> blob{new (allocation)
GrTextBlob(bytesNeededForSubRun, drawMatrix, initialLuminance)};
for (auto& glyphRun : glyphRunList) {
painter->processGlyphRun(glyphRun,
drawMatrix,
glyphRunList.paint(),
paint,
control,
blob.get(),
"GrTextBlob");
@ -1719,6 +1730,7 @@ public:
makeAtlasTextOp(const GrClip* clip,
const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList,
const SkPaint& paint,
GrSurfaceDrawContext* sdc,
GrAtlasSubRunOwner subRunOwner) const override;
@ -1813,6 +1825,7 @@ std::tuple<const GrClip*, GrOp::Owner>
DirectMaskSubRunNoCache::makeAtlasTextOp(const GrClip* clip,
const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList,
const SkPaint& paint,
GrSurfaceDrawContext* sdc,
GrAtlasSubRunOwner subRunOwner) const {
SkASSERT(this->glyphCount() != 0);
@ -1843,9 +1856,8 @@ DirectMaskSubRunNoCache::makeAtlasTextOp(const GrClip* clip,
if (!clipRect.isEmpty()) { SkASSERT(clip == nullptr); }
GrPaint grPaint;
const SkPaint& drawPaint = glyphRunList.paint();
const SkPMColor4f drawingColor =
calculate_colors(sdc, drawPaint, viewMatrix, fMaskFormat, &grPaint);
calculate_colors(sdc, paint, viewMatrix, fMaskFormat, &grPaint);
GrRecordingContext* const rContext = sdc->recordingContext();
@ -1953,6 +1965,7 @@ public:
makeAtlasTextOp(const GrClip* clip,
const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList,
const SkPaint& paint,
GrSurfaceDrawContext* sdc,
GrAtlasSubRunOwner subRunOwner) const override;
@ -2026,16 +2039,16 @@ std::tuple<const GrClip*, GrOp::Owner>
TransformedMaskSubRunNoCache::makeAtlasTextOp(const GrClip* clip,
const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList,
const SkPaint& paint,
GrSurfaceDrawContext* sdc,
GrAtlasSubRunOwner subRunOwner) const {
SkASSERT(this->glyphCount() != 0);
SkPoint drawOrigin = glyphRunList.origin();
const SkPaint& drawPaint = glyphRunList.paint();
const SkMatrix& drawMatrix = viewMatrix.localToDevice();
GrPaint grPaint;
SkPMColor4f drawingColor = calculate_colors(sdc, drawPaint, viewMatrix, fMaskFormat, &grPaint);
SkPMColor4f drawingColor = calculate_colors(sdc, paint, viewMatrix, fMaskFormat, &grPaint);
// We can clip geometrically using clipRect and ignore clip if we're not using SDFs or
// transformed glyphs, and we have an axis-aligned rectangular non-AA clip.
@ -2174,6 +2187,7 @@ public:
makeAtlasTextOp(const GrClip* clip,
const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList,
const SkPaint& paint,
GrSurfaceDrawContext* sdc,
GrAtlasSubRunOwner subRunOwner) const override;
@ -2260,16 +2274,16 @@ std::tuple<const GrClip*, GrOp::Owner>
SDFTSubRunNoCache::makeAtlasTextOp(const GrClip* clip,
const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList,
const SkPaint& paint,
GrSurfaceDrawContext* sdc,
GrAtlasSubRunOwner subRunOwner) const {
SkASSERT(this->glyphCount() != 0);
SkPoint drawOrigin = glyphRunList.origin();
const SkPaint& drawPaint = glyphRunList.paint();
const SkMatrix& drawMatrix = viewMatrix.localToDevice();
GrPaint grPaint;
SkPMColor4f drawingColor = calculate_colors(sdc, drawPaint, viewMatrix, fMaskFormat, &grPaint);
SkPMColor4f drawingColor = calculate_colors(sdc, paint, viewMatrix, fMaskFormat, &grPaint);
auto [maskType, DFGPFlags, useGammaCorrectDistanceTable] =
calculate_sdf_parameters(*sdc, drawMatrix, fUseLCDText, fAntiAliased);
@ -2291,7 +2305,7 @@ SDFTSubRunNoCache::makeAtlasTextOp(const GrClip* clip,
true,
this->glyphCount(),
this->deviceRect(drawMatrix, drawOrigin),
SkPaintPriv::ComputeLuminanceColor(drawPaint),
SkPaintPriv::ComputeLuminanceColor(paint),
useGammaCorrectDistanceTable,
DFGPFlags,
geometry,
@ -2345,12 +2359,14 @@ GrSubRunNoCachePainter::GrSubRunNoCachePainter(GrSurfaceDrawContext* sdc,
GrSubRunAllocator* alloc,
const GrClip* clip,
const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList)
const SkGlyphRunList& glyphRunList,
const SkPaint& paint)
: fSDC{sdc}
, fAlloc{alloc}
, fClip{clip}
, fViewMatrix{viewMatrix}
, fGlyphRunList{glyphRunList} {}
, fGlyphRunList{glyphRunList}
, fPaint {paint} {}
void GrSubRunNoCachePainter::processDeviceMasks(
const SkZip<SkGlyphVariant, SkPoint>& drawables, const SkStrikeSpec& strikeSpec) {
@ -2406,7 +2422,7 @@ void GrSubRunNoCachePainter::processSourcePaths(const SkZip<SkGlyphVariant, SkPo
const SkStrikeSpec& strikeSpec) {
SkASSERT(!drawables.empty());
SkPoint drawOrigin = fGlyphRunList.origin();
const SkPaint& drawPaint = fGlyphRunList.paint();
const SkPaint& drawPaint = fPaint;
SkPaint runPaint{drawPaint};
runPaint.setAntiAlias(has_some_antialiasing(runFont));
// If there are shaders, blurs or styles, the path must be scaled into source
@ -2467,7 +2483,7 @@ void GrSubRunNoCachePainter::processSourceSDFT(const SkZip<SkGlyphVariant, SkPoi
void GrSubRunNoCachePainter::draw(GrAtlasSubRunOwner subRun) {
GrAtlasSubRun* subRunPtr = subRun.get();
auto [drawingClip, op] = subRunPtr->makeAtlasTextOp(
fClip, fViewMatrix, fGlyphRunList, fSDC, std::move(subRun));
fClip, fViewMatrix, fGlyphRunList, fPaint, fSDC, std::move(subRun));
if (op != nullptr) {
fSDC->addDrawOp(drawingClip, std::move(op));
}

View File

@ -271,6 +271,7 @@ public:
const GrClip* clip,
const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList,
const SkPaint& paint,
GrSurfaceDrawContext* rtc,
GrAtlasSubRunOwner subRun) const = 0;
virtual void fillVertexData(
@ -305,6 +306,7 @@ public:
virtual void draw(const GrClip* clip,
const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList,
const SkPaint& paint,
GrSurfaceDrawContext* rtc) const = 0;
// Given an already cached subRun, can this subRun handle this combination paint, matrix, and
@ -376,6 +378,7 @@ public:
// list search using operator =().
struct Key {
static std::tuple<bool, Key> Make(const SkGlyphRunList& glyphRunList,
const SkPaint& paint,
const SkSurfaceProps& surfaceProps,
const GrColorInfo& colorInfo,
const SkMatrix& drawMatrix,
@ -405,6 +408,7 @@ public:
// Make a GrTextBlob and its sub runs.
static sk_sp<GrTextBlob> Make(const SkGlyphRunList& glyphRunList,
const SkPaint& paint,
const SkMatrix& drawMatrix,
const GrSDFTControl& control,
SkGlyphRunListPainter* painter);
@ -492,7 +496,8 @@ public:
GrSubRunAllocator* alloc,
const GrClip* clip,
const SkMatrixProvider& viewMatrix,
const SkGlyphRunList& glyphRunList);
const SkGlyphRunList& glyphRunList,
const SkPaint& paint);
void processDeviceMasks(const SkZip<SkGlyphVariant, SkPoint>& drawables,
const SkStrikeSpec& strikeSpec) override;
void processSourceMasks(const SkZip<SkGlyphVariant, SkPoint>& drawables,
@ -511,6 +516,7 @@ private:
const GrClip* const fClip;
const SkMatrixProvider& fViewMatrix;
const SkGlyphRunList& fGlyphRunList;
const SkPaint& fPaint;
};
#endif // GrTextBlob_DEFINED

View File

@ -950,9 +950,9 @@ void SkPDFDevice::internalDrawGlyphRun(
}
}
void SkPDFDevice::drawGlyphRunList(const SkGlyphRunList& glyphRunList) {
void SkPDFDevice::drawGlyphRunList(const SkGlyphRunList& glyphRunList, const SkPaint& paint) {
for (const SkGlyphRun& glyphRun : glyphRunList) {
this->internalDrawGlyphRun(glyphRun, glyphRunList.origin(), glyphRunList.paint());
this->internalDrawGlyphRun(glyphRun, glyphRunList.origin(), paint);
}
}

View File

@ -84,7 +84,7 @@ public:
const SkSamplingOptions&,
const SkPaint&,
SkCanvas::SrcRectConstraint) override;
void drawGlyphRunList(const SkGlyphRunList& glyphRunList) override;
void drawGlyphRunList(const SkGlyphRunList& glyphRunList, const SkPaint& paint) override;
void drawVertices(const SkVertices*, SkBlendMode, const SkPaint&) override;
// PDF specific methods.

View File

@ -1060,9 +1060,9 @@ private:
fHasConstY = true;
};
void SkSVGDevice::drawGlyphRunList(const SkGlyphRunList& glyphRunList) {
void SkSVGDevice::drawGlyphRunList(const SkGlyphRunList& glyphRunList, const SkPaint& paint) {
const auto draw_as_path = (fFlags & SkSVGCanvas::kConvertTextToPaths_Flag) ||
glyphRunList.paint().getPathEffect();
paint.getPathEffect();
if (draw_as_path) {
// Emit a single <path> element.
@ -1071,14 +1071,14 @@ void SkSVGDevice::drawGlyphRunList(const SkGlyphRunList& glyphRunList) {
AddPath(glyphRun, glyphRunList.origin(), &path);
}
this->drawPath(path, glyphRunList.paint());
this->drawPath(path, paint);
return;
}
// Emit one <text> element for each run.
for (auto& glyphRun : glyphRunList) {
AutoElement elem("text", this, fResourceBucket.get(), MxCp(this), glyphRunList.paint());
AutoElement elem("text", this, fResourceBucket.get(), MxCp(this), paint);
elem.addTextAttributes(glyphRun.font());
SVGTextBuilder builder(glyphRunList.origin(), glyphRun);

View File

@ -34,7 +34,7 @@ protected:
const SkPaint& paint,
bool pathIsMutable = false) override;
void drawGlyphRunList(const SkGlyphRunList& glyphRunList) override;
void drawGlyphRunList(const SkGlyphRunList& glyphRunList, const SkPaint& paint) override;
void drawVertices(const SkVertices*, SkBlendMode, const SkPaint&) override;
private:

View File

@ -1892,9 +1892,7 @@ static bool text_must_be_pathed(const SkPaint& paint, const SkMatrix& matrix) {
;
}
void SkXPSDevice::drawGlyphRunList(const SkGlyphRunList& glyphRunList) {
const SkPaint& paint = glyphRunList.paint();
void SkXPSDevice::drawGlyphRunList(const SkGlyphRunList& glyphRunList, const SkPaint& paint) {
for (const auto& run : glyphRunList) {
const SkGlyphID* glyphIDs = run.glyphsIDs().data();
size_t glyphCount = run.glyphsIDs().size();

View File

@ -92,7 +92,7 @@ protected:
const SkRect* srcOrNull, const SkRect& dst,
const SkSamplingOptions&, const SkPaint& paint,
SkCanvas::SrcRectConstraint) override;
void drawGlyphRunList(const SkGlyphRunList& glyphRunList) override;
void drawGlyphRunList(const SkGlyphRunList& glyphRunList, const SkPaint& paint) override;
void drawVertices(const SkVertices*, SkBlendMode, const SkPaint&) override;
void drawDevice(SkBaseDevice*, const SkSamplingOptions&, const SkPaint&) override;