Skip to content

Commit

Permalink
Merge branch 'directwrite' of https://githubfast.com/snowie2000/mactype
Browse files Browse the repository at this point in the history
… into directwrite
  • Loading branch information
snowie2000 committed May 7, 2021
2 parents 1dfb340 + 999790b commit 4742bb6
Show file tree
Hide file tree
Showing 45 changed files with 961 additions and 940 deletions.
2 changes: 1 addition & 1 deletion EventLogging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ void EventLogging::LogIt(WORD CategoryID, DWORD EventID, LPCTSTR ArrayOfStrings[
ReportEvent(m_hEventLinker,EVENTLOG_INFORMATION_TYPE,CategoryID,
EventID,NULL,NumOfArrayStr,RawDataSize,ArrayOfStrings,RawData);

}
}
24 changes: 12 additions & 12 deletions cache.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "override.h"

//CreateDIBシニハ」ャスォヤレサ贍ニマツチミエホハコ�ツDIBヌ
#define BITMAP_REDUCE_COUNTER 256//トャネマ1024
//CreateDIB计数,将在绘制下列次数后更新DIB区
#define BITMAP_REDUCE_COUNTER 256//默认1024


HDC CBitmapCache::CreateDC(HDC dc)
Expand All @@ -23,8 +23,8 @@ HBITMAP CBitmapCache::CreateDIB(int width, int height, BYTE** lplpPixels)
*lplpPixels = m_lpPixels;
return m_hbmp;
}
//カウンタ超過
//ただしサイズが全く同じなら再生成しない
//カウンタ超過
//ただしサイズが全く同じなら再生成しない
if (dibSize.cx == width && dibSize.cy == height) {
m_counter = 0;
*lplpPixels = m_lpPixels;
Expand All @@ -46,16 +46,16 @@ HBITMAP CBitmapCache::CreateDIB(int width, int height, BYTE** lplpPixels)
}
TRACE(_T("width=%d, height=%d\n"), width, height);

//メモリ不足等でhbmpNew==NULLの場合を想定し、
//成功したときのみキャッシュを更新
//メモリ不足等でhbmpNew==NULLの場合を想定し、
//成功したときのみキャッシュを更新
if (m_hbmp) {
DeleteBitmap(m_hbmp);
}

m_hbmp = hbmpNew;
dibSize.cx = width;
dibSize.cy = height;
//CreateDIBSectionは多分ページ境界かセグメント境界
//CreateDIBSectionは多分ページ境界かセグメント境界
m_lpPixels = *lplpPixels;
m_counter = 0;
return m_hbmp;
Expand All @@ -79,7 +79,7 @@ void CBitmapCache::FillSolidRect(COLORREF rgb, const RECT* lprc)
const DWORD dwBmpBytes = m_dibSize.cx * m_dibSize.cy;
rgb = RGB2DIB(rgb);
//TODO: MMX or SSE化
//TODO: MMX or SSE化
__asm {
mov edi, dword ptr [lpPixels]
mov ecx, dword ptr [dwBmpBytes]
Expand All @@ -94,7 +94,7 @@ void CBitmapCache::FillSolidRect(COLORREF rgb, const RECT* lprc)
// }
}

//水平線を引く
//水平線を引く
//(X1,Y1) (X2,Y1)
// +-----------------+ ^
// | rgb | | width
Expand All @@ -111,7 +111,7 @@ void CBitmapCache::DrawHorizontalLine(int X1, int Y1, int X2, COLORREF rgb, int
X2 = xx;
}

//クリッピング
//クリッピング
const int xSize = m_dibSize.cx;
const int ySize = m_dibSize.cy;
X1 = Bound(X1, 0, xSize);
Expand Down Expand Up @@ -142,7 +142,7 @@ void CBitmapCache::DrawHorizontalLine(int X1, int Y1, int X2, COLORREF rgb, int
}*/

