[Ttssh2-commit] [7496] 高速化テスト(Ttssh2-devel 3598)

scmno****@osdn***** scmno****@osdn*****
2019年 3月 18日 (月) 23:01:33 JST


Revision: 7496
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/7496
Author:   zmatsuo
Date:     2019-03-18 23:01:33 +0900 (Mon, 18 Mar 2019)
Log Message:
-----------
高速化テスト(Ttssh2-devel 3598)

Modified Paths:
--------------
    trunk/teraterm/teraterm/buffer.c
    trunk/teraterm/teraterm/teraterm.cpp
    trunk/teraterm/teraterm/vtdisp.c
    trunk/teraterm/teraterm/vtterm.c
    trunk/teraterm/teraterm/vtwin.cpp

Added Paths:
-----------
    trunk/teraterm/teraterm/vtdisp_delay.c
    trunk/teraterm/teraterm/vtdisp_delay.h

-------------- next part --------------
Modified: trunk/teraterm/teraterm/buffer.c
===================================================================
--- trunk/teraterm/teraterm/buffer.c	2019-03-18 13:57:53 UTC (rev 7495)
+++ trunk/teraterm/teraterm/buffer.c	2019-03-18 14:01:33 UTC (rev 7496)
@@ -88,7 +88,7 @@
 static BOOL BoxSelect;
 static POINT DblClkStart, DblClkEnd;
 
-static int StrChangeStart, StrChangeCount;
+int StrChangeStart, StrChangeCount;
 
 static BOOL SeveralPageSelect;  // add (2005.5.15 yutaka)
 
@@ -1900,6 +1900,7 @@
 			StrChangeStart = CursorX;
 		}
 		StrChangeCount++;
+		UpdateStr();
 	}
 }
 
@@ -2024,7 +2025,7 @@
 	}
 }
 
-void BuffUpdateRect
+void BuffUpdateRect2
   (int XStart, int YStart, int XEnd, int YEnd)
 // Display text in a rectangular region in the screen
 //   XStart: x position of the upper-left corner (screen cordinate)
@@ -2121,6 +2122,7 @@
 	}
 }
 
+#if 0
 void UpdateStr()
 // Display not-yet-displayed string
 {
@@ -2175,6 +2177,7 @@
 
 	StrChangeCount = 0;
 }
+#endif
 
 #if 0
 void UpdateStrUnicode(void)

Modified: trunk/teraterm/teraterm/teraterm.cpp
===================================================================
--- trunk/teraterm/teraterm/teraterm.cpp	2019-03-18 13:57:53 UTC (rev 7495)
+++ trunk/teraterm/teraterm/teraterm.cpp	2019-03-18 14:01:33 UTC (rev 7496)
@@ -47,6 +47,7 @@
 #include "keyboard.h"
 #include "dllutil.h"
 #include "compat_win.h"
+#include "vtdisp_delay.h"
 
 #include "teraapp.h"
 
@@ -302,6 +303,12 @@
 		Busy--;
 	}
 
+	if (Busy == 0) {
+		if (IsUpdateTerm()) {
+			Busy++;
+		}
+	}
+
 	return (Busy>0);
 }
 

Modified: trunk/teraterm/teraterm/vtdisp.c
===================================================================
--- trunk/teraterm/teraterm/vtdisp.c	2019-03-18 13:57:53 UTC (rev 7495)
+++ trunk/teraterm/teraterm/vtdisp.c	2019-03-18 14:01:33 UTC (rev 7496)
@@ -80,7 +80,7 @@
   {168,168,168}, {178,178,178}, {188,188,188}, {198,198,198}, {208,208,208}, {218,218,218}, {228,228,228}, {238,238,238}   // 248 - 255
 };
 
-int WinWidth, WinHeight;
+int WinWidth, WinHeight;								// \x89\xE6\x96ʂɕ\\x8E\xA6\x82\xB3\x82\xEA\x82Ă\xA2\x82镶\x8E\x9A\x90\x94
 static BOOL Active = FALSE;
 static BOOL CompletelyVisible;
 HFONT VTFont[AttrFontMask+1];
@@ -95,10 +95,12 @@
 RECT VirtualScreen;
 
 // --- scrolling status flags
