summaryrefslogtreecommitdiff
path: root/libs/surfaces
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2016-09-16 13:17:24 -0500
committerPaul Davis <paul@linuxaudiosystems.com>2016-09-27 14:59:31 -0500
commitb83548617077eecacd4e65c3c10ee154494f9823 (patch)
treeba3b4329605263aa28ae2e48a995ee4b8778a46a /libs/surfaces
parent8cc94e79ac74e9d4c2b95b589a228cb6a973313d (diff)
tweaks and so forth to get first canvas-based rendering to Push2 display
Diffstat (limited to 'libs/surfaces')
-rw-r--r--libs/surfaces/push2/canvas.cc33
-rw-r--r--libs/surfaces/push2/canvas.h2
-rw-r--r--libs/surfaces/push2/mix.cc2
-rw-r--r--libs/surfaces/push2/push2.cc42
-rw-r--r--libs/surfaces/push2/push2.h2
-rw-r--r--libs/surfaces/push2/scale.cc2
-rw-r--r--libs/surfaces/push2/splash.cc7
-rw-r--r--libs/surfaces/push2/splash.h3
-rw-r--r--libs/surfaces/push2/track_mix.cc2
9 files changed, 72 insertions, 23 deletions
diff --git a/libs/surfaces/push2/canvas.cc b/libs/surfaces/push2/canvas.cc
index e178e0d8b5..9d5ad14562 100644
--- a/libs/surfaces/push2/canvas.cc
+++ b/libs/surfaces/push2/canvas.cc
@@ -21,12 +21,17 @@
#include <cairomm/surface.h>
#include <cairomm/context.h>
+#include "pbd/compose.h"
+
+#include "ardour/debug.h"
+
#include "canvas.h"
#include "layout.h"
#include "push2.h"
using namespace ArdourCanvas;
using namespace ArdourSurface;
+using namespace PBD;
const int Push2Canvas::pixels_per_row = 1024;
@@ -62,6 +67,7 @@ Push2Canvas::vblank ()
/* re-render dirty areas, if any */
if (expose ()) {
+ DEBUG_TRACE (DEBUG::Push2, "re-blit to device frame buffer\n");
/* something rendered, update device_frame_buffer */
blit_to_device_frame_buffer ();
}
@@ -94,11 +100,13 @@ Push2Canvas::request_redraw (Rect const & r)
{
Cairo::RectangleInt cr;
- cr.x = r.x1;
- cr.y = r.y1;
+ cr.x = r.x0;
+ cr.y = r.y0;
cr.width = r.width();
cr.width = r.height();
+ DEBUG_TRACE (DEBUG::Push2, string_compose ("invalidate rect %1\n", r));
+
expose_region->do_union (cr);
/* next vblank will redraw */
@@ -115,6 +123,8 @@ Push2Canvas::expose ()
const int nrects = expose_region->get_num_rectangles ();
+ DEBUG_TRACE (DEBUG::Push2, string_compose ("expose with %1 rects\n", nrects));
+
for (int n = 0; n < nrects; ++n) {
Cairo::RectangleInt r = expose_region->get_rectangle (n);
context->rectangle (r.x, r.y, r.width, r.height);
@@ -126,11 +136,17 @@ Push2Canvas::expose ()
if (layout) {
Cairo::RectangleInt r = expose_region->get_extents();
+ Rect rr (r.x, r.y, r.x + r.width, r.y + r.height);
+ DEBUG_TRACE (DEBUG::Push2, string_compose ("render layout with %1\n", rr));
layout->render (Rect (r.x, r.y, r.x + r.width, r.y + r.height), context);
}
context->reset_clip ();
+ /* why is there no "reset()" method for Cairo::Region? */
+
+ expose_region = Cairo::Region::create ();
+
return true;
}
@@ -188,3 +204,16 @@ Push2Canvas::blit_to_device_frame_buffer ()
return 0;
}
+
+void
+Push2Canvas::request_size (Duple)
+{
+ /* fixed size canvas */
+}
+
+Rect
+Push2Canvas::visible_area () const
+{
+ /* may need to get more sophisticated once we do scrolling */
+ return Rect (0, 0, 960, 160);
+}
diff --git a/libs/surfaces/push2/canvas.h b/libs/surfaces/push2/canvas.h
index 853b93f778..e3343e3296 100644
--- a/libs/surfaces/push2/canvas.h
+++ b/libs/surfaces/push2/canvas.h
@@ -47,8 +47,6 @@ class Push2Canvas : public ArdourCanvas::Canvas
void request_redraw (ArdourCanvas::Rect const &);
bool vblank ();
- void splash ();
-
Cairo::RefPtr<Cairo::Context> image_context() { return context; }
int rows() const { return _rows; }
diff --git a/libs/surfaces/push2/mix.cc b/libs/surfaces/push2/mix.cc
index a0d59d9f67..cd4464b22e 100644
--- a/libs/surfaces/push2/mix.cc
+++ b/libs/surfaces/push2/mix.cc
@@ -146,6 +146,8 @@ MixLayout::show ()
void
MixLayout::render (Rect const& area, Cairo::RefPtr<Cairo::Context> context) const
{
+ DEBUG_TRACE (DEBUG::Push2, string_compose ("mix render %1\n", area));
+
set_source_rgb (context, p2.get_color (Push2::DarkBackground));
context->rectangle (0, 0, display_width(), display_height());
context->fill ();
diff --git a/libs/surfaces/push2/push2.cc b/libs/surfaces/push2/push2.cc
index 0cf7ceee96..6887bb73a5 100644
--- a/libs/surfaces/push2/push2.cc
+++ b/libs/surfaces/push2/push2.cc
@@ -51,6 +51,7 @@
#include "mix.h"
#include "push2.h"
#include "scale.h"
+#include "splash.h"
#include "track_mix.h"
#include "pbd/i18n.h"
@@ -126,7 +127,6 @@ Push2::Push2 (ARDOUR::Session& s)
, _modifier_state (None)
, splash_start (0)
, _current_layout (0)
- , drawn_layout (0)
, connection_state (ConnectionState (0))
, gui (0)
, _mode (MusicalMode::IonianMajor)
@@ -228,10 +228,11 @@ Push2::open ()
}
try {
- _canvas = new Push2Canvas (*this, 160, 960);
+ _canvas = new Push2Canvas (*this, 960, 160);
mix_layout = new MixLayout (*this, *session);
scale_layout = new ScaleLayout (*this, *session);
track_mix_layout = new TrackMixLayout (*this, *session);
+ splash_layout = new SplashLayout (*this, *session);
} catch (...) {
error << _("Cannot construct Canvas for display") << endmsg;
libusb_release_interface (handle, 0x00);
@@ -279,8 +280,6 @@ Push2::open ()
connect_to_parser ();
- _canvas->splash ();
-
return 0;
}
@@ -317,12 +316,17 @@ Push2::close ()
periodic_connection.disconnect ();
session_connections.drop_connections ();
- _current_layout = 0;
- drawn_layout = 0;
+ if (_current_layout) {
+ _canvas->root()->remove (_current_layout);
+ _current_layout = 0;
+ }
+
delete mix_layout;
mix_layout = 0;
delete scale_layout;
scale_layout = 0;
+ delete splash_layout;
+ splash_layout = 0;
if (handle) {
libusb_release_interface (handle, 0x00);
@@ -449,6 +453,14 @@ Push2::stop ()
return 0;
}
+
+void
+Push2::splash ()
+{
+ set_current_layout (splash_layout);
+ splash_start = get_microseconds ();
+}
+
bool
Push2::vblank ()
{
@@ -458,15 +470,13 @@ Push2::vblank ()
if (get_microseconds() - splash_start > 3000000) {
splash_start = 0;
+ DEBUG_TRACE (DEBUG::Push2, "splash interval ended, switch to mix layout\n");
+ set_current_layout (mix_layout);
}
+ }
- return true;
-
- } else {
-
- _canvas->vblank();
+ _canvas->vblank();
- }
return true;
}
@@ -519,7 +529,6 @@ Push2::set_active (bool yn)
init_touch_strip ();
set_pad_scale (_scale_root, _root_octave, _mode, _in_key);
splash ();
- set_current_layout (mix_layout);
} else {
@@ -1106,11 +1115,6 @@ Push2::end_shift ()
}
}
-void
-Push2::splash ()
-{
-}
-
bool
Push2::pad_filter (MidiBuffer& in, MidiBuffer& out) const
{
@@ -1600,6 +1604,8 @@ Push2::set_current_layout (Push2Layout* layout)
_current_layout->show ();
_canvas->root()->add (_current_layout);
}
+
+ _canvas->request_redraw ();
}
void
diff --git a/libs/surfaces/push2/push2.h b/libs/surfaces/push2/push2.h
index 4704ce9a30..b27de8704c 100644
--- a/libs/surfaces/push2/push2.h
+++ b/libs/surfaces/push2/push2.h
@@ -515,10 +515,10 @@ class Push2 : public ARDOUR::ControlProtocol
mutable Glib::Threads::Mutex layout_lock;
Push2Layout* _current_layout;
- Push2Layout* drawn_layout;
Push2Layout* mix_layout;
Push2Layout* scale_layout;
Push2Layout* track_mix_layout;
+ Push2Layout* splash_layout;
void set_current_layout (Push2Layout*);
bool pad_filter (ARDOUR::MidiBuffer& in, ARDOUR::MidiBuffer& out) const;
diff --git a/libs/surfaces/push2/scale.cc b/libs/surfaces/push2/scale.cc
index 97b59220c3..5596aa7029 100644
--- a/libs/surfaces/push2/scale.cc
+++ b/libs/surfaces/push2/scale.cc
@@ -67,6 +67,8 @@ ScaleLayout::~ScaleLayout ()
void
ScaleLayout::render (Rect const& area, Cairo::RefPtr<Cairo::Context> context) const
{
+ DEBUG_TRACE (DEBUG::Push2, string_compose ("scale render %1\n", area));
+
context->set_source_rgb (0.764, 0.882, 0.882);
context->rectangle (0, 0, 960, 160);
context->fill ();
diff --git a/libs/surfaces/push2/splash.cc b/libs/surfaces/push2/splash.cc
index d03205e3a6..8b25e6eac6 100644
--- a/libs/surfaces/push2/splash.cc
+++ b/libs/surfaces/push2/splash.cc
@@ -24,6 +24,7 @@
#include "pbd/i18n.h"
#include "pbd/search_path.h"
+#include "ardour/debug.h"
#include "ardour/filesystem_paths.h"
#include "splash.h"
@@ -50,9 +51,15 @@ SplashLayout::SplashLayout (Push2& p, Session& s)
img = Cairo::ImageSurface::create_from_png (splash_file);
}
+SplashLayout::~SplashLayout ()
+{
+}
+
void
SplashLayout::render (Rect const& area, Cairo::RefPtr<Cairo::Context> context) const
{
+ DEBUG_TRACE (DEBUG::Push2, string_compose ("splash render %1\n", area));
+
int rows = display_height ();
int cols = display_width ();
diff --git a/libs/surfaces/push2/splash.h b/libs/surfaces/push2/splash.h
index c58a383f52..e587cd2344 100644
--- a/libs/surfaces/push2/splash.h
+++ b/libs/surfaces/push2/splash.h
@@ -38,6 +38,9 @@ class SplashLayout : public Push2Layout
void render (ArdourCanvas::Rect const &, Cairo::RefPtr<Cairo::Context>) const;
+ void strip_vpot (int, int) {}
+ void strip_vpot_touch (int, bool) {}
+
private:
Cairo::RefPtr<Cairo::ImageSurface> img;
};
diff --git a/libs/surfaces/push2/track_mix.cc b/libs/surfaces/push2/track_mix.cc
index 139e2df341..a4abbed1f1 100644
--- a/libs/surfaces/push2/track_mix.cc
+++ b/libs/surfaces/push2/track_mix.cc
@@ -146,6 +146,8 @@ TrackMixLayout::show ()
void
TrackMixLayout::render (ArdourCanvas::Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
{
+ DEBUG_TRACE (DEBUG::Push2, string_compose ("track mix render %1\n", area));
+
set_source_rgb (context, p2.get_color (Push2::DarkBackground));
context->rectangle (0, 0, display_width(), display_height());
context->fill ();