epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
bungeman@google.com | 9df621d | 2011-06-23 21:43:52 +0000 | [diff] [blame] | 2 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 3 | * Copyright 2011 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
bungeman@google.com | 9df621d | 2011-06-23 21:43:52 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 9 | |
bungeman@google.com | 9df621d | 2011-06-23 21:43:52 +0000 | [diff] [blame] | 10 | #ifndef SkIStream_DEFINED |
| 11 | #define SkIStream_DEFINED |
| 12 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 13 | #include "include/core/SkTypes.h" |
halcanary | 0cbe7ee | 2015-12-01 09:02:49 -0800 | [diff] [blame] | 14 | |
| 15 | #ifdef SK_BUILD_FOR_WIN |
| 16 | |
Ben Wagner | ab6eefe | 2019-05-20 11:02:49 -0400 | [diff] [blame^] | 17 | #include "src/core/SkLeanWindows.h" |
bungeman@google.com | 9df621d | 2011-06-23 21:43:52 +0000 | [diff] [blame] | 18 | #include <ole2.h> |
| 19 | |
| 20 | class SkStream; |
| 21 | class SkWStream; |
| 22 | |
| 23 | /** |
| 24 | * A bare IStream implementation which properly reference counts |
| 25 | * but returns E_NOTIMPL for all ISequentialStream and IStream methods. |
| 26 | */ |
| 27 | class SkBaseIStream : public IStream { |
| 28 | private: |
| 29 | LONG _refcount; |
| 30 | |
| 31 | protected: |
| 32 | explicit SkBaseIStream(); |
| 33 | virtual ~SkBaseIStream(); |
| 34 | |
| 35 | public: |
| 36 | virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid |
| 37 | , void ** ppvObject); |
| 38 | virtual ULONG STDMETHODCALLTYPE AddRef(void); |
| 39 | virtual ULONG STDMETHODCALLTYPE Release(void); |
| 40 | |
| 41 | // ISequentialStream Interface |
| 42 | public: |
| 43 | virtual HRESULT STDMETHODCALLTYPE Read(void* pv, ULONG cb, ULONG* pcbRead); |
| 44 | |
| 45 | virtual HRESULT STDMETHODCALLTYPE Write(void const* pv |
| 46 | , ULONG cb |
| 47 | , ULONG* pcbWritten); |
| 48 | |
| 49 | // IStream Interface |
| 50 | public: |
| 51 | virtual HRESULT STDMETHODCALLTYPE SetSize(ULARGE_INTEGER); |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 52 | |
bungeman@google.com | 9df621d | 2011-06-23 21:43:52 +0000 | [diff] [blame] | 53 | virtual HRESULT STDMETHODCALLTYPE CopyTo(IStream* |
| 54 | , ULARGE_INTEGER |
| 55 | , ULARGE_INTEGER* |
| 56 | , ULARGE_INTEGER*); |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 57 | |
bungeman@google.com | 9df621d | 2011-06-23 21:43:52 +0000 | [diff] [blame] | 58 | virtual HRESULT STDMETHODCALLTYPE Commit(DWORD); |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 59 | |
bungeman@google.com | 9df621d | 2011-06-23 21:43:52 +0000 | [diff] [blame] | 60 | virtual HRESULT STDMETHODCALLTYPE Revert(void); |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 61 | |
bungeman@google.com | 9df621d | 2011-06-23 21:43:52 +0000 | [diff] [blame] | 62 | virtual HRESULT STDMETHODCALLTYPE LockRegion(ULARGE_INTEGER |
| 63 | , ULARGE_INTEGER |
| 64 | , DWORD); |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 65 | |
bungeman@google.com | 9df621d | 2011-06-23 21:43:52 +0000 | [diff] [blame] | 66 | virtual HRESULT STDMETHODCALLTYPE UnlockRegion(ULARGE_INTEGER |
| 67 | , ULARGE_INTEGER |
| 68 | , DWORD); |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 69 | |
bungeman@google.com | 9df621d | 2011-06-23 21:43:52 +0000 | [diff] [blame] | 70 | virtual HRESULT STDMETHODCALLTYPE Clone(IStream **); |
| 71 | |
| 72 | virtual HRESULT STDMETHODCALLTYPE Seek(LARGE_INTEGER liDistanceToMove |
| 73 | , DWORD dwOrigin |
| 74 | , ULARGE_INTEGER* lpNewFilePointer); |
| 75 | |
| 76 | virtual HRESULT STDMETHODCALLTYPE Stat(STATSTG* pStatstg |
| 77 | , DWORD grfStatFlag); |
| 78 | }; |
| 79 | |
| 80 | /** |
bungeman | 44af7ba | 2015-01-22 07:33:51 -0800 | [diff] [blame] | 81 | * A minimal read-only IStream implementation which wraps an SkStream. |
bungeman@google.com | 9df621d | 2011-06-23 21:43:52 +0000 | [diff] [blame] | 82 | */ |
| 83 | class SkIStream : public SkBaseIStream { |
| 84 | private: |
| 85 | SkStream *fSkStream; |
bungeman | 44af7ba | 2015-01-22 07:33:51 -0800 | [diff] [blame] | 86 | const bool fDeleteOnRelease; |
bungeman@google.com | 6015792 | 2011-08-13 00:06:17 +0000 | [diff] [blame] | 87 | ULARGE_INTEGER fLocation; |
bungeman@google.com | 9df621d | 2011-06-23 21:43:52 +0000 | [diff] [blame] | 88 | |
bungeman | 2dca817 | 2015-01-22 06:08:31 -0800 | [diff] [blame] | 89 | SkIStream(SkStream* stream, bool fDeleteOnRelease); |
bungeman@google.com | 9df621d | 2011-06-23 21:43:52 +0000 | [diff] [blame] | 90 | virtual ~SkIStream(); |
| 91 | |
| 92 | public: |
| 93 | HRESULT static CreateFromSkStream(SkStream* stream |
bungeman | 2dca817 | 2015-01-22 06:08:31 -0800 | [diff] [blame] | 94 | , bool fDeleteOnRelease |
bungeman@google.com | 9df621d | 2011-06-23 21:43:52 +0000 | [diff] [blame] | 95 | , IStream ** ppStream); |
| 96 | |
| 97 | virtual HRESULT STDMETHODCALLTYPE Read(void* pv, ULONG cb, ULONG* pcbRead); |
| 98 | |
| 99 | virtual HRESULT STDMETHODCALLTYPE Write(void const* pv |
| 100 | , ULONG cb |
| 101 | , ULONG* pcbWritten); |
| 102 | |
| 103 | virtual HRESULT STDMETHODCALLTYPE Seek(LARGE_INTEGER liDistanceToMove |
| 104 | , DWORD dwOrigin |
| 105 | , ULARGE_INTEGER* lpNewFilePointer); |
| 106 | |
| 107 | virtual HRESULT STDMETHODCALLTYPE Stat(STATSTG* pStatstg |
| 108 | , DWORD grfStatFlag); |
| 109 | }; |
| 110 | |
| 111 | /** |
| 112 | * A minimal write-only IStream implementation which wraps an SkWIStream. |
| 113 | */ |
| 114 | class SkWIStream : public SkBaseIStream { |
| 115 | private: |
| 116 | SkWStream *fSkWStream; |
| 117 | |
| 118 | SkWIStream(SkWStream* stream); |
| 119 | virtual ~SkWIStream(); |
| 120 | |
| 121 | public: |
| 122 | HRESULT static CreateFromSkWStream(SkWStream* stream, IStream ** ppStream); |
| 123 | |
| 124 | virtual HRESULT STDMETHODCALLTYPE Write(void const* pv |
| 125 | , ULONG cb |
| 126 | , ULONG* pcbWritten); |
| 127 | |
bungeman@google.com | 14fc321 | 2011-08-01 20:41:53 +0000 | [diff] [blame] | 128 | virtual HRESULT STDMETHODCALLTYPE Commit(DWORD); |
| 129 | |
bungeman@google.com | 9df621d | 2011-06-23 21:43:52 +0000 | [diff] [blame] | 130 | virtual HRESULT STDMETHODCALLTYPE Stat(STATSTG* pStatstg |
| 131 | , DWORD grfStatFlag); |
| 132 | }; |
| 133 | |
halcanary | 0cbe7ee | 2015-12-01 09:02:49 -0800 | [diff] [blame] | 134 | #endif // SK_BUILD_FOR_WIN |
| 135 | #endif // SkIStream_DEFINED |