aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-02-03 17:55:00 +0800
committercrupest <crupest@outlook.com>2022-02-03 17:55:00 +0800
commit5aca7b099c46a87a859f40110efce708200a4bc8 (patch)
tree76a0daef247ab2b2269eebdbbda10134f213d1ca /include
parentd15172cfe1ac8558567c1b1c10c2e671b0d1f033 (diff)
downloadcru-5aca7b099c46a87a859f40110efce708200a4bc8.tar.gz
cru-5aca7b099c46a87a859f40110efce708200a4bc8.tar.bz2
cru-5aca7b099c46a87a859f40110efce708200a4bc8.zip
...
Diffstat (limited to 'include')
-rw-r--r--include/cru/common/io/MemoryStream.hpp3
-rw-r--r--include/cru/common/platform/win/BrigdeComStream.hpp48
-rw-r--r--include/cru/common/platform/win/ComAutoInit.hpp21
-rw-r--r--include/cru/common/platform/win/StreamConvert.hpp14
-rw-r--r--include/cru/common/platform/win/Win32FileStream.hpp3
-rw-r--r--include/cru/win/graphics/direct/Factory.hpp3
6 files changed, 44 insertions, 48 deletions
diff --git a/include/cru/common/io/MemoryStream.hpp b/include/cru/common/io/MemoryStream.hpp
index e917814c..29da7b9f 100644
--- a/include/cru/common/io/MemoryStream.hpp
+++ b/include/cru/common/io/MemoryStream.hpp
@@ -31,6 +31,9 @@ class CRU_BASE_API MemoryStream : public Stream {
bool CanWrite() override;
Index Write(const std::byte* buffer, Index offset, Index size) override;
+ std::byte* GetBuffer() const { return buffer_; }
+ Index GetSize() override { return size_; }
+
private:
std::byte* buffer_ = nullptr;
Index size_ = 0;
diff --git a/include/cru/common/platform/win/BrigdeComStream.hpp b/include/cru/common/platform/win/BrigdeComStream.hpp
deleted file mode 100644
index 38b75dae..00000000
--- a/include/cru/common/platform/win/BrigdeComStream.hpp
+++ /dev/null
@@ -1,48 +0,0 @@
-#pragma once
-#include "../../PreConfig.hpp"
-#ifdef CRU_PLATFORM_WINDOWS
-
-#include "WinPreConfig.hpp"
-
-#include "../../io/Stream.hpp"
-
-#include <objidlbase.h>
-
-namespace cru::platform::win {
-class BridgeComStream : public IStream {
- public:
- explicit BridgeComStream(io::Stream* stream);
-
- CRU_DELETE_COPY(BridgeComStream)
- CRU_DELETE_MOVE(BridgeComStream)
-
- ~BridgeComStream();
-
- public:
- ULONG AddRef() override;
- ULONG Release() override;
- HRESULT QueryInterface(REFIID riid, void** ppvObject) override;
-
- HRESULT Read(void* pv, ULONG cb, ULONG* pcbRead) override;
- HRESULT Write(const void* pv, ULONG cb, ULONG* pcbWritten) override;
- HRESULT Seek(LARGE_INTEGER dlibMove, DWORD dwOrigin,
- ULARGE_INTEGER* plibNewPosition) override;
- HRESULT SetSize(ULARGE_INTEGER libNewSize) override;
- HRESULT CopyTo(IStream* pstm, ULARGE_INTEGER cb, ULARGE_INTEGER* pcbRead,
- ULARGE_INTEGER* pcbWritten) override;
- HRESULT Commit(DWORD grfCommitFlags) override;
- HRESULT Revert() override;
- HRESULT LockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb,
- DWORD dwLockType) override;
- HRESULT UnlockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb,
- DWORD dwLockType) override;
- HRESULT Stat(STATSTG* pstatstg, DWORD grfStatFlag) override;
- HRESULT Clone(IStream** ppstm) override;
-
- private:
- io::Stream* stream_;
- ULONG ref_count_;
-};
-} // namespace cru::platform::win
-
-#endif
diff --git a/include/cru/common/platform/win/ComAutoInit.hpp b/include/cru/common/platform/win/ComAutoInit.hpp
new file mode 100644
index 00000000..131f3f30
--- /dev/null
+++ b/include/cru/common/platform/win/ComAutoInit.hpp
@@ -0,0 +1,21 @@
+#pragma once
+
+#include "../../PreConfig.hpp"
+#ifdef CRU_PLATFORM_WINDOWS
+
+#include "WinPreConfig.hpp"
+#include "cru/common/Base.hpp"
+
+namespace cru::platform::win {
+class CRU_BASE_API ComAutoInit {
+ public:
+ ComAutoInit();
+
+ CRU_DELETE_COPY(ComAutoInit)
+ CRU_DELETE_MOVE(ComAutoInit)
+
+ ~ComAutoInit();
+};
+} // namespace cru::platform::win
+
+#endif
diff --git a/include/cru/common/platform/win/StreamConvert.hpp b/include/cru/common/platform/win/StreamConvert.hpp
new file mode 100644
index 00000000..80800115
--- /dev/null
+++ b/include/cru/common/platform/win/StreamConvert.hpp
@@ -0,0 +1,14 @@
+#pragma once
+#include "../../PreConfig.hpp"
+
+#ifdef CRU_PLATFORM_WINDOWS
+
+#include "../../io/Stream.hpp"
+
+#include <objidlbase.h>
+
+namespace cru::platform::win {
+CRU_BASE_API IStream* ConvertStreamToComStream(io::Stream* stream);
+}
+
+#endif
diff --git a/include/cru/common/platform/win/Win32FileStream.hpp b/include/cru/common/platform/win/Win32FileStream.hpp
index ebb23357..b5511ba3 100644
--- a/include/cru/common/platform/win/Win32FileStream.hpp
+++ b/include/cru/common/platform/win/Win32FileStream.hpp
@@ -36,6 +36,9 @@ class CRU_BASE_API Win32FileStream : public io::Stream {
void Close() override;
+ String GetPath() const { return path_; }
+ io::OpenFileFlag GetOpenFileFlags() const { return flags_; }
+
private:
void CheckClosed();
diff --git a/include/cru/win/graphics/direct/Factory.hpp b/include/cru/win/graphics/direct/Factory.hpp
index ba504f0d..4ceed7c5 100644
--- a/include/cru/win/graphics/direct/Factory.hpp
+++ b/include/cru/win/graphics/direct/Factory.hpp
@@ -3,6 +3,7 @@
#include "ImageFactory.hpp"
+#include "cru/common/platform/win/ComAutoInit.hpp"
#include "cru/platform/graphics/Base.hpp"
#include "cru/platform/graphics/Factory.hpp"
@@ -52,6 +53,8 @@ class CRU_WIN_GRAPHICS_DIRECT_API DirectGraphicsFactory
IImageFactory* GetImageFactory() override;
private:
+ platform::win::ComAutoInit com_auto_init_;
+
Microsoft::WRL::ComPtr<ID3D11Device> d3d11_device_;
Microsoft::WRL::ComPtr<ID2D1Factory2> d2d1_factory_;
Microsoft::WRL::ComPtr<ID2D1Device1> d2d1_device_;