From 5cb2341c853b809e590027e2f0bd3f487dbb7240 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Mon, 21 Jun 2021 15:58:14 -0400 Subject: [PATCH] Increase dirtyOnSubpixelChange threshold to 0.1 px. --- include/common.hpp | 2 +- src/widget/FramebufferWidget.cpp | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/include/common.hpp b/include/common.hpp index 0abf9540..e9f22b28 100644 --- a/include/common.hpp +++ b/include/common.hpp @@ -30,7 +30,7 @@ E.g. #endif /** Attribute for private functions and symbols not intended to be used by plugins. -By default this does nothing, but when #including rack.hpp, it prints a compile-time warning. +When #including rack.hpp, using an INTERNAL function prints a compile-time warning and will not link. */ #if defined ARCH_WIN #define INTERNAL diff --git a/src/widget/FramebufferWidget.cpp b/src/widget/FramebufferWidget.cpp index 2578d406..4b836cc2 100644 --- a/src/widget/FramebufferWidget.cpp +++ b/src/widget/FramebufferWidget.cpp @@ -185,9 +185,11 @@ void FramebufferWidget::draw(const DrawArgs& args) { math::Vec offsetI = offset.floor(); internal->offsetF = offset.minus(offsetI); - if (dirtyOnSubpixelChange && !(math::isNear(internal->offsetF.x, internal->fbOffsetF.x, 0.01f) && math::isNear(internal->offsetF.y, internal->fbOffsetF.y, 0.01f))) { - // If drawing to a new subpixel location, rerender in the next frame. - // DEBUG("%p dirty subpixel", this); + // If drawing to a new subpixel location, rerender in the next frame. + // Anything less than 0.1 pixels isn't noticeable. + math::Vec offsetFDelta = internal->offsetF.minus(internal->fbOffsetF); + if (dirtyOnSubpixelChange && offsetFDelta.square() >= std::pow(0.1f, 2)) { + // DEBUG("%p dirty subpixel (%f, %f) (%f, %f)", this, VEC_ARGS(internal->offsetF), VEC_ARGS(internal->fbOffsetF)); setDirty(); } if (!internal->scale.equals(internal->fbScale)) { @@ -247,6 +249,7 @@ void FramebufferWidget::drawFramebuffer() { nvgTranslate(vg, internal->fbOffsetF.x, internal->fbOffsetF.y); nvgScale(vg, internal->fbScale.x, internal->fbScale.y); + // Draw children DrawArgs args; args.vg = vg; args.clipBox = box.zeroPos();