| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkTypes.h" | 8 #include "SkTypes.h" |
| 9 #include "SkDWriteFontFileStream.h" | 9 #include "SkDWriteFontFileStream.h" |
| 10 #include "SkHRESULT.h" | 10 #include "SkHRESULT.h" |
| 11 #include "SkTemplates.h" |
| 11 #include "SkTScopedComPtr.h" | 12 #include "SkTScopedComPtr.h" |
| 12 | 13 |
| 13 #include <dwrite.h> | 14 #include <dwrite.h> |
| 14 #include <limits> | 15 #include <limits> |
| 15 | 16 |
| 16 /////////////////////////////////////////////////////////////////////////////// | 17 /////////////////////////////////////////////////////////////////////////////// |
| 17 // SkIDWriteFontFileStream | 18 // SkIDWriteFontFileStream |
| 18 | 19 |
| 19 SkDWriteFontFileStream::SkDWriteFontFileStream(IDWriteFontFileStream* fontFileSt
ream) | 20 SkDWriteFontFileStream::SkDWriteFontFileStream(IDWriteFontFileStream* fontFileSt
ream) |
| 20 : fFontFileStream(SkRefComPtr(fontFileStream)) | 21 : fFontFileStream(SkRefComPtr(fontFileStream)) |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 SkDWriteFontFileStream* SkDWriteFontFileStream::fork() const { | 105 SkDWriteFontFileStream* SkDWriteFontFileStream::fork() const { |
| 105 SkAutoTUnref<SkDWriteFontFileStream> that(this->duplicate()); | 106 SkAutoTUnref<SkDWriteFontFileStream> that(this->duplicate()); |
| 106 that->seek(fPos); | 107 that->seek(fPos); |
| 107 return that.detach(); | 108 return that.detach(); |
| 108 } | 109 } |
| 109 | 110 |
| 110 size_t SkDWriteFontFileStream::getLength() const { | 111 size_t SkDWriteFontFileStream::getLength() const { |
| 111 HRESULT hr = S_OK; | 112 HRESULT hr = S_OK; |
| 112 UINT64 realFileSize = 0; | 113 UINT64 realFileSize = 0; |
| 113 hr = fFontFileStream->GetFileSize(&realFileSize); | 114 hr = fFontFileStream->GetFileSize(&realFileSize); |
| 114 if (realFileSize > (std::numeric_limits<size_t>::max)()) { | 115 if (!SkTFitsIn<size_t>(realFileSize)) { |
| 115 return 0; | 116 return 0; |
| 116 } | 117 } |
| 117 return static_cast<size_t>(realFileSize); | 118 return static_cast<size_t>(realFileSize); |
| 118 } | 119 } |
| 119 | 120 |
| 120 const void* SkDWriteFontFileStream::getMemoryBase() { | 121 const void* SkDWriteFontFileStream::getMemoryBase() { |
| 121 if (fLockedMemory) { | 122 if (fLockedMemory) { |
| 122 return fLockedMemory; | 123 return fLockedMemory; |
| 123 } | 124 } |
| 124 | 125 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 HRESULT STDMETHODCALLTYPE SkDWriteFontFileStreamWrapper::GetFileSize(UINT64* fil
eSize) { | 223 HRESULT STDMETHODCALLTYPE SkDWriteFontFileStreamWrapper::GetFileSize(UINT64* fil
eSize) { |
| 223 *fileSize = fStream->getLength(); | 224 *fileSize = fStream->getLength(); |
| 224 return S_OK; | 225 return S_OK; |
| 225 } | 226 } |
| 226 | 227 |
| 227 HRESULT STDMETHODCALLTYPE SkDWriteFontFileStreamWrapper::GetLastWriteTime(UINT64
* lastWriteTime) { | 228 HRESULT STDMETHODCALLTYPE SkDWriteFontFileStreamWrapper::GetLastWriteTime(UINT64
* lastWriteTime) { |
| 228 // The concept of last write time does not apply to this loader. | 229 // The concept of last write time does not apply to this loader. |
| 229 *lastWriteTime = 0; | 230 *lastWriteTime = 0; |
| 230 return E_NOTIMPL; | 231 return E_NOTIMPL; |
| 231 } | 232 } |
| OLD | NEW |