• R/O
  • SSH

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqt誰得cocoapythonrubywindowsphpgameguibathyscaphec翻訳omegatframework計画中(planning stage)twitterdombtronvb.nettestarduinodirectxpreviewerゲームエンジン

K.Takata's patch queue for Vim


Commit MetaInfo

Revisionfe2e4ccfbbf9831c774b5b53f3ea42fc90f80aeb (tree)
Zeit2022-01-21 16:11:13
AutorK.Takata <kentkt@csc....>
CommiterK.Takata

Log Message

Remove wip from ambiwidth auto patch

Ändern Zusammenfassung

Diff

diff -r 372d08a230fe -r fe2e4ccfbbf9 series
--- a/series Fri Jan 21 16:03:09 2022 +0900
+++ b/series Fri Jan 21 16:11:13 2022 +0900
@@ -31,5 +31,5 @@
3131 win32-fix-font.patch
3232 win32-remove-casts.patch
3333 win32-use-unicode-message-api.patch
34-wip-win32-directwrite-ambiwidth-auto.patch #+wip
34+win32-directwrite-ambiwidth-auto.patch
3535 fix-config_cache-removal.patch #+rejected
diff -r 372d08a230fe -r fe2e4ccfbbf9 win32-directwrite-ambiwidth-auto.patch
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/win32-directwrite-ambiwidth-auto.patch Fri Jan 21 16:11:13 2022 +0900
@@ -0,0 +1,157 @@
1+# HG changeset patch
2+# Parent 653be08b1f6a0e52b52b70ae5a0239d5a7d3f796
3+
4+diff --git a/src/gui_dwrite.cpp b/src/gui_dwrite.cpp
5+--- a/src/gui_dwrite.cpp
6++++ b/src/gui_dwrite.cpp
7+@@ -343,6 +343,8 @@ struct DWriteContext {
8+
9+ void Flush();
10+
11++ int GetCharWidth(int c);
12++
13+ void SetRenderingParams(
14+ const DWriteRenderingParams *params);
15+
16+@@ -1155,6 +1157,60 @@ DWriteContext::Flush()
17+ SetDrawingMode(DM_GDI);
18+ }
19+
20++ int
21++DWriteContext::GetCharWidth(int c)
22++{
23++ HRESULT hr;
24++ IDWriteTextLayout *textLayout = NULL;
25++ WCHAR text[3];
26++ int len, w = 0;
27++
28++ //SetDrawingMode(DM_DIRECTX);
29++
30++ if (c < 0x10000)
31++ {
32++ text[0] = (WCHAR)c;
33++ len = 1;
34++ }
35++ else
36++ {
37++ text[0] = ((c - 0x10000) >> 10) + 0xD800;
38++ text[1] = ((c - 0x10000) & 0x3ff) + 0xDC00;
39++ len = 2;
40++ }
41++ text[len] = L'\0';
42++
43++ hr = mDWriteFactory->CreateTextLayout(text, len, mTextFormat,
44++ 10.0f, 10.0f, &textLayout);
45++
46++ if (SUCCEEDED(hr))
47++ {
48++ DWRITE_TEXT_RANGE textRange = { 0, UINT32(len) };
49++ textLayout->SetFontWeight(mFontWeight, textRange);
50++ textLayout->SetFontStyle(mFontStyle, textRange);
51++
52++ UINT32 count;
53++ if (textLayout->GetClusterMetrics(NULL, 0, &count) == E_NOT_SUFFICIENT_BUFFER)
54++ {
55++ DWRITE_CLUSTER_METRICS *metrics = new DWRITE_CLUSTER_METRICS[count];
56++ textLayout->GetClusterMetrics(metrics, count, &count);
57++#ifdef DEBUG
58++ //_RPT2(_CRT_WARN, "len %d, count %d", len, count);
59++ for (UINT32 i = 0; i < count; i++)
60++ {
61++ _RPT2(_CRT_WARN, "%x (%C), [%d]: width %f", c, c, i, metrics[i].width);
62++ }
63++#endif
64++ if (count >= 1)
65++ w = (int)metrics[0].width;
66++ delete [] metrics;
67++ }
68++ }
69++
70++ SafeRelease(&textLayout);
71++ return w;
72++}
73++
74+ void
75+ DWriteContext::SetRenderingParams(
76+ const DWriteRenderingParams *params)
77+@@ -1322,6 +1378,14 @@ DWriteContext_Flush(DWriteContext *ctx)
78+ ctx->Flush();
79+ }
80+
81++ int
82++DWriteContext_GetCharWidth(DWriteContext *ctx, int c)
83++{
84++ if (ctx != NULL)
85++ return ctx->GetCharWidth(c);
86++ return 0;
87++}
88++
89+ void
90+ DWriteContext_Close(DWriteContext *ctx)
91+ {
92+diff --git a/src/gui_dwrite.h b/src/gui_dwrite.h
93+--- a/src/gui_dwrite.h
94++++ b/src/gui_dwrite.h
95+@@ -76,6 +76,7 @@ void DWriteContext_DrawLine(DWriteContex
96+ void DWriteContext_SetPixel(DWriteContext *ctx, int x, int y, COLORREF color);
97+ void DWriteContext_Scroll(DWriteContext *ctx, int x, int y, const RECT *rc);
98+ void DWriteContext_Flush(DWriteContext *ctx);
99++int DWriteContext_GetCharWidth(DWriteContext *ctx, int c);
100+ void DWriteContext_Close(DWriteContext *ctx);
101+
102+ void DWriteContext_SetRenderingParams(
103+diff --git a/src/gui_w32.c b/src/gui_w32.c
104+--- a/src/gui_w32.c
105++++ b/src/gui_w32.c
106+@@ -5182,21 +5182,21 @@ error:
107+
108+ #ifdef USE_AMBIWIDTH_AUTO
109+ # define CHARWIDE_CACHESIZE 0x20000
110+-static GuiFont last_font = NOFONT;
111+
112+ int
113+ gui_mch_get_charwidth(int c)
114+ {
115+ static int cache[CHARWIDE_CACHESIZE];
116++ static GuiFont last_font = NOFONT;
117+ GuiFont usingfont = gui.wide_font ? gui.wide_font : gui.norm_font;
118+
119+- /* Check validity of charwide cache */
120++ /* Check validity of charwidth cache */
121+ if (last_font != usingfont)
122+ {
123+ /* Update cache. -1 is mark for uninitialized cell */
124+ int i;
125+
126+- TRACE("Charwide cache will be updated (base=%d)\n", gui.char_width);
127++ TRACE("Charwidth cache will be updated (base=%d)\n", gui.char_width);
128+ last_font = usingfont;
129+ for (i = 0; i < CHARWIDE_CACHESIZE; ++i)
130+ cache[i] = -1;
131+@@ -5205,6 +5205,17 @@ gui_mch_get_charwidth(int c)
132+ {
133+ if (cache[c] >= 0)
134+ return cache[c]; /* Use cached value */
135++# if defined(FEAT_DIRECTX)
136++ else if (IS_ENABLE_DIRECTX())
137++ {
138++ int len;
139++
140++ DWriteContext_SetFont(s_dwc, (HFONT)usingfont);
141++ len = DWriteContext_GetCharWidth(s_dwc, c);
142++ cache[c] = (len + (gui.char_width >> 1)) / gui.char_width;
143++ return cache[c];
144++ }
145++# endif
146+ else
147+ {
148+ /*
149+@@ -5222,7 +5233,7 @@ gui_mch_get_charwidth(int c)
150+ cache[c] = 0;
151+ }
152+ else
153+- cache[c] = ((len + (gui.char_width >> 1)) / gui.char_width);
154++ cache[c] = (len + (gui.char_width >> 1)) / gui.char_width;
155+ SelectFont(s_hdc, hfntOld);
156+
157+ return cache[c];
diff -r 372d08a230fe -r fe2e4ccfbbf9 wip-win32-directwrite-ambiwidth-auto.patch
--- a/wip-win32-directwrite-ambiwidth-auto.patch Fri Jan 21 16:03:09 2022 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,157 +0,0 @@
1-# HG changeset patch
2-# Parent 653be08b1f6a0e52b52b70ae5a0239d5a7d3f796
3-
4-diff --git a/src/gui_dwrite.cpp b/src/gui_dwrite.cpp
5---- a/src/gui_dwrite.cpp
6-+++ b/src/gui_dwrite.cpp
7-@@ -343,6 +343,8 @@ struct DWriteContext {
8-
9- void Flush();
10-
11-+ int GetCharWidth(int c);
12-+
13- void SetRenderingParams(
14- const DWriteRenderingParams *params);
15-
16-@@ -1155,6 +1157,60 @@ DWriteContext::Flush()
17- SetDrawingMode(DM_GDI);
18- }
19-
20-+ int
21-+DWriteContext::GetCharWidth(int c)
22-+{
23-+ HRESULT hr;
24-+ IDWriteTextLayout *textLayout = NULL;
25-+ WCHAR text[3];
26-+ int len, w = 0;
27-+
28-+ //SetDrawingMode(DM_DIRECTX);
29-+
30-+ if (c < 0x10000)
31-+ {
32-+ text[0] = (WCHAR)c;
33-+ len = 1;
34-+ }
35-+ else
36-+ {
37-+ text[0] = ((c - 0x10000) >> 10) + 0xD800;
38-+ text[1] = ((c - 0x10000) & 0x3ff) + 0xDC00;
39-+ len = 2;
40-+ }
41-+ text[len] = L'\0';
42-+
43-+ hr = mDWriteFactory->CreateTextLayout(text, len, mTextFormat,
44-+ 10.0f, 10.0f, &textLayout);
45-+
46-+ if (SUCCEEDED(hr))
47-+ {
48-+ DWRITE_TEXT_RANGE textRange = { 0, UINT32(len) };
49-+ textLayout->SetFontWeight(mFontWeight, textRange);
50-+ textLayout->SetFontStyle(mFontStyle, textRange);
51-+
52-+ UINT32 count;
53-+ if (textLayout->GetClusterMetrics(NULL, 0, &count) == E_NOT_SUFFICIENT_BUFFER)
54-+ {
55-+ DWRITE_CLUSTER_METRICS *metrics = new DWRITE_CLUSTER_METRICS[count];
56-+ textLayout->GetClusterMetrics(metrics, count, &count);
57-+#ifdef DEBUG
58-+ //_RPT2(_CRT_WARN, "len %d, count %d", len, count);
59-+ for (UINT32 i = 0; i < count; i++)
60-+ {
61-+ _RPT2(_CRT_WARN, "%x (%C), [%d]: width %f", c, c, i, metrics[i].width);
62-+ }
63-+#endif
64-+ if (count >= 1)
65-+ w = (int)metrics[0].width;
66-+ delete [] metrics;
67-+ }
68-+ }
69-+
70-+ SafeRelease(&textLayout);
71-+ return w;
72-+}
73-+
74- void
75- DWriteContext::SetRenderingParams(
76- const DWriteRenderingParams *params)
77-@@ -1322,6 +1378,14 @@ DWriteContext_Flush(DWriteContext *ctx)
78- ctx->Flush();
79- }
80-
81-+ int
82-+DWriteContext_GetCharWidth(DWriteContext *ctx, int c)
83-+{
84-+ if (ctx != NULL)
85-+ return ctx->GetCharWidth(c);
86-+ return 0;
87-+}
88-+
89- void
90- DWriteContext_Close(DWriteContext *ctx)
91- {
92-diff --git a/src/gui_dwrite.h b/src/gui_dwrite.h
93---- a/src/gui_dwrite.h
94-+++ b/src/gui_dwrite.h
95-@@ -76,6 +76,7 @@ void DWriteContext_DrawLine(DWriteContex
96- void DWriteContext_SetPixel(DWriteContext *ctx, int x, int y, COLORREF color);
97- void DWriteContext_Scroll(DWriteContext *ctx, int x, int y, const RECT *rc);
98- void DWriteContext_Flush(DWriteContext *ctx);
99-+int DWriteContext_GetCharWidth(DWriteContext *ctx, int c);
100- void DWriteContext_Close(DWriteContext *ctx);
101-
102- void DWriteContext_SetRenderingParams(
103-diff --git a/src/gui_w32.c b/src/gui_w32.c
104---- a/src/gui_w32.c
105-+++ b/src/gui_w32.c
106-@@ -5182,21 +5182,21 @@ error:
107-
108- #ifdef USE_AMBIWIDTH_AUTO
109- # define CHARWIDE_CACHESIZE 0x20000
110--static GuiFont last_font = NOFONT;
111-
112- int
113- gui_mch_get_charwidth(int c)
114- {
115- static int cache[CHARWIDE_CACHESIZE];
116-+ static GuiFont last_font = NOFONT;
117- GuiFont usingfont = gui.wide_font ? gui.wide_font : gui.norm_font;
118-
119-- /* Check validity of charwide cache */
120-+ /* Check validity of charwidth cache */
121- if (last_font != usingfont)
122- {
123- /* Update cache. -1 is mark for uninitialized cell */
124- int i;
125-
126-- TRACE("Charwide cache will be updated (base=%d)\n", gui.char_width);
127-+ TRACE("Charwidth cache will be updated (base=%d)\n", gui.char_width);
128- last_font = usingfont;
129- for (i = 0; i < CHARWIDE_CACHESIZE; ++i)
130- cache[i] = -1;
131-@@ -5205,6 +5205,17 @@ gui_mch_get_charwidth(int c)
132- {
133- if (cache[c] >= 0)
134- return cache[c]; /* Use cached value */
135-+# if defined(FEAT_DIRECTX)
136-+ else if (IS_ENABLE_DIRECTX())
137-+ {
138-+ int len;
139-+
140-+ DWriteContext_SetFont(s_dwc, (HFONT)usingfont);
141-+ len = DWriteContext_GetCharWidth(s_dwc, c);
142-+ cache[c] = (len + (gui.char_width >> 1)) / gui.char_width;
143-+ return cache[c];
144-+ }
145-+# endif
146- else
147- {
148- /*
149-@@ -5222,7 +5233,7 @@ gui_mch_get_charwidth(int c)
150- cache[c] = 0;
151- }
152- else
153-- cache[c] = ((len + (gui.char_width >> 1)) / gui.char_width);
154-+ cache[c] = (len + (gui.char_width >> 1)) / gui.char_width;
155- SelectFont(s_hdc, hfntOld);
156-
157- return cache[c];