/*#ifdef _M_IX86
//無意味にアセンブリ化
//無意味にアセンブリ化
__asm {
mov ebx, dword ptr [Yd]
mov edx, dword ptr [lpPixels]
Expand All @@ -157,7 +157,7 @@ void CBitmapCache::DrawHorizontalLine(int X1, int Y1, int X2, COLORREF rgb, int
dec ebx
jnz L1
}
#else*/ //カヤモレ64ホサマオヘウ」ャハケモテCモ�ヤ
#else*/ //对于64位系统,使用C语言
for (int yy=Y1; yy<Y2; yy++) {
for (int xx=X1; xx<X2; xx++) {
*( (DWORD*)m_lpPixels + (yy * xSize + xx) ) = rgb;
Expand Down
6 changes: 3 additions & 3 deletions cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ typedef StringHashT<LF_FACESIZE,true> StringHashFont;
typedef StringHashT<MAX_PATH,true> StringHashModule;


//COLORREF(RR GG BB 00) を DIB32(BB GG RR 00) に変換
//COLORREF(RR GG BB 00) を DIB32(BB GG RR 00) に変換
#define RGB2DIB(rgb) RGB(GetBValue(rgb), GetGValue(rgb), GetRValue(rgb))
#define DIB2RGB(dib) RGB2DIB(dib)

// ExtTextOutWのビットマップキャッシュ
// ExtTextOutWのビットマップキャッシュ
class CBitmapCache
{
private:
Expand Down Expand Up @@ -142,7 +142,7 @@ class CBitmapCache
*m_CurrentPixel = RGB2DIB(rgb);
}

//本体はcache.cpp
//本体はcache.cpp
HDC CreateDC(HDC dc);
HBITMAP CreateDIB(int width, int height, BYTE** lplpPixels);
void FillSolidRect(COLORREF rgb, const RECT* lprc);
Expand Down
2 changes: 1 addition & 1 deletion colorinvert.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#pragma once
//formula: (x+482)^2+(y+481)^2=880^2
unsigned char InvertTable[260] = { 255,255,254,253,253,252,251,251,250,249,249,248,247,247,246,245,245,244,243,242,242,241,240,240,239,238,238,237,236,235,235,234,233,233,232,231,230,230,229,228,227,227,226,225,224,224,223,222,221,221,220,219,218,218,217,216,215,215,214,213,212,211,211,210,209,208,208,207,206,205,204,204,203,202,201,200,199,199,198,197,196,195,195,194,193,192,191,190,189,189,188,187,186,185,184,183,183,182,181,180,179,178,177,176,176,175,174,173,172,171,170,169,168,167,166,166,165,164,163,162,161,160,159,158,157,156,155,154,153,152,151,150,149,148,147,146,145,144,143,143,142,141,140,138,137,136,135,134,133,132,131,130,129,128,127,126,125,124,123,122,121,120,119,118,117,115,114,113,112,111,110,109,108,107,106,104,103,102,101,100,99,98,96,95,94,93,92,91,90,88,87,86,85,84,82,81,80,79,78,76,75,74,73,71,70,69,68,66,65,64,63,61,60,59,58,56,55,54,52,51,50,48,47,46,44,43,42,40,39,38,36,35,33,32,31,29,28,26,25,24,22,21,19,18,16,15,13,12,10,9,7,6,4,3,1,0,0,0,0,0};
unsigned char InvertTable[260] = { 255,255,254,253,253,252,251,251,250,249,249,248,247,247,246,245,245,244,243,242,242,241,240,240,239,238,238,237,236,235,235,234,233,233,232,231,230,230,229,228,227,227,226,225,224,224,223,222,221,221,220,219,218,218,217,216,215,215,214,213,212,211,211,210,209,208,208,207,206,205,204,204,203,202,201,200,199,199,198,197,196,195,195,194,193,192,191,190,189,189,188,187,186,185,184,183,183,182,181,180,179,178,177,176,176,175,174,173,172,171,170,169,168,167,166,166,165,164,163,162,161,160,159,158,157,156,155,154,153,152,151,150,149,148,147,146,145,144,143,143,142,141,140,138,137,136,135,134,133,132,131,130,129,128,127,126,125,124,123,122,121,120,119,118,117,115,114,113,112,111,110,109,108,107,106,104,103,102,101,100,99,98,96,95,94,93,92,91,90,88,87,86,85,84,82,81,80,79,78,76,75,74,73,71,70,69,68,66,65,64,63,61,60,59,58,56,55,54,52,51,50,48,47,46,44,43,42,40,39,38,36,35,33,32,31,29,28,26,25,24,22,21,19,18,16,15,13,12,10,9,7,6,4,3,1,0,0,0,0,0};
36 changes: 18 additions & 18 deletions common.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ FORCEINLINE HINSTANCE GetDLLInstance()
return g_hinstDLL;
}

//排他制御
//排他制御
class CCriticalSectionLock
{
#define MAX_CRITICAL_COUNT 20
Expand Down Expand Up @@ -148,11 +148,11 @@ static void _Trace(LPCTSTR pszFormat, ...)
CCriticalSectionLock __lock;
va_list argptr;
va_start(argptr, pszFormat);
//w(v)sprintfは1024文字以上返してこない
//w(v)sprintfは1024文字以上返してこない
TCHAR szBuffer[10240];
wvsprintf(szBuffer, pszFormat, argptr);

//デバッガをアタッチしてる時はデバッガにメッセージを出す
//デバッガをアタッチしてる時はデバッガにメッセージを出す
//if (IsDebuggerPresent()) {
OutputDebugString(szBuffer);
return;
Expand Down Expand Up @@ -188,7 +188,7 @@ static void _Trace(LPCTSTR pszFormat, ...)
}
#else //!_DEBUG
#define TRACE NOP_FUNCTION
//↓PSDK 2003R2のwinnt.h
//↓PSDK 2003R2のwinnt.h
//#ifndef NOP_FUNCTION
//#if (_MSC_VER >= 1210)
//#define NOP_FUNCTION __noop
Expand All @@ -198,8 +198,8 @@ static void _Trace(LPCTSTR pszFormat, ...)
//#endif
#endif //_DEBUG

//TRACEマクロ
//使用例: TRACE(_T("cx: %d\n"), cx);
//TRACEマクロ
//使用例: TRACE(_T("cx: %d\n"), cx);
#ifdef USE_TRACE
#define TRACE2 _Trace2
#define TRACE2_STR _Trace2_Str
Expand All @@ -212,7 +212,7 @@ static void _Trace2(LPCTSTR pszFormat, ...)
CCriticalSectionLock __lock;
va_list argptr;
va_start(argptr, pszFormat);
//w(v)sprintfは1024文字以上返してこない
//w(v)sprintfは1024文字以上返してこない
TCHAR szBuffer[1024];
wvsprintf(szBuffer, pszFormat, argptr);
OutputDebugString(szBuffer);
Expand Down Expand Up @@ -332,7 +332,7 @@ class CCriticalSectionLockTry
}
};

