Quellcode-Bibliothek gfxDWriteCommon.cpp
Sprache: C
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
class gfxDWriteFontFileStream final : public IDWriteFontFileStream { public: /** * Used by the FontFileLoader to create a new font stream, * this font stream is created from data in memory. The memory * passed may be released after object creation, it will be * copied internally. * * @param aData Font data
*/
gfxDWriteFontFileStream(const uint8_t* aData, uint32_t aLength,
uint64_t aFontFileKey);
~gfxDWriteFontFileStream();
gfxDWriteFontFileStream::gfxDWriteFontFileStream(const uint8_t* aData,
uint32_t aLength,
uint64_t aFontFileKey)
: mFontFileKey(aFontFileKey) { // If this fails, mData will remain empty. That's OK: GetFileSize() // will then return 0, etc., and the font just won't load. if (!mData.AppendElements(aData, aLength, mozilla::fallible_t())) {
NS_WARNING("Failed to store data in gfxDWriteFontFileStream");
}
}
HRESULT STDMETHODCALLTYPE gfxDWriteFontFileStream::ReadFileFragment( constvoid** fragmentStart, UINT64 fileOffset, UINT64 fragmentSize, void** fragmentContext) { // We are required to do bounds checking. if (fileOffset + fragmentSize > (UINT64)mData.Length()) { return E_FAIL;
} // We should be alive for the duration of this.
*fragmentStart = &mData[fileOffset];
*fragmentContext = nullptr; return S_OK;
}
RefPtr<IDWriteFactory> factory = mozilla::gfx::Factory::GetDWriteFactory(); if (!factory) {
gfxCriticalError()
<< "Failed to get DWrite Factory in CreateCustomFontFile."; return E_FAIL;
}
// We are a singleton type that is effective owner of sFontFileStreams.
MOZ_ASSERT(this == mInstance); for (constauto& entry : sFontFileStreams) {
gfxDWriteFontFileStream* fileStream = entry.second;
sizes += fileStream->SizeOfIncludingThis(mallocSizeOf);
}
return sizes;
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.1Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.