optimize
This commit is contained in:
parent
a76add7880
commit
125c66df3e
|
|
@ -22,7 +22,6 @@
|
||||||
#include "Geometry.h"
|
#include "Geometry.h"
|
||||||
#include "include-forwards.h"
|
#include "include-forwards.h"
|
||||||
#include "Node.h"
|
#include "Node.h"
|
||||||
#include <algorithm>
|
|
||||||
#include <cfloat>
|
#include <cfloat>
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@
|
||||||
|
|
||||||
#include "Sprite.h"
|
#include "Sprite.h"
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
#include "Singleton.hpp"
|
#include "Singleton.hpp"
|
||||||
#include "noncopyable.hpp"
|
#include "noncopyable.hpp"
|
||||||
#include <xaudio2.h>
|
#include <xaudio2.h>
|
||||||
|
#include <unordered_set>
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
|
|
@ -78,6 +79,8 @@ namespace easy2d
|
||||||
{
|
{
|
||||||
E2D_DECLARE_SINGLETON(AudioDevice);
|
E2D_DECLARE_SINGLETON(AudioDevice);
|
||||||
|
|
||||||
|
using VoiceMap = std::unordered_set<Voice*>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HRESULT Init(bool debug);
|
HRESULT Init(bool debug);
|
||||||
|
|
||||||
|
|
@ -106,7 +109,7 @@ namespace easy2d
|
||||||
protected:
|
protected:
|
||||||
IXAudio2* x_audio2_;
|
IXAudio2* x_audio2_;
|
||||||
IXAudio2MasteringVoice* mastering_voice_;
|
IXAudio2MasteringVoice* mastering_voice_;
|
||||||
std::set<Voice*> voice_cache_;
|
VoiceMap voice_cache_;
|
||||||
};
|
};
|
||||||
|
|
||||||
E2D_DECLARE_SINGLETON_TYPE(AudioDevice, Audio);
|
E2D_DECLARE_SINGLETON_TYPE(AudioDevice, Audio);
|
||||||
|
|
|
||||||
|
|
@ -84,9 +84,6 @@
|
||||||
// C++ RunTime Header Files
|
// C++ RunTime Header Files
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
|
||||||
#include <set>
|
|
||||||
#include <list>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@
|
||||||
#include "TextStyle.hpp"
|
#include "TextStyle.hpp"
|
||||||
#include "Singleton.hpp"
|
#include "Singleton.hpp"
|
||||||
#include "../math/Matrix.hpp"
|
#include "../math/Matrix.hpp"
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
|
|
@ -42,6 +43,8 @@ namespace easy2d
|
||||||
int primitives;
|
int primitives;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
using BitmapMap = std::unordered_map<size_t, cpBitmap>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HRESULT Init(HWND hwnd, bool vsync, bool debug);
|
HRESULT Init(HWND hwnd, bool vsync, bool debug);
|
||||||
|
|
||||||
|
|
@ -184,7 +187,7 @@ namespace easy2d
|
||||||
cpHwndRenderTarget render_target_;
|
cpHwndRenderTarget render_target_;
|
||||||
cpTextFormat fps_text_format_;
|
cpTextFormat fps_text_format_;
|
||||||
cpTextLayout fps_text_layout_;
|
cpTextLayout fps_text_layout_;
|
||||||
std::map<size_t, cpBitmap> bitmap_cache_;
|
BitmapMap bitmap_cache_;
|
||||||
};
|
};
|
||||||
|
|
||||||
E2D_DECLARE_SINGLETON_TYPE(GraphicsDevice, Graphics);
|
E2D_DECLARE_SINGLETON_TYPE(GraphicsDevice, Graphics);
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
#include "time.h"
|
#include "time.h"
|
||||||
#include "logs.h"
|
#include "logs.h"
|
||||||
#include <regex>
|
#include <regex>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
|
|
@ -108,7 +109,7 @@ namespace easy2d
|
||||||
{
|
{
|
||||||
const auto duration_regex = std::wregex(LR"([-+]?([0-9]*(\.[0-9]*)?[a-z]+)+)");
|
const auto duration_regex = std::wregex(LR"([-+]?([0-9]*(\.[0-9]*)?[a-z]+)+)");
|
||||||
|
|
||||||
typedef std::map<std::wstring, Duration> UnitMap;
|
typedef std::unordered_map<std::wstring, Duration> UnitMap;
|
||||||
const auto unit_map = UnitMap
|
const auto unit_map = UnitMap
|
||||||
{
|
{
|
||||||
{L"ms", Millisecond},
|
{L"ms", Millisecond},
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "../base/Resource.h"
|
#include "../base/Resource.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <list>
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "../base/include-forwards.h"
|
#include "../base/include-forwards.h"
|
||||||
#include "../base/Resource.h"
|
#include "../base/Resource.h"
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
|
|
@ -28,6 +29,8 @@ namespace easy2d
|
||||||
class Player
|
class Player
|
||||||
: protected Noncopyable
|
: protected Noncopyable
|
||||||
{
|
{
|
||||||
|
using MusicMap = std::unordered_map<size_t, spMusic>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Player();
|
Player();
|
||||||
|
|
||||||
|
|
@ -117,6 +120,6 @@ namespace easy2d
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
float volume_;
|
float volume_;
|
||||||
std::map<size_t, spMusic> musics_cache_;
|
MusicMap musics_cache_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue