Make GrFontScaler not be ref-counted
This object is made invalid when the SkGlyphCache that it points to is destroyed.
BUG=chromium:608566
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1982303002
Review-Url: https://codereview.chromium.org/1982303002
diff --git a/src/gpu/text/GrFontScaler.h b/src/gpu/text/GrFontScaler.h
index f6b6770..a2be746 100644
--- a/src/gpu/text/GrFontScaler.h
+++ b/src/gpu/text/GrFontScaler.h
@@ -43,10 +43,10 @@
* The client is responsible for instantiating this. The instance is created
* for a specific font+size+matrix.
*/
-class GrFontScaler : public SkRefCnt {
+class GrFontScaler final : public SkNoncopyable {
public:
explicit GrFontScaler(SkGlyphCache* strike);
- virtual ~GrFontScaler();
+ ~GrFontScaler();
const GrFontDescKey* getKey();
GrMaskFormat getMaskFormat() const;
@@ -60,10 +60,12 @@
const SkGlyph& grToSkGlyph(GrGlyph::PackedID);
private:
+ // The SkGlyphCache actually owns this GrFontScaler. The GrFontScaler is deleted when the
+ // SkGlyphCache is deleted.
SkGlyphCache* fStrike;
GrFontDescKey* fKey;
- typedef SkRefCnt INHERITED;
+ typedef SkNoncopyable INHERITED;
};
#endif
diff --git a/src/gpu/text/GrTextUtils.cpp b/src/gpu/text/GrTextUtils.cpp
index c368c21..da2b3e2 100644
--- a/src/gpu/text/GrTextUtils.cpp
+++ b/src/gpu/text/GrTextUtils.cpp
@@ -572,7 +572,7 @@
static void glyph_cache_aux_proc(void* data) {
GrFontScaler* scaler = (GrFontScaler*)data;
- SkSafeUnref(scaler);
+ delete scaler;
}
GrFontScaler* GrTextUtils::GetGrFontScaler(SkGlyphCache* cache) {