From 434ea41aa400557964d73867008cfa8b1f64d8c4 Mon Sep 17 00:00:00 2001 From: Neil Date: Sat, 20 Mar 2021 16:25:35 +1100 Subject: 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. --- src/EditView.cxx | 34 ++++++++-------------------------- 1 file changed, 8 insertions(+), 26 deletions(-) (limited to 'src/EditView.cxx') 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); -- cgit v1.2.3