aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornyamatongwe <unknown>2003-03-13 12:54:57 +0000
committernyamatongwe <unknown>2003-03-13 12:54:57 +0000
commit7c0fd4b35c851e39842b9187a62ce785cdcab605 (patch)
tree945237310685eacc7e222196fabf3afb7a727019
parent3712f66d6b8eb6b1fdb5947a51f2b9cf12a72e6c (diff)
downloadscintilla-mirror-7c0fd4b35c851e39842b9187a62ce785cdcab605.tar.gz
Avoiding drawing strings consisting entirely of space characters
in transparent mode. Remembering pixel widths of all single character strings as many single character runs occur in source code. These add up to a 22% speed improvement.
-rw-r--r--gtk/PlatGTK.cxx23
1 files changed, 21 insertions, 2 deletions
diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx
index 073e51faa..56ead18a3 100644
--- a/gtk/PlatGTK.cxx
+++ b/gtk/PlatGTK.cxx
@@ -49,6 +49,7 @@
class FontHandle {
public:
int ascent;
+ int width[128];
GdkFont *pfont;
#ifdef USE_PANGO
PangoFontDescription *pfd;
@@ -59,12 +60,18 @@ public:
#ifdef USE_PANGO
pfd = 0;
#endif
+ for (int i=0;i<128;i++) {
+ width[i] = 0;
+ }
}
#ifdef USE_PANGO
FontHandle(PangoFontDescription *pfd_) {
ascent = 0;
pfont = 0;
pfd = pfd_;
+ for (int i=0;i<128;i++) {
+ width[i] = 0;
+ }
}
#endif
~FontHandle() {
@@ -1070,10 +1077,15 @@ void SurfaceImpl::DrawTextClipped(PRectangle rc, Font &font_, int ybase, const c
DrawTextBase(rc, font_, ybase, s, len, fore);
}
-// On GTK+, exactly same as DrawTextNoClip
void SurfaceImpl::DrawTextTransparent(PRectangle rc, Font &font_, int ybase, const char *s, int len,
ColourAllocated fore) {
- DrawTextBase(rc, font_, ybase, s, len, fore);
+ // Avoid drawing spaces in transparent mode
+ for (int i=0;i<len;i++) {
+ if (s[i] != ' ') {
+ DrawTextBase(rc, font_, ybase, s, len, fore);
+ return;
+ }
+ }
}
void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, int *positions) {
@@ -1081,6 +1093,10 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, int *positi
int totalWidth = 0;
#ifdef USE_PANGO
if (PFont(font_)->pfd) {
+ if (len == 1 && (static_cast<unsigned char>(*s) <= 127) && PFont(font_)->width[*s]) {
+ positions[0] = PFont(font_)->width[*s];
+ return;
+ }
PangoRectangle pos;
pango_layout_set_font_description(layout, PFont(font_)->pfd);
if (unicodeMode) {
@@ -1131,6 +1147,9 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, int *positi
delete []utfForm;
}
}
+ if (len == 1 && (static_cast<unsigned char>(*s) <= 127)) {
+ PFont(font_)->width[*s] = positions[0];
+ }
return;
}
#endif