generalize text geometry back pointer

This change allows types other than GrTextBlob to use the
geometry's lifetime to manage refs.

Change-Id: Iacb726cd4d097c87df146e119c476c014d4df99e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/471616
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
Herb Derby 2021-11-15 09:48:39 -05:00 committed by SkCQ
parent 25deba3516
commit c1bbd1f190
2 changed files with 6 additions and 6 deletions

View File

@ -44,14 +44,14 @@ public:
GrAtlasSubRunOwner subRunOwner,
const SkPMColor4f& color)
: fSubRun{subRun}
, fBlob{std::move(blob)}
, fSupportDataKeepAlive{std::move(blob)}
, fSubRunDtor{std::move(subRunOwner)}
, fDrawMatrix{drawMatrix}
, fDrawOrigin{drawOrigin}
, fClipRect{clipRect}
, fColor{color} {
SkASSERT(fBlob != nullptr || fSubRunDtor != nullptr);
SkASSERT(SkToBool(fSubRunDtor) != SkToBool(fBlob));
SkASSERT(fSupportDataKeepAlive != nullptr || fSubRunDtor != nullptr);
SkASSERT(SkToBool(fSubRunDtor) != SkToBool(fSupportDataKeepAlive));
}
static Geometry* MakeForBlob(const GrAtlasSubRun& subRun,
@ -66,10 +66,10 @@ public:
const GrAtlasSubRun& fSubRun;
// Either this Geometry holds a ref to the GrTextBlob in the case of a text blob based
// Either this Geometry holds a ref to the support data in the case of a blob based
// SubRun (WithCaching case), or it holds a unique_ptr to a SubRun allocated on the
// GrTextBlobAllocator in the NoCache case. It must hold one, and can't hold both.
sk_sp<GrTextBlob> fBlob; // mutable to make unref call in Op dtor.
sk_sp<SkRefCnt> fSupportDataKeepAlive;
GrAtlasSubRunOwner fSubRunDtor;
const SkMatrix fDrawMatrix;

View File

@ -178,7 +178,7 @@ struct GrSubRunList {
// with.
//
//
class GrTextBlob final : public SkNVRefCnt<GrTextBlob>, public SkGlyphRunPainterInterface {
class GrTextBlob final : public SkRefCnt, public SkGlyphRunPainterInterface {
public:
// Key is not used as part of a hash map, so the hash is never taken. It's only used in a