Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2023-07-02 00:52:36 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2023-07-02 00:52:36 +1000
commit17af21fd421429b7a64c93c8b09e3f9ea436069a (patch)
tree165732dde2360fc56b9b08a1a25355b95575c132
parent210d6326fcbc87ad69e8a18fa60554d223739b7c (diff)
use raw wrapWidth ptr instead of Maybe
-rw-r--r--source/core/StarStringView.cpp1
-rw-r--r--source/rendering/StarTextPainter.cpp6
-rw-r--r--source/rendering/StarTextPainter.hpp2
3 files changed, 5 insertions, 4 deletions
diff --git a/source/core/StarStringView.cpp b/source/core/StarStringView.cpp
index 0399b86..8ad3b8c 100644
--- a/source/core/StarStringView.cpp
+++ b/source/core/StarStringView.cpp
@@ -295,6 +295,7 @@ size_t StringView::findFirstNotOf(StringView pattern, size_t beg) const {
}
size_t StringView::findNextBoundary(size_t index, bool backwards) const {
+ //TODO: Make this faster.
size_t mySize = size();
starAssert(index <= mySize);
if (!backwards && (index == mySize))
diff --git a/source/rendering/StarTextPainter.cpp b/source/rendering/StarTextPainter.cpp
index 48837a0..c779c96 100644
--- a/source/rendering/StarTextPainter.cpp
+++ b/source/rendering/StarTextPainter.cpp
@@ -206,7 +206,7 @@ int TextPainter::stringWidth(StringView s) {
return width;
}
-bool TextPainter::processWrapText(StringView text, Maybe<unsigned> wrapWidth, WrapTextCallback textFunc) {
+bool TextPainter::processWrapText(StringView text, unsigned* wrapWidth, WrapTextCallback textFunc) {
String font = m_renderSettings.font, setFont = font;
m_fontTextureGroup.switchFont(font);
int lines = 0;
@@ -351,7 +351,7 @@ List<StringView> TextPainter::wrapTextViews(StringView s, Maybe<unsigned> wrapWi
return true;
};
- processWrapText(s, wrapWidth, textCallback);
+ processWrapText(s, wrapWidth.ptr(), textCallback);
if (active)
views.push_back(current);
@@ -374,7 +374,7 @@ StringList TextPainter::wrapText(StringView s, Maybe<unsigned> wrapWidth) {
return true;
};
- processWrapText(s, wrapWidth, textCallback);
+ processWrapText(s, wrapWidth.ptr(), textCallback);
if (!current.empty())
result.append(move(current));
diff --git a/source/rendering/StarTextPainter.hpp b/source/rendering/StarTextPainter.hpp
index 8535a09..1a0b1d9 100644
--- a/source/rendering/StarTextPainter.hpp
+++ b/source/rendering/StarTextPainter.hpp
@@ -68,7 +68,7 @@ public:
typedef function<bool(StringView, int)> WrapTextCallback;
- bool processWrapText(StringView s, Maybe<unsigned> wrapWidth, WrapTextCallback textFunc);
+ bool processWrapText(StringView s, unsigned* wrapWidth, WrapTextCallback textFunc);
List<StringView> wrapTextViews(StringView s, Maybe<unsigned> wrapWidth);
StringList wrapText(StringView s, Maybe<unsigned> wrapWidth);