Magic_Game/core/e2dcustom.h

199 lines
3.5 KiB
C
Raw Normal View History

#pragma once
#include "e2dmacros.h"
#include "e2dcommon.h"
namespace e2d
{
2018-05-24 00:58:16 +08:00
template<class Interface>
inline void SafeRelease(Interface*& p)
{
if (p != nullptr)
2018-05-10 20:23:32 +08:00
{
2018-05-24 00:58:16 +08:00
p->Release();
p = nullptr;
}
2018-05-24 00:58:16 +08:00
}
2018-05-24 00:58:16 +08:00
class Music;
2018-05-24 00:58:16 +08:00
// <20><>Դ<EFBFBD>ص<EFBFBD>
class VoiceCallback
: public IXAudio2VoiceCallback
{
public:
VoiceCallback(Music * music);
~VoiceCallback();
2018-05-24 00:58:16 +08:00
void __stdcall OnStreamEnd();
2018-05-24 00:58:16 +08:00
void __stdcall OnBufferEnd(
void * pBufferContext
);
2018-05-24 00:58:16 +08:00
void __stdcall OnBufferStart(
void * pBufferContext
);
2018-05-24 00:58:16 +08:00
void __stdcall OnLoopEnd(
void * pBufferContext
);
2018-05-24 00:58:16 +08:00
void __stdcall OnVoiceProcessingPassEnd();
2018-05-24 00:58:16 +08:00
void __stdcall OnVoiceProcessingPassStart(
UINT32 SamplesRequired
);
2018-05-24 00:58:16 +08:00
void __stdcall OnVoiceError(
void * pBufferContext,
HRESULT Error
);
2018-05-24 00:58:16 +08:00
void SetFuncOnStreamEnd(
const Function& func
);
2018-05-24 00:58:16 +08:00
void SetFuncOnLoopEnd(
const Function& func
);
2018-05-24 00:58:16 +08:00
protected:
Music * _music;
Function _loopEndFunc;
Function _streamEndFunc;
};
2018-05-24 00:58:16 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ⱦ<EFBFBD><C8BE>
class TextRenderer
: public IDWriteTextRenderer
{
private:
TextRenderer();
~TextRenderer();
2018-05-24 00:58:16 +08:00
public:
static HRESULT Create(
TextRenderer** ppTextRenderer,
2018-05-24 00:58:16 +08:00
ID2D1Factory* pD2DFactory,
ID2D1HwndRenderTarget* pRT,
ID2D1SolidColorBrush* pBrush
);
STDMETHOD_(void, SetTextStyle)(
CONST D2D1_COLOR_F &fillColor,
BOOL hasOutline,
CONST D2D1_COLOR_F &outlineColor,
FLOAT outlineWidth,
D2D1_LINE_JOIN outlineJoin
);
STDMETHOD(DrawGlyphRun)(
__maybenull void* clientDrawingContext,
FLOAT baselineOriginX,
FLOAT baselineOriginY,
DWRITE_MEASURING_MODE measuringMode,
__in DWRITE_GLYPH_RUN const* glyphRun,
__in DWRITE_GLYPH_RUN_DESCRIPTION const* glyphRunDescription,
IUnknown* clientDrawingEffect
);
STDMETHOD(DrawUnderline)(
__maybenull void* clientDrawingContext,
FLOAT baselineOriginX,
FLOAT baselineOriginY,
__in DWRITE_UNDERLINE const* underline,
IUnknown* clientDrawingEffect
);
STDMETHOD(DrawStrikethrough)(
__maybenull void* clientDrawingContext,
FLOAT baselineOriginX,
FLOAT baselineOriginY,
__in DWRITE_STRIKETHROUGH const* strikethrough,
IUnknown* clientDrawingEffect
);
STDMETHOD(DrawInlineObject)(
__maybenull void* clientDrawingContext,
FLOAT originX,
FLOAT originY,
IDWriteInlineObject* inlineObject,
BOOL isSideways,
BOOL isRightToLeft,
IUnknown* clientDrawingEffect
);
STDMETHOD(IsPixelSnappingDisabled)(
__maybenull void* clientDrawingContext,
__out BOOL* isDisabled
);
STDMETHOD(GetCurrentTransform)(
__maybenull void* clientDrawingContext,
__out DWRITE_MATRIX* transform
);
STDMETHOD(GetPixelsPerDip)(
__maybenull void* clientDrawingContext,
__out FLOAT* pixelsPerDip
);
public:
unsigned long STDMETHODCALLTYPE AddRef();
unsigned long STDMETHODCALLTYPE Release();
HRESULT STDMETHODCALLTYPE QueryInterface(
IID const& riid,
void** ppvObject
);
private:
unsigned long cRefCount_;
D2D1_COLOR_F sFillColor_;
D2D1_COLOR_F sOutlineColor_;
FLOAT fOutlineWidth;
BOOL bShowOutline_;
ID2D1Factory* pD2DFactory_;
ID2D1HwndRenderTarget* pRT_;
ID2D1SolidColorBrush* pBrush_;
ID2D1StrokeStyle * pCurrStrokeStyle_;
2018-05-24 00:58:16 +08:00
};
// <20>
class Exception
{
public:
Exception() E2D_NOEXCEPT;
2018-05-24 00:58:16 +08:00
explicit Exception(const String& message) E2D_NOEXCEPT;
2018-05-24 00:58:16 +08:00
Exception(Exception const& other) E2D_NOEXCEPT;
2018-05-24 00:58:16 +08:00
virtual ~Exception() E2D_NOEXCEPT;
2018-05-24 00:58:16 +08:00
Exception& operator=(Exception const& other) E2D_NOEXCEPT;
2018-05-24 00:58:16 +08:00
// <20><>ȡ<EFBFBD><EFBFBD><ECB3A3>Ϣ
virtual String msg() const;
private:
String _message;
};
2018-05-24 12:24:39 +08:00
// ϵͳ<CFB5>
class SystemException
: public Exception
{
public:
SystemException() E2D_NOEXCEPT;
2018-05-24 12:24:39 +08:00
explicit SystemException(const String& message) E2D_NOEXCEPT;
2018-05-24 12:24:39 +08:00
};
}