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 |
11 #include <windows.h> | 11 #include <windows.h> |
12 #include <ole2.h> | 12 #include <ole2.h> |
13 #include "SkIStream.h" | 13 #include "SkIStream.h" |
14 #include "SkStream.h" | 14 #include "SkStream.h" |
15 | 15 |
16 /** | 16 /** |
17 * SkBaseIStream | 17 * SkBaseIStream |
18 */ | 18 */ |
19 SkBaseIStream::SkBaseIStream() : _refcount(1) { } | 19 SkBaseIStream::SkBaseIStream() : _refcount(1) { } |
20 SkBaseIStream::~SkBaseIStream() { } | 20 SkBaseIStream::~SkBaseIStream() { } |
21 | 21 |
22 HRESULT STDMETHODCALLTYPE SkBaseIStream::QueryInterface(REFIID iid | 22 HRESULT STDMETHODCALLTYPE SkBaseIStream::QueryInterface(REFIID iid |
23 , void ** ppvObject) | 23 , void ** ppvObject) |
24 { | 24 { |
25 if (NULL == ppvObject) { | 25 if (nullptr == ppvObject) { |
26 return E_INVALIDARG; | 26 return E_INVALIDARG; |
27 } | 27 } |
28 if (iid == __uuidof(IUnknown) | 28 if (iid == __uuidof(IUnknown) |
29 || iid == __uuidof(IStream) | 29 || iid == __uuidof(IStream) |
30 || iid == __uuidof(ISequentialStream)) | 30 || iid == __uuidof(ISequentialStream)) |
31 { | 31 { |
32 *ppvObject = static_cast<IStream*>(this); | 32 *ppvObject = static_cast<IStream*>(this); |
33 AddRef(); | 33 AddRef(); |
34 return S_OK; | 34 return S_OK; |
35 } else { | 35 } else { |
36 *ppvObject = NULL; | 36 *ppvObject = nullptr; |
37 return E_NOINTERFACE; | 37 return E_NOINTERFACE; |
38 } | 38 } |
39 } | 39 } |
40 | 40 |
41 ULONG STDMETHODCALLTYPE SkBaseIStream::AddRef(void) { | 41 ULONG STDMETHODCALLTYPE SkBaseIStream::AddRef(void) { |
42 return (ULONG)InterlockedIncrement(&_refcount); | 42 return (ULONG)InterlockedIncrement(&_refcount); |
43 } | 43 } |
44 | 44 |
45 ULONG STDMETHODCALLTYPE SkBaseIStream::Release(void) { | 45 ULONG STDMETHODCALLTYPE SkBaseIStream::Release(void) { |
46 ULONG res = (ULONG) InterlockedDecrement(&_refcount); | 46 ULONG res = (ULONG) InterlockedDecrement(&_refcount); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 SkIStream::~SkIStream() { | 115 SkIStream::~SkIStream() { |
116 if (fDeleteOnRelease) { | 116 if (fDeleteOnRelease) { |
117 delete this->fSkStream; | 117 delete this->fSkStream; |
118 } | 118 } |
119 } | 119 } |
120 | 120 |
121 HRESULT SkIStream::CreateFromSkStream(SkStream* stream | 121 HRESULT SkIStream::CreateFromSkStream(SkStream* stream |
122 , bool deleteOnRelease | 122 , bool deleteOnRelease |
123 , IStream ** ppStream) | 123 , IStream ** ppStream) |
124 { | 124 { |
125 if (NULL == stream) { | 125 if (nullptr == stream) { |
126 return E_INVALIDARG; | 126 return E_INVALIDARG; |
127 } | 127 } |
128 *ppStream = new SkIStream(stream, deleteOnRelease); | 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; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 } | 201 } |
202 return hr; | 202 return hr; |
203 } | 203 } |
204 | 204 |
205 HRESULT STDMETHODCALLTYPE SkIStream::Stat(STATSTG* pStatstg | 205 HRESULT STDMETHODCALLTYPE SkIStream::Stat(STATSTG* pStatstg |
206 , DWORD grfStatFlag) | 206 , DWORD grfStatFlag) |
207 { | 207 { |
208 if (0 == (grfStatFlag & STATFLAG_NONAME)) { | 208 if (0 == (grfStatFlag & STATFLAG_NONAME)) { |
209 return STG_E_INVALIDFLAG; | 209 return STG_E_INVALIDFLAG; |
210 } | 210 } |
211 pStatstg->pwcsName = NULL; | 211 pStatstg->pwcsName = nullptr; |
212 // FIXME: Should not depend on getLength | 212 // FIXME: Should not depend on getLength |
213 // See https://code.google.com/p/skia/issues/detail?id=1570 | 213 // See https://code.google.com/p/skia/issues/detail?id=1570 |
214 pStatstg->cbSize.QuadPart = this->fSkStream->getLength(); | 214 pStatstg->cbSize.QuadPart = this->fSkStream->getLength(); |
215 pStatstg->clsid = CLSID_NULL; | 215 pStatstg->clsid = CLSID_NULL; |
216 pStatstg->type = STGTY_STREAM; | 216 pStatstg->type = STGTY_STREAM; |
217 pStatstg->grfMode = STGM_READ; | 217 pStatstg->grfMode = STGM_READ; |
218 return S_OK; | 218 return S_OK; |
219 } | 219 } |
220 | 220 |
221 | 221 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 this->fSkWStream->flush(); | 261 this->fSkWStream->flush(); |
262 return S_OK; | 262 return S_OK; |
263 } | 263 } |
264 | 264 |
265 HRESULT STDMETHODCALLTYPE SkWIStream::Stat(STATSTG* pStatstg | 265 HRESULT STDMETHODCALLTYPE SkWIStream::Stat(STATSTG* pStatstg |
266 , DWORD grfStatFlag) | 266 , DWORD grfStatFlag) |
267 { | 267 { |
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 = nullptr; |
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 |