aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--cocoa/PlatCocoa.h1
-rw-r--r--cocoa/PlatCocoa.mm5
-rwxr-xr-xgtk/PlatGTK.cxx14
-rw-r--r--qt/ScintillaEditBase/PlatQt.cpp8
-rw-r--r--qt/ScintillaEditBase/PlatQt.h1
-rw-r--r--src/EditView.cxx7
-rw-r--r--src/Editor.cxx5
-rw-r--r--src/Platform.h1
-rw-r--r--win32/PlatWin.cxx15
9 files changed, 54 insertions, 3 deletions
diff --git a/cocoa/PlatCocoa.h b/cocoa/PlatCocoa.h
index 870b61aa3..8f959014b 100644
--- a/cocoa/PlatCocoa.h
+++ b/cocoa/PlatCocoa.h
@@ -118,6 +118,7 @@ public:
XYPOSITION AverageCharWidth(const Font *font_) override;
void SetClip(PRectangle rc) override;
+ void PopClip() override;
void FlushCachedState() override;
void SetUnicodeMode(bool unicodeMode_) override;
diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm
index b662c25e6..f5f69608e 100644
--- a/cocoa/PlatCocoa.mm
+++ b/cocoa/PlatCocoa.mm
@@ -1270,9 +1270,14 @@ XYPOSITION SurfaceImpl::AverageCharWidth(const Font *font_) {
}
void SurfaceImpl::SetClip(PRectangle rc) {
+ CGContextSaveGState(gc);
CGContextClipToRect(gc, PRectangleToCGRect(rc));
}
+void SurfaceImpl::PopClip() {
+ CGContextRestoreGState(gc);
+}
+
void SurfaceImpl::FlushCachedState() {
CGContextSynchronize(gc);
}
diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx
index 33a0b8917..3b19df3ba 100755
--- a/gtk/PlatGTK.cxx
+++ b/gtk/PlatGTK.cxx
@@ -136,6 +136,7 @@ class SurfaceImpl : public Surface {
Converter conv;
int characterSet;
void SetConverter(int characterSet_);
+ void CairoRectangle(PRectangle rc);
public:
SurfaceImpl() noexcept;
// Deleted so SurfaceImpl objects can not be copied.
@@ -186,6 +187,7 @@ public:
XYPOSITION AverageCharWidth(const Font *font_) override;
void SetClip(PRectangle rc) override;
+ void PopClip() override;
void FlushCachedState() override;
void SetUnicodeMode(bool unicodeMode_) override;
@@ -257,6 +259,10 @@ void SurfaceImpl::SetConverter(int characterSet_) {
}
}
+void SurfaceImpl::CairoRectangle(PRectangle rc) {
+ cairo_rectangle(context, rc.left, rc.top, rc.Width(), rc.Height());
+}
+
SurfaceImpl::SurfaceImpl() noexcept : et(singleByte),
context(nullptr),
psurf(nullptr),
@@ -950,10 +956,16 @@ XYPOSITION SurfaceImpl::AverageCharWidth(const Font *font_) {
void SurfaceImpl::SetClip(PRectangle rc) {
PLATFORM_ASSERT(context);
- cairo_rectangle(context, rc.left, rc.top, rc.Width(), rc.Height());
+ cairo_save(context);
+ CairoRectangle(rc);
cairo_clip(context);
}
+void SurfaceImpl::PopClip() {
+ PLATFORM_ASSERT(context);
+ cairo_restore(context);
+}
+
void SurfaceImpl::FlushCachedState() {}
void SurfaceImpl::SetUnicodeMode(bool unicodeMode_) {
diff --git a/qt/ScintillaEditBase/PlatQt.cpp b/qt/ScintillaEditBase/PlatQt.cpp
index 1b8f75c02..ce6f0313b 100644
--- a/qt/ScintillaEditBase/PlatQt.cpp
+++ b/qt/ScintillaEditBase/PlatQt.cpp
@@ -470,7 +470,7 @@ void SurfaceImpl::DrawTextClipped(PRectangle rc,
{
SetClip(rc);
DrawTextNoClip(rc, font, ybase, text, fore, back);
- GetPainter()->setClipping(false);
+ PopClip();
}
void SurfaceImpl::DrawTextTransparent(PRectangle rc,
@@ -489,9 +489,15 @@ void SurfaceImpl::DrawTextTransparent(PRectangle rc,
void SurfaceImpl::SetClip(PRectangle rc)
{
+ GetPainter()->save();
GetPainter()->setClipRect(QRectFFromPRect(rc));
}
+void SurfaceImpl::PopClip()
+{
+ GetPainter()->restore();
+}
+
void SurfaceImpl::MeasureWidths(const Font *font,
std::string_view text,
XYPOSITION *positions)
diff --git a/qt/ScintillaEditBase/PlatQt.h b/qt/ScintillaEditBase/PlatQt.h
index 7b43e0b02..4069898ff 100644
--- a/qt/ScintillaEditBase/PlatQt.h
+++ b/qt/ScintillaEditBase/PlatQt.h
@@ -133,6 +133,7 @@ public:
XYPOSITION AverageCharWidth(const Font *font) override;
void SetClip(PRectangle rc) override;
+ void PopClip() override;
void FlushCachedState() override;
void SetUnicodeMode(bool unicodeMode_) override;
diff --git a/src/EditView.cxx b/src/EditView.cxx
index 16614de48..5d15abf12 100644
--- a/src/EditView.cxx
+++ b/src/EditView.cxx
@@ -2246,7 +2246,8 @@ void EditView::PaintText(Surface *surfaceWindow, const EditModel &model, PRectan
// Remove selection margin from drawing area so text will not be drawn
// on it in unbuffered mode.
- if (!bufferedDraw && vsDraw.marginInside) {
+ const bool clipping = !bufferedDraw && vsDraw.marginInside;
+ if (clipping) {
PRectangle rcClipText = rcTextArea;
rcClipText.left -= leftTextOverlap;
surfaceWindow->SetClip(rcClipText);
@@ -2394,6 +2395,10 @@ void EditView::PaintText(Surface *surfaceWindow, const EditModel &model, PRectan
}
}
}
+
+ if (clipping)
+ surfaceWindow->PopClip();
+
//Platform::DebugPrintf("start display %d, offset = %d\n", model.pdoc->Length(), model.xOffset);
#if defined(TIME_PAINTING)
Platform::DebugPrintf(
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 5877239f0..c0a0135e1 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -1806,6 +1806,8 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
NeedWrapping(pcs->DocFromDisplay(topLine));
}
}
+ if (!view.bufferedDraw)
+ surfaceWindow->PopClip();
return;
}
@@ -1818,6 +1820,9 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
}
}
+ if (!view.bufferedDraw)
+ surfaceWindow->PopClip();
+
NotifyPainted();
}
diff --git a/src/Platform.h b/src/Platform.h
index 382ae30ee..bdb6a161d 100644
--- a/src/Platform.h
+++ b/src/Platform.h
@@ -215,6 +215,7 @@ public:
virtual XYPOSITION AverageCharWidth(const Font *font_)=0;
virtual void SetClip(PRectangle rc)=0;
+ virtual void PopClip()=0;
virtual void FlushCachedState()=0;
virtual void SetUnicodeMode(bool unicodeMode_)=0;
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx
index 014c09793..18cf7bca7 100644
--- a/win32/PlatWin.cxx
+++ b/win32/PlatWin.cxx
@@ -513,6 +513,7 @@ public:
XYPOSITION AverageCharWidth(const Font *font_) override;
void SetClip(PRectangle rc) override;
+ void PopClip() override;
void FlushCachedState() override;
void SetUnicodeMode(bool unicodeMode_) override;
@@ -1091,10 +1092,15 @@ XYPOSITION SurfaceGDI::AverageCharWidth(const Font *font_) {
}
void SurfaceGDI::SetClip(PRectangle rc) {
+ ::SaveDC(hdc);
::IntersectClipRect(hdc, static_cast<int>(rc.left), static_cast<int>(rc.top),
static_cast<int>(rc.right), static_cast<int>(rc.bottom));
}
+void SurfaceGDI::PopClip() {
+ ::RestoreDC(hdc, -1);
+}
+
void SurfaceGDI::FlushCachedState() {
pen = {};
brush = {};
@@ -1207,6 +1213,7 @@ public:
XYPOSITION AverageCharWidth(const Font *font_) override;
void SetClip(PRectangle rc) override;
+ void PopClip() override;
void FlushCachedState() override;
void SetUnicodeMode(bool unicodeMode_) override;
@@ -2250,6 +2257,14 @@ void SurfaceD2D::SetClip(PRectangle rc) {
}
}
+void SurfaceD2D::PopClip() {
+ if (pRenderTarget) {
+ PLATFORM_ASSERT(clipsActive > 0);
+ pRenderTarget->PopAxisAlignedClip();
+ clipsActive--;
+ }
+}
+
void SurfaceD2D::FlushCachedState() {
}