tidy project

This commit is contained in:
Nomango 2019-12-30 14:24:29 +08:00
parent 24655f8de5
commit f8db6f3550
34 changed files with 216 additions and 180 deletions

View File

@ -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

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClInclude Include="..\..\src\kiwano-audio\audio-modules.h" />
<ClInclude Include="..\..\src\kiwano-audio\libraries.h" />
<ClInclude Include="..\..\src\kiwano-audio\AudioEngine.h" />
<ClInclude Include="..\..\src\kiwano-audio\kiwano-audio.h" />
<ClInclude Include="..\..\src\kiwano-audio\Sound.h" />
@ -19,7 +19,7 @@
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\kiwano-audio\audio-modules.cpp" />
<ClCompile Include="..\..\src\kiwano-audio\libraries.cpp" />
<ClCompile Include="..\..\src\kiwano-audio\AudioEngine.cpp" />
<ClCompile Include="..\..\src\kiwano-audio\Sound.cpp" />
<ClCompile Include="..\..\src\kiwano-audio\SoundPlayer.cpp" />

View File

@ -3,16 +3,16 @@
<ItemGroup>
<ClInclude Include="..\..\src\kiwano-audio\kiwano-audio.h" />
<ClInclude Include="..\..\src\kiwano-audio\AudioEngine.h" />
<ClInclude Include="..\..\src\kiwano-audio\audio-modules.h" />
<ClInclude Include="..\..\src\kiwano-audio\Sound.h" />
<ClInclude Include="..\..\src\kiwano-audio\SoundPlayer.h" />
<ClInclude Include="..\..\src\kiwano-audio\Transcoder.h" />
<ClInclude Include="..\..\src\kiwano-audio\libraries.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\kiwano-audio\AudioEngine.cpp" />
<ClCompile Include="..\..\src\kiwano-audio\audio-modules.cpp" />
<ClCompile Include="..\..\src\kiwano-audio\Sound.cpp" />
<ClCompile Include="..\..\src\kiwano-audio\SoundPlayer.cpp" />
<ClCompile Include="..\..\src\kiwano-audio\Transcoder.cpp" />
<ClCompile Include="..\..\src\kiwano-audio\libraries.cpp" />
</ItemGroup>
</Project>

View File

@ -14,7 +14,6 @@
<ClInclude Include="..\..\src\kiwano\core\common.h" />
<ClInclude Include="..\..\src\kiwano\core\Event.h" />
<ClInclude Include="..\..\src\kiwano\core\Library.h" />
<ClInclude Include="..\..\src\kiwano\core\win32\ComPtr.hpp" />
<ClInclude Include="..\..\src\kiwano\kiwano.h" />
<ClInclude Include="..\..\src\kiwano\config.h" />
<ClInclude Include="..\..\src\kiwano\macros.h" />
@ -54,7 +53,9 @@
<ClInclude Include="..\..\src\kiwano\platform\Director.h" />
<ClInclude Include="..\..\src\kiwano\platform\FileSystem.h" />
<ClInclude Include="..\..\src\kiwano\platform\Input.h" />
<ClInclude Include="..\..\src\kiwano\platform\modules.h" />
<ClInclude Include="..\..\src\kiwano\platform\win32\ComPtr.hpp" />
<ClInclude Include="..\..\src\kiwano\platform\win32\helper.h" />
<ClInclude Include="..\..\src\kiwano\platform\win32\libraries.h" />
<ClInclude Include="..\..\src\kiwano\platform\Window.h" />
<ClInclude Include="..\..\src\kiwano\renderer\Brush.h" />
<ClInclude Include="..\..\src\kiwano\renderer\Color.h" />
@ -121,7 +122,7 @@
<ClCompile Include="..\..\src\kiwano\platform\Director.cpp" />
<ClCompile Include="..\..\src\kiwano\platform\FileSystem.cpp" />
<ClCompile Include="..\..\src\kiwano\platform\Input.cpp" />
<ClCompile Include="..\..\src\kiwano\platform\modules.cpp" />
<ClCompile Include="..\..\src\kiwano\platform\win32\libraries.cpp" />
<ClCompile Include="..\..\src\kiwano\platform\Window.cpp" />
<ClCompile Include="..\..\src\kiwano\renderer\Brush.cpp" />
<ClCompile Include="..\..\src\kiwano\renderer\Color.cpp" />