-int WinOrgX, WinOrgY, NewOrgX, NewOrgY;
+int WinOrgX, WinOrgY;		// \x8C\xBB\x8D݂̕\\x8E\xA6\x88ʒu
+int NewOrgX, NewOrgY;		// \x8DX\x90V\x8C\xE3\x82̕\\x8E\xA6\x88ʒu
+int ScrollBarVPos;			// \x83X\x83N\x83\x8D\x81[\x83\x8B\x83o\x81[\x82̈ʒu
 
-int NumOfLines, NumOfColumns;
-int PageStart, BuffEnd;
+int NumOfLines, NumOfColumns;	// \x83o\x83b\x83t\x83@\x83\x8A\x83\x93\x83O\x82\xB5\x82Ă\xA2\x82镶\x8E\x9A\x90\x94
+int PageStart, BuffEnd;			// \x95\\x8E\xA6\x82\xB5\x82Ă\xA2\x82\xE9\x83o\x83b\x83t\x83@\x93\xE0\x82̈ʒu
 
 static BOOL CursorOnDBCS = FALSE;
 static LOGFONT VTlf;
@@ -130,7 +132,7 @@
 
 // scrolling
 static int ScrollCount = 0;
-static int dScroll = 0;
+int dScroll = 0;
 static int SRegionTop;
 static int SRegionBottom;
 
@@ -3179,6 +3181,7 @@
   if (ScrollCount>=ts.ScrollThreshold) DispUpdateScroll();
 }
 
+#if 0
 void DispUpdateScroll()
 {
   int d;
@@ -3284,6 +3287,7 @@
 
   if (IsCaretOn()) CaretOn();
 }
