Skip to content

Commit be4d704

Browse files
committed
Minor optimisation: only blit to screen when software rendered area forces an update
1 parent 4273945 commit be4d704

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

Source/NVGSurface.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -369,14 +369,19 @@ void NVGSurface::render()
369369
}
370370

371371
if (needsBufferSwap) {
372-
nvgBindFramebuffer(nullptr);
373-
nvgBlitFramebuffer(nvg, invalidFBO, 0, 0, viewWidth, viewHeight);
372+
blitToScreen();
373+
needsBufferSwap = false;
374+
}
375+
}
376+
377+
void NVGSurface::blitToScreen()
378+
{
379+
nvgBindFramebuffer(nullptr);
380+
nvgBlitFramebuffer(nvg, invalidFBO, 0, 0, viewWidth, viewHeight);
374381

375382
#ifdef NANOVG_GL_IMPLEMENTATION
376-
glContext->swapBuffers();
383+
glContext->swapBuffers();
377384
#endif
378-
needsBufferSwap = false;
379-
}
380385
}
381386

382387
void NVGSurface::renderFrameToImage(Image& image, Rectangle<int> area)

Source/NVGSurface.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ class NVGSurface final :
4141

4242
void renderAll();
4343
void render();
44+
45+
void blitToScreen();
4446

4547
bool makeContextActive();
4648

@@ -106,7 +108,6 @@ class NVGSurface final :
106108

107109
void addBufferedObject(NVGComponent* component);
108110
void removeBufferedObject(NVGComponent* component);
109-
110111

111112
private:
112113
float calculateRenderScale() const;

Source/PluginEditor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1894,7 +1894,7 @@ void PluginEditor::broughtToFront()
18941894

18951895
void PluginEditor::handleCommandMessage(int commandID)
18961896
{
1897-
nvgSurface.invalidateAll();
1897+
nvgSurface.blitToScreen();
18981898
}
18991899

19001900
void PluginEditor::timerCallback()

0 commit comments

Comments
 (0)