Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
michael@0 | 2 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "gfxDWriteCommon.h" |
michael@0 | 7 | |
michael@0 | 8 | IDWriteFontFileLoader* gfxDWriteFontFileLoader::mInstance = nullptr; |
michael@0 | 9 | |
michael@0 | 10 | HRESULT STDMETHODCALLTYPE |
michael@0 | 11 | gfxDWriteFontFileLoader::CreateStreamFromKey(const void *fontFileReferenceKey, |
michael@0 | 12 | UINT32 fontFileReferenceKeySize, |
michael@0 | 13 | IDWriteFontFileStream **fontFileStream) |
michael@0 | 14 | { |
michael@0 | 15 | if (!fontFileReferenceKey || !fontFileStream) { |
michael@0 | 16 | return E_POINTER; |
michael@0 | 17 | } |
michael@0 | 18 | |
michael@0 | 19 | *fontFileStream = |
michael@0 | 20 | new gfxDWriteFontFileStream( |
michael@0 | 21 | static_cast<const ffReferenceKey*>(fontFileReferenceKey)->mArray); |
michael@0 | 22 | |
michael@0 | 23 | if (!*fontFileStream) { |
michael@0 | 24 | return E_OUTOFMEMORY; |
michael@0 | 25 | } |
michael@0 | 26 | (*fontFileStream)->AddRef(); |
michael@0 | 27 | return S_OK; |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | gfxDWriteFontFileStream::gfxDWriteFontFileStream(FallibleTArray<uint8_t> *aData) |
michael@0 | 31 | { |
michael@0 | 32 | mData.SwapElements(*aData); |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | gfxDWriteFontFileStream::~gfxDWriteFontFileStream() |
michael@0 | 36 | { |
michael@0 | 37 | } |
michael@0 | 38 | |
michael@0 | 39 | HRESULT STDMETHODCALLTYPE |
michael@0 | 40 | gfxDWriteFontFileStream::GetFileSize(UINT64 *fileSize) |
michael@0 | 41 | { |
michael@0 | 42 | *fileSize = mData.Length(); |
michael@0 | 43 | return S_OK; |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | HRESULT STDMETHODCALLTYPE |
michael@0 | 47 | gfxDWriteFontFileStream::GetLastWriteTime(UINT64 *lastWriteTime) |
michael@0 | 48 | { |
michael@0 | 49 | return E_NOTIMPL; |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | HRESULT STDMETHODCALLTYPE |
michael@0 | 53 | gfxDWriteFontFileStream::ReadFileFragment(const void **fragmentStart, |
michael@0 | 54 | UINT64 fileOffset, |
michael@0 | 55 | UINT64 fragmentSize, |
michael@0 | 56 | void **fragmentContext) |
michael@0 | 57 | { |
michael@0 | 58 | // We are required to do bounds checking. |
michael@0 | 59 | if (fileOffset + fragmentSize > (UINT64)mData.Length()) { |
michael@0 | 60 | return E_FAIL; |
michael@0 | 61 | } |
michael@0 | 62 | // We should be alive for the duration of this. |
michael@0 | 63 | *fragmentStart = &mData[fileOffset]; |
michael@0 | 64 | *fragmentContext = nullptr; |
michael@0 | 65 | return S_OK; |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | void STDMETHODCALLTYPE |
michael@0 | 69 | gfxDWriteFontFileStream::ReleaseFileFragment(void *fragmentContext) |
michael@0 | 70 | { |
michael@0 | 71 | } |