diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-09-11 23:45:54 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-09-11 23:45:54 +0300 |
commit | 25417c357d46f3ba65d7ac1ef460d52ccea41a9b (patch) | |
tree | 0214c508c49763cfaec46d05075e37e4f8122d40 | |
parent | 35cd31e58751b72d69bb9ece02241d31b449d8a1 (diff) |
Cleanup
-rw-r--r-- | src/ui/documentwidget.c | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index b7b40aca..199b6aa9 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -1032,6 +1032,7 @@ static void allocVisBuffer_DocumentWidget_(const iDocumentWidget *d) { | |||
1032 | if (isVisible && !d->visBuffer->texture[0]) { | 1032 | if (isVisible && !d->visBuffer->texture[0]) { |
1033 | iZap(d->visBuffer->validRange); | 1033 | iZap(d->visBuffer->validRange); |
1034 | d->visBuffer->size = size; | 1034 | d->visBuffer->size = size; |
1035 | iAssert(size.x > 0); | ||
1035 | iForIndices(i, d->visBuffer->texture) { | 1036 | iForIndices(i, d->visBuffer->texture) { |
1036 | d->visBuffer->texture[i] = | 1037 | d->visBuffer->texture[i] = |
1037 | SDL_CreateTexture(renderer_Window(get_Window()), | 1038 | SDL_CreateTexture(renderer_Window(get_Window()), |
@@ -1066,7 +1067,7 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) | |||
1066 | } | 1067 | } |
1067 | } | 1068 | } |
1068 | invalidate_DocumentWidget_(d); | 1069 | invalidate_DocumentWidget_(d); |
1069 | allocVisBuffer_DocumentWidget_(d); | 1070 | deallocVisBuffer_DocumentWidget_(d); |
1070 | refresh_Widget(w); | 1071 | refresh_Widget(w); |
1071 | updateWindowTitle_DocumentWidget_(d); | 1072 | updateWindowTitle_DocumentWidget_(d); |
1072 | } | 1073 | } |
@@ -1815,17 +1816,6 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) { | |||
1815 | // drawRect_Paint(&d->paint, (iRect){ visPos, run->visBounds.size }, red_ColorId); | 1816 | // drawRect_Paint(&d->paint, (iRect){ visPos, run->visBounds.size }, red_ColorId); |
1816 | } | 1817 | } |
1817 | 1818 | ||
1818 | static iRangei intersect_Rangei_(iRangei a, iRangei b) { | ||
1819 | if (a.end < b.start || a.start > b.end) { | ||
1820 | return (iRangei){ 0, 0 }; | ||
1821 | } | ||
1822 | return (iRangei){ iMax(a.start, b.start), iMin(a.end, b.end) }; | ||
1823 | } | ||
1824 | |||
1825 | iLocalDef iBool isEmpty_Rangei_(iRangei d) { | ||
1826 | return size_Range(&d) == 0; | ||
1827 | } | ||
1828 | |||
1829 | static void draw_DocumentWidget_(const iDocumentWidget *d) { | 1819 | static void draw_DocumentWidget_(const iDocumentWidget *d) { |
1830 | const iWidget *w = constAs_Widget(d); | 1820 | const iWidget *w = constAs_Widget(d); |
1831 | const iRect bounds = bounds_Widget(w); | 1821 | const iRect bounds = bounds_Widget(w); |
@@ -1858,7 +1848,7 @@ static void draw_DocumentWidget_(const iDocumentWidget *d) { | |||
1858 | beginTarget_Paint(p, visBuf->texture[vbDst]); | 1848 | beginTarget_Paint(p, visBuf->texture[vbDst]); |
1859 | const iRect visBufferRect = { zero_I2(), visBuf->size }; | 1849 | const iRect visBufferRect = { zero_I2(), visBuf->size }; |
1860 | iRect drawRect = visBufferRect; | 1850 | iRect drawRect = visBufferRect; |
1861 | if (!isEmpty_Rangei_(intersect_Rangei_(visRange, visBuf->validRange))) { | 1851 | if (!isEmpty_Rangei(intersect_Rangei(visRange, visBuf->validRange))) { |
1862 | if (visRange.start < visBuf->validRange.start) { | 1852 | if (visRange.start < visBuf->validRange.start) { |
1863 | drawRange = (iRangei){ visRange.start, visBuf->validRange.start }; | 1853 | drawRange = (iRangei){ visRange.start, visBuf->validRange.start }; |
1864 | } | 1854 | } |