diff options
author | Neil <nyamatongwe@gmail.com> | 2021-03-19 15:44:55 +1100 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2021-03-19 15:44:55 +1100 |
commit | 09534ab81f72ce766c8d13ea13216dd589d41a1c (patch) | |
tree | 2bb190bb18294936a55b1e2c6e70961f22268968 | |
parent | dd9ae27be2d1b983638337f24685e6458360dfa3 (diff) | |
download | scintilla-mirror-09534ab81f72ce766c8d13ea13216dd589d41a1c.tar.gz |
Add an explicit FlushDrawing method to Surface that should be called after
completing a bitmap. Currently only has a real implementation on Direct2D.
Avoiding implicit flushes inside Copy and FillRectangle produced a 23% speed
improvement on files with about 1 indentation guide per line as the drawing
pipeline was being flushed for each indentation guide.
-rw-r--r-- | cocoa/PlatCocoa.h | 1 | ||||
-rw-r--r-- | cocoa/PlatCocoa.mm | 3 | ||||
-rwxr-xr-x | gtk/PlatGTK.cxx | 4 | ||||
-rw-r--r-- | qt/ScintillaEditBase/PlatQt.cpp | 4 | ||||
-rw-r--r-- | qt/ScintillaEditBase/PlatQt.h | 1 | ||||
-rw-r--r-- | src/EditView.cxx | 3 | ||||
-rw-r--r-- | src/Editor.cxx | 1 | ||||
-rw-r--r-- | src/MarginView.cxx | 2 | ||||
-rw-r--r-- | src/Platform.h | 1 | ||||
-rw-r--r-- | win32/PlatWin.cxx | 25 |
10 files changed, 32 insertions, 13 deletions
diff --git a/cocoa/PlatCocoa.h b/cocoa/PlatCocoa.h index 8f959014b..1ddb203c7 100644 --- a/cocoa/PlatCocoa.h +++ b/cocoa/PlatCocoa.h @@ -120,6 +120,7 @@ public: void SetClip(PRectangle rc) override; void PopClip() override; void FlushCachedState() override; + void FlushDrawing() override; void SetUnicodeMode(bool unicodeMode_) override; void SetDBCSMode(int codePage_) override; diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm index f5f69608e..2e3ab2d57 100644 --- a/cocoa/PlatCocoa.mm +++ b/cocoa/PlatCocoa.mm @@ -1294,6 +1294,9 @@ void SurfaceImpl::SetDBCSMode(int codePage_) { void SurfaceImpl::SetBidiR2L(bool) { } +void SurfaceImpl::FlushDrawing() { +} + std::unique_ptr<Surface> Surface::Allocate(int) { return std::make_unique<SurfaceImpl>(); } diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx index 3b19df3ba..3f0918886 100755 --- a/gtk/PlatGTK.cxx +++ b/gtk/PlatGTK.cxx @@ -189,6 +189,7 @@ public: void SetClip(PRectangle rc) override; void PopClip() override; void FlushCachedState() override; + void FlushDrawing() override; void SetUnicodeMode(bool unicodeMode_) override; void SetDBCSMode(int codePage) override; @@ -981,6 +982,9 @@ void SurfaceImpl::SetDBCSMode(int codePage) { void SurfaceImpl::SetBidiR2L(bool) { } +void SurfaceImpl::FlushDrawing() { +} + std::unique_ptr<Surface> Surface::Allocate(int) { return std::make_unique<SurfaceImpl>(); } diff --git a/qt/ScintillaEditBase/PlatQt.cpp b/qt/ScintillaEditBase/PlatQt.cpp index ce6f0313b..6a26d47c4 100644 --- a/qt/ScintillaEditBase/PlatQt.cpp +++ b/qt/ScintillaEditBase/PlatQt.cpp @@ -612,6 +612,10 @@ void SurfaceImpl::SetBidiR2L(bool) { } +void SurfaceImpl::FlushDrawing() +{ +} + QPaintDevice *SurfaceImpl::GetPaintDevice() { return device; diff --git a/qt/ScintillaEditBase/PlatQt.h b/qt/ScintillaEditBase/PlatQt.h index 4069898ff..c690e7697 100644 --- a/qt/ScintillaEditBase/PlatQt.h +++ b/qt/ScintillaEditBase/PlatQt.h @@ -135,6 +135,7 @@ public: void SetClip(PRectangle rc) override; void PopClip() override; void FlushCachedState() override; + void FlushDrawing() override; void SetUnicodeMode(bool unicodeMode_) override; void SetDBCSMode(int codePage_) override; diff --git a/src/EditView.cxx b/src/EditView.cxx index 5d15abf12..8243169d0 100644 --- a/src/EditView.cxx +++ b/src/EditView.cxx @@ -324,6 +324,8 @@ void EditView::RefreshPixMaps(Surface *surfaceWindow, WindowID wid, const ViewSt pixmapIndentGuide->FillRectangle(rcPixel, vsDraw.styles[STYLE_INDENTGUIDE].fore); pixmapIndentGuideHighlight->FillRectangle(rcPixel, vsDraw.styles[STYLE_BRACELIGHT].fore); } + pixmapIndentGuide->FlushDrawing(); + pixmapIndentGuideHighlight->FlushDrawing(); } } @@ -2349,6 +2351,7 @@ void EditView::PaintText(Surface *surfaceWindow, const EditModel &model, PRectan const PRectangle rcCopyArea = PRectangle::FromInts(vsDraw.textStart - leftTextOverlap, yposScreen, static_cast<int>(rcClient.right - vsDraw.rightMarginWidth), yposScreen + vsDraw.lineHeight); + pixmapLine->FlushDrawing(); surfaceWindow->Copy(rcCopyArea, from, *pixmapLine); } diff --git a/src/Editor.cxx b/src/Editor.cxx index c0a0135e1..15936e150 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -1713,6 +1713,7 @@ void Editor::PaintSelMargin(Surface *surfaceWindow, const PRectangle &rc) { marginView.PaintMargin(surface, topLine, rc, rcMargin, *this, vs); if (view.bufferedDraw) { + marginView.pixmapSelMargin->FlushDrawing(); surfaceWindow->Copy(rcMargin, Point(rcMargin.left, rcMargin.top), *marginView.pixmapSelMargin); } } diff --git a/src/MarginView.cxx b/src/MarginView.cxx index fbe3488c0..4d040776d 100644 --- a/src/MarginView.cxx +++ b/src/MarginView.cxx @@ -172,6 +172,8 @@ void MarginView::RefreshPixMaps(Surface *surfaceWindow, WindowID wid, const View pixmapSelPatternOffset1->FillRectangle(rcPixel, colourFMFill); } } + pixmapSelPattern->FlushDrawing(); + pixmapSelPatternOffset1->FlushDrawing(); } } diff --git a/src/Platform.h b/src/Platform.h index bdb6a161d..3333d3d4c 100644 --- a/src/Platform.h +++ b/src/Platform.h @@ -217,6 +217,7 @@ public: virtual void SetClip(PRectangle rc)=0; virtual void PopClip()=0; virtual void FlushCachedState()=0; + virtual void FlushDrawing()=0; virtual void SetUnicodeMode(bool unicodeMode_)=0; virtual void SetDBCSMode(int codePage)=0; diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index 18cf7bca7..26a351871 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -515,6 +515,7 @@ public: void SetClip(PRectangle rc) override; void PopClip() override; void FlushCachedState() override; + void FlushDrawing() override; void SetUnicodeMode(bool unicodeMode_) override; void SetDBCSMode(int codePage_) override; @@ -1106,6 +1107,9 @@ void SurfaceGDI::FlushCachedState() { brush = {}; } +void SurfaceGDI::FlushDrawing() { +} + void SurfaceGDI::SetUnicodeMode(bool unicodeMode_) { unicodeMode=unicodeMode_; } @@ -1177,8 +1181,6 @@ public: int Supports(int feature) noexcept override; bool Initialised() override; - HRESULT FlushDrawing(); - void PenColour(ColourDesired fore) override; void D2DPenColour(ColourDesired fore, int alpha=255); int LogPixelsY() override; @@ -1215,6 +1217,7 @@ public: void SetClip(PRectangle rc) override; void PopClip() override; void FlushCachedState() override; + void FlushDrawing() override; void SetUnicodeMode(bool unicodeMode_) override; void SetDBCSMode(int codePage_) override; @@ -1285,10 +1288,6 @@ bool SurfaceD2D::Initialised() { return pRenderTarget != nullptr; } -HRESULT SurfaceD2D::FlushDrawing() { - return pRenderTarget->Flush(); -} - void SurfaceD2D::Init(WindowID wid) { Release(); SetScale(wid); @@ -1485,7 +1484,6 @@ void SurfaceD2D::FillRectangle(PRectangle rc, ColourDesired back) { void SurfaceD2D::FillRectangle(PRectangle rc, Surface &surfacePattern) { SurfaceD2D *psurfOther = dynamic_cast<SurfaceD2D *>(&surfacePattern); PLATFORM_ASSERT(psurfOther); - psurfOther->FlushDrawing(); ID2D1Bitmap *pBitmap = nullptr; HRESULT hr = psurfOther->GetBitmap(&pBitmap); if (SUCCEEDED(hr) && pBitmap) { @@ -1642,18 +1640,13 @@ void SurfaceD2D::Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back) void SurfaceD2D::Copy(PRectangle rc, Point from, Surface &surfaceSource) { SurfaceD2D &surfOther = dynamic_cast<SurfaceD2D &>(surfaceSource); - surfOther.FlushDrawing(); ID2D1Bitmap *pBitmap = nullptr; - HRESULT hr = surfOther.GetBitmap(&pBitmap); + const HRESULT hr = surfOther.GetBitmap(&pBitmap); if (SUCCEEDED(hr) && pBitmap) { const D2D1_RECT_F rcDestination = RectangleFromPRectangle(rc); D2D1_RECT_F rcSource = {from.x, from.y, from.x + rc.Width(), from.y + rc.Height()}; pRenderTarget->DrawBitmap(pBitmap, rcDestination, 1.0f, D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, rcSource); - hr = pRenderTarget->Flush(); - if (FAILED(hr)) { - Platform::DebugPrintf("Failed Flush 0x%lx\n", hr); - } ReleaseUnknown(pBitmap); } } @@ -2268,6 +2261,12 @@ void SurfaceD2D::PopClip() { void SurfaceD2D::FlushCachedState() { } +void SurfaceD2D::FlushDrawing() { + if (pRenderTarget) { + pRenderTarget->Flush(); + } +} + void SurfaceD2D::SetUnicodeMode(bool unicodeMode_) { unicodeMode=unicodeMode_; } |