Checking in debug_view, some extra missing utils, and the y2016 target_sender code.
Change-Id: I241947265da8f332c39862f4d0ddcdc2d29c7b68
diff --git a/aos/vision/debug/debug_viewer.h b/aos/vision/debug/debug_viewer.h
new file mode 100644
index 0000000..3bada28
--- /dev/null
+++ b/aos/vision/debug/debug_viewer.h
@@ -0,0 +1,78 @@
+#ifndef AOS_VISION_DEBUG_DEBUG_VIEWER_H_
+#define AOS_VISION_DEBUG_DEBUG_VIEWER_H_
+
+#include <cairo.h>
+#include <functional>
+#include "aos/vision/debug/overlay.h"
+#include "aos/vision/image/image_types.h"
+
+namespace aos {
+namespace vision {
+
+// Implement Cairo version of RenderInterface.
+class CairoRender : public RenderInterface {
+ public:
+ explicit CairoRender(cairo_t *cr) : cr_(cr) {}
+ virtual ~CairoRender() {}
+
+ void Translate(double x, double y) override { cairo_translate(cr_, x, y); }
+
+ void SetSourceRGB(double r, double g, double b) override {
+ cairo_set_source_rgb(cr_, r, g, b);
+ }
+
+ void MoveTo(double x, double y) override { cairo_move_to(cr_, x, y); }
+
+ void LineTo(double x, double y) override { cairo_line_to(cr_, x, y); }
+
+ void Circle(double x, double y, double r) override {
+ cairo_arc(cr_, x, y, r, 0.0, 2 * M_PI);
+ }
+
+ void Stroke() override { cairo_stroke(cr_); }
+
+ void Text(int x, int y, int text_x, int text_y,
+ const std::string &text) override;
+
+ private:
+ cairo_t *cr_;
+};
+
+// Simple debug view window.
+class DebugViewer {
+ public:
+ struct Internals;
+ explicit DebugViewer(bool flip);
+ ~DebugViewer();
+ // Explicit redraw queuing (Will not double-queue).
+ void Redraw();
+
+ // This will resize the window as well as updating to draw from the
+ // (not owned) ptr. When you change ptr, you should call Redraw();
+ void UpdateImage(ImagePtr ptr);
+
+ // Sets up the window to draw a list of overlays.
+ // See overlay.h for more info.
+ void SetOverlays(std::vector<OverlayBase *> *overlay);
+
+ // Resizes the window.
+ void SetScale(double scale_factor);
+
+ // Move window.
+ void MoveTo(int x, int y);
+
+ // Set to change the key_press behaviour.
+ // The argument type is a constant that looks like: GDK_KEY_#{key_val_name}
+ std::function<void(uint32_t)> key_press_event;
+
+ private:
+ double scale_factor = 1.0;
+ int window_width_ = 100;
+ int window_height_ = 100;
+ std::unique_ptr<Internals> self;
+};
+
+} // namespace vision
+} // namespace aos
+
+#endif // AOS_VISION_DEBUG_DEBUG_VIEWER_H_