Browse Source

Add `FramebufferWidget::dirtyOnSubpixelChange` setting. Disable it for the FramebufferWidget that contains the RackRail.

tags/v2.0.0
Andrew Belt 4 years ago
parent
commit
d85856eccc
3 changed files with 6 additions and 2 deletions
  1. +2
    -0
      include/widget/FramebufferWidget.hpp
  2. +2
    -0
      src/app/RackWidget.cpp
  3. +2
    -2
      src/widget/FramebufferWidget.cpp

+ 2
- 0
include/widget/FramebufferWidget.hpp View File

@@ -18,6 +18,8 @@ struct FramebufferWidget : Widget {
bool dirty = true; bool dirty = true;
bool bypass = false; bool bypass = false;
float oversample = 1.0; float oversample = 1.0;
/** Redraw when the world offset of the FramebufferWidget changes its fractional value. */
bool dirtyOnSubpixelChange = true;


FramebufferWidget(); FramebufferWidget();
~FramebufferWidget(); ~FramebufferWidget();


+ 2
- 0
src/app/RackWidget.cpp View File

@@ -71,6 +71,8 @@ RackWidget::RackWidget() {
railFb = new widget::FramebufferWidget; railFb = new widget::FramebufferWidget;
railFb->box.size = math::Vec(); railFb->box.size = math::Vec();
railFb->oversample = 1.0; railFb->oversample = 1.0;
// Don't redraw when the world offset of the rail FramebufferWidget changes its fractional value.
railFb->dirtyOnSubpixelChange = false;
{ {
RackRail* rail = new RackRail; RackRail* rail = new RackRail;
rail->box.size = math::Vec(); rail->box.size = math::Vec();


+ 2
- 2
src/widget/FramebufferWidget.cpp View File

@@ -80,7 +80,7 @@ void FramebufferWidget::step() {
localBox = getChildrenBoundingBox(); localBox = getChildrenBoundingBox();
} }


// DEBUG("%g %g %g %g, %g %g, %g %g", RECT_ARGS(localBox), VEC_ARGS(internal->fbOffsetF), VEC_ARGS(internal->fbScale));
// DEBUG("rendering FramebufferWidget localBox (%g %g %g %g) fbOffset (%g %g) fbScale (%g %g)", RECT_ARGS(localBox), VEC_ARGS(internal->fbOffsetF), VEC_ARGS(internal->fbScale));
// Transform to world coordinates, then expand to nearest integer coordinates // Transform to world coordinates, then expand to nearest integer coordinates
math::Vec min = localBox.getTopLeft().mult(internal->fbScale).plus(internal->fbOffsetF).floor(); math::Vec min = localBox.getTopLeft().mult(internal->fbScale).plus(internal->fbOffsetF).floor();
math::Vec max = localBox.getBottomRight().mult(internal->fbScale).plus(internal->fbOffsetF).ceil(); math::Vec max = localBox.getBottomRight().mult(internal->fbScale).plus(internal->fbOffsetF).ceil();
@@ -178,7 +178,7 @@ void FramebufferWidget::draw(const DrawArgs& args) {
math::Vec offsetI = offset.floor(); math::Vec offsetI = offset.floor();
internal->offsetF = offset.minus(offsetI); internal->offsetF = offset.minus(offsetI);


if (!math::isNear(internal->offsetF.x, internal->fbOffsetF.x, 0.01f) || !math::isNear(internal->offsetF.y, internal->fbOffsetF.y, 0.01f)) {
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. // If drawing to a new subpixel location, rerender in the next frame.
// DEBUG("%p dirty subpixel", this); // DEBUG("%p dirty subpixel", this);
dirty = true; dirty = true;


Loading…
Cancel
Save