Allow Viewer to filter glyphRunList.

This allows force overriding font settings embedded in the glyphRunList.

Change-Id: I49f15786ec8d35c55f769fc910e009693cfc5879
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/508179
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
This commit is contained in:
Ben Wagner 2022-02-12 19:24:21 -05:00 committed by SkCQ
parent 4e920eb1cc
commit 51a553d8c5

View File

@ -19,6 +19,7 @@
#include "include/utils/SkPaintFilterCanvas.h"
#include "src/core/SkAutoPixmapStorage.h"
#include "src/core/SkColorSpacePriv.h"
#include "src/core/SkGlyphRun.h"
#include "src/core/SkImagePriv.h"
#include "src/core/SkMD5.h"
#include "src/core/SkOSFile.h"
@ -1383,6 +1384,16 @@ public:
this->SkPaintFilterCanvas::onDrawTextBlob(
this->filterTextBlob(paint, blob, &cache), x, y, paint);
}
void onDrawGlyphRunList(const SkGlyphRunList& glyphRunList, const SkPaint& paint) override {
sk_sp<SkTextBlob> cache;
sk_sp<SkTextBlob> blob = glyphRunList.makeBlob();
this->filterTextBlob(paint, blob.get(), &cache);
SkGlyphRunBuilder builder;
const SkGlyphRunList& filtered = builder.blobToGlyphRunList(*cache, glyphRunList.origin());
this->SkPaintFilterCanvas::onDrawGlyphRunList(filtered, paint);
}
bool filterFont(SkTCopyOnFirstWrite<SkFont>* font) const {
if (fFontOverrides->fTypeface) {
font->writable()->setTypeface(fFont->refTypeface());