+#endif
 
 void DispScrollHomePos()
 {

Added: trunk/teraterm/teraterm/vtdisp_delay.c
===================================================================
--- trunk/teraterm/teraterm/vtdisp_delay.c	                        (rev 0)
+++ trunk/teraterm/teraterm/vtdisp_delay.c	2019-03-18 14:01:33 UTC (rev 7496)
@@ -0,0 +1,183 @@
+/* Tera Term \x8D\x82\x91\xAC\x89\xBB\x83e\x83X\x83g */
+
+#include <windows.h>
+#include <time.h>
+#include <stdio.h>
+
+#include "tttypes.h"
+#include "ttwinman.h"
+#include "ttlib.h"
+#include "vtdisp.h"
+#include "vtdisp_delay.h"
+
+// buffer.c
+extern int StrChangeStart, StrChangeCount;
+extern int dScroll;
+
+#define DISPLAY_INTERVAL	(1000 / 30)		// (ms)
+//#define DISPLAY_INTERVAL	(1000)	// (ms)
+
+#define OutputDebugPrintf(...)
+
+void BuffUpdateRect2(int XStart, int YStart, int XEnd, int YEnd);
+
+////////////////////////////////////////
+
+typedef struct {
+	enum {
+		NONE,				// \x95`\x89\xE6\x82Ȃ\xB5
+		ONE_LINE,			// 1\x8Ds\x95`\x89\xE6
+		WHOLE_TERM,			// \x91S\x89\xE6\x96ʕ`\x89\xE6
+	} Type;
+
+	// ONE_LINE\x8E\x9E\x82̃f\x81[\x83^
+	int StrChangeStart;		// cursor\x82\xCCX
+	int CursorY;			// cursor\x82\xCCY
+	int StrChangeCount;		// \x95\xB6\x8E\x9A\x90\x94
+
+	// \x95\\x8E\xA6\x8AJ\x8En\x88ʒu
+	int NewOrgX;
+	int NewOrgY;
+
+	DWORD UpdateTick;
+
+	// scroll bar\x8F\xEE\x95\xF1
+	int ScrollBarVPos;
+} UpdateInfo_t;
+
+static UpdateInfo_t UpdateInfo;
+
+void UpdateStr()
+{
+	if (UpdateInfo.Type == NONE) {
+		if (StrChangeCount != 0) {
+			UpdateInfo.Type = ONE_LINE;
+			UpdateInfo.CursorY = CursorY;
+			UpdateInfo.StrChangeStart = StrChangeStart;
+			UpdateInfo.StrChangeCount = StrChangeCount;
+		}
+	} else if (UpdateInfo.Type == ONE_LINE) {
+		if (StrChangeCount == 0) {
+			;
+		} else if (UpdateInfo.CursorY != CursorY) {
+			UpdateInfo.Type = WHOLE_TERM;
+		} else if (UpdateInfo.StrChangeStart + UpdateInfo.StrChangeCount == StrChangeStart ) {
+			UpdateInfo.StrChangeCount += StrChangeCount;
+		} else {
+			UpdateInfo.StrChangeStart = 0;
+			UpdateInfo.StrChangeCount = NumOfColumns;
+		}
+	}
+
+	OutputDebugPrintf("%d (%d,%d)%d , (%d,%d)%d\n",
+					  UpdateInfo.Type,
+					  StrChangeStart, CursorY, StrChangeCount,
+					  UpdateInfo.StrChangeStart, UpdateInfo.CursorY, UpdateInfo.StrChangeCount);
+
+	StrChangeCount = 0;
+}
+
+void BuffUpdateRect(int XStart, int YStart, int XEnd, int YEnd)
+{
+	OutputDebugPrintf("BuffUpdateRect(%d,%d,%d,%d)\n",
+					  XStart, YStart, XEnd, YEnd);
+	UpdateInfo.Type = WHOLE_TERM;
+}
+
+void DispUpdateScroll()
+{
+	OutputDebugPrintf("DispUpdateScroll\n");
+	UpdateInfo.Type = WHOLE_TERM;
+	UpdateInfo.NewOrgX += NewOrgX;
+	UpdateInfo.NewOrgY += NewOrgY;
+	dScroll = 0;
+}
+
+void UpdateTerm()
+{
+	DWORD now = timeGetTime();
+	int NewOrgX;
+	int NewOrgY;
+	int ScrollBarUpdated = 0;
+	OutputDebugPrintf("UpdateTerm %d\n", UpdateInfo.Type);
+
+	if (UpdateInfo.Type == NONE) {
+		return;
+	}
+
+	NewOrgX = UpdateInfo.NewOrgX;
+	NewOrgY = UpdateInfo.NewOrgY;
+
+	/* Update normal scroll */
+	if (NewOrgX < 0) NewOrgX = 0;
+	if (NewOrgX > NumOfColumns - WinWidth)
+		NewOrgX = NumOfColumns - WinWidth;
+	if (NewOrgY < -PageStart)
+		NewOrgY = -PageStart;
+	if (NewOrgY > BuffEnd - WinHeight - PageStart)
+		NewOrgY = BuffEnd - WinHeight - PageStart;
+
+	if (NewOrgX != WinOrgX) {
+		SetScrollPos(HVTWin, SB_HORZ, NewOrgX, TRUE);
+		ScrollBarUpdated = 1;
+	}
+
+	if (((ts.AutoScrollOnlyInBottomLine != 0 || NewOrgY!=WinOrgY)) &&
+		(UpdateInfo.ScrollBarVPos != NewOrgY + PageStart))
+	{
+		SCROLLINFO scroll_info;
+		scroll_info.cbSize = sizeof(scroll_info);
+		scroll_info.fMask = SIF_PAGE | SIF_RANGE | SIF_POS;
+		scroll_info.nPage = WinHeight;
+		scroll_info.nMin = 0;
+		scroll_info.nMax = BuffEnd-WinHeight;
+
+		if ((BuffEnd==WinHeight) && (ts.EnableScrollBuff>0)) {
+			scroll_info.nMax = BuffEnd;
+			scroll_info.nPos = 0;
+		} else {
+			int max = BuffEnd - WinHeight;
+			scroll_info.nMax = BuffEnd;
+			scroll_info.nPos = NewOrgY+PageStart;
+		}
+
+		SetScrollInfo(HVTWin, SB_VERT, &scroll_info, TRUE);
+		UpdateInfo.ScrollBarVPos = scroll_info.nPos;
+		ScrollBarUpdated = 1;
+		OutputDebugPrintf("sb_vert %d-%d-%d,%d\n",
+						  scroll_info.nMin,
+						  scroll_info.nPos,
+						  scroll_info.nMax,
+						  scroll_info.nPage);
+	}
+
+#if 0
+	if (ScrollBarUpdated) {
+		// \x83X\x83N\x83\x8D\x81[\x83\x8B\x83o\x81[\x82\xAA\x8DX\x90V\x82\xB3\x82ꂽ\x8Fꍇ\x82͂\xB7\x82\xAE\x82ɕ`\x89悷\x82\xE9
+		InvalidateRect(HVTWin, NULL, FALSE);
+	} else
+#endif
+	if (UpdateInfo.Type == WHOLE_TERM) {
+		if ((now - UpdateInfo.UpdateTick) < DISPLAY_INTERVAL) {
+			return;
+		}
+		InvalidateRect(HVTWin, NULL, FALSE);
+	} else if (UpdateInfo.Type == ONE_LINE) {
+		BuffUpdateRect2(UpdateInfo.StrChangeStart, UpdateInfo.CursorY,
+						UpdateInfo.StrChangeStart + UpdateInfo.StrChangeCount, UpdateInfo.CursorY);
+	}
+
+	WinOrgX = NewOrgX;
+	WinOrgY = NewOrgY;
+	UpdateInfo.UpdateTick = now;
+	UpdateInfo.Type = NONE;
+
+}
+
+int IsUpdateTerm()
+{
+	if (UpdateInfo.Type == NONE) {
+		return 0;
+	}
+	return 1;
+}

Added: trunk/teraterm/teraterm/vtdisp_delay.h
===================================================================
--- trunk/teraterm/teraterm/vtdisp_delay.h	                        (rev 0)
+++ trunk/teraterm/teraterm/vtdisp_delay.h	2019-03-18 14:01:33 UTC (rev 7496)
@@ -0,0 +1,10 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int IsUpdateTerm();
+void UpdateTerm();
+
+#ifdef __cplusplus
+}
+#endif

