From dd9ae27be2d1b983638337f24685e6458360dfa3 Mon Sep 17 00:00:00 2001 From: Neil Date: Fri, 19 Mar 2021 15:04:38 +1100 Subject: Implement PopClip to allow local clipping. --- gtk/PlatGTK.cxx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'gtk') 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_) { -- cgit v1.2.3