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 "include-forwards.h"
#include "Node.h"
#include <algorithm>
#include <cfloat>
namespace easy2d

View File

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

View File

@ -23,6 +23,7 @@
#include "Singleton.hpp"
#include "noncopyable.hpp"
#include <xaudio2.h>
#include <unordered_set>
namespace easy2d
{
@ -78,6 +79,8 @@ namespace easy2d
{
E2D_DECLARE_SINGLETON(AudioDevice);
using VoiceMap = std::unordered_set<Voice*>;
public:
HRESULT Init(bool debug);
@ -106,7 +109,7 @@ namespace easy2d
protected:
IXAudio2* x_audio2_;
IXAudio2MasteringVoice* mastering_voice_;
std::set<Voice*> voice_cache_;
VoiceMap voice_cache_;
};
E2D_DECLARE_SINGLETON_TYPE(AudioDevice, Audio);

View File

@ -84,9 +84,6 @@
// C++ RunTime Header Files
#include <cstdlib>
#include <string>
#include <map>
#include <set>
#include <list>
#include <vector>
#include <algorithm>

View File

@ -27,6 +27,7 @@
#include "TextStyle.hpp"
#include "Singleton.hpp"
#include "../math/Matrix.hpp"
#include <unordered_map>
namespace easy2d
{
@ -42,6 +43,8 @@ namespace easy2d
int primitives;
};
using BitmapMap = std::unordered_map<size_t, cpBitmap>;
public:
HRESULT Init(HWND hwnd, bool vsync, bool debug);
@ -171,20 +174,20 @@ namespace easy2d
~GraphicsDevice();
protected:
bool debug_;
bool window_occluded_;
bool vsync_enabled_;
bool antialias_;
float opacity_;
D2D1_COLOR_F clear_color_;
TextAntialias text_antialias_;
Status status_;
cpTextRenderer text_renderer_;
cpSolidColorBrush solid_brush_;
cpHwndRenderTarget render_target_;
cpTextFormat fps_text_format_;
cpTextLayout fps_text_layout_;
std::map<size_t, cpBitmap> bitmap_cache_;
bool debug_;
bool window_occluded_;
bool vsync_enabled_;
bool antialias_;
float opacity_;
D2D1_COLOR_F clear_color_;
TextAntialias text_antialias_;
Status status_;
cpTextRenderer text_renderer_;
cpSolidColorBrush solid_brush_;
cpHwndRenderTarget render_target_;
cpTextFormat fps_text_format_;
cpTextLayout fps_text_layout_;
BitmapMap bitmap_cache_;
};
E2D_DECLARE_SINGLETON_TYPE(GraphicsDevice, Graphics);

View File

@ -21,6 +21,7 @@
#include "time.h"
#include "logs.h"
#include <regex>
#include <unordered_map>
namespace easy2d
{
@ -108,7 +109,7 @@ namespace easy2d
{
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
{
{L"ms", Millisecond},

View File

@ -21,6 +21,7 @@
#pragma once
#include "../base/Resource.h"
#include <string>
#include <list>
namespace easy2d
{

View File

@ -21,6 +21,7 @@
#pragma once
#include "../base/include-forwards.h"
#include "../base/Resource.h"
#include <unordered_map>
namespace easy2d
{
@ -28,6 +29,8 @@ namespace easy2d
class Player
: protected Noncopyable
{
using MusicMap = std::unordered_map<size_t, spMusic>;
public:
Player();
@ -116,7 +119,7 @@ namespace easy2d
void ClearCache();
protected:
float volume_;
std::map<size_t, spMusic> musics_cache_;
float volume_;
MusicMap musics_cache_;
};
}