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.

42 lines
1.2KB

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