9#if defined(SK_BUILD_FOR_WIN)
17SkBaseIStream::SkBaseIStream() : _refcount(1) { }
18SkBaseIStream::~SkBaseIStream() { }
20SK_STDMETHODIMP SkBaseIStream::QueryInterface(REFIID iid,
void ** ppvObject) {
21 if (
nullptr == ppvObject) {
24 if (iid == __uuidof(IUnknown)
25 || iid == __uuidof(IStream)
26 || iid == __uuidof(ISequentialStream))
28 *ppvObject =
static_cast<IStream*
>(
this);
38 return (
ULONG)InterlockedIncrement(&_refcount);
42 ULONG res = (
ULONG) InterlockedDecrement(&_refcount);
60SK_STDMETHODIMP SkBaseIStream::CopyTo(IStream*, ULARGE_INTEGER, ULARGE_INTEGER*, ULARGE_INTEGER*)
80 ULARGE_INTEGER* lpNewFilePointer)
90SkIStream::SkIStream(std::unique_ptr<SkStreamAsset>
stream)
95 this->fSkStream->rewind();
98SkIStream::~SkIStream() {}
100HRESULT SkIStream::CreateFromSkStream(std::unique_ptr<SkStreamAsset>
stream, IStream** ppStream) {
104 *ppStream =
new SkIStream(std::move(
stream));
110 *pcbRead =
static_cast<ULONG>(this->fSkStream->read(pv, cb));
111 this->fLocation.QuadPart += *pcbRead;
112 return (*pcbRead == cb) ? S_OK : S_FALSE;
116 return STG_E_CANTSAVE;
122 ULARGE_INTEGER* lpNewFilePointer)
127 case STREAM_SEEK_SET: {
128 if (!this->fSkStream->rewind()) {
131 size_t skip =
static_cast<size_t>(liDistanceToMove.QuadPart);
132 size_t skipped = this->fSkStream->skip(
skip);
133 this->fLocation.QuadPart = skipped;
134 if (skipped !=
skip) {
140 case STREAM_SEEK_CUR: {
141 size_t skip =
static_cast<size_t>(liDistanceToMove.QuadPart);
142 size_t skipped = this->fSkStream->skip(
skip);
143 this->fLocation.QuadPart += skipped;
144 if (skipped !=
skip) {
149 case STREAM_SEEK_END: {
150 if (!this->fSkStream->rewind()) {
153 size_t skip =
static_cast<size_t>(this->fSkStream->getLength() +
154 liDistanceToMove.QuadPart);
155 size_t skipped = this->fSkStream->skip(
skip);
156 this->fLocation.QuadPart = skipped;
157 if (skipped !=
skip) {
164 hr = STG_E_INVALIDFUNCTION;
168 if (lpNewFilePointer) {
169 lpNewFilePointer->QuadPart = this->fLocation.QuadPart;
175 if (0 == (grfStatFlag & STATFLAG_NONAME)) {
176 return STG_E_INVALIDFLAG;
178 pStatstg->pwcsName =
nullptr;
179 pStatstg->cbSize.QuadPart = this->fSkStream->getLength();
180 pStatstg->clsid = CLSID_NULL;
181 pStatstg->type = STGTY_STREAM;
182 pStatstg->grfMode = STGM_READ;
195SkWIStream::~SkWIStream() {
196 if (this->fSkWStream) {
197 this->fSkWStream->flush();
201HRESULT SkWIStream::CreateFromSkWStream(
SkWStream*
stream, IStream ** ppStream) {
202 *ppStream =
new SkWIStream(
stream);
209 bool wrote = this->fSkWStream->write(pv, cb);
221 this->fSkWStream->flush();
226 if (0 == (grfStatFlag & STATFLAG_NONAME)) {
227 return STG_E_INVALIDFLAG;
229 pStatstg->pwcsName =
nullptr;
230 pStatstg->cbSize.QuadPart = 0;
231 pStatstg->clsid = CLSID_NULL;
232 pStatstg->type = STGTY_STREAM;
233 pStatstg->grfMode = STGM_WRITE;
static bool skip(SkStream *stream, size_t amount)
#define SK_STDMETHODIMP_(type)
SK_API bool Read(SkStreamSeekable *src, SkDocumentPage *dstArray, int dstArrayCount, const SkDeserialProcs *=nullptr)