Bug 1495919 - ensure IDWriteFontFileStream stays alive with NativeFontResourceDWrite. r=jrmuizel
authorLee Salzman <lsalzman@mozilla.com>
Thu, 18 Oct 2018 18:00:23 -0400
changeset 500511 11f359e1b03813e834e3c34c9d13aa93564d7999
parent 500510 72b97e539421a38d16e843783c2359381bc6ac33
child 500513 7d74c59053843bd79ed1456e830a760fdf82656b
child 500542 0b54085a89d475b6ea1c7ded43a69451c0c400a3
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1495919
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1495919 - ensure IDWriteFontFileStream stays alive with NativeFontResourceDWrite. r=jrmuizel
gfx/2d/NativeFontResourceDWrite.cpp
gfx/2d/NativeFontResourceDWrite.h
--- a/gfx/2d/NativeFontResourceDWrite.cpp
+++ b/gfx/2d/NativeFontResourceDWrite.cpp
@@ -267,18 +267,18 @@ NativeFontResourceDWrite::Create(uint8_t
   UINT32 numberOfFaces;
   hr = fontFile->Analyze(&isSupported, &fileType, &faceType, &numberOfFaces);
   if (FAILED(hr) || !isSupported) {
     gfxWarning() << "Font file is not supported.";
     return nullptr;
   }
 
   RefPtr<NativeFontResourceDWrite> fontResource =
-    new NativeFontResourceDWrite(factory, fontFile.forget(), faceType,
-                                 numberOfFaces, aNeedsCairo);
+    new NativeFontResourceDWrite(factory, fontFile.forget(), ffsRef.forget(),
+                                 faceType, numberOfFaces, aNeedsCairo);
   return fontResource.forget();
 }
 
 already_AddRefed<UnscaledFont>
 NativeFontResourceDWrite::CreateUnscaledFont(uint32_t aIndex,
                                              const uint8_t* aInstanceData,
                                              uint32_t aInstanceDataLength)
 {
--- a/gfx/2d/NativeFontResourceDWrite.h
+++ b/gfx/2d/NativeFontResourceDWrite.h
@@ -35,24 +35,30 @@ public:
   already_AddRefed<UnscaledFont>
     CreateUnscaledFont(uint32_t aIndex,
                        const uint8_t* aInstanceData,
                        uint32_t aInstanceDataLength) final;
 
 private:
   NativeFontResourceDWrite(IDWriteFactory *aFactory,
                            already_AddRefed<IDWriteFontFile> aFontFile,
+                           already_AddRefed<IDWriteFontFileStream> aFontFileStream,
                            DWRITE_FONT_FACE_TYPE aFaceType,
                            uint32_t aNumberOfFaces, bool aNeedsCairo)
-    : mFactory(aFactory), mFontFile(aFontFile), mFaceType(aFaceType)
-    , mNumberOfFaces(aNumberOfFaces), mNeedsCairo(aNeedsCairo)
+    : mFactory(aFactory)
+    , mFontFile(aFontFile)
+    , mFontFileStream(aFontFileStream)
+    , mFaceType(aFaceType)
+    , mNumberOfFaces(aNumberOfFaces)
+    , mNeedsCairo(aNeedsCairo)
   {}
 
   IDWriteFactory *mFactory;
   RefPtr<IDWriteFontFile> mFontFile;
+  RefPtr<IDWriteFontFileStream> mFontFileStream;
   DWRITE_FONT_FACE_TYPE mFaceType;
   uint32_t mNumberOfFaces;
   bool mNeedsCairo;
 };
 
 } // gfx
 } // mozilla