View File

@ -28,8 +28,8 @@
<Filter Include="renderer\win32">
<UniqueIdentifier>{30333461-e9bc-4709-84bd-ce6e0e1a3079}</UniqueIdentifier>
</Filter>
<Filter Include="core\win32">
<UniqueIdentifier>{192a47a9-9df6-4f40-a7d3-888eb00c53ac}</UniqueIdentifier>
<Filter Include="platform\win32">
<UniqueIdentifier>{e84dcf9a-e650-473e-8c9c-193804ab9e76}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
@ -78,9 +78,6 @@
<ClInclude Include="..\..\src\kiwano\platform\Application.h">
<Filter>platform</Filter>
</ClInclude>
<ClInclude Include="..\..\src\kiwano\platform\modules.h">
<Filter>platform</Filter>
</ClInclude>
<ClInclude Include="..\..\src\kiwano\config.h" />
<ClInclude Include="..\..\src\kiwano\macros.h" />
<ClInclude Include="..\..\src\kiwano\math\Vec2.hpp">
@ -222,9 +219,6 @@
<ClInclude Include="..\..\src\kiwano\math\scalar.h">
<Filter>math</Filter>
</ClInclude>
<ClInclude Include="..\..\src\kiwano\core\win32\ComPtr.hpp">
<Filter>core\win32</Filter>
</ClInclude>
<ClInclude Include="..\..\src\kiwano\utils\LocalStorage.h">
<Filter>utils</Filter>
</ClInclude>
@ -270,6 +264,15 @@
<ClInclude Include="..\..\src\kiwano\renderer\GeometrySink.h">
<Filter>renderer</Filter>
</ClInclude>
<ClInclude Include="..\..\src\kiwano\platform\win32\ComPtr.hpp">
<Filter>platform\win32</Filter>
</ClInclude>
<ClInclude Include="..\..\src\kiwano\platform\win32\libraries.h">
<Filter>platform\win32</Filter>
</ClInclude>
<ClInclude Include="..\..\src\kiwano\platform\win32\helper.h">
<Filter>platform\win32</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\kiwano\ui\Button.cpp">
@ -305,9 +308,6 @@
<ClCompile Include="..\..\src\kiwano\platform\Application.cpp">
<Filter>platform</Filter>
</ClCompile>
<ClCompile Include="..\..\src\kiwano\platform\modules.cpp">
<Filter>platform</Filter>
</ClCompile>
<ClCompile Include="..\..\src\kiwano\core\Timer.cpp">
<Filter>core</Filter>
</ClCompile>
@ -455,5 +455,8 @@
<ClCompile Include="..\..\src\kiwano\renderer\GeometrySink.cpp">
<Filter>renderer</Filter>
</ClCompile>
<ClCompile Include="..\..\src\kiwano\platform\win32\libraries.cpp">
<Filter>platform\win32</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -18,8 +18,9 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#include <kiwano/renderer/win32/helper.h> // DX::ThrowIfFailed
#include <kiwano-audio/audio-modules.h>
#include <kiwano/platform/win32/helper.h> // win32::ThrowIfFailed
#include <kiwano/core/Logger.h>
#include <kiwano-audio/libraries.h>
#include <kiwano-audio/AudioEngine.h>
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)

View File

@ -21,7 +21,6 @@
#pragma once
#include <kiwano/core/common.h>
#include <kiwano/core/Component.h>
#include <kiwano/core/win32/ComPtr.hpp>
#include <kiwano-audio/Transcoder.h>
#include <xaudio2.h>

View File

@ -26,9 +26,9 @@
#include <kiwano/core/common.h>
#include <kiwano/core/Resource.h>
#include <kiwano/core/Logger.h>
#include <kiwano/core/win32/ComPtr.hpp>
#include <kiwano/platform/modules.h>
#include <kiwano-audio/audio-modules.h>
#include <kiwano/platform/win32/ComPtr.hpp>
#include <kiwano/platform/win32/libraries.h>
#include <kiwano-audio/libraries.h>
#include <kiwano-audio/Transcoder.h>
namespace kiwano
@ -76,7 +76,7 @@ namespace kiwano
ComPtr<IMFSourceReader> 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<const BYTE*>(data.buffer),
static_cast<uint32_t>(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<IMFMediaType> partial_type;
ComPtr<IMFMediaType> 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,

View File

@ -19,13 +19,13 @@
// THE SOFTWARE.
#include <kiwano/core/Logger.h>
#include <kiwano-audio/audio-modules.h>
#include <kiwano-audio/libraries.h>
namespace kiwano
{
namespace audio
{
namespace modules
namespace dlls
{
XAudio2::XAudio2()
: xaudio2()

View File

@ -29,7 +29,7 @@ namespace kiwano
{
namespace audio
{
namespace modules
namespace dlls
{
class KGE_API XAudio2
{

View File

@ -1,6 +1,5 @@
// dear imgui: Renderer for Kiwano (DirectX11)
#include <kiwano/renderer/win32/helper.h>
#include <kiwano-imgui/imgui_impl_dx11.h>
// 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();
}

View File

@ -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:

View File

@ -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()

View File

@ -75,6 +75,8 @@ namespace kiwano
void SetBorderStrokeBrush(BrushPtr brush);
protected:
/// \~chinese
/// @brief 绘制所有子节点的边界
void RenderBorder(RenderTarget* rt) override;
private:

View File

@ -35,6 +35,8 @@ namespace kiwano
class KGE_API ActionManager
{
public:
/// \~chinese
/// @brief 动画列表
using Actions = IntrusiveList<ActionPtr>;
/// \~chinese

View File

@ -30,6 +30,8 @@ namespace kiwano
class KGE_API EventDispatcher
{
public:
/// \~chinese
/// @brief 监听器列表
using Listeners = IntrusiveList<EventListenerPtr>;
/// \~chinese

View File

@ -30,6 +30,8 @@ namespace kiwano
class KGE_API TimerManager
{
public:
/// \~chinese
/// @brief 定时器列表
using Timers = IntrusiveList<TimerPtr>;
/// \~chinese

View File

@ -105,7 +105,6 @@
// platform
//
#include <kiwano/platform/modules.h>
#include <kiwano/platform/FileSystem.h>
#include <kiwano/platform/Input.h>
#include <kiwano/platform/Window.h>

View File

@ -20,9 +20,8 @@
#include <mutex>
#include <kiwano/platform/Application.h>
#include <kiwano/platform/modules.h>
#include <kiwano/core/Logger.h>
#include <kiwano/platform/Application.h>
#include <kiwano/platform/Input.h>
#include <kiwano/platform/Director.h>
#include <kiwano/renderer/TextureCache.h>
@ -67,7 +66,7 @@ namespace kiwano
, inited_(false)
, time_scale_(1.f)
{
DX::ThrowIfFailed(::CoInitialize(nullptr));
::CoInitialize(nullptr);
Use(&Renderer::instance());
Use(&Input::instance());

View File

@ -19,7 +19,6 @@
// THE SOFTWARE.
#include <kiwano/platform/FileSystem.h>
#include <kiwano/platform/modules.h>
namespace kiwano
{

View File

@ -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
{

View File

@ -41,7 +41,7 @@ namespace kiwano
// ComPtr<> is a smart pointer for COM
template<
typename _Ty,
typename = typename std::enable_if<std::is_base_of<IUnknown, _Ty>::value, int>::type>
typename = typename std::enable_if<std::is_base_of<IUnknown, _Ty>::value, int>::type
>
using ComPtr = IntrusivePtr<_Ty, ComPtrProxy>;
}

View File

@ -18,27 +18,24 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#include <kiwano/platform/modules.h>
#include <kiwano/core/Logger.h>
#pragma once
#include <stdexcept>
#include <kiwano/macros.h>
#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<PFN_PathFileExistsW>(L"PathFileExistsW");
SHCreateMemStream = shlwapi.GetProcess<PFN_SHCreateMemStream>(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);
}
}
}

View File

@ -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 <kiwano/platform/win32/libraries.h>
#include <kiwano/core/Logger.h>
namespace kiwano
{
namespace win32
{
namespace dlls
{
Shlwapi::Shlwapi()
: shlwapi()
, PathFileExistsW(nullptr)
, SHCreateMemStream(nullptr)
{
if (shlwapi.Load(L"shlwapi.dll"))
{
PathFileExistsW = shlwapi.GetProcess<PFN_PathFileExistsW>(L"PathFileExistsW");
SHCreateMemStream = shlwapi.GetProcess<PFN_SHCreateMemStream>(L"SHCreateMemStream");
}
else
{
KGE_ERROR(L"Load shlapi.dll failed");
throw std::runtime_error("Load shlapi.dll failed");
}
}
}
}
}

View File

@ -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;
};
}
}
}

View File

@ -20,8 +20,8 @@
#pragma once
#include <kiwano/core/ObjectBase.h>
#include <kiwano/core/win32/ComPtr.hpp>
#include <kiwano/core/Resource.h>
#include <kiwano/platform/win32/ComPtr.hpp>
#include <dwrite.h>
namespace kiwano

View File

@ -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<ID2D1Geometry> geo = input.geo_;
DX::ThrowIfFailed(
win32::ThrowIfFailed(
geo->Outline(
DX::ConvertToMatrix3x2F(input_matrix),
D2D1_DEFAULT_FLATTENING_TOLERANCE,
@ -164,7 +164,7 @@ namespace kiwano
ComPtr<ID2D1Geometry> geo_a_raw = geo_a.geo_;
ComPtr<ID2D1Geometry> geo_b_raw = geo_b.geo_;
DX::ThrowIfFailed(
win32::ThrowIfFailed(
geo_a_raw->CombineWithGeometry(
geo_b_raw.get(),
D2D1_COMBINE_MODE(mode),

View File

@ -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);
}
}

View File

@ -21,7 +21,6 @@
#pragma once
#include <kiwano/core/time.h>
#include <kiwano/core/ObjectBase.h>
#include <kiwano/core/win32/ComPtr.hpp>
#include <kiwano/renderer/Brush.h>
#include <kiwano/renderer/Texture.h>
#include <kiwano/renderer/Geometry.h>

View File

@ -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<Resource> 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<GradientStop> 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<const Size&>(GetRenderTarget()->GetSize()));
}
DX::ThrowIfFailed(hr);
win32::ThrowIfFailed(hr);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -18,7 +18,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#include <kiwano/core/win32/ComPtr.hpp>
#include <kiwano/renderer/win32/TextRenderer.h>
namespace kiwano

View File

@ -19,11 +19,10 @@
// THE SOFTWARE.
#pragma once
#include <stdexcept>
#include <kiwano/math/math.h>
#include <kiwano/core/win32/ComPtr.hpp>
#include <kiwano/platform/win32/ComPtr.hpp>
#include <kiwano/platform/win32/helper.h>
#include <kiwano/renderer/Color.h>
#include <3rd-party/StackWalker/StackWalker.h>
#include <d2d1.h>
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);
}
}
}
}