Commit MetaInfo

修订版4a2dc01d09ecfcde1572267eeb033a8d75c563de (tree)
时间2019-02-06 02:00:02
作者 <jarmonik@c0f5...>

Log Message

- Sketchpad Fixes, Safety checks.

更改概述

差异

diff -r 1ecdc9345cf9 -r 4a2dc01d09ec Orbitersdk/D3D9Client/D3D9Client.cpp
--- a/Orbitersdk/D3D9Client/D3D9Client.cpp Tue Feb 05 16:50:25 2019 +0000
+++ b/Orbitersdk/D3D9Client/D3D9Client.cpp Tue Feb 05 17:00:02 2019 +0000
@@ -394,6 +394,7 @@
394394 pBltGrpTgt = NULL; // Let's set this NULL here, constructor is called only once. Not when exiting and restarting a simulation.
395395 pNoiseTex = NULL;
396396 surfBltTgt = NULL; // This variable is not used, set it to NULL anyway
397+ hMainThread = GetCurrentThread();
397398
398399 memset2(&D3D9Stats, 0, sizeof(D3D9Stats));
399400
@@ -2541,6 +2542,11 @@
25412542 _TRACE;
25422543 oapi::Sketchpad *pSkp = NULL;
25432544
2545+ if (GetCurrentThread() != hMainThread) {
2546+ _wassert(L"Sketchpad called from a worker thread !", _CRT_WIDE(__FILE__), __LINE__);
2547+ return NULL;
2548+ }
2549+
25442550 sketching_time = D3D9GetTime();
25452551
25462552 if (surf == NULL) surf = GetBackBufferHandle();
@@ -2557,6 +2563,7 @@
25572563 if (pCur) {
25582564 if (pCur == pPad) _wassert(L"Sketchpad already exists for this surface", _CRT_WIDE(__FILE__), __LINE__);
25592565 pCur->EndDrawing(); // Put the current one in hold
2566+ //LogErr("Double Sketching");
25602567 }
25612568
25622569 // Push a new Sketchpad onto a stack
@@ -2596,7 +2603,10 @@
25962603
25972604 // Do we have an old interface ?
25982605 D3D9Pad *pOld = GetTopInterface();
2599- if (pOld) pOld->BeginDrawing(); // Continue with the old one
2606+ if (pOld) {
2607+ pOld->BeginDrawing(); // Continue with the old one
2608+ //LogErr("Continue Old");
2609+ }
26002610 }
26012611 else {
26022612 GDIPad *pGDI = (GDIPad *)sp;
diff -r 1ecdc9345cf9 -r 4a2dc01d09ec Orbitersdk/D3D9Client/D3D9Client.h
--- a/Orbitersdk/D3D9Client/D3D9Client.h Tue Feb 05 16:50:25 2019 +0000
+++ b/Orbitersdk/D3D9Client/D3D9Client.h Tue Feb 05 17:00:02 2019 +0000
@@ -1256,6 +1256,7 @@
12561256 D3DCAPS9 caps;
12571257 FileParser * parser;
12581258 std::string scenarioName;
1259+ HANDLE hMainThread;
12591260
12601261 HWND hRenderWnd; // render window handle
12611262
diff -r 1ecdc9345cf9 -r 4a2dc01d09ec Orbitersdk/D3D9Client/D3D9ClientVS2015.sln
--- a/Orbitersdk/D3D9Client/D3D9ClientVS2015.sln Tue Feb 05 16:50:25 2019 +0000
+++ b/Orbitersdk/D3D9Client/D3D9ClientVS2015.sln Tue Feb 05 17:00:02 2019 +0000
@@ -1,6 +1,6 @@
11 Microsoft Visual Studio Solution File, Format Version 12.00
22 # Visual Studio 14
3-VisualStudioVersion = 14.0.25123.0
3+VisualStudioVersion = 14.0.25420.1
44 MinimumVisualStudioVersion = 10.0.40219.1
55 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "D3D9Client", "D3D9ClientVS2015.vcxproj", "{5B2C5D1A-7B8E-4343-BC33-836ABD122D3A}"
66 EndProject
diff -r 1ecdc9345cf9 -r 4a2dc01d09ec Orbitersdk/D3D9Client/D3D9Pad.cpp
--- a/Orbitersdk/D3D9Client/D3D9Pad.cpp Tue Feb 05 16:50:25 2019 +0000
+++ b/Orbitersdk/D3D9Client/D3D9Pad.cpp Tue Feb 05 17:00:02 2019 +0000
@@ -153,6 +153,21 @@
153153 }
154154
155155
156+
157+void D3D9Pad::Reset()
158+{
159+ bBeginDraw = false;
160+ vI = 0;
161+ iI = 0;
162+ D3DXMatrixIdentity(&mO);
163+ vTarget = D3DXVECTOR4(1,1,1,1);
164+ pTgt = NULL;
165+ pDep = NULL;
166+ zfar = 1.0f;
167+}
168+
169+
170+
156171 // ===============================================================================================
157172 // Restore Default Settings: Fonts, Pens, Colors, etc...
158173 //
@@ -222,11 +237,7 @@
222237 if (_name) strcpy_s(name, 32, _name);
223238 else strcpy_s(name, 32, "NoName");
224239
225- // Don't put these in LoadDefaults()
226- bBeginDraw = false;
227- vI = 0;
228- iI = 0;
229-
240+ Reset();
230241 LoadDefaults();
231242 }
232243
@@ -244,11 +255,7 @@
244255 if (_name) strcpy_s(name, 32, _name);
245256 else strcpy_s(name, 32, "NoName");
246257
247- // Don't put these in Reset()
248- bBeginDraw = false;
249- vI = 0;
250- iI = 0;
251-
258+ Reset();
252259 LoadDefaults();
253260 }
254261
@@ -291,14 +298,11 @@
291298 }
292299 else bMustEndScene = false;
293300
294-
295- if (pTgt != pRenderTgt) {
296- pRenderTgt->GetDesc(&tgt_desc);
297- zfar = float(max(tgt_desc.Width, tgt_desc.Height));
298- D3DXMatrixOrthoOffCenterLH(&mO, 0.0f, (float)tgt_desc.Width, (float)tgt_desc.Height, 0.0f, 0.0f, zfar);
299- vTarget = D3DXVECTOR4(2.0f / (float)tgt_desc.Width, 2.0f / (float)tgt_desc.Height, (float)tgt_desc.Width, (float)tgt_desc.Height);
300- }
301-
301+ pRenderTgt->GetDesc(&tgt_desc);
302+ zfar = float(max(tgt_desc.Width, tgt_desc.Height));
303+ D3DXMatrixOrthoOffCenterLH(&mO, 0.0f, (float)tgt_desc.Width, (float)tgt_desc.Height, 0.0f, 0.0f, zfar);
304+ vTarget = D3DXVECTOR4(2.0f / (float)tgt_desc.Width, 2.0f / (float)tgt_desc.Height, (float)tgt_desc.Width, (float)tgt_desc.Height);
305+
302306 pTgt = pRenderTgt;
303307 pDep = pDepthStensil;
304308
@@ -321,6 +325,8 @@
321325 gc->EndScene();
322326 bMustEndScene = false;
323327 }
328+
329+ Reset();
324330 }
325331
326332
diff -r 1ecdc9345cf9 -r 4a2dc01d09ec Orbitersdk/D3D9Client/D3D9Pad.h
--- a/Orbitersdk/D3D9Client/D3D9Pad.h Tue Feb 05 16:50:25 2019 +0000
+++ b/Orbitersdk/D3D9Client/D3D9Pad.h Tue Feb 05 17:00:02 2019 +0000
@@ -574,6 +574,7 @@
574574
575575 float GetPenWidth() const;
576576
577+ void Reset();
577578 bool Flush(HPOLY hPoly = NULL);
578579 void AddRectIdx(WORD aV);
579580 void FillRect(int l, int t, int r, int b, SkpColor &c);
diff -r 1ecdc9345cf9 -r 4a2dc01d09ec Orbitersdk/D3D9Client/D3D9Pad2.cpp
--- a/Orbitersdk/D3D9Client/D3D9Pad2.cpp Tue Feb 05 16:50:25 2019 +0000
+++ b/Orbitersdk/D3D9Client/D3D9Pad2.cpp Tue Feb 05 17:00:02 2019 +0000
@@ -449,7 +449,6 @@
449449 //
450450 bool D3D9Pad::TexChangeNative(LPDIRECT3DTEXTURE9 hNew)
451451 {
452- if (hNew == hTexture) return false;
453452 Change |= SKPCHG_TEXTURE;
454453 hTexture = hNew;
455454 return true;
@@ -470,16 +469,15 @@
470469 return;
471470 }
472471
473- if (TexChangeNative(SURFACE(hNew)->GetTexture())) {
474-
475- if (SURFACE(hNew)->IsColorKeyEnabled()) {
476- bColorKey = true;
477- cColorKey = SURFACE(hNew)->ClrKey;
478- }
479- else {
480- bColorKey = false;
481- cColorKey = D3DXCOLOR(DWORD(0));
482- }
472+ TexChangeNative(SURFACE(hNew)->GetTexture());
473+
474+ if (SURFACE(hNew)->IsColorKeyEnabled()) {
475+ bColorKey = true;
476+ cColorKey = SURFACE(hNew)->ClrKey;
477+ }
478+ else {
479+ bColorKey = false;
480+ cColorKey = D3DXCOLOR(DWORD(0));
483481 }
484482 }
485483
Show on old repository browser