This commit is contained in:
Haibo 2018-11-25 20:25:46 +08:00 committed by Nomango
parent a76add7880
commit 125c66df3e
8 changed files with 29 additions and 23 deletions

View File

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

View File

@ -20,7 +20,6 @@
#include "Sprite.h" #include "Sprite.h"
#include "render.h" #include "render.h"
#include <algorithm>
namespace easy2d namespace easy2d
{ {

View File

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

View File

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

View File

@ -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);
@ -171,20 +174,20 @@ namespace easy2d
~GraphicsDevice(); ~GraphicsDevice();
protected: protected:
bool debug_; bool debug_;
bool window_occluded_; bool window_occluded_;
bool vsync_enabled_; bool vsync_enabled_;
bool antialias_; bool antialias_;
float opacity_; float opacity_;
D2D1_COLOR_F clear_color_; D2D1_COLOR_F clear_color_;
TextAntialias text_antialias_; TextAntialias text_antialias_;
Status status_; Status status_;
cpTextRenderer text_renderer_; cpTextRenderer text_renderer_;
cpSolidColorBrush solid_brush_; cpSolidColorBrush solid_brush_;
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);

View File

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

View File

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

View File

@ -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();
@ -116,7 +119,7 @@ namespace easy2d
void ClearCache(); void ClearCache();
protected: protected:
float volume_; float volume_;
std::map<size_t, spMusic> musics_cache_; MusicMap musics_cache_;
}; };
} }