update DebugActor

This commit is contained in:
Nomango 2019-08-20 14:55:36 +08:00
parent 7b8e4814a9
commit 3c47aaf007
10 changed files with 63 additions and 24 deletions

View File

@ -29,7 +29,6 @@
<ClInclude Include="..\src\kiwano\2d\include-forwards.h" />
<ClInclude Include="..\src\kiwano\2d\Canvas.h" />
<ClInclude Include="..\src\kiwano\2d\DebugActor.h" />
<ClInclude Include="..\src\kiwano\2d\Font.hpp" />
<ClInclude Include="..\src\kiwano\2d\FrameSequence.h" />
<ClInclude Include="..\src\kiwano\2d\ShapeActor.h" />
<ClInclude Include="..\src\kiwano\2d\Layer.h" />

View File

@ -51,9 +51,6 @@
<ClInclude Include="..\src\kiwano\2d\Canvas.h">
<Filter>2d</Filter>
</ClInclude>
<ClInclude Include="..\src\kiwano\2d\Font.hpp">
<Filter>2d</Filter>
</ClInclude>
<ClInclude Include="..\src\kiwano\2d\include-forwards.h">
<Filter>2d</Filter>
</ClInclude>

View File

@ -3,7 +3,13 @@ $replaceTo = "<DebugInformationFormat>None</DebugInformationFormat>"
Get-ChildItem -Path 'projects\' *.vcxproj | ForEach-Object {
$filePath = 'projects\' + $_
# Create a copy of .vcxproj file
Copy-Item -Path $filePath -Destination ($filePath + '.template')
# Overlay some configurations
Get-Content ($filePath + '.template') -Encoding UTF8 | ForEach-Object { $_ -replace $replace, $replaceTo } | Out-File $filePath -Encoding UTF8
# Delete the copy file
Remove-Item -Path ($filePath + '.template')
}

View File

@ -25,8 +25,14 @@ Write-Host "Start to build nupkg files"
# This is the CoApp .autopkg file to create.
$autopkgFile = "scripts\coapp\kiwano.autopkg"
# Create a copy of ".autopkg" file
Copy-Item -Path $autopkgFile -Destination ($autopkgFile + '.template')
# Get the ".autopkg.template" file, replace "@appveyor_version" with the Appveyor version number, then save to the ".autopkg" file.
Get-Content ($autopkgFile + ".template") | ForEach-Object { $_ -replace "@appveyor_version", $env:appveyor_build_version } > $autopkgFile
Get-Content ($autopkgFile + ".template") -Encoding UTF8 | ForEach-Object { $_ -replace "@appveyor_version", $env:appveyor_build_version } | Out-File $autopkgFile -Encoding UTF8
# Delete the copy file
Remove-Item -Path ($autopkgFile + '.template')
# Use the CoApp tools to create NuGet native packages from the .autopkg.
Write-NuGetPackage $autopkgFile

View File

@ -1,4 +1,4 @@
#defines {
#defines {
// Global variables may be added here.
// Variables on the "value" side of each definition will be processed at access time.
// GlobalVar1 = "";

View File

@ -21,13 +21,29 @@
#include "DebugActor.h"
#include "Text.h"
#include "../renderer/Renderer.h"
#include <sstream>
#include <psapi.h>
#pragma comment(lib, "psapi.lib")
namespace kiwano
{
namespace
{
class comma_numpunct : public std::numpunct<wchar_t>
{
protected:
virtual wchar_t do_thousands_sep() const override
{
return L',';
}
virtual std::string do_grouping() const override
{
return "\03";
}
};
}
DebugActor::DebugActor()
: background_color_(0.0f, 0.0f, 0.0f, 0.7f)
{
@ -41,6 +57,7 @@ namespace kiwano
this->AddChild(debug_text_);
Font font;
font.family = L"Arial";
font.size = 16.f;
font.weight = FontWeight::Normal;
debug_text_->SetFont(font);
@ -61,11 +78,7 @@ namespace kiwano
{
PrepareRender(renderer);
renderer->GetSolidColorBrush()->SetColor(DX::ConvertToColorF(background_color_));
renderer->GetD2DDeviceResources()->GetDeviceContext()->FillRoundedRectangle(
D2D1::RoundedRect(DX::ConvertToRectF(GetBounds()), 5.f, 5.f),
renderer->GetSolidColorBrush()
);
renderer->FillRoundedRectangle(GetBounds(), Vec2{ 5.f, 5.f }, background_color_);
}
void DebugActor::OnUpdate(Duration dt)
@ -78,7 +91,14 @@ namespace kiwano
frame_time_.erase(frame_time_.begin());
}
std::wstringstream ss;
StringStream ss;
{
// For formatting integers with commas
static std::locale comma_locale(std::locale(), new comma_numpunct);
(void)ss.imbue(comma_locale);
}
ss << "Fps: " << frame_time_.size() << std::endl;
#if defined(KGE_DEBUG)
@ -90,11 +110,21 @@ namespace kiwano
ss << "Render: " << Renderer::GetInstance()->GetStatus().duration.Milliseconds() << "ms" << std::endl;
ss << "Primitives / sec: " << Renderer::GetInstance()->GetStatus().primitives * frame_time_.size() << std::endl;
ss << "Primitives / sec: " << std::fixed << Renderer::GetInstance()->GetStatus().primitives * frame_time_.size() << std::endl;
PROCESS_MEMORY_COUNTERS_EX pmc;
GetProcessMemoryInfo(GetCurrentProcess(), (PROCESS_MEMORY_COUNTERS*)&pmc, sizeof(pmc));
ss << "Memory: " << pmc.PrivateUsage / 1024 << "kb";
ss << "Memory: ";
{
PROCESS_MEMORY_COUNTERS_EX pmc;
GetProcessMemoryInfo(GetCurrentProcess(), (PROCESS_MEMORY_COUNTERS*)&pmc, sizeof(pmc));
if (pmc.PrivateUsage > 1024 * 1024)
{
ss << pmc.PrivateUsage / (1024 * 1024) << "Mb ";
pmc.PrivateUsage %= (1024 * 1024);
}
ss << pmc.PrivateUsage / 1024 << "Kb";
}
debug_text_->SetText(ss.str());
SetSize(Size{ 20 + debug_text_->GetSize().x, 20 + debug_text_->GetSize().y });

View File

@ -279,7 +279,7 @@ namespace kiwano
{
static WChar temp_buffer[1024 * 3 + 1];
std::wstringstream ss;
StringStream ss;
ss << Logger::OutPrefix;
if (prompt)

View File

@ -263,7 +263,7 @@ namespace kiwano
template <typename ..._Args>
std::wstring Logger::MakeOutputString(const WChar* prompt, _Args&& ... args) const
{
std::wstringstream ss;
StringStream ss;
ss << Logger::OutPrefix;
if (prompt)

View File

@ -33,6 +33,7 @@
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
namespace kiwano
{

View File

@ -43,15 +43,15 @@ namespace kiwano
public:
String family; // 字体族
Float32 size; // 字号
UInt32 weight; // ´Öϸֵ
UInt32 weight; // ´Öϸֵ
bool italic; // 是否斜体
FontCollection collection; // 字体集
public:
Font(
const String& family = L"",
Float32 size = 18,
UInt32 weight = FontWeight::Normal,
Float32 size = 18,
UInt32 weight = FontWeight::Normal,
bool italic = false,
FontCollection collection = FontCollection()
);