aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornyamatongwe <devnull@localhost>2012-08-05 17:25:16 +1000
committernyamatongwe <devnull@localhost>2012-08-05 17:25:16 +1000
commitf69ba9aceede05a682156e755a12dae0321fb5e4 (patch)
tree1c462611b2d3da5fe25533b749d34d230e0f13c6
parent455081f4b96fde8d552bdf8fa772f9957f65c8ed (diff)
downloadscintilla-mirror-f69ba9aceede05a682156e755a12dae0321fb5e4.tar.gz
Add INDIC_SQUIGGLEPIXMAP as a faster version of INDIC_SQUIGGLE.
Based on work by Matthew Brush and Lex Trottman.
-rw-r--r--doc/ScintillaDoc.html11
-rw-r--r--include/Scintilla.h1
-rw-r--r--include/Scintilla.iface1
-rw-r--r--src/Indicator.cxx24
4 files changed, 37 insertions, 0 deletions
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html
index e0dc42bad..5e726b498 100644
--- a/doc/ScintillaDoc.html
+++ b/doc/ScintillaDoc.html
@@ -3811,6 +3811,17 @@ struct Sci_TextToFind {
Not available for OS X Carbon.</td>
</tr>
+ <tr>
+ <td align="left"><code>INDIC_SQUIGGLEPIXMAP</code></td>
+
+ <td align="center">13</td>
+
+ <td>A version of <code>INDIC_SQUIGGLE</code> that draws using a pixmap instead of
+ as a series of line segments for performance.
+ Measured to be between 3 and 6 times faster than <code>INDIC_SQUIGGLE</code> on GTK+.
+ Apperance will not be as good as <code>INDIC_SQUIGGLE</code> on OS X in HiDPI mode.</td>
+ </tr>
+
</tbody>
</table>
diff --git a/include/Scintilla.h b/include/Scintilla.h
index 4d467a175..63fe4fff5 100644
--- a/include/Scintilla.h
+++ b/include/Scintilla.h
@@ -262,6 +262,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define INDIC_DOTS 10
#define INDIC_SQUIGGLELOW 11
#define INDIC_DOTBOX 12
+#define INDIC_SQUIGGLEPIXMAP 13
#define INDIC_MAX 31
#define INDIC_CONTAINER 8
#define INDIC0_MASK 0x20
diff --git a/include/Scintilla.iface b/include/Scintilla.iface
index e31863cfd..138730e61 100644
--- a/include/Scintilla.iface
+++ b/include/Scintilla.iface
@@ -578,6 +578,7 @@ val INDIC_DASH=9
val INDIC_DOTS=10
val INDIC_SQUIGGLELOW=11
val INDIC_DOTBOX=12
+val INDIC_SQUIGGLEPIXMAP=13
val INDIC_MAX=31
val INDIC_CONTAINER=8
val INDIC0_MASK=0x20
diff --git a/src/Indicator.cxx b/src/Indicator.cxx
index bd17c3d1c..7eab44433 100644
--- a/src/Indicator.cxx
+++ b/src/Indicator.cxx
@@ -18,6 +18,11 @@
using namespace Scintilla;
#endif
+static PRectangle PixelGridAlign(const PRectangle &rc) {
+ // Move left and right side to nearest pixel to avoid blurry visuals
+ return PRectangle(int(rc.left + 0.5), rc.top, int(rc.right + 0.5), rc.bottom);
+}
+
void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine) {
surface->PenColour(fore);
int ymid = (rc.bottom + rc.top) / 2;
@@ -31,6 +36,25 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
y = 2 - y;
}
surface->LineTo(rc.right, rc.top + y); // Finish the line
+ } else if (style == INDIC_SQUIGGLEPIXMAP) {
+ PRectangle rcSquiggle = PixelGridAlign(rc);
+
+ int width = Platform::Minimum(4000, rcSquiggle.Width());
+ RGBAImage image(width, 3, 1.0, 0);
+ enum { alphaFull = 0xff, alphaSide = 0x2f, alphaSide2=0x5f };
+ for (int x = 0; x < width; x++) {
+ if (x%2) {
+ // Two halfway columns have a full pixel in middle flanked by light pixels
+ image.SetPixel(x, 0, fore, alphaSide);
+ image.SetPixel(x, 1, fore, alphaFull);
+ image.SetPixel(x, 2, fore, alphaSide);
+ } else {
+ // Extreme columns have a full pixel at bottom or top and a mid-tone pixel in centre
+ image.SetPixel(x, (x%4) ? 0 : 2, fore, alphaFull);
+ image.SetPixel(x, 1, fore, alphaSide2);
+ }
+ }
+ surface->DrawRGBAImage(rcSquiggle, image.GetWidth(), image.GetHeight(), image.Pixels());
} else if (style == INDIC_SQUIGGLELOW) {
surface->MoveTo(rc.left, rc.top);
int x = rc.left + 3;