diff --git a/include/private/chromium/GrSlug.h b/include/private/chromium/GrSlug.h index 52891b4491..6b51fc5e3b 100644 --- a/include/private/chromium/GrSlug.h +++ b/include/private/chromium/GrSlug.h @@ -61,7 +61,11 @@ public: void draw(SkCanvas* canvas) const; virtual SkRect sourceBounds() const = 0; - virtual const SkPaint& paint() const = 0; + + // The paint passed into ConvertBlob; this paint is used instead of the paint resulting from + // the call to aboutToDraw because when we call draw(), the initial paint is needed to call + // aboutToDraw again to get the layer right. + virtual const SkPaint& initialPaint() const = 0; virtual void doFlatten(SkWriteBuffer&) const = 0; diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp index a574b15acb..11ff5442a8 100644 --- a/src/core/SkBitmapDevice.cpp +++ b/src/core/SkBitmapDevice.cpp @@ -523,9 +523,10 @@ void SkBitmapDevice::drawImageRect(const SkImage* image, const SkRect* src, cons void SkBitmapDevice::onDrawGlyphRunList(SkCanvas* canvas, const SkGlyphRunList& glyphRunList, - const SkPaint& paint) { + const SkPaint& initialPaint, + const SkPaint& drawingPaint) { SkASSERT(!glyphRunList.hasRSXForm()); - LOOP_TILER( drawGlyphRunList(canvas, &fGlyphPainter, glyphRunList, paint), nullptr ) + LOOP_TILER( drawGlyphRunList(canvas, &fGlyphPainter, glyphRunList, drawingPaint), nullptr ) } void SkBitmapDevice::drawVertices(const SkVertices* vertices, diff --git a/src/core/SkBitmapDevice.h b/src/core/SkBitmapDevice.h index c23ecc3a0d..d32ee32943 100644 --- a/src/core/SkBitmapDevice.h +++ b/src/core/SkBitmapDevice.h @@ -107,7 +107,10 @@ protected: /////////////////////////////////////////////////////////////////////////// - void onDrawGlyphRunList(SkCanvas*, const SkGlyphRunList&, const SkPaint&) override; + void onDrawGlyphRunList(SkCanvas*, + const SkGlyphRunList&, + const SkPaint& initialPaint, + const SkPaint& drawingPaint) override; bool onReadPixels(const SkPixmap&, int x, int y) override; bool onWritePixels(const SkPixmap&, int, int) override; bool onPeekPixels(SkPixmap*) override; diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp index 8c1a3fa093..ef8e029df8 100644 --- a/src/core/SkCanvas.cpp +++ b/src/core/SkCanvas.cpp @@ -2338,7 +2338,7 @@ void SkCanvas::onDrawGlyphRunList(const SkGlyphRunList& glyphRunList, const SkPa } auto layer = this->aboutToDraw(this, paint, &bounds); if (layer) { - this->topDevice()->drawGlyphRunList(this, glyphRunList, layer->paint()); + this->topDevice()->drawGlyphRunList(this, glyphRunList, paint, layer->paint()); } } @@ -2358,7 +2358,7 @@ SkCanvas::onConvertGlyphRunListToSlug(const SkGlyphRunList& glyphRunList, const } auto layer = this->aboutToDraw(this, paint, &bounds); if (layer) { - return this->topDevice()->convertGlyphRunListToSlug(glyphRunList, layer->paint()); + return this->topDevice()->convertGlyphRunListToSlug(glyphRunList, paint, layer->paint()); } return nullptr; } @@ -2372,11 +2372,14 @@ void SkCanvas::drawSlug(const GrSlug* slug) { void SkCanvas::onDrawSlug(const GrSlug* slug) { SkRect bounds = slug->sourceBounds(); - if (this->internalQuickReject(bounds, slug->paint())) { + if (this->internalQuickReject(bounds, slug->initialPaint())) { return; } - this->topDevice()->drawSlug(this, slug); + auto layer = this->aboutToDraw(this, slug->initialPaint(), &bounds); + if (layer) { + this->topDevice()->drawSlug(this, slug, layer->paint()); + } } #endif diff --git a/src/core/SkChromeRemoteGlyphCache.cpp b/src/core/SkChromeRemoteGlyphCache.cpp index 7b748ed2b1..1b979add6e 100644 --- a/src/core/SkChromeRemoteGlyphCache.cpp +++ b/src/core/SkChromeRemoteGlyphCache.cpp @@ -814,7 +814,8 @@ protected: #if SK_SUPPORT_GPU void onDrawGlyphRunList(SkCanvas*, const SkGlyphRunList& glyphRunList, - const SkPaint& paint) override { + const SkPaint& initialPaint, + const SkPaint& drawingPaint) override { GrContextOptions ctxOptions; GrSDFTControl control = GrSDFTControl{fDFTSupport, @@ -829,7 +830,7 @@ protected: fPainter.processGlyphRun(nullptr, glyphRun, drawMatrix, - paint, + drawingPaint, control, "Cache Diff", uniqueID); @@ -837,7 +838,8 @@ protected: } sk_sp convertGlyphRunListToSlug(const SkGlyphRunList& glyphRunList, - const SkPaint& paint) override { + const SkPaint& initialPaint, + const SkPaint& drawingPaint) override { GrContextOptions ctxOptions; GrSDFTControl control = GrSDFTControl{fDFTSupport, @@ -858,14 +860,18 @@ protected: fPainter.processGlyphRun(nullptr, glyphRun, positionMatrix, - paint, + drawingPaint, control, "Convert Slug Analysis"); } // Use the glyph strike cache to get actual glyph information. - return skgpu::v1::MakeSlug( - this->localToDevice(), glyphRunList, paint, control, &fConvertPainter); + return skgpu::v1::MakeSlug(this->localToDevice(), + glyphRunList, + initialPaint, + drawingPaint, + control, + &fConvertPainter); } #endif // SK_SUPPORT_GPU diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp index f1223485bc..d2d31210c7 100644 --- a/src/core/SkDevice.cpp +++ b/src/core/SkDevice.cpp @@ -428,25 +428,27 @@ static sk_sp make_post_inverse_lm(const SkShader* shader, const SkMatr void SkBaseDevice::drawGlyphRunList(SkCanvas* canvas, const SkGlyphRunList& glyphRunList, - const SkPaint& paint) { + const SkPaint& initialPaint, + const SkPaint& drawingPaint) { if (!this->localToDevice().isFinite()) { return; } if (!glyphRunList.hasRSXForm()) { - this->onDrawGlyphRunList(canvas, glyphRunList, paint); + this->onDrawGlyphRunList(canvas, glyphRunList, initialPaint, drawingPaint); } else { - this->simplifyGlyphRunRSXFormAndRedraw(canvas, glyphRunList, paint); + this->simplifyGlyphRunRSXFormAndRedraw(canvas, glyphRunList, initialPaint, drawingPaint); } } void SkBaseDevice::simplifyGlyphRunRSXFormAndRedraw(SkCanvas* canvas, const SkGlyphRunList& glyphRunList, - const SkPaint& paint) { + const SkPaint& initialPaint, + const SkPaint& drawingPaint) { for (const SkGlyphRun& run : glyphRunList) { if (run.scaledRotations().empty()) { - SkGlyphRunList subList{run, run.sourceBounds(paint), {0, 0}}; - this->drawGlyphRunList(canvas, subList, paint); + SkGlyphRunList subList{run, run.sourceBounds(drawingPaint), {0, 0}}; + this->drawGlyphRunList(canvas, subList, initialPaint, drawingPaint); } else { SkPoint origin = glyphRunList.origin(); SkPoint sharedPos{0, 0}; // we're at the origin @@ -471,12 +473,13 @@ void SkBaseDevice::simplifyGlyphRunRSXFormAndRedraw(SkCanvas* canvas, // (i.e. the shader that cares about the ctm) so we have to undo our little ctm // trick with a localmatrixshader so that the shader draws as if there was no // change to the ctm. - SkPaint invertingPaint{paint}; - invertingPaint.setShader(make_post_inverse_lm(paint.getShader(), glyphToLocal)); + SkPaint invertingPaint{drawingPaint}; + invertingPaint.setShader( + make_post_inverse_lm(drawingPaint.getShader(), glyphToLocal)); SkAutoCanvasRestore acr(canvas, true); canvas->concat(SkM44(glyphToLocal)); - SkGlyphRunList subList{glyphRun, glyphRun.sourceBounds(paint), {0, 0}}; - this->drawGlyphRunList(canvas, subList, invertingPaint); + SkGlyphRunList subList{glyphRun, glyphRun.sourceBounds(drawingPaint), {0, 0}}; + this->drawGlyphRunList(canvas, subList, initialPaint, invertingPaint); } } } @@ -485,11 +488,12 @@ void SkBaseDevice::simplifyGlyphRunRSXFormAndRedraw(SkCanvas* canvas, #if SK_SUPPORT_GPU sk_sp SkBaseDevice::convertGlyphRunListToSlug( const SkGlyphRunList& glyphRunList, - const SkPaint& paint) { + const SkPaint& initialPaint, + const SkPaint& drawingPaint) { return nullptr; } -void SkBaseDevice::drawSlug(SkCanvas*, const GrSlug*) { +void SkBaseDevice::drawSlug(SkCanvas*, const GrSlug*, const SkPaint&) { SK_ABORT("GrSlug drawing not supported."); } #endif diff --git a/src/core/SkDevice.h b/src/core/SkDevice.h index 47bc05513a..2926979950 100644 --- a/src/core/SkDevice.h +++ b/src/core/SkDevice.h @@ -199,7 +199,10 @@ public: virtual skgpu::graphite::Device* asGraphiteDevice() { return nullptr; } // Ensure that non-RSXForm runs are passed to onDrawGlyphRunList. - void drawGlyphRunList(SkCanvas*, const SkGlyphRunList& glyphRunList, const SkPaint& paint); + void drawGlyphRunList(SkCanvas*, + const SkGlyphRunList& glyphRunList, + const SkPaint& initialPaint, + const SkPaint& drawingPaint); protected: enum TileUsage { @@ -311,14 +314,18 @@ protected: virtual void drawDrawable(SkCanvas*, SkDrawable*, const SkMatrix*); // Only called with glyphRunLists that do not contain RSXForm. - virtual void onDrawGlyphRunList(SkCanvas*, const SkGlyphRunList&, const SkPaint&) = 0; + virtual void onDrawGlyphRunList(SkCanvas*, + const SkGlyphRunList&, + const SkPaint& initialPaint, + const SkPaint& drawingPaint) = 0; // GrSlug handling routines. #if SK_SUPPORT_GPU virtual sk_sp convertGlyphRunListToSlug( const SkGlyphRunList& glyphRunList, - const SkPaint& paint); - virtual void drawSlug(SkCanvas*, const GrSlug* slug); + const SkPaint& initialPaint, + const SkPaint& drawingPaint); + virtual void drawSlug(SkCanvas*, const GrSlug* slug, const SkPaint& drawingPaint); #endif /** @@ -436,7 +443,10 @@ private: friend class SkSurface_Raster; friend class DeviceTestingAccess; - void simplifyGlyphRunRSXFormAndRedraw(SkCanvas*, const SkGlyphRunList&, const SkPaint&); + void simplifyGlyphRunRSXFormAndRedraw(SkCanvas*, + const SkGlyphRunList&, + const SkPaint& initialPaint, + const SkPaint& drawingPaint); // used to change the backend's pixels (and possibly config/rowbytes) // but cannot change the width/height, so there should be no change to @@ -548,8 +558,8 @@ protected: void drawFilteredImage(const skif::Mapping&, SkSpecialImage* src, const SkImageFilter*, const SkSamplingOptions&, const SkPaint&) override {} - void onDrawGlyphRunList(SkCanvas*, const SkGlyphRunList&, const SkPaint&) override {} - + void onDrawGlyphRunList( + SkCanvas*, const SkGlyphRunList&, const SkPaint&, const SkPaint&) override {} bool isNoPixelsDevice() const override { return true; } diff --git a/src/core/SkOverdrawCanvas.cpp b/src/core/SkOverdrawCanvas.cpp index 4a0651964e..36e5b9d1b1 100644 --- a/src/core/SkOverdrawCanvas.cpp +++ b/src/core/SkOverdrawCanvas.cpp @@ -62,10 +62,12 @@ public: void drawBitmap(const SkBitmap&, const SkMatrix&, const SkRect* dstOrNull, const SkSamplingOptions&, const SkPaint&) const override {} - void onDrawGlyphRunList(SkCanvas* canvas, const SkGlyphRunList& glyphRunList, - const SkPaint& paint) override { + void onDrawGlyphRunList(SkCanvas* canvas, + const SkGlyphRunList& glyphRunList, + const SkPaint& initialPaint, + const SkPaint& drawingPaint) override { SkASSERT(!glyphRunList.hasRSXForm()); - fPainter.drawForBitmapDevice(canvas, this, glyphRunList, paint, + fPainter.drawForBitmapDevice(canvas, this, glyphRunList, drawingPaint, fOverdrawCanvas->getTotalMatrix()); } @@ -83,12 +85,13 @@ void SkOverdrawCanvas::onDrawTextBlob( } void SkOverdrawCanvas::onDrawGlyphRunList( - const SkGlyphRunList& glyphRunList, const SkPaint& paint) { + const SkGlyphRunList& glyphRunList, + const SkPaint& paint) { SkSurfaceProps props{0, kUnknown_SkPixelGeometry}; this->getProps(&props); TextDevice device{this, props}; - device.drawGlyphRunList(this, glyphRunList, paint); + device.drawGlyphRunList(this, glyphRunList, paint, paint); } void SkOverdrawCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], diff --git a/src/core/SkRecordDraw.cpp b/src/core/SkRecordDraw.cpp index a9227d3e0a..2143f286a1 100644 --- a/src/core/SkRecordDraw.cpp +++ b/src/core/SkRecordDraw.cpp @@ -479,7 +479,7 @@ private: #if SK_SUPPORT_GPU Bounds bounds(const DrawSlug& op) const { SkRect dst = op.slug->sourceBounds(); - return this->adjustAndMap(dst, &op.slug->paint()); + return this->adjustAndMap(dst, &op.slug->initialPaint()); } #else Bounds bounds(const DrawSlug& op) const { diff --git a/src/gpu/ganesh/text/GrTextBlob.cpp b/src/gpu/ganesh/text/GrTextBlob.cpp index 4f378b16ee..ce57fa3a90 100644 --- a/src/gpu/ganesh/text/GrTextBlob.cpp +++ b/src/gpu/ganesh/text/GrTextBlob.cpp @@ -2211,7 +2211,8 @@ public: static sk_sp Make(const SkMatrixProvider& viewMatrix, const SkGlyphRunList& glyphRunList, - const SkPaint& paint, + const SkPaint& initialPaint, + const SkPaint& drawingPaint, const GrSDFTControl& control, SkGlyphRunListPainter* painter); static sk_sp MakeFromBuffer(SkReadBuffer& buffer, @@ -2220,11 +2221,12 @@ public: void surfaceDraw(SkCanvas*, const GrClip* clip, const SkMatrixProvider& viewMatrix, + const SkPaint& paint, skgpu::v1::SurfaceDrawContext* sdc) const; void doFlatten(SkWriteBuffer& buffer) const override; SkRect sourceBounds() const override { return fSourceBounds; } - const SkPaint& paint() const override { return fPaint; } + const SkPaint& initialPaint() const override { return fInitialPaint; } // SkGlyphRunPainterInterface void processDeviceMasks( @@ -2268,33 +2270,33 @@ private: // structure may have pointers into it. GrSubRunAllocator fAlloc; const SkRect fSourceBounds; - const SkPaint fPaint; + const SkPaint fInitialPaint; const SkMatrix fInitialPositionMatrix; const SkPoint fOrigin; GrSubRunList fSubRuns; }; Slug::Slug(SkRect sourceBounds, - const SkPaint& paint, + const SkPaint& initialPaint, const SkMatrix& positionMatrix, SkPoint origin, int allocSize) : fAlloc {SkTAddOffset(this, sizeof(Slug)), allocSize, allocSize/2} , fSourceBounds{sourceBounds} - , fPaint{paint} + , fInitialPaint{initialPaint} , fInitialPositionMatrix{positionMatrix} , fOrigin{origin} { } void Slug::surfaceDraw(SkCanvas* canvas, const GrClip* clip, const SkMatrixProvider& viewMatrix, - skgpu::v1::SurfaceDrawContext* sdc) const { + const SkPaint& drawingPaint, skgpu::v1::SurfaceDrawContext* sdc) const { for (const GrSubRun& subRun : fSubRuns) { - subRun.draw(canvas, clip, viewMatrix, fOrigin, fPaint, sdc); + subRun.draw(canvas, clip, viewMatrix, fOrigin, drawingPaint, sdc); } } void Slug::doFlatten(SkWriteBuffer& buffer) const { buffer.writeRect(fSourceBounds); - SkPaintPriv::Flatten(fPaint, buffer); + SkPaintPriv::Flatten(fInitialPaint, buffer); buffer.writeMatrix(fInitialPositionMatrix); buffer.writePoint(fOrigin); auto [subRunCount, subRunsUnflattenSizeHint] = this->subRunCountAndUnflattenSizeHint(); @@ -2772,7 +2774,8 @@ void Slug::processDeviceMasks( sk_sp Slug::Make(const SkMatrixProvider& viewMatrix, const SkGlyphRunList& glyphRunList, - const SkPaint& paint, + const SkPaint& initialPaint, + const SkPaint& drawingPaint, const GrSDFTControl& control, SkGlyphRunListPainter* painter) { // The difference in alignment from the per-glyph data to the SubRun; @@ -2795,7 +2798,7 @@ sk_sp Slug::Make(const SkMatrixProvider& viewMatrix, sk_sp slug{new (::operator new (allocationSize)) Slug(glyphRunList.sourceBounds(), - paint, + initialPaint, positionMatrix, glyphRunList.origin(), bytesNeededForSubRun)}; @@ -2805,7 +2808,7 @@ sk_sp Slug::Make(const SkMatrixProvider& viewMatrix, painter->processGlyphRun(slug.get(), glyphRun, positionMatrix, - paint, + drawingPaint, control, "Make Slug", uniqueID); @@ -2867,19 +2870,22 @@ void Slug::processSourceMasks(const SkZip& accepted, namespace skgpu::v1 { sk_sp -Device::convertGlyphRunListToSlug(const SkGlyphRunList& glyphRunList, const SkPaint& paint) { +Device::convertGlyphRunListToSlug(const SkGlyphRunList& glyphRunList, + const SkPaint& initialPaint, + const SkPaint& drawingPaint) { auto recordingContextPriv = this->recordingContext()->priv(); const GrSDFTControl control = recordingContextPriv.getSDFTControl( this->surfaceProps().isUseDeviceIndependentFonts()); return Slug::Make(this->asMatrixProvider(), glyphRunList, - paint, + initialPaint, + drawingPaint, control, fSurfaceDrawContext->glyphRunPainter()); } -void Device::drawSlug(SkCanvas* canvas, const GrSlug* grSlug) { +void Device::drawSlug(SkCanvas* canvas, const GrSlug* grSlug, const SkPaint& drawingPaint) { const Slug* slug = static_cast(grSlug); auto matrixProvider = this->asMatrixProvider(); #if defined(SK_DEBUG) @@ -2893,15 +2899,17 @@ void Device::drawSlug(SkCanvas* canvas, const GrSlug* grSlug) { SkASSERT(slugMatrix == positionMatrix); } #endif - slug->surfaceDraw(canvas, this->clip(), matrixProvider, fSurfaceDrawContext.get()); + slug->surfaceDraw( + canvas, this->clip(), matrixProvider, drawingPaint, fSurfaceDrawContext.get()); } sk_sp MakeSlug(const SkMatrixProvider& drawMatrix, const SkGlyphRunList& glyphRunList, - const SkPaint& paint, + const SkPaint& initialPaint, + const SkPaint& drawingPaint, const GrSDFTControl& control, SkGlyphRunListPainter* painter) { - return Slug::Make(drawMatrix, glyphRunList, paint, control, painter); + return Slug::Make(drawMatrix, glyphRunList, initialPaint, drawingPaint, control, painter); } } // namespace skgpu::v1 diff --git a/src/gpu/ganesh/text/GrTextBlob.h b/src/gpu/ganesh/text/GrTextBlob.h index c992c9a8e0..65dd52c83f 100644 --- a/src/gpu/ganesh/text/GrTextBlob.h +++ b/src/gpu/ganesh/text/GrTextBlob.h @@ -298,7 +298,8 @@ private: namespace skgpu::v1 { sk_sp MakeSlug(const SkMatrixProvider& drawMatrix, const SkGlyphRunList& glyphRunList, - const SkPaint& paint, + const SkPaint& initialPaint, + const SkPaint& drawingPaint, const GrSDFTControl& control, SkGlyphRunListPainter* painter); } // namespace skgpu::v1 diff --git a/src/gpu/ganesh/v1/Device.cpp b/src/gpu/ganesh/v1/Device.cpp index b57178e79b..8d7883e22d 100644 --- a/src/gpu/ganesh/v1/Device.cpp +++ b/src/gpu/ganesh/v1/Device.cpp @@ -960,10 +960,11 @@ void Device::drawAtlas(const SkRSXform xform[], #if defined(SK_EXPERIMENTAL_SIMULATE_DRAWGLYPHRUNLIST_WITH_SLUG) void Device::testingOnly_drawGlyphRunListWithSlug(SkCanvas* canvas, const SkGlyphRunList& glyphRunList, - const SkPaint& paint) { - auto slug = this->convertGlyphRunListToSlug(glyphRunList, paint); + const SkPaint& initialPaint, + const SkPaint& drawingPaint) { + auto slug = this->convertGlyphRunListToSlug(glyphRunList, initialPaint, drawingPaint); if (slug != nullptr) { - this->drawSlug(canvas, slug.get()); + this->drawSlug(canvas, slug.get(), drawingPaint); } } #endif @@ -971,16 +972,18 @@ void Device::testingOnly_drawGlyphRunListWithSlug(SkCanvas* canvas, #if defined(SK_EXPERIMENTAL_SIMULATE_DRAWGLYPHRUNLIST_WITH_SLUG_SERIALIZE) void Device::testingOnly_drawGlyphRunListWithSerializedSlug(SkCanvas* canvas, const SkGlyphRunList& glyphRunList, - const SkPaint& paint) { + const SkPaint& initialPaint, + const SkPaint& drawingPaint) { // This is not a text blob draw. Handle using glyphRunList conversion. if (glyphRunList.blob() == nullptr) { - auto slug = this->convertGlyphRunListToSlug(glyphRunList, paint); + auto slug = this->convertGlyphRunListToSlug(glyphRunList, initialPaint, drawingPaint); if (slug != nullptr) { - this->drawSlug(canvas, slug.get()); + this->drawSlug(canvas, slug.get(), drawingPaint); } return; } - auto srcSlug = GrSlug::ConvertBlob(canvas, *glyphRunList.blob(), glyphRunList.origin(), paint); + auto srcSlug = GrSlug::ConvertBlob( + canvas, *glyphRunList.blob(), glyphRunList.origin(), initialPaint); // There is nothing to draw. if (srcSlug == nullptr) { @@ -992,7 +995,7 @@ void Device::testingOnly_drawGlyphRunListWithSerializedSlug(SkCanvas* canvas, auto dstSlug = GrSlug::Deserialize(dstSlugData->data(), dstSlugData->size()); SkASSERT(dstSlug != nullptr); if (dstSlug != nullptr) { - this->drawSlug(canvas, dstSlug.get()); + this->drawSlug(canvas, dstSlug.get(), drawingPaint); } } #endif @@ -1052,10 +1055,15 @@ private: } // namespace void Device::testingOnly_drawGlyphRunListWithSerializedSlugAndStrike( - SkCanvas* canvas, const SkGlyphRunList& glyphRunList, const SkPaint& paint) { + SkCanvas* canvas, + const SkGlyphRunList& glyphRunList, + const SkPaint& initialPaint, + const SkPaint& drawingPaint) { if (glyphRunList.blob() == nullptr) { - fSurfaceDrawContext->drawGlyphRunList( - canvas, this->clip(), this->asMatrixProvider(), glyphRunList, paint); + auto slug = this->convertGlyphRunListToSlug(glyphRunList, initialPaint, drawingPaint); + if (slug != nullptr) { + this->drawSlug(canvas, slug.get(), drawingPaint); + } return; } @@ -1080,7 +1088,7 @@ void Device::testingOnly_drawGlyphRunListWithSerializedSlugAndStrike( auto srcSlug = GrSlug::ConvertBlob(analysisCanvas.get(), *glyphRunList.blob(), glyphRunList.origin(), - paint); + initialPaint); if (srcSlug == nullptr) { return; @@ -1095,34 +1103,37 @@ void Device::testingOnly_drawGlyphRunListWithSerializedSlugAndStrike( auto dstSlugData = srcSlug->serialize(); auto dstSlug = client.deserializeSlug(dstSlugData->data(), dstSlugData->size()); - this->drawSlug(canvas, dstSlug.get()); + this->drawSlug(canvas, dstSlug.get(), drawingPaint); } #endif void Device::onDrawGlyphRunList(SkCanvas* canvas, const SkGlyphRunList& glyphRunList, - const SkPaint& paint) { + const SkPaint& initialPaint, + const SkPaint& drawingPaint) { ASSERT_SINGLE_OWNER GR_CREATE_TRACE_MARKER_CONTEXT("skgpu::v1::Device", "drawGlyphRunList", fContext.get()); SkASSERT(!glyphRunList.hasRSXForm()); #if defined(SK_EXPERIMENTAL_SIMULATE_DRAWGLYPHRUNLIST_WITH_SLUG) - this->testingOnly_drawGlyphRunListWithSlug(canvas, glyphRunList, paint); + this->testingOnly_drawGlyphRunListWithSlug(canvas, glyphRunList, initialPaint, drawingPaint); #elif defined(SK_EXPERIMENTAL_SIMULATE_DRAWGLYPHRUNLIST_WITH_SLUG_SERIALIZE) - this->testingOnly_drawGlyphRunListWithSerializedSlug(canvas, glyphRunList, paint); + this->testingOnly_drawGlyphRunListWithSerializedSlug( + canvas, glyphRunList, initialPaint, drawingPaint); #elif defined(SK_EXPERIMENTAL_SIMULATE_DRAWGLYPHRUNLIST_WITH_SLUG_STRIKE_SERIALIZE) - this->testingOnly_drawGlyphRunListWithSerializedSlugAndStrike(canvas, glyphRunList, paint); + this->testingOnly_drawGlyphRunListWithSerializedSlugAndStrike( + canvas, glyphRunList, initialPaint, drawingPaint); #else if (glyphRunList.blob() == nullptr) { // If the glyphRunList does not have an associated text blob, then it was created by one of // the direct draw APIs (drawGlyphs, etc.). Use a Slug to draw the glyphs. - auto slug = this->convertGlyphRunListToSlug(glyphRunList, paint); + auto slug = this->convertGlyphRunListToSlug(glyphRunList, initialPaint, drawingPaint); if (slug != nullptr) { - this->drawSlug(canvas, slug.get()); + this->drawSlug(canvas, slug.get(), drawingPaint); } } else { fSurfaceDrawContext->drawGlyphRunList( - canvas, this->clip(), this->asMatrixProvider(), glyphRunList, paint); + canvas, this->clip(), this->asMatrixProvider(), glyphRunList, drawingPaint); } #endif } diff --git a/src/gpu/ganesh/v1/Device_v1.h b/src/gpu/ganesh/v1/Device_v1.h index 0f5247e532..231407dc6d 100644 --- a/src/gpu/ganesh/v1/Device_v1.h +++ b/src/gpu/ganesh/v1/Device_v1.h @@ -155,13 +155,17 @@ protected: void onSave() override { fClip.save(); } void onRestore() override { fClip.restore(); } - void onDrawGlyphRunList(SkCanvas*, const SkGlyphRunList&, const SkPaint&) override; + void onDrawGlyphRunList(SkCanvas*, + const SkGlyphRunList&, + const SkPaint& initialPaint, + const SkPaint& drawingPaint) override; sk_sp convertGlyphRunListToSlug( const SkGlyphRunList& glyphRunList, - const SkPaint& paint) override; + const SkPaint& initialPaint, + const SkPaint& drawingPaint) override; - void drawSlug(SkCanvas*, const GrSlug* slug) override; + void drawSlug(SkCanvas*, const GrSlug* slug, const SkPaint& drawingPaint) override; void onClipRect(const SkRect& rect, SkClipOp op, bool aa) override { SkASSERT(op == SkClipOp::kIntersect || op == SkClipOp::kDifference); @@ -213,19 +217,22 @@ private: #if defined(SK_EXPERIMENTAL_SIMULATE_DRAWGLYPHRUNLIST_WITH_SLUG) void testingOnly_drawGlyphRunListWithSlug(SkCanvas* canvas, const SkGlyphRunList& glyphRunList, - const SkPaint& paint); + const SkPaint& initialPaint, + const SkPaint& drawingPaint); #endif #if defined(SK_EXPERIMENTAL_SIMULATE_DRAWGLYPHRUNLIST_WITH_SLUG_SERIALIZE) void testingOnly_drawGlyphRunListWithSerializedSlug(SkCanvas* canvas, const SkGlyphRunList& glyphRunList, - const SkPaint& paint); + const SkPaint& initialPaint, + const SkPaint& drawingPaint); #endif #if defined(SK_EXPERIMENTAL_SIMULATE_DRAWGLYPHRUNLIST_WITH_SLUG_STRIKE_SERIALIZE) void testingOnly_drawGlyphRunListWithSerializedSlugAndStrike(SkCanvas* canvas, const SkGlyphRunList& glyphRunList, - const SkPaint& paint); + const SkPaint& initialPaint, + const SkPaint& drawingPaint); #endif // If not null, dstClip must be contained inside dst and will also respect the edge AA flags. diff --git a/src/gpu/graphite/Device.h b/src/gpu/graphite/Device.h index 86bb860afb..f1d5e36e9f 100644 --- a/src/gpu/graphite/Device.h +++ b/src/gpu/graphite/Device.h @@ -129,7 +129,8 @@ private: void drawVertices(const SkVertices*, sk_sp, const SkPaint&, bool) override {} void drawCustomMesh(SkCustomMesh, sk_sp, const SkPaint&) override {} void drawShadow(const SkPath&, const SkDrawShadowRec&) override {} - void onDrawGlyphRunList(SkCanvas*, const SkGlyphRunList&, const SkPaint&) override {} + void onDrawGlyphRunList( + SkCanvas*, const SkGlyphRunList&, const SkPaint&, const SkPaint&) override {} void drawDevice(SkBaseDevice*, const SkSamplingOptions&, const SkPaint&) override {} void drawSpecial(SkSpecialImage*, const SkMatrix& localToDevice, diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp index ae66acbe24..cdaae7d81b 100644 --- a/src/pdf/SkPDFDevice.cpp +++ b/src/pdf/SkPDFDevice.cpp @@ -958,10 +958,11 @@ void SkPDFDevice::internalDrawGlyphRun( void SkPDFDevice::onDrawGlyphRunList(SkCanvas*, const SkGlyphRunList& glyphRunList, - const SkPaint& paint) { + const SkPaint& initialPaint, + const SkPaint& drawingPaint) { SkASSERT(!glyphRunList.hasRSXForm()); for (const SkGlyphRun& glyphRun : glyphRunList) { - this->internalDrawGlyphRun(glyphRun, glyphRunList.origin(), paint); + this->internalDrawGlyphRun(glyphRun, glyphRunList.origin(), drawingPaint); } } diff --git a/src/pdf/SkPDFDevice.h b/src/pdf/SkPDFDevice.h index 76df936ce5..fabf8c4574 100644 --- a/src/pdf/SkPDFDevice.h +++ b/src/pdf/SkPDFDevice.h @@ -84,7 +84,10 @@ public: const SkSamplingOptions&, const SkPaint&, SkCanvas::SrcRectConstraint) override; - void onDrawGlyphRunList(SkCanvas*, const SkGlyphRunList&, const SkPaint&) override; + void onDrawGlyphRunList(SkCanvas*, + const SkGlyphRunList&, + const SkPaint& initialPaint, + const SkPaint& drawingPaint) override; void drawVertices(const SkVertices*, sk_sp, const SkPaint&, bool) override; void drawCustomMesh(SkCustomMesh, sk_sp, const SkPaint&) override; diff --git a/src/svg/SkSVGDevice.cpp b/src/svg/SkSVGDevice.cpp index e02b3a263c..f3316ec681 100644 --- a/src/svg/SkSVGDevice.cpp +++ b/src/svg/SkSVGDevice.cpp @@ -1106,10 +1106,11 @@ private: void SkSVGDevice::onDrawGlyphRunList(SkCanvas* canvas, const SkGlyphRunList& glyphRunList, - const SkPaint& paint) { + const SkPaint& initialPaint, + const SkPaint& drawingPaint) { SkASSERT(!glyphRunList.hasRSXForm()); const auto draw_as_path = (fFlags & SkSVGCanvas::kConvertTextToPaths_Flag) || - paint.getPathEffect(); + drawingPaint.getPathEffect(); if (draw_as_path) { // Emit a single element. @@ -1118,14 +1119,14 @@ void SkSVGDevice::onDrawGlyphRunList(SkCanvas* canvas, AddPath(glyphRun, glyphRunList.origin(), &path); } - this->drawPath(path, paint); + this->drawPath(path, drawingPaint); return; } // Emit one element for each run. for (auto& glyphRun : glyphRunList) { - AutoElement elem("text", this, fResourceBucket.get(), MxCp(this), paint); + AutoElement elem("text", this, fResourceBucket.get(), MxCp(this), drawingPaint); elem.addTextAttributes(glyphRun.font()); SVGTextBuilder builder(glyphRunList.origin(), glyphRun); diff --git a/src/svg/SkSVGDevice.h b/src/svg/SkSVGDevice.h index d99fb8afd1..e47e3388de 100644 --- a/src/svg/SkSVGDevice.h +++ b/src/svg/SkSVGDevice.h @@ -57,7 +57,10 @@ protected: const SkPaint& paint, bool pathIsMutable = false) override; - void onDrawGlyphRunList(SkCanvas*, const SkGlyphRunList&, const SkPaint&) override; + void onDrawGlyphRunList(SkCanvas*, + const SkGlyphRunList&, + const SkPaint& initialPaint, + const SkPaint& drawingPaint) override; void drawVertices(const SkVertices*, sk_sp, const SkPaint&, bool) override; #ifdef SK_ENABLE_SKSL void drawCustomMesh(SkCustomMesh, sk_sp, const SkPaint&) override; diff --git a/src/utils/SkNWayCanvas.cpp b/src/utils/SkNWayCanvas.cpp index acd11b4cbe..3d162adca1 100644 --- a/src/utils/SkNWayCanvas.cpp +++ b/src/utils/SkNWayCanvas.cpp @@ -284,7 +284,8 @@ void SkNWayCanvas::onDrawAtlas2(const SkImage* image, const SkRSXform xform[], c } } -void SkNWayCanvas::onDrawGlyphRunList(const SkGlyphRunList& list, const SkPaint &paint) { +void SkNWayCanvas::onDrawGlyphRunList(const SkGlyphRunList& list, + const SkPaint &paint) { Iter iter(fList); while (iter.next()) { iter->onDrawGlyphRunList(list, paint); diff --git a/src/xps/SkXPSDevice.cpp b/src/xps/SkXPSDevice.cpp index 816e7ddbdd..a12698866e 100644 --- a/src/xps/SkXPSDevice.cpp +++ b/src/xps/SkXPSDevice.cpp @@ -1898,7 +1898,8 @@ static bool text_must_be_pathed(const SkPaint& paint, const SkMatrix& matrix) { void SkXPSDevice::onDrawGlyphRunList(SkCanvas*, const SkGlyphRunList& glyphRunList, - const SkPaint& paint) { + const SkPaint& initailPaint, + const SkPaint& drawingPaint) { SkASSERT(!glyphRunList.hasRSXForm()); for (const auto& run : glyphRunList) { @@ -1912,7 +1913,7 @@ void SkXPSDevice::onDrawGlyphRunList(SkCanvas*, TypefaceUse* typeface; if (FAILED(CreateTypefaceUse(font, &typeface)) || - text_must_be_pathed(paint, this->localToDevice())) { + text_must_be_pathed(drawingPaint, this->localToDevice())) { SkPath path; //TODO: make this work, Draw currently does not handle as well. //paint.getTextPath(text, byteLength, x, y, &path); @@ -1961,7 +1962,7 @@ void SkXPSDevice::onDrawGlyphRunList(SkCanvas*, SkScalarToFLOAT(font.getSize()), XPS_STYLE_SIMULATION_NONE, this->localToDevice(), - paint)); + drawingPaint)); } } diff --git a/src/xps/SkXPSDevice.h b/src/xps/SkXPSDevice.h index 63452cb03b..7968f7c629 100644 --- a/src/xps/SkXPSDevice.h +++ b/src/xps/SkXPSDevice.h @@ -92,7 +92,8 @@ protected: const SkRect* srcOrNull, const SkRect& dst, const SkSamplingOptions&, const SkPaint& paint, SkCanvas::SrcRectConstraint) override; - void onDrawGlyphRunList(SkCanvas*, const SkGlyphRunList&, const SkPaint&) override; + void onDrawGlyphRunList( + SkCanvas*, const SkGlyphRunList&, const SkPaint&, const SkPaint&) override; void drawVertices(const SkVertices*, sk_sp, const SkPaint&, bool) override; void drawCustomMesh(SkCustomMesh, sk_sp, const SkPaint&) override; void drawDevice(SkBaseDevice*, const SkSamplingOptions&, const SkPaint&) override;