// 使用後はfreeで開放する事
// 使用後はfreeで開放する事
LPWSTR _StrDupExAtoW(LPCSTR pszMB, int cchMB, LPWSTR pszStack, int cchStack, int* pcchWC, int nACP = CP_ACP);
static inline LPWSTR _StrDupAtoW(LPCSTR pszMB, int cchMB = -1, int* pcchWC = NULL)
{
Expand All @@ -358,8 +358,8 @@ template<typename T> FORCEINLINE T Bound(T x, T m, T M) { return (x < m) ? m : (
template<typename T> FORCEINLINE int Sgn(T x, T y) { return (x > y) ? 1 : ((x < y) ? -1 : 0); }


//型チェック機能つきDeleteXXX/SelectXXX
//SelectObject/DeleteObjectは使用できなくなる
//型チェック機能つきDeleteXXX/SelectXXX
//SelectObject/DeleteObjectは使用できなくなる

#ifdef _DEBUG
#undef DeletePen
Expand Down Expand Up @@ -448,8 +448,8 @@ DEFINE_SELECT_FUNCTION(HBITMAP, Bitmap)
#endif //_DEBUG


//TRACEマクロ
//使用例: TRACE(_T("cx: %d\n"), cx);
//TRACEマクロ
//使用例: TRACE(_T("cx: %d\n"), cx);
#ifndef _WIN64
#ifdef _DEBUG
FORCEINLINE static __int64 GetClockCount()
Expand All @@ -463,12 +463,12 @@ FORCEINLINE static __int64 GetClockCount()
return cycles.QuadPart;
}

//使用例
//使用例
//{
// CDebugElapsedCounter _cntr("hogehoge");
// : (適当な処理)
// : (適当な処理)
//}
//出力例: "hogehoge: 10000 clocks"
//出力例: "hogehoge: 10000 clocks"
class CDebugElapsedCounter
{
private:
Expand Down Expand Up @@ -497,7 +497,7 @@ class CDebugElapsedCounter
#endif


//String to intオネマオチミコッハオトカィメ
//String to int等系列函数的定义
/*
int _StrToInt(LPCTSTR pStr, int nDefault)
{
Expand Down Expand Up @@ -577,7 +577,7 @@ int _httoi(const TCHAR *value)
return result;
}
//atofにデフォルト値を返せるようにしたような物
//atofにデフォルト値を返せるようにしたような物
float _StrToFloat(LPCTSTR pStr, float fDefault)
{
#define isspace(ch) (ch == _T('\t') || ch == _T(' '))
Expand Down Expand Up @@ -628,4 +628,4 @@ bool HookD2D1();
void HookGdiplus();
void ChangeFileName(LPWSTR lpSrc, int nSize, LPCWSTR lpNewFileName);
std::wstring MakeUniqueFontName(const std::wstring strFullName, const std::wstring strFamilyName, const std::wstring strStyleName);
std::string WstringToString(const std::wstring str);
std::string WstringToString(const std::wstring str);
2 changes: 1 addition & 1 deletion crc32.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ class crc32
return crc ^ ~0U;
}
};
#endif
#endif
4 changes: 2 additions & 2 deletions directwrite.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "directwrite.h"
#include "directwrite.h"
#include "settings.h"
#include "dynCodeHelper.h"

Expand Down Expand Up @@ -2114,4 +2114,4 @@ void WINAPI IMPL_D2D1RenderTarget_DrawTextLayout(
options
);
}
}
}
2 changes: 1 addition & 1 deletion directwrite.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
#define HOOK_DEFINE(rettype, name, argtype) ;
#include "hooklist.h"
#undef HOOK_DEFINE
#undef HOOK_MANUALLY
#undef HOOK_MANUALLY
Loading

0 comments on commit 4742bb6

Please sign in to comment.