Modified: trunk/teraterm/teraterm/vtterm.c
===================================================================
--- trunk/teraterm/teraterm/vtterm.c	2019-03-18 13:57:53 UTC (rev 7495)
+++ trunk/teraterm/teraterm/vtterm.c	2019-03-18 14:01:33 UTC (rev 7496)
@@ -54,6 +54,8 @@
 #include "clipboar.h"
 #include "codeconv.h"
 
+#include "vtdisp_delay.h"
+
 #include "vtterm.h"
 
 #ifdef _DEBUG
@@ -5748,7 +5750,12 @@
 
 	c = CommRead1Byte(&cv,&b);
 
-	if (c==0) return 0;
+	if (c==0) {
+		if (IsUpdateTerm()) {
+			UpdateTerm();
+		}
+		return 0;
+	}
 
 	CaretOff();
 	UpdateCaretPosition(FALSE);	// \x94\xF1\x83A\x83N\x83e\x83B\x83u\x82̏ꍇ\x82̂ݍĕ`\x89悷\x82\xE9
@@ -5807,7 +5814,9 @@
 			c = CommRead1Byte(&cv,&b);
 	}
 
-	BuffUpdateScroll();
+	if (IsUpdateTerm()) {
+		UpdateTerm();
+	}
 
 	BuffSetCaretWidth();
 	UnlockBuffer();

Modified: trunk/teraterm/teraterm/vtwin.cpp
===================================================================
--- trunk/teraterm/teraterm/vtwin.cpp	2019-03-18 13:57:53 UTC (rev 7495)
+++ trunk/teraterm/teraterm/vtwin.cpp	2019-03-18 14:01:33 UTC (rev 7496)
@@ -94,6 +94,8 @@
 static char THIS_FILE[] = __FILE__;
 #endif
 
+extern "C" void BuffUpdateRect2(int XStart, int YStart, int XEnd, int YEnd);
+
 // \x83E\x83B\x83\x93\x83h\x83E\x8Dő剻\x83{\x83^\x83\x93\x82\xF0\x97L\x8C\xF8\x82ɂ\xB7\x82\xE9 (2005.1.15 yutaka)
 #define WINDOW_MAXMIMUM_ENABLED 1
 
@@ -2655,7 +2657,7 @@
 
 	PaintWindow(PaintDC,ps.rcPaint,ps.fErase, &Xs,&Ys,&Xe,&Ye);
 	LockBuffer();
-	BuffUpdateRect(Xs,Ys,Xe,Ye);
+	BuffUpdateRect2(Xs,Ys,Xe,Ye);
 	UnlockBuffer();
 	DispEndPaint();
 


Ttssh2-commit メーリングリストの案内