Fix reference counting on SkStream in SkFontMgr_android.

R=tomhudson@google.com

Author: bungeman@google.com

Review URL: https://codereview.chromium.org/447003002
This commit is contained in:
bungeman 2014-08-06 13:20:59 -07:00 committed by Commit bot
parent b5f7826c51
commit 8560cd5396

View File

@ -95,7 +95,7 @@ public:
bool isFixedPitch,
const SkString familyName)
: INHERITED(index, style, isFixedPitch, familyName)
, fStream(stream) { }
, fStream(SkRef(stream)) { }
virtual void onGetFontDescriptor(SkFontDescriptor* desc,
bool* serialize) const SK_OVERRIDE {
@ -382,16 +382,14 @@ protected:
return stream.get() ? this->createFromStream(stream, ttcIndex) : NULL;
}
virtual SkTypeface* onCreateFromStream(SkStream* s, int ttcIndex) const SK_OVERRIDE {
SkAutoTUnref<SkStream> stream(s);
virtual SkTypeface* onCreateFromStream(SkStream* stream, int ttcIndex) const SK_OVERRIDE {
bool isFixedPitch;
SkTypeface::Style style;
SkString name;
if (!SkTypeface_FreeType::ScanFont(stream, ttcIndex, &name, &style, &isFixedPitch)) {
return NULL;
}
return SkNEW_ARGS(SkTypeface_AndroidStream, (stream.detach(), ttcIndex,
return SkNEW_ARGS(SkTypeface_AndroidStream, (stream, ttcIndex,
style, isFixedPitch, name));
}