diff options
author | Neil <nyamatongwe@gmail.com> | 2021-03-20 16:25:35 +1100 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2021-03-20 16:25:35 +1100 |
commit | 434ea41aa400557964d73867008cfa8b1f64d8c4 (patch) | |
tree | 7a6981a28f521391a97cdbd4224fd81b2035bf24 | |
parent | 3d45c4bf974b6fdcce9712bbd3f0071a9618b89f (diff) | |
download | scintilla-mirror-434ea41aa400557964d73867008cfa8b1f64d8c4.tar.gz |
Use Surface::AllocatePixMap instead of changing an existing surface with
InitPixMap. Changed DropGraphics from releasing surfaces to deleting them.
This simplifies code and the added cost of allocating a new Surface is small.
-rw-r--r-- | cocoa/ScintillaCocoa.mm | 2 | ||||
-rw-r--r-- | doc/ScintillaHistory.html | 10 | ||||
-rwxr-xr-x | gtk/ScintillaGTK.cxx | 2 | ||||
-rw-r--r-- | src/EditView.cxx | 34 | ||||
-rw-r--r-- | src/EditView.h | 5 | ||||
-rw-r--r-- | src/Editor.cxx | 36 | ||||
-rw-r--r-- | src/Editor.h | 3 | ||||
-rw-r--r-- | src/MarginView.cxx | 34 | ||||
-rw-r--r-- | src/MarginView.h | 5 | ||||
-rw-r--r-- | win32/ScintillaWin.cxx | 6 |
10 files changed, 48 insertions, 89 deletions
diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm index 54b809cd9..8e7c80260 100644 --- a/cocoa/ScintillaCocoa.mm +++ b/cocoa/ScintillaCocoa.mm @@ -847,7 +847,7 @@ sptr_t ScintillaCocoa::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPar case SCI_SETBIDIRECTIONAL: bidirectional = static_cast<EditModel::Bidirectional>(wParam); // Invalidate all cached information including layout. - DropGraphics(true); + DropGraphics(); InvalidateStyleRedraw(); return 0; diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index a8de50362..2159127a8 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -571,7 +571,7 @@ </ul> <h2>Releases</h2> <h3> - <a href="https://www.scintilla.org/scite500.zip">Release 5.0.0</a> + <a href="https://www.scintilla.org/scite501.zip">Release 5.0.1</a> </h3> <ul> <li> @@ -581,6 +581,14 @@ Remove SetLexer, SetLexerLanguage, and LoadLexerLibrary methods. These have been superceded by Lexilla and the SetILexer API. </li> + <li> + Improve the platform layer interface. + Add support for stroke width and translucency to drawing methods. + Allow clipping to nest. + Add methods for UTF-8 text. + Add methods for encoding conversion. + Use these changes to improve appearance. + </li> </ul> <h3> <a href="https://www.scintilla.org/scite500.zip">Release 5.0.0</a> diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx index e0ec61245..50e46ecc8 100755 --- a/gtk/ScintillaGTK.cxx +++ b/gtk/ScintillaGTK.cxx @@ -368,7 +368,7 @@ void ScintillaGTK::UnMapThis() { try { //Platform::DebugPrintf("ScintillaGTK::unmap this\n"); gtk_widget_set_mapped(PWidget(wMain), FALSE); - DropGraphics(false); + DropGraphics(); gdk_window_hide(PWindow(wMain)); gtk_widget_unmap(PWidget(wText)); if (PWidget(scrollbarh)) diff --git a/src/EditView.cxx b/src/EditView.cxx index 8243169d0..a835ab0a0 100644 --- a/src/EditView.cxx +++ b/src/EditView.cxx @@ -251,28 +251,10 @@ void EditView::LinesAddedOrRemoved(Sci::Line lineOfPos, Sci::Line linesAdded) { } } -void EditView::DropGraphics(bool freeObjects) noexcept { - if (freeObjects) { - pixmapLine.reset(); - pixmapIndentGuide.reset(); - pixmapIndentGuideHighlight.reset(); - } else { - if (pixmapLine) - pixmapLine->Release(); - if (pixmapIndentGuide) - pixmapIndentGuide->Release(); - if (pixmapIndentGuideHighlight) - pixmapIndentGuideHighlight->Release(); - } -} - -void EditView::AllocateGraphics(const ViewStyle &vsDraw) { - if (!pixmapLine) - pixmapLine = Surface::Allocate(vsDraw.technology); - if (!pixmapIndentGuide) - pixmapIndentGuide = Surface::Allocate(vsDraw.technology); - if (!pixmapIndentGuideHighlight) - pixmapIndentGuideHighlight = Surface::Allocate(vsDraw.technology); +void EditView::DropGraphics() noexcept { + pixmapLine.reset(); + pixmapIndentGuide.reset(); + pixmapIndentGuideHighlight.reset(); } static const char *ControlCharacterString(unsigned char ch) noexcept { @@ -311,11 +293,11 @@ static void DrawTabArrow(Surface *surface, PRectangle rcTab, int ymid, const Vie } } -void EditView::RefreshPixMaps(Surface *surfaceWindow, WindowID wid, const ViewStyle &vsDraw) { - if (!pixmapIndentGuide->Initialised()) { +void EditView::RefreshPixMaps(Surface *surfaceWindow, const ViewStyle &vsDraw) { + if (!pixmapIndentGuide) { // 1 extra pixel in height so can handle odd/even positions and so produce a continuous line - pixmapIndentGuide->InitPixMap(1, vsDraw.lineHeight + 1, surfaceWindow, wid); - pixmapIndentGuideHighlight->InitPixMap(1, vsDraw.lineHeight + 1, surfaceWindow, wid); + pixmapIndentGuide = surfaceWindow->AllocatePixMap(1, vsDraw.lineHeight + 1); + pixmapIndentGuideHighlight = surfaceWindow->AllocatePixMap(1, vsDraw.lineHeight + 1); const PRectangle rcIG = PRectangle::FromInts(0, 0, 1, vsDraw.lineHeight); pixmapIndentGuide->FillRectangle(rcIG, vsDraw.styles[STYLE_INDENTGUIDE].back); pixmapIndentGuideHighlight->FillRectangle(rcIG, vsDraw.styles[STYLE_BRACELIGHT].back); diff --git a/src/EditView.h b/src/EditView.h index 11fe5c659..f5df7143f 100644 --- a/src/EditView.h +++ b/src/EditView.h @@ -109,9 +109,8 @@ public: int GetNextTabstop(Sci::Line line, int x) const noexcept; void LinesAddedOrRemoved(Sci::Line lineOfPos, Sci::Line linesAdded); - void DropGraphics(bool freeObjects) noexcept; - void AllocateGraphics(const ViewStyle &vsDraw); - void RefreshPixMaps(Surface *surfaceWindow, WindowID wid, const ViewStyle &vsDraw); + void DropGraphics() noexcept; + void RefreshPixMaps(Surface *surfaceWindow, const ViewStyle &vsDraw); LineLayout *RetrieveLineLayout(Sci::Line lineNumber, const EditModel &model); void LayoutLine(const EditModel &model, Sci::Line line, Surface *surface, const ViewStyle &vstyle, diff --git a/src/Editor.cxx b/src/Editor.cxx index 15936e150..44c80451b 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -199,7 +199,7 @@ Editor::Editor() : durationWrapOneLine(0.00001, 0.000001, 0.0001) { Editor::~Editor() { pdoc->RemoveWatcher(this, 0); - DropGraphics(true); + DropGraphics(); } void Editor::Finalise() { @@ -262,21 +262,15 @@ void Editor::SetRepresentations() { } } -void Editor::DropGraphics(bool freeObjects) noexcept { - marginView.DropGraphics(freeObjects); - view.DropGraphics(freeObjects); -} - -void Editor::AllocateGraphics() { - marginView.AllocateGraphics(vs); - view.AllocateGraphics(vs); +void Editor::DropGraphics() noexcept { + marginView.DropGraphics(); + view.DropGraphics(); } void Editor::InvalidateStyleData() { stylesValid = false; vs.technology = technology; - DropGraphics(false); - AllocateGraphics(); + DropGraphics(); view.llc.Invalidate(LineLayout::ValidLevel::invalid); view.posCache.Clear(); } @@ -1677,7 +1671,6 @@ void Editor::PaintSelMargin(Surface *surfaceWindow, const PRectangle &rc) { if (vs.fixedColumnWidth == 0) return; - AllocateGraphics(); RefreshStyleData(); RefreshPixMaps(surfaceWindow); @@ -1719,18 +1712,16 @@ void Editor::PaintSelMargin(Surface *surfaceWindow, const PRectangle &rc) { } void Editor::RefreshPixMaps(Surface *surfaceWindow) { - view.RefreshPixMaps(surfaceWindow, wMain.GetID(), vs); - marginView.RefreshPixMaps(surfaceWindow, wMain.GetID(), vs); + view.RefreshPixMaps(surfaceWindow, vs); + marginView.RefreshPixMaps(surfaceWindow, vs); if (view.bufferedDraw) { const PRectangle rcClient = GetClientRectangle(); - if (!view.pixmapLine->Initialised()) { - - view.pixmapLine->InitPixMap(static_cast<int>(rcClient.Width()), vs.lineHeight, - surfaceWindow, wMain.GetID()); + if (!view.pixmapLine) { + view.pixmapLine = surfaceWindow->AllocatePixMap(static_cast<int>(rcClient.Width()), vs.lineHeight); } - if (!marginView.pixmapSelMargin->Initialised()) { - marginView.pixmapSelMargin->InitPixMap(vs.fixedColumnWidth, - static_cast<int>(rcClient.Height()), surfaceWindow, wMain.GetID()); + if (!marginView.pixmapSelMargin) { + marginView.pixmapSelMargin = surfaceWindow->AllocatePixMap(vs.fixedColumnWidth, + static_cast<int>(rcClient.Height())); } } } @@ -1738,7 +1729,6 @@ void Editor::RefreshPixMaps(Surface *surfaceWindow) { void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { //Platform::DebugPrintf("Paint:%1d (%3d,%3d) ... (%3d,%3d)\n", // paintingAllText, rcArea.left, rcArea.top, rcArea.right, rcArea.bottom); - AllocateGraphics(); RefreshStyleData(); if (paintState == PaintState::abandoned) @@ -1882,7 +1872,7 @@ void Editor::SetScrollBars() { } void Editor::ChangeSize() { - DropGraphics(false); + DropGraphics(); SetScrollBars(); if (Wrapping()) { PRectangle rcTextArea = GetClientRectangle(); diff --git a/src/Editor.h b/src/Editor.h index fc3a84ecd..d4f997af6 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -284,8 +284,7 @@ protected: // ScintillaBase subclass needs access to much of Editor void InvalidateStyleRedraw(); void RefreshStyleData(); void SetRepresentations(); - void DropGraphics(bool freeObjects) noexcept; - void AllocateGraphics(); + void DropGraphics() noexcept; // The top left visible point in main window coordinates. Will be 0,0 except for // scroll views where it will be equivalent to the current scroll position. diff --git a/src/MarginView.cxx b/src/MarginView.cxx index 4d040776d..913fd0e2d 100644 --- a/src/MarginView.cxx +++ b/src/MarginView.cxx @@ -109,35 +109,17 @@ MarginView::MarginView() noexcept { customDrawWrapMarker = nullptr; } -void MarginView::DropGraphics(bool freeObjects) noexcept { - if (freeObjects) { - pixmapSelMargin.reset(); - pixmapSelPattern.reset(); - pixmapSelPatternOffset1.reset(); - } else { - if (pixmapSelMargin) - pixmapSelMargin->Release(); - if (pixmapSelPattern) - pixmapSelPattern->Release(); - if (pixmapSelPatternOffset1) - pixmapSelPatternOffset1->Release(); - } -} - -void MarginView::AllocateGraphics(const ViewStyle &vsDraw) { - if (!pixmapSelMargin) - pixmapSelMargin = Surface::Allocate(vsDraw.technology); - if (!pixmapSelPattern) - pixmapSelPattern = Surface::Allocate(vsDraw.technology); - if (!pixmapSelPatternOffset1) - pixmapSelPatternOffset1 = Surface::Allocate(vsDraw.technology); +void MarginView::DropGraphics() noexcept { + pixmapSelMargin.reset(); + pixmapSelPattern.reset(); + pixmapSelPatternOffset1.reset(); } -void MarginView::RefreshPixMaps(Surface *surfaceWindow, WindowID wid, const ViewStyle &vsDraw) { - if (!pixmapSelPattern->Initialised()) { +void MarginView::RefreshPixMaps(Surface *surfaceWindow, const ViewStyle &vsDraw) { + if (!pixmapSelPattern) { const int patternSize = 8; - pixmapSelPattern->InitPixMap(patternSize, patternSize, surfaceWindow, wid); - pixmapSelPatternOffset1->InitPixMap(patternSize, patternSize, surfaceWindow, wid); + pixmapSelPattern = surfaceWindow->AllocatePixMap(patternSize, patternSize); + pixmapSelPatternOffset1 = surfaceWindow->AllocatePixMap(patternSize, patternSize); // This complex procedure is to reproduce the checkerboard dithered pattern used by windows // for scroll bars and Visual Studio for its selection margin. The colour of this pattern is half // way between the chrome colour and the chrome highlight colour making a nice transition diff --git a/src/MarginView.h b/src/MarginView.h index bb1981ed8..9d74ddb5e 100644 --- a/src/MarginView.h +++ b/src/MarginView.h @@ -34,9 +34,8 @@ public: MarginView() noexcept; - void DropGraphics(bool freeObjects) noexcept; - void AllocateGraphics(const ViewStyle &vsDraw); - void RefreshPixMaps(Surface *surfaceWindow, WindowID wid, const ViewStyle &vsDraw); + void DropGraphics() noexcept; + void RefreshPixMaps(Surface *surfaceWindow, const ViewStyle &vsDraw); void PaintMargin(Surface *surface, Sci::Line topLine, PRectangle rc, PRectangle rcMargin, const EditModel &model, const ViewStyle &vs); }; diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index 2b6748fb0..44d08af71 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -670,7 +670,7 @@ void ScintillaWin::EnsureRenderTarget(HDC hdc) { #endif // Pixmaps were created to be compatible with previous render target so // need to be recreated. - DropGraphics(false); + DropGraphics(); } if ((technology == SC_TECHNOLOGY_DIRECTWRITEDC) && pRenderTarget) { @@ -1833,7 +1833,7 @@ sptr_t ScintillaWin::SciMessage(unsigned int iMessage, uptr_t wParam, sptr_t lPa #endif technology = technologyNew; // Invalidate all cached information including layout. - DropGraphics(true); + DropGraphics(); InvalidateStyleRedraw(); } } @@ -1846,7 +1846,7 @@ sptr_t ScintillaWin::SciMessage(unsigned int iMessage, uptr_t wParam, sptr_t lPa bidirectional = static_cast<EditModel::Bidirectional>(wParam); } // Invalidate all cached information including layout. - DropGraphics(true); + DropGraphics(); InvalidateStyleRedraw(); break; |