You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.1KB

  1. #pragma once
  2. #include <widget/Widget.hpp>
  3. namespace rack {
  4. namespace widget {
  5. /** Caches its children's draw() result to a framebuffer image.
  6. When dirty, its children will be re-rendered on the next call to step().
  7. */
  8. struct FramebufferWidget : Widget {
  9. struct Internal;
  10. Internal* internal;
  11. /** Set this to true to re-render the children to the framebuffer the next time it is drawn */
  12. bool dirty = true;
  13. bool bypassed = false;
  14. float oversample = 1.0;
  15. /** Redraw when the world offset of the FramebufferWidget changes its fractional value. */
  16. bool dirtyOnSubpixelChange = true;
  17. FramebufferWidget();
  18. ~FramebufferWidget();
  19. void setDirty(bool dirty = true);
  20. void onDirty(const DirtyEvent& e) override;
  21. void step() override;
  22. void draw(const DrawArgs& args) override;
  23. virtual void drawFramebuffer();
  24. int getImageHandle();
  25. NVGLUframebuffer* getFramebuffer();
  26. math::Vec getFramebufferSize();
  27. void onContextCreate(const ContextCreateEvent& e) override;
  28. void onContextDestroy(const ContextDestroyEvent& e) override;
  29. };
  30. } // namespace widget
  31. } // namespace rack