Skip to content

Commit dc3c652

Browse files
author
alcomposer
committed
Use improved blur shader with blur-process-fbo in nvgSurface
1 parent 76bb615 commit dc3c652

4 files changed

Lines changed: 13 additions & 3 deletions

File tree

Libraries/nanovg

Source/Canvas.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2692,7 +2692,6 @@ void Canvas::showSuggestions(Object* object, TextEditor* textEditor)
26922692
}
26932693
void Canvas::hideSuggestions()
26942694
{
2695-
std::cout << "hideSuggestions" << std::endl;
26962695
suggestor->removeCalloutBox();
26972696
}
26982697

Source/NVGSurface.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ void NVGSurface::detachContext()
182182
nvgDeleteFramebuffer(quickCanvasBlurFBO);
183183
quickCanvasBlurFBO = nullptr;
184184
}
185+
if (quickCanvasBlurProcessFBO) {
186+
nvgDeleteFramebuffer(quickCanvasBlurProcessFBO);
187+
quickCanvasBlurProcessFBO = nullptr;
188+
}
185189
if (nvg) {
186190
nvgDeleteContext(nvg);
187191
nvg = nullptr;
@@ -218,6 +222,10 @@ void NVGSurface::updateBufferSize()
218222
nvgDeleteFramebuffer(quickCanvasBlurFBO);
219223
quickCanvasBlurFBO = nvgCreateFramebuffer(nvg, scaledWidth, scaledHeight, NVG_IMAGE_PREMULTIPLIED);
220224

225+
if (quickCanvasBlurProcessFBO)
226+
nvgDeleteFramebuffer(quickCanvasBlurProcessFBO);
227+
quickCanvasBlurProcessFBO = nvgCreateFramebuffer(nvg, scaledWidth, scaledHeight, NVG_IMAGE_PREMULTIPLIED);
228+
221229
fbWidth = scaledWidth;
222230
fbHeight = scaledHeight;
223231
invalidArea = getLocalBounds();
@@ -416,9 +424,11 @@ void NVGSurface::render()
416424
nvgBlitFramebuffer(nvg, invalidFBO, 0, 0, fbWidth, fbHeight);
417425

418426
if (!approximatelyEqual(0.0f, cnv->quickCanvasAlpha)) {
419-
nvgBlurFramebuffer(nvg, quickCanvasBlurFBO, fbWidth, fbHeight, cnv->quickCanvasAlpha * 15, 1.0f);
427+
nvgBlurFramebuffer(nvg, quickCanvasBlurFBO, quickCanvasBlurProcessFBO, fbWidth, fbHeight, cnv->quickCanvasAlpha * getValue<float>(cnv->zoomScale));
420428
}
421429

430+
nvgBindFramebuffer(quickCanvasBlurFBO);
431+
422432
nvgViewport(0, 0, fbWidth, fbHeight);
423433
nvgBeginFrame(nvg, fbWidth, fbHeight, 1);
424434
nvgGlobalScissor(nvg, 0, 0, fbWidth, fbHeight);

Source/NVGSurface.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ class NVGSurface :
126126

127127
NVGframebuffer* quickCanvasFBO = nullptr;
128128
NVGframebuffer* quickCanvasBlurFBO = nullptr;
129+
NVGframebuffer* quickCanvasBlurProcessFBO = nullptr;
129130
int fbWidth = 0, fbHeight = 0;
130131

131132
static inline UnorderedMap<NVGcontext*, NVGSurface*> surfaces;

0 commit comments

Comments
 (0)