renderer.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /* renderer.h - renderer
  2. * Copyright (C) 2017 caryoscelus
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef STUDIO_MAIN_RENDERER_H_39419D23_FC77_52F5_BAE0_212BEBF4F7AD
  18. #define STUDIO_MAIN_RENDERER_H_39419D23_FC77_52F5_BAE0_212BEBF4F7AD
  19. #include <thread>
  20. #include <mutex>
  21. #include <queue>
  22. #include <QObject>
  23. #include <generic/context_listener.h>
  24. namespace rainynite::core::renderers {
  25. class SvgRenderer;
  26. }
  27. namespace rainynite::studio {
  28. class Canvas;
  29. class Renderer : public QObject, public ContextListener {
  30. Q_OBJECT
  31. public:
  32. Renderer(Canvas* canvas_);
  33. virtual ~Renderer();
  34. void setup_renderer();
  35. void render_period(core::TimePeriod const& period);
  36. void set_fname(string fname_);
  37. void set_context(shared_ptr<EditorContext> context_) override;
  38. public Q_SLOTS:
  39. /// Render active period
  40. void render();
  41. /// Render current frame
  42. void render_frame();
  43. void stop_render();
  44. /// Redraw canvas using render result
  45. void redraw();
  46. void toggle_extra_style(bool checked);
  47. void toggle_auto_redraw(bool checked);
  48. Q_SIGNALS:
  49. void redraw_signal();
  50. private:
  51. void set_mainarea_image(string const& fname);
  52. void quit();
  53. private:
  54. Canvas* canvas;
  55. string fname;
  56. bool extra_style = true;
  57. bool auto_redraw = true;
  58. std::thread render_thread;
  59. shared_ptr<core::renderers::SvgRenderer> renderer;
  60. std::queue<core::Context> renderer_queue;
  61. std::mutex renderer_mutex;
  62. bool renderer_quit = false;
  63. bool renderer_restart = false;
  64. };
  65. } // namespace rainynite::studio
  66. #endif