change: minor fixes.
This commit is contained in:
parent
155cd0b211
commit
75440b15a2
|
|
@ -23,46 +23,13 @@
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
class MediaAsyncCallback : public IMFAsyncCallback
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MediaAsyncCallback(
|
|
||||||
HWND hwnd,
|
|
||||||
IMFMediaSession * pSession,
|
|
||||||
HANDLE hCloseEvent
|
|
||||||
);
|
|
||||||
|
|
||||||
// IUnknown methods
|
|
||||||
STDMETHODIMP QueryInterface(REFIID iid, void** ppv);
|
|
||||||
STDMETHODIMP_(ULONG) AddRef();
|
|
||||||
STDMETHODIMP_(ULONG) Release();
|
|
||||||
|
|
||||||
// IMFAsyncCallback methods
|
|
||||||
STDMETHODIMP GetParameters(DWORD*, DWORD*);
|
|
||||||
STDMETHODIMP Invoke(IMFAsyncResult* pAsyncResult);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
long m_nRefCount;
|
|
||||||
IMFMediaSession * m_pSession;
|
|
||||||
HWND m_hwnd;
|
|
||||||
HANDLE m_hCloseEvent;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// ÎÄ×ÖäÖȾÆ÷
|
// ÎÄ×ÖäÖȾÆ÷
|
||||||
class E2DTextRenderer
|
class TextRenderer
|
||||||
: public IDWriteTextRenderer
|
: public IDWriteTextRenderer
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
E2DTextRenderer();
|
|
||||||
|
|
||||||
~E2DTextRenderer();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static HRESULT Create(
|
static HRESULT Create(
|
||||||
E2DTextRenderer** ppTextRenderer,
|
TextRenderer** ppTextRenderer,
|
||||||
ID2D1Factory* pD2DFactory,
|
ID2D1Factory* pD2DFactory,
|
||||||
ID2D1HwndRenderTarget* pRT,
|
ID2D1HwndRenderTarget* pRT,
|
||||||
ID2D1SolidColorBrush* pBrush
|
ID2D1SolidColorBrush* pBrush
|
||||||
|
|
@ -74,7 +41,7 @@ namespace easy2d
|
||||||
CONST D2D1_COLOR_F &outline_color,
|
CONST D2D1_COLOR_F &outline_color,
|
||||||
FLOAT outline_width,
|
FLOAT outline_width,
|
||||||
D2D1_LINE_JOIN outlineJoin
|
D2D1_LINE_JOIN outlineJoin
|
||||||
);
|
);
|
||||||
|
|
||||||
STDMETHOD(DrawGlyphRun)(
|
STDMETHOD(DrawGlyphRun)(
|
||||||
__maybenull void* clientDrawingContext,
|
__maybenull void* clientDrawingContext,
|
||||||
|
|
@ -84,7 +51,7 @@ namespace easy2d
|
||||||
__in DWRITE_GLYPH_RUN const* glyphRun,
|
__in DWRITE_GLYPH_RUN const* glyphRun,
|
||||||
__in DWRITE_GLYPH_RUN_DESCRIPTION const* glyphRunDescription,
|
__in DWRITE_GLYPH_RUN_DESCRIPTION const* glyphRunDescription,
|
||||||
IUnknown* clientDrawingEffect
|
IUnknown* clientDrawingEffect
|
||||||
);
|
);
|
||||||
|
|
||||||
STDMETHOD(DrawUnderline)(
|
STDMETHOD(DrawUnderline)(
|
||||||
__maybenull void* clientDrawingContext,
|
__maybenull void* clientDrawingContext,
|
||||||
|
|
@ -92,7 +59,7 @@ namespace easy2d
|
||||||
FLOAT baselineOriginY,
|
FLOAT baselineOriginY,
|
||||||
__in DWRITE_UNDERLINE const* underline,
|
__in DWRITE_UNDERLINE const* underline,
|
||||||
IUnknown* clientDrawingEffect
|
IUnknown* clientDrawingEffect
|
||||||
);
|
);
|
||||||
|
|
||||||
STDMETHOD(DrawStrikethrough)(
|
STDMETHOD(DrawStrikethrough)(
|
||||||
__maybenull void* clientDrawingContext,
|
__maybenull void* clientDrawingContext,
|
||||||
|
|
@ -100,7 +67,7 @@ namespace easy2d
|
||||||
FLOAT baselineOriginY,
|
FLOAT baselineOriginY,
|
||||||
__in DWRITE_STRIKETHROUGH const* strikethrough,
|
__in DWRITE_STRIKETHROUGH const* strikethrough,
|
||||||
IUnknown* clientDrawingEffect
|
IUnknown* clientDrawingEffect
|
||||||
);
|
);
|
||||||
|
|
||||||
STDMETHOD(DrawInlineObject)(
|
STDMETHOD(DrawInlineObject)(
|
||||||
__maybenull void* clientDrawingContext,
|
__maybenull void* clientDrawingContext,
|
||||||
|
|
@ -115,17 +82,17 @@ namespace easy2d
|
||||||
STDMETHOD(IsPixelSnappingDisabled)(
|
STDMETHOD(IsPixelSnappingDisabled)(
|
||||||
__maybenull void* clientDrawingContext,
|
__maybenull void* clientDrawingContext,
|
||||||
__out BOOL* isDisabled
|
__out BOOL* isDisabled
|
||||||
);
|
);
|
||||||
|
|
||||||
STDMETHOD(GetCurrentTransform)(
|
STDMETHOD(GetCurrentTransform)(
|
||||||
__maybenull void* clientDrawingContext,
|
__maybenull void* clientDrawingContext,
|
||||||
__out DWRITE_MATRIX* transform
|
__out DWRITE_MATRIX* transform
|
||||||
);
|
);
|
||||||
|
|
||||||
STDMETHOD(GetPixelsPerDip)(
|
STDMETHOD(GetPixelsPerDip)(
|
||||||
__maybenull void* clientDrawingContext,
|
__maybenull void* clientDrawingContext,
|
||||||
__out FLOAT* pixelsPerDip
|
__out FLOAT* pixelsPerDip
|
||||||
);
|
);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
unsigned long STDMETHODCALLTYPE AddRef();
|
unsigned long STDMETHODCALLTYPE AddRef();
|
||||||
|
|
@ -136,15 +103,20 @@ namespace easy2d
|
||||||
);
|
);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned long cRefCount_;
|
TextRenderer();
|
||||||
D2D1_COLOR_F sFillColor_;
|
|
||||||
D2D1_COLOR_F sOutlineColor_;
|
~TextRenderer();
|
||||||
FLOAT fOutlineWidth;
|
|
||||||
BOOL bShowOutline_;
|
private:
|
||||||
ID2D1Factory* pD2DFactory_;
|
unsigned long cRefCount_;
|
||||||
ID2D1HwndRenderTarget* pRT_;
|
D2D1_COLOR_F sFillColor_;
|
||||||
ID2D1SolidColorBrush* pBrush_;
|
D2D1_COLOR_F sOutlineColor_;
|
||||||
ID2D1StrokeStyle * pCurrStrokeStyle_;
|
FLOAT fOutlineWidth;
|
||||||
|
BOOL bShowOutline_;
|
||||||
|
ID2D1Factory* pD2DFactory_;
|
||||||
|
ID2D1HwndRenderTarget* pRT_;
|
||||||
|
ID2D1SolidColorBrush* pBrush_;
|
||||||
|
ID2D1StrokeStyle* pCurrStrokeStyle_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -171,7 +143,7 @@ namespace easy2d
|
||||||
{
|
{
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
// 在此处设置断点以捕获 D2D API 异常.
|
// 在此处设置断点以捕获系统异常.
|
||||||
static char s_str[64] = {};
|
static char s_str[64] = {};
|
||||||
sprintf_s(s_str, "Failure with HRESULT of %08X", static_cast<unsigned int>(hr));
|
sprintf_s(s_str, "Failure with HRESULT of %08X", static_cast<unsigned int>(hr));
|
||||||
throw RuntimeException(s_str);
|
throw RuntimeException(s_str);
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ namespace easy2d
|
||||||
ID2D1SolidColorBrush * GetSolidBrush() const;
|
ID2D1SolidColorBrush * GetSolidBrush() const;
|
||||||
|
|
||||||
// 获取文字渲染工具
|
// 获取文字渲染工具
|
||||||
E2DTextRenderer * GetTextRender() const;
|
TextRenderer * GetTextRender() const;
|
||||||
|
|
||||||
// 获取 Miter 样式的 ID2D1StrokeStyle
|
// 获取 Miter 样式的 ID2D1StrokeStyle
|
||||||
ID2D1StrokeStyle * GetMiterStrokeStyle();
|
ID2D1StrokeStyle * GetMiterStrokeStyle();
|
||||||
|
|
@ -84,7 +84,7 @@ namespace easy2d
|
||||||
ID2D1StrokeStyle* miter_stroke_style_;
|
ID2D1StrokeStyle* miter_stroke_style_;
|
||||||
ID2D1StrokeStyle* bevel_stroke_style_;
|
ID2D1StrokeStyle* bevel_stroke_style_;
|
||||||
ID2D1StrokeStyle* round_stroke_style_;
|
ID2D1StrokeStyle* round_stroke_style_;
|
||||||
E2DTextRenderer* text_renderer_;
|
TextRenderer* text_renderer_;
|
||||||
IDWriteTextFormat* fps_text_format_;
|
IDWriteTextFormat* fps_text_format_;
|
||||||
IDWriteTextLayout* fps_text_layout_;
|
IDWriteTextLayout* fps_text_layout_;
|
||||||
ID2D1SolidColorBrush* solid_brush_;
|
ID2D1SolidColorBrush* solid_brush_;
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,14 @@ namespace easy2d
|
||||||
public:
|
public:
|
||||||
Music();
|
Music();
|
||||||
|
|
||||||
|
Music(
|
||||||
|
const easy2d::String& file_path /* 稜있匡숭쨌쓺 */
|
||||||
|
);
|
||||||
|
|
||||||
|
Music(
|
||||||
|
const Resource& res /* 稜있栗都 */
|
||||||
|
);
|
||||||
|
|
||||||
virtual ~Music();
|
virtual ~Music();
|
||||||
|
|
||||||
// 打开音乐文件
|
// 打开音乐文件
|
||||||
|
|
@ -84,7 +92,7 @@ namespace easy2d
|
||||||
|
|
||||||
// 打开音乐资源
|
// 打开音乐资源
|
||||||
bool Load(
|
bool Load(
|
||||||
const Resource& res
|
const Resource& res /* 稜있栗都 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 播放
|
// 播放
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
using namespace easy2d;
|
using namespace easy2d;
|
||||||
|
|
||||||
E2DTextRenderer::E2DTextRenderer()
|
TextRenderer::TextRenderer()
|
||||||
: cRefCount_(0)
|
: cRefCount_(0)
|
||||||
, pD2DFactory_(nullptr)
|
, pD2DFactory_(nullptr)
|
||||||
, pRT_(nullptr)
|
, pRT_(nullptr)
|
||||||
|
|
@ -36,21 +36,21 @@ E2DTextRenderer::E2DTextRenderer()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
E2DTextRenderer::~E2DTextRenderer()
|
TextRenderer::~TextRenderer()
|
||||||
{
|
{
|
||||||
SafeRelease(pD2DFactory_);
|
SafeRelease(pD2DFactory_);
|
||||||
SafeRelease(pRT_);
|
SafeRelease(pRT_);
|
||||||
SafeRelease(pBrush_);
|
SafeRelease(pBrush_);
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT E2DTextRenderer::Create(
|
HRESULT TextRenderer::Create(
|
||||||
E2DTextRenderer** ppTextRenderer,
|
TextRenderer** ppTextRenderer,
|
||||||
ID2D1Factory* pD2DFactory,
|
ID2D1Factory* pD2DFactory,
|
||||||
ID2D1HwndRenderTarget* pRT,
|
ID2D1HwndRenderTarget* pRT,
|
||||||
ID2D1SolidColorBrush* pBrush
|
ID2D1SolidColorBrush* pBrush
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
*ppTextRenderer = new (std::nothrow) E2DTextRenderer();
|
*ppTextRenderer = new (std::nothrow) TextRenderer();
|
||||||
if (*ppTextRenderer)
|
if (*ppTextRenderer)
|
||||||
{
|
{
|
||||||
pD2DFactory->AddRef();
|
pD2DFactory->AddRef();
|
||||||
|
|
@ -66,7 +66,7 @@ HRESULT E2DTextRenderer::Create(
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP_(void) E2DTextRenderer::SetTextStyle(
|
STDMETHODIMP_(void) TextRenderer::SetTextStyle(
|
||||||
CONST D2D1_COLOR_F &fillColor,
|
CONST D2D1_COLOR_F &fillColor,
|
||||||
BOOL outline,
|
BOOL outline,
|
||||||
CONST D2D1_COLOR_F &outline_color,
|
CONST D2D1_COLOR_F &outline_color,
|
||||||
|
|
@ -96,7 +96,7 @@ STDMETHODIMP_(void) E2DTextRenderer::SetTextStyle(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP E2DTextRenderer::DrawGlyphRun(
|
STDMETHODIMP TextRenderer::DrawGlyphRun(
|
||||||
__maybenull void* clientDrawingContext,
|
__maybenull void* clientDrawingContext,
|
||||||
FLOAT baselineOriginX,
|
FLOAT baselineOriginX,
|
||||||
FLOAT baselineOriginY,
|
FLOAT baselineOriginY,
|
||||||
|
|
@ -185,7 +185,7 @@ STDMETHODIMP E2DTextRenderer::DrawGlyphRun(
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP E2DTextRenderer::DrawUnderline(
|
STDMETHODIMP TextRenderer::DrawUnderline(
|
||||||
__maybenull void* clientDrawingContext,
|
__maybenull void* clientDrawingContext,
|
||||||
FLOAT baselineOriginX,
|
FLOAT baselineOriginX,
|
||||||
FLOAT baselineOriginY,
|
FLOAT baselineOriginY,
|
||||||
|
|
@ -252,7 +252,7 @@ STDMETHODIMP E2DTextRenderer::DrawUnderline(
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP E2DTextRenderer::DrawStrikethrough(
|
STDMETHODIMP TextRenderer::DrawStrikethrough(
|
||||||
__maybenull void* clientDrawingContext,
|
__maybenull void* clientDrawingContext,
|
||||||
FLOAT baselineOriginX,
|
FLOAT baselineOriginX,
|
||||||
FLOAT baselineOriginY,
|
FLOAT baselineOriginY,
|
||||||
|
|
@ -319,7 +319,7 @@ STDMETHODIMP E2DTextRenderer::DrawStrikethrough(
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP E2DTextRenderer::DrawInlineObject(
|
STDMETHODIMP TextRenderer::DrawInlineObject(
|
||||||
__maybenull void* clientDrawingContext,
|
__maybenull void* clientDrawingContext,
|
||||||
FLOAT originX,
|
FLOAT originX,
|
||||||
FLOAT originY,
|
FLOAT originY,
|
||||||
|
|
@ -332,12 +332,12 @@ STDMETHODIMP E2DTextRenderer::DrawInlineObject(
|
||||||
return E_NOTIMPL;
|
return E_NOTIMPL;
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP_(unsigned long) E2DTextRenderer::AddRef()
|
STDMETHODIMP_(unsigned long) TextRenderer::AddRef()
|
||||||
{
|
{
|
||||||
return InterlockedIncrement(&cRefCount_);
|
return InterlockedIncrement(&cRefCount_);
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP_(unsigned long) E2DTextRenderer::Release()
|
STDMETHODIMP_(unsigned long) TextRenderer::Release()
|
||||||
{
|
{
|
||||||
unsigned long newCount = InterlockedDecrement(&cRefCount_);
|
unsigned long newCount = InterlockedDecrement(&cRefCount_);
|
||||||
|
|
||||||
|
|
@ -350,7 +350,7 @@ STDMETHODIMP_(unsigned long) E2DTextRenderer::Release()
|
||||||
return newCount;
|
return newCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP E2DTextRenderer::IsPixelSnappingDisabled(
|
STDMETHODIMP TextRenderer::IsPixelSnappingDisabled(
|
||||||
__maybenull void* clientDrawingContext,
|
__maybenull void* clientDrawingContext,
|
||||||
__out BOOL* isDisabled
|
__out BOOL* isDisabled
|
||||||
)
|
)
|
||||||
|
|
@ -359,7 +359,7 @@ STDMETHODIMP E2DTextRenderer::IsPixelSnappingDisabled(
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP E2DTextRenderer::GetCurrentTransform(
|
STDMETHODIMP TextRenderer::GetCurrentTransform(
|
||||||
__maybenull void* clientDrawingContext,
|
__maybenull void* clientDrawingContext,
|
||||||
__out DWRITE_MATRIX* transform
|
__out DWRITE_MATRIX* transform
|
||||||
)
|
)
|
||||||
|
|
@ -368,7 +368,7 @@ STDMETHODIMP E2DTextRenderer::GetCurrentTransform(
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP E2DTextRenderer::GetPixelsPerDip(
|
STDMETHODIMP TextRenderer::GetPixelsPerDip(
|
||||||
__maybenull void* clientDrawingContext,
|
__maybenull void* clientDrawingContext,
|
||||||
__out FLOAT* pixelsPerDip
|
__out FLOAT* pixelsPerDip
|
||||||
)
|
)
|
||||||
|
|
@ -381,7 +381,7 @@ STDMETHODIMP E2DTextRenderer::GetPixelsPerDip(
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP E2DTextRenderer::QueryInterface(
|
STDMETHODIMP TextRenderer::QueryInterface(
|
||||||
IID const& riid,
|
IID const& riid,
|
||||||
void** ppvObject
|
void** ppvObject
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ easy2d::Graphics::Graphics(HWND hwnd)
|
||||||
|
|
||||||
// 创建自定义的文字渲染器
|
// 创建自定义的文字渲染器
|
||||||
ThrowIfFailed(
|
ThrowIfFailed(
|
||||||
E2DTextRenderer::Create(
|
TextRenderer::Create(
|
||||||
&text_renderer_,
|
&text_renderer_,
|
||||||
factory_,
|
factory_,
|
||||||
render_target_,
|
render_target_,
|
||||||
|
|
@ -223,7 +223,7 @@ ID2D1SolidColorBrush * easy2d::Graphics::GetSolidBrush() const
|
||||||
return solid_brush_;
|
return solid_brush_;
|
||||||
}
|
}
|
||||||
|
|
||||||
easy2d::E2DTextRenderer * easy2d::Graphics::GetTextRender() const
|
easy2d::TextRenderer * easy2d::Graphics::GetTextRender() const
|
||||||
{
|
{
|
||||||
return text_renderer_;
|
return text_renderer_;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ inline bool TraceError(wchar_t* prompt, HRESULT hr)
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
|
// 音频解码器
|
||||||
class Transcoder
|
class Transcoder
|
||||||
{
|
{
|
||||||
WAVEFORMATEX* wave_format_;
|
WAVEFORMATEX* wave_format_;
|
||||||
|
|
@ -324,6 +324,26 @@ easy2d::Music::Music()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
easy2d::Music::Music(const easy2d::String& file_path)
|
||||||
|
: opened_(false)
|
||||||
|
, playing_(false)
|
||||||
|
, wave_data_(nullptr)
|
||||||
|
, size_(0)
|
||||||
|
, voice_(nullptr)
|
||||||
|
{
|
||||||
|
Load(file_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
easy2d::Music::Music(const Resource& res)
|
||||||
|
: opened_(false)
|
||||||
|
, playing_(false)
|
||||||
|
, wave_data_(nullptr)
|
||||||
|
, size_(0)
|
||||||
|
, voice_(nullptr)
|
||||||
|
{
|
||||||
|
Load(res);
|
||||||
|
}
|
||||||
|
|
||||||
easy2d::Music::~Music()
|
easy2d::Music::~Music()
|
||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue