diff --git a/Doxyfile b/Doxyfile
index 000da894..87bd77fc 100644
--- a/Doxyfile
+++ b/Doxyfile
@@ -45,7 +45,9 @@ FILE_PATTERNS = *.c \
*.h++
RECURSIVE = YES
-EXCLUDE = src/3rd-party
+EXCLUDE = src/3rd-party \
+ src/kiwano/platform/win32 \
+ src/kiwano/renderer/win32
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
diff --git a/projects/kiwano-audio/kiwano-audio.vcxproj b/projects/kiwano-audio/kiwano-audio.vcxproj
index 4bb63a42..c593786f 100644
--- a/projects/kiwano-audio/kiwano-audio.vcxproj
+++ b/projects/kiwano-audio/kiwano-audio.vcxproj
@@ -1,7 +1,7 @@
-
+
@@ -19,7 +19,7 @@
-
+
diff --git a/projects/kiwano-audio/kiwano-audio.vcxproj.filters b/projects/kiwano-audio/kiwano-audio.vcxproj.filters
index 2e5726c2..a842f4fe 100644
--- a/projects/kiwano-audio/kiwano-audio.vcxproj.filters
+++ b/projects/kiwano-audio/kiwano-audio.vcxproj.filters
@@ -3,16 +3,16 @@
-
+
-
+
\ No newline at end of file
diff --git a/projects/kiwano/kiwano.vcxproj b/projects/kiwano/kiwano.vcxproj
index 50bdf07a..e83c8301 100644
--- a/projects/kiwano/kiwano.vcxproj
+++ b/projects/kiwano/kiwano.vcxproj
@@ -14,7 +14,6 @@
-
@@ -54,7 +53,9 @@
-
+
+
+
@@ -121,7 +122,7 @@
-
+
diff --git a/projects/kiwano/kiwano.vcxproj.filters b/projects/kiwano/kiwano.vcxproj.filters
index 0d25de48..504b6bf1 100644
--- a/projects/kiwano/kiwano.vcxproj.filters
+++ b/projects/kiwano/kiwano.vcxproj.filters
@@ -28,8 +28,8 @@
{30333461-e9bc-4709-84bd-ce6e0e1a3079}
-
- {192a47a9-9df6-4f40-a7d3-888eb00c53ac}
+
+ {e84dcf9a-e650-473e-8c9c-193804ab9e76}
@@ -78,9 +78,6 @@
platform
-
- platform
-
@@ -222,9 +219,6 @@
math
-
- core\win32
-
utils
@@ -270,6 +264,15 @@
renderer
+
+ platform\win32
+
+
+ platform\win32
+
+
+ platform\win32
+
@@ -305,9 +308,6 @@
platform
-
- platform
-
core
@@ -455,5 +455,8 @@
renderer
+
+ platform\win32
+
\ No newline at end of file
diff --git a/src/kiwano-audio/AudioEngine.cpp b/src/kiwano-audio/AudioEngine.cpp
index 652bd1a7..2b155787 100644
--- a/src/kiwano-audio/AudioEngine.cpp
+++ b/src/kiwano-audio/AudioEngine.cpp
@@ -18,8 +18,9 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#include // DX::ThrowIfFailed
-#include
+#include // win32::ThrowIfFailed
+#include
+#include
#include
namespace kiwano
@@ -38,13 +39,13 @@ namespace kiwano
void AudioEngine::SetupComponent()
{
- // KGE_SYS_LOG(L"Creating audio resources");
+ KGE_SYS_LOG(L"Creating audio resources");
- HRESULT hr = modules::MediaFoundation::Get().MFStartup(MF_VERSION, MFSTARTUP_FULL);
+ HRESULT hr = dlls::MediaFoundation::Get().MFStartup(MF_VERSION, MFSTARTUP_FULL);
if (SUCCEEDED(hr))
{
- hr = modules::XAudio2::Get().XAudio2Create(&x_audio2_, 0, XAUDIO2_DEFAULT_PROCESSOR);
+ hr = dlls::XAudio2::Get().XAudio2Create(&x_audio2_, 0, XAUDIO2_DEFAULT_PROCESSOR);
}
if (SUCCEEDED(hr))
@@ -52,12 +53,12 @@ namespace kiwano
hr = x_audio2_->CreateMasteringVoice(&mastering_voice_);
}
- DX::ThrowIfFailed(hr);
+ win32::ThrowIfFailed(hr);
}
void AudioEngine::DestroyComponent()
{
- // KGE_SYS_LOG(L"Destroying audio resources");
+ KGE_SYS_LOG(L"Destroying audio resources");
if (mastering_voice_)
{
@@ -71,7 +72,7 @@ namespace kiwano
x_audio2_ = nullptr;
}
- modules::MediaFoundation::Get().MFShutdown();
+ dlls::MediaFoundation::Get().MFShutdown();
}
HRESULT AudioEngine::CreateVoice(IXAudio2SourceVoice** voice, const Transcoder::Buffer& buffer)
diff --git a/src/kiwano-audio/AudioEngine.h b/src/kiwano-audio/AudioEngine.h
index 158810a9..4a5de063 100644
--- a/src/kiwano-audio/AudioEngine.h
+++ b/src/kiwano-audio/AudioEngine.h
@@ -21,7 +21,6 @@
#pragma once
#include
#include
-#include
#include
#include
diff --git a/src/kiwano-audio/Transcoder.cpp b/src/kiwano-audio/Transcoder.cpp
index ed3705dd..08ff08e6 100644
--- a/src/kiwano-audio/Transcoder.cpp
+++ b/src/kiwano-audio/Transcoder.cpp
@@ -26,9 +26,9 @@
#include
#include
#include
-#include
-#include
-#include
+#include
+#include
+#include
#include
namespace kiwano
@@ -76,7 +76,7 @@ namespace kiwano
ComPtr reader;
- hr = modules::MediaFoundation::Get().MFCreateSourceReaderFromURL(
+ hr = dlls::MediaFoundation::Get().MFCreateSourceReaderFromURL(
file_path.c_str(),
nullptr,
&reader
@@ -101,7 +101,7 @@ namespace kiwano
Resource::Data data = res.GetData();
if (!data) { return E_FAIL; }
- stream = kiwano::modules::Shlwapi::Get().SHCreateMemStream(
+ stream = win32::dlls::Shlwapi::Get().SHCreateMemStream(
static_cast(data.buffer),
static_cast(data.size)
);
@@ -114,12 +114,12 @@ namespace kiwano
if (SUCCEEDED(hr))
{
- hr = modules::MediaFoundation::Get().MFCreateMFByteStreamOnStream(stream.get(), &byte_stream);
+ hr = dlls::MediaFoundation::Get().MFCreateMFByteStreamOnStream(stream.get(), &byte_stream);
}
if (SUCCEEDED(hr))
{
- hr = modules::MediaFoundation::Get().MFCreateSourceReaderFromByteStream(
+ hr = dlls::MediaFoundation::Get().MFCreateSourceReaderFromByteStream(
byte_stream.get(),
nullptr,
&reader
@@ -142,7 +142,7 @@ namespace kiwano
ComPtr partial_type;
ComPtr uncompressed_type;
- hr = modules::MediaFoundation::Get().MFCreateMediaType(&partial_type);
+ hr = dlls::MediaFoundation::Get().MFCreateMediaType(&partial_type);
if (SUCCEEDED(hr))
{
@@ -186,7 +186,7 @@ namespace kiwano
if (SUCCEEDED(hr))
{
uint32_t size = 0;
- hr = modules::MediaFoundation::Get().MFCreateWaveFormatExFromMFMediaType(
+ hr = dlls::MediaFoundation::Get().MFCreateWaveFormatExFromMFMediaType(
uncompressed_type.get(),
&wave_format_,
&size,
diff --git a/src/kiwano-audio/audio-modules.cpp b/src/kiwano-audio/libraries.cpp
similarity index 98%
rename from src/kiwano-audio/audio-modules.cpp
rename to src/kiwano-audio/libraries.cpp
index 255230ac..8523bfea 100644
--- a/src/kiwano-audio/audio-modules.cpp
+++ b/src/kiwano-audio/libraries.cpp
@@ -19,13 +19,13 @@
// THE SOFTWARE.
#include
-#include
+#include
namespace kiwano
{
namespace audio
{
- namespace modules
+ namespace dlls
{
XAudio2::XAudio2()
: xaudio2()
diff --git a/src/kiwano-audio/audio-modules.h b/src/kiwano-audio/libraries.h
similarity index 99%
rename from src/kiwano-audio/audio-modules.h
rename to src/kiwano-audio/libraries.h
index 299beb34..f40db8ba 100644
--- a/src/kiwano-audio/audio-modules.h
+++ b/src/kiwano-audio/libraries.h
@@ -29,7 +29,7 @@ namespace kiwano
{
namespace audio
{
- namespace modules
+ namespace dlls
{
class KGE_API XAudio2
{
diff --git a/src/kiwano-imgui/imgui_impl_dx11.cpp b/src/kiwano-imgui/imgui_impl_dx11.cpp
index 72b96eb7..470f914b 100644
--- a/src/kiwano-imgui/imgui_impl_dx11.cpp
+++ b/src/kiwano-imgui/imgui_impl_dx11.cpp
@@ -1,6 +1,5 @@
// dear imgui: Renderer for Kiwano (DirectX11)
-#include
#include
// DirectX
@@ -259,9 +258,7 @@ static void ImGui_ImplDX11_CreateFontsTexture()
subResource.pSysMem = pixels;
subResource.SysMemPitch = desc.Width * 4;
subResource.SysMemSlicePitch = 0;
- kiwano::DX::ThrowIfFailed(
- g_pd3dDevice->CreateTexture2D(&desc, &subResource, &pTexture)
- );
+ g_pd3dDevice->CreateTexture2D(&desc, &subResource, &pTexture);
if (pTexture)
{
@@ -272,9 +269,7 @@ static void ImGui_ImplDX11_CreateFontsTexture()
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
srvDesc.Texture2D.MipLevels = desc.MipLevels;
srvDesc.Texture2D.MostDetailedMip = 0;
- kiwano::DX::ThrowIfFailed(
- g_pd3dDevice->CreateShaderResourceView(pTexture, &srvDesc, &g_pFontTextureView)
- );
+ g_pd3dDevice->CreateShaderResourceView(pTexture, &srvDesc, &g_pFontTextureView);
pTexture->Release();
}
diff --git a/src/kiwano/2d/Actor.h b/src/kiwano/2d/Actor.h
index a73473f0..2caa9497 100644
--- a/src/kiwano/2d/Actor.h
+++ b/src/kiwano/2d/Actor.h
@@ -394,22 +394,40 @@ namespace kiwano
static void SetDefaultAnchor(float anchor_x, float anchor_y);
protected:
+ /// \~chinese
+ /// @brief 更新自身和所有子节点
virtual void Update(Duration dt);
+ /// \~chinese
+ /// @brief 渲染自身和所有子节点
virtual void Render(RenderTarget* rt);
- virtual void PrepareToRender(RenderTarget* rt);
-
+ /// \~chinese
+ /// @brief 绘制自身和所有子节点的边界
virtual void RenderBorder(RenderTarget* rt);
+ /// \~chinese
+ /// @brief 检查是否在渲染目标的视区内
virtual bool CheckVisibilty(RenderTarget* rt) const;
+ /// \~chinese
+ /// @brief 渲染前初始化渲染目标状态,仅当 CheckVisibilty 返回真时调用该函数
+ virtual void PrepareToRender(RenderTarget* rt);
+
+ /// \~chinese
+ /// @brief 更新自己的二维变换,并通知所有子节点
void UpdateTransform() const;
+ /// \~chinese
+ /// @brief 更新自己和所有子节点的透明度
void UpdateOpacity();
+ /// \~chinese
+ /// @brief 将所有子节点按Z轴顺序排序
void Reorder();
+ /// \~chinese
+ /// @brief 设置节点所在舞台
void SetStage(Stage* stage);
private:
diff --git a/src/kiwano/2d/GifSprite.cpp b/src/kiwano/2d/GifSprite.cpp
index ef233925..26c2f148 100644
--- a/src/kiwano/2d/GifSprite.cpp
+++ b/src/kiwano/2d/GifSprite.cpp
@@ -136,20 +136,13 @@ namespace kiwano
break;
case GifImage::DisposalType::Background:
- {
ClearCurrentFrameArea();
break;
- }
case GifImage::DisposalType::Previous:
- {
RestoreSavedFrame();
break;
}
-
- default:
- DX::ThrowIfFailed(E_FAIL);
- }
}
void GifSprite::OverlayNextFrame()
@@ -208,9 +201,7 @@ namespace kiwano
TexturePtr frame_to_be_saved = new Texture;
- HRESULT hr = frame_rt_->GetOutput(*frame_to_be_saved) ? S_OK : E_FAIL;
-
- if (SUCCEEDED(hr))
+ if (frame_rt_->GetOutput(*frame_to_be_saved))
{
if (!saved_frame_)
{
@@ -218,35 +209,23 @@ namespace kiwano
frame_rt_->CreateTexture(*saved_frame_, frame_to_be_saved->GetSizeInPixels(), frame_to_be_saved->GetPixelFormat());
}
- hr = saved_frame_ ? S_OK : E_FAIL;
- }
-
- if (SUCCEEDED(hr))
- {
saved_frame_->CopyFrom(frame_to_be_saved);
}
-
- DX::ThrowIfFailed(hr);
}
void GifSprite::RestoreSavedFrame()
{
KGE_ASSERT(frame_rt_);
- HRESULT hr = saved_frame_ ? S_OK : E_FAIL;
- if (SUCCEEDED(hr))
+ if (saved_frame_)
{
TexturePtr frame_to_copy_to = new Texture;
- hr = frame_rt_->GetOutput(*frame_to_copy_to) ? S_OK : E_FAIL;
-
- if (SUCCEEDED(hr))
+ if (frame_rt_->GetOutput(*frame_to_copy_to))
{
frame_to_copy_to->CopyFrom(saved_frame_);
}
}
-
- DX::ThrowIfFailed(hr);
}
void GifSprite::ClearCurrentFrameArea()
diff --git a/src/kiwano/2d/Stage.h b/src/kiwano/2d/Stage.h
index 2798dd9e..cbbd5a0b 100644
--- a/src/kiwano/2d/Stage.h
+++ b/src/kiwano/2d/Stage.h
@@ -75,6 +75,8 @@ namespace kiwano
void SetBorderStrokeBrush(BrushPtr brush);
protected:
+ /// \~chinese
+ /// @brief 绘制所有子节点的边界
void RenderBorder(RenderTarget* rt) override;
private:
diff --git a/src/kiwano/2d/action/ActionManager.h b/src/kiwano/2d/action/ActionManager.h
index 0d614ac7..a38305e5 100644
--- a/src/kiwano/2d/action/ActionManager.h
+++ b/src/kiwano/2d/action/ActionManager.h
@@ -35,6 +35,8 @@ namespace kiwano
class KGE_API ActionManager
{
public:
+ /// \~chinese
+ /// @brief 动画列表
using Actions = IntrusiveList;
/// \~chinese
diff --git a/src/kiwano/core/EventDispatcher.h b/src/kiwano/core/EventDispatcher.h
index 0cbe879c..56ab8e13 100644
--- a/src/kiwano/core/EventDispatcher.h
+++ b/src/kiwano/core/EventDispatcher.h
@@ -30,6 +30,8 @@ namespace kiwano
class KGE_API EventDispatcher
{
public:
+ /// \~chinese
+ /// @brief 监听器列表
using Listeners = IntrusiveList;
/// \~chinese
diff --git a/src/kiwano/core/TimerManager.h b/src/kiwano/core/TimerManager.h
index 06f5faf6..96530649 100644
--- a/src/kiwano/core/TimerManager.h
+++ b/src/kiwano/core/TimerManager.h
@@ -30,6 +30,8 @@ namespace kiwano
class KGE_API TimerManager
{
public:
+ /// \~chinese
+ /// @brief 定时器列表
using Timers = IntrusiveList;
/// \~chinese
diff --git a/src/kiwano/kiwano.h b/src/kiwano/kiwano.h
index d99d537e..8e9df3c1 100644
--- a/src/kiwano/kiwano.h
+++ b/src/kiwano/kiwano.h
@@ -105,7 +105,6 @@
// platform
//
-#include
#include
#include
#include
diff --git a/src/kiwano/platform/Application.cpp b/src/kiwano/platform/Application.cpp
index 6ac8ebd3..81d312d1 100644
--- a/src/kiwano/platform/Application.cpp
+++ b/src/kiwano/platform/Application.cpp
@@ -20,9 +20,8 @@
#include
-#include
-#include
#include
+#include
#include
#include
#include
@@ -67,7 +66,7 @@ namespace kiwano
, inited_(false)
, time_scale_(1.f)
{
- DX::ThrowIfFailed(::CoInitialize(nullptr));
+ ::CoInitialize(nullptr);
Use(&Renderer::instance());
Use(&Input::instance());
diff --git a/src/kiwano/platform/FileSystem.cpp b/src/kiwano/platform/FileSystem.cpp
index af2ad9c2..04c6f895 100644
--- a/src/kiwano/platform/FileSystem.cpp
+++ b/src/kiwano/platform/FileSystem.cpp
@@ -19,7 +19,6 @@
// THE SOFTWARE.
#include
-#include
namespace kiwano
{
diff --git a/src/kiwano/platform/Window.cpp b/src/kiwano/platform/Window.cpp
index 8ef41e2a..376b6a7d 100644
--- a/src/kiwano/platform/Window.cpp
+++ b/src/kiwano/platform/Window.cpp
@@ -160,7 +160,7 @@ namespace kiwano
if (handle_ == nullptr)
{
::UnregisterClass(KGE_WND_CLASS_NAME, hinst);
- DX::ThrowIfFailed(HRESULT_FROM_WIN32(GetLastError()));
+ win32::ThrowIfFailed(HRESULT_FROM_WIN32(GetLastError()));
}
else
{
diff --git a/src/kiwano/core/win32/ComPtr.hpp b/src/kiwano/platform/win32/ComPtr.hpp
similarity index 98%
rename from src/kiwano/core/win32/ComPtr.hpp
rename to src/kiwano/platform/win32/ComPtr.hpp
index 7050b90e..eaf3a075 100644
--- a/src/kiwano/core/win32/ComPtr.hpp
+++ b/src/kiwano/platform/win32/ComPtr.hpp
@@ -41,7 +41,7 @@ namespace kiwano
// ComPtr<> is a smart pointer for COM
template<
typename _Ty,
- typename = typename std::enable_if::value, int>::type>
+ typename = typename std::enable_if::value, int>::type
+ >
using ComPtr = IntrusivePtr<_Ty, ComPtrProxy>;
-
}
diff --git a/src/kiwano/platform/modules.cpp b/src/kiwano/platform/win32/helper.h
similarity index 69%
rename from src/kiwano/platform/modules.cpp
rename to src/kiwano/platform/win32/helper.h
index 305beb6e..6091e753 100644
--- a/src/kiwano/platform/modules.cpp
+++ b/src/kiwano/platform/win32/helper.h
@@ -18,27 +18,24 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#include
-#include
+#pragma once
+#include
+#include
+#include <3rd-party/StackWalker/StackWalker.h>
namespace kiwano
{
- namespace modules
+ namespace win32
{
- Shlwapi::Shlwapi()
- : shlwapi()
- , PathFileExistsW(nullptr)
- , SHCreateMemStream(nullptr)
+ inline void ThrowIfFailed(HRESULT hr)
{
- if (shlwapi.Load(L"shlwapi.dll"))
+ if (FAILED(hr))
{
- PathFileExistsW = shlwapi.GetProcess(L"PathFileExistsW");
- SHCreateMemStream = shlwapi.GetProcess(L"SHCreateMemStream");
- }
- else
- {
- KGE_ERROR(L"Load shlapi.dll failed");
- throw std::runtime_error("Load shlapi.dll failed");
+ StackWalker().ShowCallstack();
+
+ static char buffer[1024 + 1];
+ sprintf_s(buffer, "Failed with HRESULT of %08X", hr);
+ throw std::runtime_error(buffer);
}
}
}
diff --git a/src/kiwano/platform/win32/libraries.cpp b/src/kiwano/platform/win32/libraries.cpp
new file mode 100644
index 00000000..fd2aca13
--- /dev/null
+++ b/src/kiwano/platform/win32/libraries.cpp
@@ -0,0 +1,48 @@
+// Copyright (c) 2016-2018 Kiwano - Nomango
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#include
+#include
+
+namespace kiwano
+{
+ namespace win32
+ {
+ namespace dlls
+ {
+ Shlwapi::Shlwapi()
+ : shlwapi()
+ , PathFileExistsW(nullptr)
+ , SHCreateMemStream(nullptr)
+ {
+ if (shlwapi.Load(L"shlwapi.dll"))
+ {
+ PathFileExistsW = shlwapi.GetProcess(L"PathFileExistsW");
+ SHCreateMemStream = shlwapi.GetProcess(L"SHCreateMemStream");
+ }
+ else
+ {
+ KGE_ERROR(L"Load shlapi.dll failed");
+ throw std::runtime_error("Load shlapi.dll failed");
+ }
+ }
+ }
+ }
+}
diff --git a/src/kiwano/platform/modules.h b/src/kiwano/platform/win32/libraries.h
similarity index 69%
rename from src/kiwano/platform/modules.h
rename to src/kiwano/platform/win32/libraries.h
index cbb561dc..d6aed2b4 100644
--- a/src/kiwano/platform/modules.h
+++ b/src/kiwano/platform/win32/libraries.h
@@ -24,31 +24,34 @@
namespace kiwano
{
- namespace modules
+ namespace win32
{
- class KGE_API Shlwapi
+ namespace dlls
{
- public:
- static inline Shlwapi& Get()
+ class KGE_API Shlwapi
{
- static Shlwapi instance;
- return instance;
- }
+ public:
+ static inline Shlwapi& Get()
+ {
+ static Shlwapi instance;
+ return instance;
+ }
- // Shlwapi functions
- typedef BOOL(WINAPI* PFN_PathFileExistsW)(LPCWSTR);
- typedef IStream* (WINAPI* PFN_SHCreateMemStream)(const BYTE*, UINT);
+ // Shlwapi functions
+ typedef BOOL(WINAPI* PFN_PathFileExistsW)(LPCWSTR);
+ typedef IStream* (WINAPI* PFN_SHCreateMemStream)(const BYTE*, UINT);
- PFN_PathFileExistsW PathFileExistsW;
- PFN_SHCreateMemStream SHCreateMemStream;
+ PFN_PathFileExistsW PathFileExistsW;
+ PFN_SHCreateMemStream SHCreateMemStream;
- private:
- Shlwapi();
+ private:
+ Shlwapi();
- Shlwapi(const Shlwapi&) = delete;
- Shlwapi& operator=(const Shlwapi&) = delete;
+ Shlwapi(const Shlwapi&) = delete;
+ Shlwapi& operator=(const Shlwapi&) = delete;
- Library shlwapi;
- };
+ Library shlwapi;
+ };
+ }
}
}
diff --git a/src/kiwano/renderer/Font.h b/src/kiwano/renderer/Font.h
index 6b138004..f8947aa9 100644
--- a/src/kiwano/renderer/Font.h
+++ b/src/kiwano/renderer/Font.h
@@ -20,8 +20,8 @@
#pragma once
#include
-#include
#include
+#include
#include
namespace kiwano
diff --git a/src/kiwano/renderer/GeometrySink.cpp b/src/kiwano/renderer/GeometrySink.cpp
index a76f3648..9c9cd431 100644
--- a/src/kiwano/renderer/GeometrySink.cpp
+++ b/src/kiwano/renderer/GeometrySink.cpp
@@ -40,7 +40,7 @@ namespace kiwano
path_geo_.reset();
Renderer::instance().CreateGeometrySink(*this);
- DX::ThrowIfFailed(path_geo_->Open(&sink_));
+ win32::ThrowIfFailed(path_geo_->Open(&sink_));
}
}
@@ -48,7 +48,7 @@ namespace kiwano
{
if (IsOpened())
{
- DX::ThrowIfFailed(sink_->Close());
+ win32::ThrowIfFailed(sink_->Close());
sink_.reset();
}
}
@@ -75,7 +75,7 @@ namespace kiwano
}
ComPtr geo = input.geo_;
- DX::ThrowIfFailed(
+ win32::ThrowIfFailed(
geo->Outline(
DX::ConvertToMatrix3x2F(input_matrix),
D2D1_DEFAULT_FLATTENING_TOLERANCE,
@@ -164,7 +164,7 @@ namespace kiwano
ComPtr geo_a_raw = geo_a.geo_;
ComPtr geo_b_raw = geo_b.geo_;
- DX::ThrowIfFailed(
+ win32::ThrowIfFailed(
geo_a_raw->CombineWithGeometry(
geo_b_raw.get(),
D2D1_COMBINE_MODE(mode),
diff --git a/src/kiwano/renderer/RenderTarget.cpp b/src/kiwano/renderer/RenderTarget.cpp
index 9d2419bf..d849dc49 100644
--- a/src/kiwano/renderer/RenderTarget.cpp
+++ b/src/kiwano/renderer/RenderTarget.cpp
@@ -132,7 +132,7 @@ namespace kiwano
void RenderTarget::EndDraw()
{
- DX::ThrowIfFailed( render_target_->EndDraw() );
+ win32::ThrowIfFailed( render_target_->EndDraw() );
if (collecting_status_)
{
@@ -377,7 +377,7 @@ namespace kiwano
}
else
{
- DX::ThrowIfFailed(hr);
+ win32::ThrowIfFailed(hr);
}
}
@@ -410,7 +410,7 @@ namespace kiwano
}
else
{
- DX::ThrowIfFailed(hr);
+ win32::ThrowIfFailed(hr);
}
}
diff --git a/src/kiwano/renderer/RenderTarget.h b/src/kiwano/renderer/RenderTarget.h
index 1e83527a..108d6521 100644
--- a/src/kiwano/renderer/RenderTarget.h
+++ b/src/kiwano/renderer/RenderTarget.h
@@ -21,7 +21,6 @@
#pragma once
#include
#include
-#include
#include
#include
#include
diff --git a/src/kiwano/renderer/Renderer.cpp b/src/kiwano/renderer/Renderer.cpp
index fe11903a..256eeba1 100644
--- a/src/kiwano/renderer/Renderer.cpp
+++ b/src/kiwano/renderer/Renderer.cpp
@@ -88,37 +88,37 @@ namespace kiwano
if (SUCCEEDED(hr))
{
hr = IFontCollectionLoader::Create(&font_collection_loader_);
- }
- if (SUCCEEDED(hr))
- {
- hr = d2d_res_->GetDWriteFactory()->RegisterFontCollectionLoader(font_collection_loader_.get());
+ if (SUCCEEDED(hr))
+ {
+ hr = d2d_res_->GetDWriteFactory()->RegisterFontCollectionLoader(font_collection_loader_.get());
+ }
}
// ResourceFontFileLoader and ResourceFontCollectionLoader
if (SUCCEEDED(hr))
{
hr = IResourceFontFileLoader::Create(&res_font_file_loader_);
- }
- if (SUCCEEDED(hr))
- {
- hr = d2d_res_->GetDWriteFactory()->RegisterFontFileLoader(res_font_file_loader_.get());
- }
+ if (SUCCEEDED(hr))
+ {
+ hr = d2d_res_->GetDWriteFactory()->RegisterFontFileLoader(res_font_file_loader_.get());
+ }
- if (SUCCEEDED(hr))
- {
- hr = IResourceFontCollectionLoader::Create(&res_font_collection_loader_, res_font_file_loader_.get());
- }
+ if (SUCCEEDED(hr))
+ {
+ hr = IResourceFontCollectionLoader::Create(&res_font_collection_loader_, res_font_file_loader_.get());
- if (SUCCEEDED(hr))
- {
- hr = d2d_res_->GetDWriteFactory()->RegisterFontCollectionLoader(res_font_collection_loader_.get());
+ if (SUCCEEDED(hr))
+ {
+ hr = d2d_res_->GetDWriteFactory()->RegisterFontCollectionLoader(res_font_collection_loader_.get());
+ }
+ }
}
}
}
- DX::ThrowIfFailed(hr);
+ win32::ThrowIfFailed(hr);
}
void Renderer::DestroyComponent()
@@ -150,7 +150,7 @@ namespace kiwano
BeginDraw();
}
- DX::ThrowIfFailed(hr);
+ win32::ThrowIfFailed(hr);
}
void Renderer::AfterRender()
@@ -168,7 +168,7 @@ namespace kiwano
hr = HandleDeviceLost();
}
- DX::ThrowIfFailed(hr);
+ win32::ThrowIfFailed(hr);
}
void Renderer::HandleMessage(HWND hwnd, UINT32 msg, WPARAM wparam, LPARAM lparam)
@@ -596,7 +596,7 @@ namespace kiwano
}
}
- DX::ThrowIfFailed(hr);
+ win32::ThrowIfFailed(hr);
}
void Renderer::CreateFontCollection(Font& font, Vector const& res_arr)
@@ -631,7 +631,7 @@ namespace kiwano
}
}
- DX::ThrowIfFailed(hr);
+ win32::ThrowIfFailed(hr);
}
void Renderer::CreateTextFormat(TextLayout& layout)
@@ -663,7 +663,7 @@ namespace kiwano
layout.SetTextFormat(output);
}
- DX::ThrowIfFailed(hr);
+ win32::ThrowIfFailed(hr);
}
void Renderer::CreateTextLayout(TextLayout& layout)
@@ -689,7 +689,7 @@ namespace kiwano
layout.SetTextLayout(output);
}
- DX::ThrowIfFailed(hr);
+ win32::ThrowIfFailed(hr);
}
void Renderer::CreateLineGeometry(Geometry& geo, Point const& begin_pos, Point const& end_pos)
@@ -725,7 +725,7 @@ namespace kiwano
geo.SetGeometry(path_geo);
}
- DX::ThrowIfFailed(hr);
+ win32::ThrowIfFailed(hr);
}
void Renderer::CreateRectGeometry(Geometry& geo, Rect const& rect)
@@ -747,7 +747,7 @@ namespace kiwano
geo.SetGeometry(output);
}
- DX::ThrowIfFailed(hr);
+ win32::ThrowIfFailed(hr);
}
void Renderer::CreateRoundedRectGeometry(Geometry& geo, Rect const& rect, Vec2 const& radius)
@@ -775,7 +775,7 @@ namespace kiwano
geo.SetGeometry(output);
}
- DX::ThrowIfFailed(hr);
+ win32::ThrowIfFailed(hr);
}
void Renderer::CreateEllipseGeometry(Geometry& geo, Point const& center, Vec2 const& radius)
@@ -803,7 +803,7 @@ namespace kiwano
geo.SetGeometry(output);
}
- DX::ThrowIfFailed(hr);
+ win32::ThrowIfFailed(hr);
}
void Renderer::CreateGeometrySink(GeometrySink& sink)
@@ -825,7 +825,7 @@ namespace kiwano
sink.SetPathGeometry(output);
}
- DX::ThrowIfFailed(hr);
+ win32::ThrowIfFailed(hr);
}
void Renderer::CreateTextureRenderTarget(TextureRenderTargetPtr& render_target)
@@ -859,7 +859,7 @@ namespace kiwano
render_target = output;
}
- DX::ThrowIfFailed(hr);
+ win32::ThrowIfFailed(hr);
}
void Renderer::CreateSolidBrush(Brush& brush, Color const& color)
@@ -881,7 +881,7 @@ namespace kiwano
brush.SetBrush(output, Brush::Type::SolidColor);
}
- DX::ThrowIfFailed(hr);
+ win32::ThrowIfFailed(hr);
}
void Renderer::CreateLinearGradientBrush(Brush& brush, Point const& begin, Point const& end, Vector const& stops, GradientExtendMode extend_mode)
@@ -922,7 +922,7 @@ namespace kiwano
}
}
- DX::ThrowIfFailed(hr);
+ win32::ThrowIfFailed(hr);
}
void Renderer::CreateRadialGradientBrush(Brush& brush, Point const& center, Vec2 const& offset, Vec2 const& radius,
@@ -966,7 +966,7 @@ namespace kiwano
}
}
- DX::ThrowIfFailed(hr);
+ win32::ThrowIfFailed(hr);
}
void Renderer::SetDpi(float dpi)
@@ -979,7 +979,7 @@ namespace kiwano
hr = d2d_res_->SetDpi(dpi);
}
- DX::ThrowIfFailed(hr);
+ win32::ThrowIfFailed(hr);
}
void Renderer::SetVSyncEnabled(bool enabled)
@@ -1016,7 +1016,7 @@ namespace kiwano
Resize(reinterpret_cast(GetRenderTarget()->GetSize()));
}
- DX::ThrowIfFailed(hr);
+ win32::ThrowIfFailed(hr);
}
}
diff --git a/src/kiwano/renderer/TextLayout.cpp b/src/kiwano/renderer/TextLayout.cpp
index e6d2e2e1..f44a0fd8 100644
--- a/src/kiwano/renderer/TextLayout.cpp
+++ b/src/kiwano/renderer/TextLayout.cpp
@@ -181,7 +181,7 @@ namespace kiwano
}
}
}
- DX::ThrowIfFailed(hr);
+ win32::ThrowIfFailed(hr);
}
}
@@ -200,7 +200,7 @@ namespace kiwano
{
hr = text_layout_->SetLineSpacing(DWRITE_LINE_SPACING_METHOD_UNIFORM, line_spacing, line_spacing * 0.8f);
}
- DX::ThrowIfFailed(hr);
+ win32::ThrowIfFailed(hr);
}
}
@@ -211,7 +211,7 @@ namespace kiwano
if (text_layout_)
{
HRESULT hr = text_layout_->SetTextAlignment(DWRITE_TEXT_ALIGNMENT(align));
- DX::ThrowIfFailed(hr);
+ win32::ThrowIfFailed(hr);
}
}
@@ -226,7 +226,7 @@ namespace kiwano
{
hr = text_layout_->SetUnderline(enable, { start, length });
}
- DX::ThrowIfFailed(hr);
+ win32::ThrowIfFailed(hr);
}
void TextLayout::SetStrikethrough(bool enable, uint32_t start, uint32_t length)
@@ -240,7 +240,7 @@ namespace kiwano
{
hr = text_layout_->SetStrikethrough(enable, { start, length });
}
- DX::ThrowIfFailed(hr);
+ win32::ThrowIfFailed(hr);
}
}
diff --git a/src/kiwano/renderer/Texture.cpp b/src/kiwano/renderer/Texture.cpp
index ae295532..50115768 100644
--- a/src/kiwano/renderer/Texture.cpp
+++ b/src/kiwano/renderer/Texture.cpp
@@ -118,7 +118,7 @@ namespace kiwano
{
HRESULT hr = bitmap_->CopyFromBitmap(nullptr, copy_from->GetBitmap().get(), nullptr);
- DX::ThrowIfFailed(hr);
+ win32::ThrowIfFailed(hr);
}
}
@@ -136,7 +136,7 @@ namespace kiwano
uint32_t(src_rect.GetBottom()))
);
- DX::ThrowIfFailed(hr);
+ win32::ThrowIfFailed(hr);
}
}
diff --git a/src/kiwano/renderer/win32/TextRenderer.cpp b/src/kiwano/renderer/win32/TextRenderer.cpp
index 429028e9..192736f4 100644
--- a/src/kiwano/renderer/win32/TextRenderer.cpp
+++ b/src/kiwano/renderer/win32/TextRenderer.cpp
@@ -18,7 +18,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#include
#include
namespace kiwano
diff --git a/src/kiwano/renderer/win32/helper.h b/src/kiwano/renderer/win32/helper.h
index 0e2cd539..b6c8b908 100644
--- a/src/kiwano/renderer/win32/helper.h
+++ b/src/kiwano/renderer/win32/helper.h
@@ -19,11 +19,10 @@
// THE SOFTWARE.
#pragma once
-#include
#include
-#include
+#include
+#include
#include
-#include <3rd-party/StackWalker/StackWalker.h>
#include
namespace kiwano
@@ -175,17 +174,5 @@ namespace kiwano
static const float dips_per_inch = 96.0f;
return math::Floor(dips * dpi / dips_per_inch + 0.5f); // Round to nearest integer.
}
-
- inline void ThrowIfFailed(HRESULT hr)
- {
- if (FAILED(hr))
- {
- StackWalker().ShowCallstack();
-
- static char buffer[1024 + 1];
- sprintf_s(buffer, "Failed with HRESULT of %08X", hr);
- throw std::runtime_error(buffer);
- }
- }
}
}