OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #define WIN32_LEAN_AND_MEAN | 10 #define WIN32_LEAN_AND_MEAN |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 { return E_NOTIMPL; } | 96 { return E_NOTIMPL; } |
97 | 97 |
98 HRESULT STDMETHODCALLTYPE SkBaseIStream::Stat(STATSTG* pStatstg | 98 HRESULT STDMETHODCALLTYPE SkBaseIStream::Stat(STATSTG* pStatstg |
99 , DWORD grfStatFlag) | 99 , DWORD grfStatFlag) |
100 { return E_NOTIMPL; } | 100 { return E_NOTIMPL; } |
101 | 101 |
102 | 102 |
103 /** | 103 /** |
104 * SkIStream | 104 * SkIStream |
105 */ | 105 */ |
106 SkIStream::SkIStream(SkStream* stream, bool unrefOnRelease) | 106 SkIStream::SkIStream(SkStream* stream, bool deleteOnRelease) |
107 : SkBaseIStream() | 107 : SkBaseIStream() |
108 , fSkStream(stream) | 108 , fSkStream(stream) |
109 , fUnrefOnRelease(unrefOnRelease) | 109 , fDeleteOnRelease(deleteOnRelease) |
110 , fLocation() | 110 , fLocation() |
111 { | 111 { |
112 this->fSkStream->rewind(); | 112 this->fSkStream->rewind(); |
113 } | 113 } |
114 | 114 |
115 SkIStream::~SkIStream() { | 115 SkIStream::~SkIStream() { |
116 if (this->fSkStream && fUnrefOnRelease) { | 116 if (this->fSkStream && fDeleteOnRelease) { |
scroggo
2015/01/22 13:55:36
It appears fSkStream can never be NULL, so this ca
| |
117 this->fSkStream->unref(); | 117 delete this->fSkStream; |
118 } | 118 } |
119 } | 119 } |
120 | 120 |
121 HRESULT SkIStream::CreateFromSkStream(SkStream* stream | 121 HRESULT SkIStream::CreateFromSkStream(SkStream* stream |
122 , bool unrefOnRelease | 122 , bool deleteOnRelease |
123 , IStream ** ppStream) | 123 , IStream ** ppStream) |
124 { | 124 { |
125 if (NULL == stream) { | 125 if (NULL == stream) { |
126 return E_INVALIDARG; | 126 return E_INVALIDARG; |
127 } | 127 } |
128 *ppStream = new SkIStream(stream, unrefOnRelease); | 128 *ppStream = new SkIStream(stream, deleteOnRelease); |
129 return S_OK; | 129 return S_OK; |
130 } | 130 } |
131 | 131 |
132 // ISequentialStream Interface | 132 // ISequentialStream Interface |
133 HRESULT STDMETHODCALLTYPE SkIStream::Read(void* pv, ULONG cb, ULONG* pcbRead) { | 133 HRESULT STDMETHODCALLTYPE SkIStream::Read(void* pv, ULONG cb, ULONG* pcbRead) { |
134 *pcbRead = static_cast<ULONG>(this->fSkStream->read(pv, cb)); | 134 *pcbRead = static_cast<ULONG>(this->fSkStream->read(pv, cb)); |
135 this->fLocation.QuadPart += *pcbRead; | 135 this->fLocation.QuadPart += *pcbRead; |
136 return (*pcbRead == cb) ? S_OK : S_FALSE; | 136 return (*pcbRead == cb) ? S_OK : S_FALSE; |
137 } | 137 } |
138 | 138 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
268 if (0 == (grfStatFlag & STATFLAG_NONAME)) { | 268 if (0 == (grfStatFlag & STATFLAG_NONAME)) { |
269 return STG_E_INVALIDFLAG; | 269 return STG_E_INVALIDFLAG; |
270 } | 270 } |
271 pStatstg->pwcsName = NULL; | 271 pStatstg->pwcsName = NULL; |
272 pStatstg->cbSize.QuadPart = 0; | 272 pStatstg->cbSize.QuadPart = 0; |
273 pStatstg->clsid = CLSID_NULL; | 273 pStatstg->clsid = CLSID_NULL; |
274 pStatstg->type = STGTY_STREAM; | 274 pStatstg->type = STGTY_STREAM; |
275 pStatstg->grfMode = STGM_WRITE; | 275 pStatstg->grfMode = STGM_WRITE; |
276 return S_OK; | 276 return S_OK; |
277 } | 277 } |
OLD | NEW |