diff options
| -rw-r--r-- | doc/ScintillaHistory.html | 6 | ||||
| -rw-r--r-- | src/EditView.cxx | 35 | ||||
| -rw-r--r-- | src/Editor.cxx | 2 | ||||
| -rw-r--r-- | src/ViewStyle.cxx | 45 | ||||
| -rw-r--r-- | src/ViewStyle.h | 2 | 
5 files changed, 56 insertions, 34 deletions
| diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index 66638ea6a..b3225f3a7 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -497,6 +497,12 @@  	The Scintilla framework on Cocoa now contains version numbers.  	</li>  	<li> +	Optimise marker redrawing by only drawing affected lines when markers shown in the text. +	</li> +	<li> +	When SC_MARK_UNDERLINE if not assigned to a margin, stop drawing the whole line. +	</li> +	<li>  	When reverting an untitled document in SciTE, just clear it with no message about a file.  	<a href="http://sourceforge.net/p/scintilla/bugs/1764/">Bug #1764</a>.  	</li> diff --git a/src/EditView.cxx b/src/EditView.cxx index f8912a991..072a715f4 100644 --- a/src/EditView.cxx +++ b/src/EditView.cxx @@ -1408,27 +1408,26 @@ static void DrawTranslucentLineState(Surface *surface, const EditModel &model, c  	if ((model.caret.active || vsDraw.alwaysShowCaretLineBackground) && vsDraw.showCaretLineBackground && ll->containsCaret) {  		SimpleAlphaRectangle(surface, rcLine, vsDraw.caretLineBackground, vsDraw.caretLineAlpha);  	} -	int marks = model.pdoc->GetMark(line); -	for (int markBit = 0; (markBit < 32) && marks; markBit++) { -		if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_BACKGROUND)) { -			SimpleAlphaRectangle(surface, rcLine, vsDraw.markers[markBit].back, vsDraw.markers[markBit].alpha); -		} else if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_UNDERLINE)) { -			PRectangle rcUnderline = rcLine; -			rcUnderline.top = rcUnderline.bottom - 2; -			SimpleAlphaRectangle(surface, rcUnderline, vsDraw.markers[markBit].back, vsDraw.markers[markBit].alpha); +	const int marksOfLine = model.pdoc->GetMark(line); +	int marksDrawnInText = marksOfLine & vsDraw.maskDrawInText; +	for (int markBit = 0; (markBit < 32) && marksDrawnInText; markBit++) { +		if (marksDrawnInText & 1) { +			if (vsDraw.markers[markBit].markType == SC_MARK_BACKGROUND) { +				SimpleAlphaRectangle(surface, rcLine, vsDraw.markers[markBit].back, vsDraw.markers[markBit].alpha); +			} else if (vsDraw.markers[markBit].markType == SC_MARK_UNDERLINE) { +				PRectangle rcUnderline = rcLine; +				rcUnderline.top = rcUnderline.bottom - 2; +				SimpleAlphaRectangle(surface, rcUnderline, vsDraw.markers[markBit].back, vsDraw.markers[markBit].alpha); +			}  		} -		marks >>= 1; +		marksDrawnInText >>= 1;  	} -	if (vsDraw.maskInLine) { -		int marksMasked = model.pdoc->GetMark(line) & vsDraw.maskInLine; -		if (marksMasked) { -			for (int markBit = 0; (markBit < 32) && marksMasked; markBit++) { -				if ((marksMasked & 1) && (vsDraw.markers[markBit].markType != SC_MARK_EMPTY)) { -					SimpleAlphaRectangle(surface, rcLine, vsDraw.markers[markBit].back, vsDraw.markers[markBit].alpha); -				} -				marksMasked >>= 1; -			} +	int marksDrawnInLine = marksOfLine & vsDraw.maskInLine; +	for (int markBit = 0; (markBit < 32) && marksDrawnInLine; markBit++) { +		if (marksDrawnInLine & 1) { +			SimpleAlphaRectangle(surface, rcLine, vsDraw.markers[markBit].back, vsDraw.markers[markBit].alpha);  		} +		marksDrawnInLine >>= 1;  	}  } diff --git a/src/Editor.cxx b/src/Editor.cxx index 165bc9fc2..2a0ac420b 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -478,7 +478,7 @@ void Editor::Redraw() {  }  void Editor::RedrawSelMargin(int line, bool allAfter) { -	const bool markersInText = vs.maskInLine != 0; +	const bool markersInText = vs.maskInLine || vs.maskDrawInText;  	if (!wMargin.GetID() || markersInText) {	// May affect text area so may need to abandon and retry  		if (AbandonPaint()) {  			return; diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx index 7ece73b2e..e8bf51363 100644 --- a/src/ViewStyle.cxx +++ b/src/ViewStyle.cxx @@ -151,6 +151,7 @@ ViewStyle::ViewStyle(const ViewStyle &source) {  		ms[margin] = source.ms[margin];  	}  	maskInLine = source.maskInLine; +	maskDrawInText = source.maskDrawInText;  	fixedColumnWidth = source.fixedColumnWidth;  	marginInside = source.marginInside;  	textStart = source.textStart; @@ -191,6 +192,32 @@ ViewStyle::~ViewStyle() {  	fonts.clear();  } +void ViewStyle::CalculateMarginWidthAndMask() { +	fixedColumnWidth = marginInside ? leftMarginWidth : 0; +	maskInLine = 0xffffffff; +	int maskDefinedMarkers = 0; +	for (int margin = 0; margin <= SC_MAX_MARGIN; margin++) { +		fixedColumnWidth += ms[margin].width; +		if (ms[margin].width > 0) +			maskInLine &= ~ms[margin].mask; +		maskDefinedMarkers |= ms[margin].mask; +	} +	maskDrawInText = 0; +	for (int markBit = 0; markBit < 32; markBit++) { +		const int maskBit = 1 << markBit; +		switch (markers[markBit].markType) { +		case SC_MARK_EMPTY: +			maskInLine &= ~maskBit; +			break; +		case SC_MARK_BACKGROUND: +		case SC_MARK_UNDERLINE: +			maskInLine &= ~maskBit; +			maskDrawInText |= maskDefinedMarkers & maskBit; +			break; +		} +	} +} +  void ViewStyle::Init(size_t stylesSize_) {  	AllocStyles(stylesSize_);  	nextExtendedStyle = 256; @@ -265,13 +292,7 @@ void ViewStyle::Init(size_t stylesSize_) {  	ms[2].width = 0;  	ms[2].mask = 0;  	marginInside = true; -	fixedColumnWidth = marginInside ? leftMarginWidth : 0; -	maskInLine = 0xffffffff; -	for (int margin=0; margin <= SC_MAX_MARGIN; margin++) { -		fixedColumnWidth += ms[margin].width; -		if (ms[margin].width > 0) -			maskInLine &= ~ms[margin].mask; -	} +	CalculateMarginWidthAndMask();  	textStart = marginInside ? fixedColumnWidth : leftMarginWidth;  	zoomLevel = 0;  	viewWhitespace = wsInvisible; @@ -368,13 +389,7 @@ void ViewStyle::Refresh(Surface &surface, int tabInChars) {  		controlCharWidth = surface.WidthChar(styles[STYLE_CONTROLCHAR].font, static_cast<char>(controlCharSymbol));  	} -	fixedColumnWidth = marginInside ? leftMarginWidth : 0; -	maskInLine = 0xffffffff; -	for (int margin=0; margin <= SC_MAX_MARGIN; margin++) { -		fixedColumnWidth += ms[margin].width; -		if (ms[margin].width > 0) -			maskInLine &= ~ms[margin].mask; -	} +	CalculateMarginWidthAndMask();  	textStart = marginInside ? fixedColumnWidth : leftMarginWidth;  } @@ -477,7 +492,7 @@ ColourOptional ViewStyle::Background(int marksOfLine, bool caretActive, bool lin  		int marksMasked = marksOfLine & maskInLine;  		if (marksMasked) {  			for (int markBit = 0; (markBit < 32) && marksMasked; markBit++) { -				if ((marksMasked & 1) && (markers[markBit].markType != SC_MARK_EMPTY) && +				if ((marksMasked & 1) &&  					(markers[markBit].alpha == SC_ALPHA_NOALPHA)) {  					background = ColourOptional(markers[markBit].back, true);  				} diff --git a/src/ViewStyle.h b/src/ViewStyle.h index 930ad104c..242e7e38e 100644 --- a/src/ViewStyle.h +++ b/src/ViewStyle.h @@ -114,6 +114,7 @@ public:  	int leftMarginWidth;	///< Spacing margin on left of text  	int rightMarginWidth;	///< Spacing margin on right of text  	int maskInLine;	///< Mask for markers to be put into text because there is nowhere for them to go in margin +	int maskDrawInText;	///< Mask for markers that always draw in text  	MarginStyle ms[SC_MAX_MARGIN+1];  	int fixedColumnWidth;	///< Total width of margins  	bool marginInside;	///< true: margin included in text view, false: separate views @@ -160,6 +161,7 @@ public:  	ViewStyle();  	ViewStyle(const ViewStyle &source);  	~ViewStyle(); +	void CalculateMarginWidthAndMask();  	void Init(size_t stylesSize_=256);  	void Refresh(Surface &surface, int tabInChars);  	void ReleaseAllExtendedStyles(); | 
