summaryrefslogtreecommitdiff
path: root/bench/core_widget.hpp
blob: cb60ec1235a4b0745c0eae658e00287c0ecc3a57 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef LIB94_BENCH_CORE_WIDGET_HPP
#define LIB94_BENCH_CORE_WIDGET_HPP

#include <lib94/lib94.hpp>
#include <gtkmm.h>
#include <mutex>
#include <set>

class core_widget : public Gtk::Widget {
public:
  core_widget();
  void clear_all();
  void age_all();
  void add_new_writes(const std::set<lib94::number_t> &writes);
  void add_new_reads(const std::set<lib94::number_t> &reads);
  void add_new_executions(const std::set<lib94::number_t> &executions);

  void measure_vfunc(Gtk::Orientation orientation, int for_size, int &minimum, int &natural, int &minimum_baseline, int &natural_baseline) const override;
  void snapshot_vfunc(const Glib::RefPtr<Gtk::Snapshot> &snapshot);

  float age_scale;

  std::chrono::nanoseconds last_draw_time;

  std::mutex mut;

private:
  uint8_t write_values[LIB94_CORE_SIZE];
  uint8_t read_values[LIB94_CORE_SIZE];
  uint8_t execute_values[LIB94_CORE_SIZE];

  std::set<lib94::number_t> to_draw_write;
  std::set<lib94::number_t> to_draw_read;
  std::set<lib94::number_t> to_draw_execute;

  Glib::RefPtr<Gdk::Pixbuf> pixbuf;

  int last_width;
  int last_height;
  int scale;
  int cpr;
  int xpad;
  int ypad;

  void draw(int width, int height);
};

#endif