clean up for Device::drawGlyphRunList

Clean up drawGlyphRunList suggested in a previous CL. The main
serialized strikes, and serialized Slugs is getting large. So,
I broke it up.

Change-Id: I1d116bcf3b28d95e31b4eec7666c0856cea54a48
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/512159
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
Herb Derby 2022-02-23 12:40:21 -05:00 committed by SkCQ
parent fe6cca4958
commit 041157848b
2 changed files with 55 additions and 37 deletions

View File

@ -947,21 +947,21 @@ void Device::drawAtlas(const SkRSXform xform[],
///////////////////////////////////////////////////////////////////////////////
void Device::onDrawGlyphRunList(SkCanvas* canvas,
#if defined(SK_EXPERIMENTAL_SIMULATE_DRAWGLYPHRUNLIST_WITH_SLUG)
void Device::testingOnly_drawGlyphRunListWithSlug(SkCanvas* canvas,
const SkGlyphRunList& glyphRunList,
const SkPaint& paint) {
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)
auto slug = this->convertGlyphRunListToSlug(glyphRunList, paint);
if (slug != nullptr) {
this->drawSlug(canvas, slug.get());
}
return;
#elif defined(SK_EXPERIMENTAL_SIMULATE_DRAWGLYPHRUNLIST_WITH_SLUG_SERIALIZE)
}
#endif
#if defined(SK_EXPERIMENTAL_SIMULATE_DRAWGLYPHRUNLIST_WITH_SLUG_SERIALIZE)
void Device::testingOnly_drawGlyphRunListWithSerializedSlug(SkCanvas* canvas,
const SkGlyphRunList& glyphRunList,
const SkPaint& paint) {
// This is not a text blob draw. Handle using glyphRunList conversion.
if (glyphRunList.blob() == nullptr) {
auto slug = this->convertGlyphRunListToSlug(glyphRunList, paint);
@ -970,29 +970,37 @@ void Device::onDrawGlyphRunList(SkCanvas* canvas,
}
return;
}
auto srcSlug = GrSlug::ConvertBlob(
canvas, *glyphRunList.blob(), glyphRunList.origin(), paint);
auto srcSlug = GrSlug::ConvertBlob(canvas, *glyphRunList.blob(), glyphRunList.origin(), paint);
// There is nothing to draw.
if (srcSlug == nullptr) { return; }
if (srcSlug == nullptr) {
return;
}
SkBinaryWriteBuffer writeBuffer;
srcSlug->flatten(writeBuffer);
auto data = writeBuffer.snapshotAsData();
auto dstSlugData = srcSlug->serialize();
SkReadBuffer readBuffer(data->data(), data->size());
auto dstSlug = GrSlug::MakeFromBuffer(readBuffer, nullptr);
auto dstSlug = GrSlug::Deserialize(dstSlugData->data(), dstSlugData->size());
SkASSERT(dstSlug != nullptr);
if (dstSlug != nullptr) {
this->drawSlug(canvas, dstSlug.get());
}
}
#endif
return;
void Device::onDrawGlyphRunList(SkCanvas* canvas,
const SkGlyphRunList& glyphRunList,
const SkPaint& paint) {
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);
#elif defined(SK_EXPERIMENTAL_SIMULATE_DRAWGLYPHRUNLIST_WITH_SLUG_SERIALIZE)
this->testingOnly_drawGlyphRunListWithSerializedSlug(canvas, glyphRunList, paint);
#else
fSurfaceDrawContext->drawGlyphRunList(
canvas, this->clip(), this->asMatrixProvider(), glyphRunList, paint);
return;
#endif
}

View File

@ -210,7 +210,17 @@ private:
bool forceConservativeRasterClip() const override { return true; }
const GrClip* clip() const { return &fClip; }
#if defined(SK_EXPERIMENTAL_SIMULATE_DRAWGLYPHRUNLIST_WITH_SLUG)
void testingOnly_drawGlyphRunListWithSlug(SkCanvas* canvas,
const SkGlyphRunList& glyphRunList,
const SkPaint& paint);
#endif
#if defined(SK_EXPERIMENTAL_SIMULATE_DRAWGLYPHRUNLIST_WITH_SLUG_SERIALIZE)
void testingOnly_drawGlyphRunListWithSerializedSlug(SkCanvas* canvas,
const SkGlyphRunList& glyphRunList,
const SkPaint& paint);
#endif
// If not null, dstClip must be contained inside dst and will also respect the edge AA flags.
// If 'preViewMatrix' is not null, final CTM will be this->ctm() * preViewMatrix.
void drawImageQuad(const SkImage*, const SkRect* src, const SkRect* dst,