1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/thebes/gfxDWriteCommon.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,71 @@ 1.4 +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- 1.5 + * This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "gfxDWriteCommon.h" 1.10 + 1.11 +IDWriteFontFileLoader* gfxDWriteFontFileLoader::mInstance = nullptr; 1.12 + 1.13 +HRESULT STDMETHODCALLTYPE 1.14 +gfxDWriteFontFileLoader::CreateStreamFromKey(const void *fontFileReferenceKey, 1.15 + UINT32 fontFileReferenceKeySize, 1.16 + IDWriteFontFileStream **fontFileStream) 1.17 +{ 1.18 + if (!fontFileReferenceKey || !fontFileStream) { 1.19 + return E_POINTER; 1.20 + } 1.21 + 1.22 + *fontFileStream = 1.23 + new gfxDWriteFontFileStream( 1.24 + static_cast<const ffReferenceKey*>(fontFileReferenceKey)->mArray); 1.25 + 1.26 + if (!*fontFileStream) { 1.27 + return E_OUTOFMEMORY; 1.28 + } 1.29 + (*fontFileStream)->AddRef(); 1.30 + return S_OK; 1.31 +} 1.32 + 1.33 +gfxDWriteFontFileStream::gfxDWriteFontFileStream(FallibleTArray<uint8_t> *aData) 1.34 +{ 1.35 + mData.SwapElements(*aData); 1.36 +} 1.37 + 1.38 +gfxDWriteFontFileStream::~gfxDWriteFontFileStream() 1.39 +{ 1.40 +} 1.41 + 1.42 +HRESULT STDMETHODCALLTYPE 1.43 +gfxDWriteFontFileStream::GetFileSize(UINT64 *fileSize) 1.44 +{ 1.45 + *fileSize = mData.Length(); 1.46 + return S_OK; 1.47 +} 1.48 + 1.49 +HRESULT STDMETHODCALLTYPE 1.50 +gfxDWriteFontFileStream::GetLastWriteTime(UINT64 *lastWriteTime) 1.51 +{ 1.52 + return E_NOTIMPL; 1.53 +} 1.54 + 1.55 +HRESULT STDMETHODCALLTYPE 1.56 +gfxDWriteFontFileStream::ReadFileFragment(const void **fragmentStart, 1.57 + UINT64 fileOffset, 1.58 + UINT64 fragmentSize, 1.59 + void **fragmentContext) 1.60 +{ 1.61 + // We are required to do bounds checking. 1.62 + if (fileOffset + fragmentSize > (UINT64)mData.Length()) { 1.63 + return E_FAIL; 1.64 + } 1.65 + // We should be alive for the duration of this. 1.66 + *fragmentStart = &mData[fileOffset]; 1.67 + *fragmentContext = nullptr; 1.68 + return S_OK; 1.69 +} 1.70 + 1.71 +void STDMETHODCALLTYPE 1.72 +gfxDWriteFontFileStream::ReleaseFileFragment(void *fragmentContext) 1.73 +{ 1.74 +}