Revert "cairo sub-surface prototype & example

This reverts commit c57fcde78c.
and also     commit f1f8f89fcb.
This commit is contained in:
Robin Gareus 2014-05-28 19:12:32 +02:00
parent 24537477c4
commit 034f3dafd7
6 changed files with 4 additions and 181 deletions

View File

@ -91,7 +91,6 @@ AudioRegionView::AudioRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView
, _end_xfade_visible (false)
, _amplitude_above_axis(1.0)
, fade_color(0)
, curve_surface(new ArdourCanvas::SurfaceGroup(group))
{
Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&AudioRegionView::parameter_changed, this, _1), gui_context());
}
@ -112,7 +111,6 @@ AudioRegionView::AudioRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView
, _end_xfade_visible (false)
, _amplitude_above_axis(1.0)
, fade_color(0)
, curve_surface(new ArdourCanvas::SurfaceGroup(group))
{
Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&AudioRegionView::parameter_changed, this, _1), gui_context());
}
@ -131,7 +129,6 @@ AudioRegionView::AudioRegionView (const AudioRegionView& other, boost::shared_pt
, _end_xfade_visible (false)
, _amplitude_above_axis (other._amplitude_above_axis)
, fade_color(0)
, curve_surface(new ArdourCanvas::SurfaceGroup(group))
{
Gdk::Color c;
int r,g,b,a;
@ -693,7 +690,7 @@ AudioRegionView::redraw_start_xfade_to (boost::shared_ptr<AudioRegion> ar, frame
}
if (!start_xfade_out) {
start_xfade_out = new ArdourCanvas::Curve (curve_surface);
start_xfade_out = new ArdourCanvas::Curve (group);
CANVAS_DEBUG_NAME (start_xfade_out, string_compose ("xfade start out line for %1", region()->name()));
start_xfade_out->set_fill_color (UINT_RGBA_CHANGE_A (ARDOUR_UI::config()->get_canvasvar_ActiveCrossfade(), 32));
start_xfade_out->set_fill_mode (ArdourCanvas::Curve::Inside);
@ -703,7 +700,7 @@ AudioRegionView::redraw_start_xfade_to (boost::shared_ptr<AudioRegion> ar, frame
}
if (!start_xfade_in) {
start_xfade_in = new ArdourCanvas::Curve (curve_surface);
start_xfade_in = new ArdourCanvas::Curve (group);
CANVAS_DEBUG_NAME (start_xfade_in, string_compose ("xfade start in line for %1", region()->name()));
start_xfade_in->set_fill_color (UINT_RGBA_CHANGE_A (ARDOUR_UI::config()->get_canvasvar_CrossfadeLine(), 96));
start_xfade_in->set_fill_mode (ArdourCanvas::Curve::Outside);
@ -798,7 +795,7 @@ AudioRegionView::redraw_end_xfade_to (boost::shared_ptr<AudioRegion> ar, framecn
}
if (!end_xfade_out) {
end_xfade_out = new ArdourCanvas::Curve (curve_surface);
end_xfade_out = new ArdourCanvas::Curve (group);
CANVAS_DEBUG_NAME (end_xfade_out, string_compose ("xfade end out line for %1", region()->name()));
end_xfade_out->set_fill_color (UINT_RGBA_CHANGE_A (ARDOUR_UI::config()->get_canvasvar_ActiveCrossfade(), 32));
end_xfade_out->set_fill_mode (ArdourCanvas::Curve::Inside);
@ -808,7 +805,7 @@ AudioRegionView::redraw_end_xfade_to (boost::shared_ptr<AudioRegion> ar, framecn
}
if (!end_xfade_in) {
end_xfade_in = new ArdourCanvas::Curve (curve_surface);
end_xfade_in = new ArdourCanvas::Curve (group);
CANVAS_DEBUG_NAME (end_xfade_in, string_compose ("xfade end in line for %1", region()->name()));
end_xfade_in->set_fill_color (UINT_RGBA_CHANGE_A (ARDOUR_UI::config()->get_canvasvar_CrossfadeLine(), 96));
end_xfade_in->set_fill_mode (ArdourCanvas::Curve::Outside);

View File

@ -30,7 +30,6 @@
#include "canvas/fwd.h"
#include "canvas/wave_view.h"
#include "canvas/surface_group.h"
#include "region_view.h"
#include "time_axis_view_item.h"
@ -205,8 +204,6 @@ class AudioRegionView : public RegionView
AutomationLine::VisibleAspects automation_line_visibility () const;
private:
ArdourCanvas::SurfaceGroup *curve_surface;
void setup_fade_handle_positions ();
void parameter_changed (std::string const &);

View File

@ -1,48 +0,0 @@
/*
Copyright (C) 2011-2013 Paul Davis
Author: Robin Gareus <robin@gareus.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __CANVAS_SURFACE_GROUP_H__
#define __CANVAS_SURFACE_GROUP_H__
#include <list>
#include <vector>
#include "canvas/visibility.h"
#include "canvas/group.h"
namespace ArdourCanvas {
class LIBCANVAS_API SurfaceGroup : public Group
{
public:
explicit SurfaceGroup (Group *);
explicit SurfaceGroup (Group *, Duple);
~SurfaceGroup ();
void render (Rect const &, Cairo::RefPtr<Cairo::Context>) const;
private:
mutable Duple _surface_position;
mutable Duple _surface_geometry;
mutable Cairo::RefPtr<Cairo::ImageSurface> _surface;
};
}
#endif

View File

@ -318,10 +318,8 @@ Curve::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
window_space = item_to_window (Duple(_points.front().x, draw.height()));
context->line_to (window_space.x, window_space.y);
context->close_path();
context->set_operator(Cairo::OPERATOR_SOURCE);
setup_fill_context(context);
context->fill ();
context->set_operator(Cairo::OPERATOR_OVER);
break;
case Outside:
context->stroke_preserve ();
@ -330,10 +328,8 @@ Curve::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
window_space = item_to_window (Duple(_points.front().x, 0.0));
context->line_to (window_space.x, window_space.y);
context->close_path();
context->set_operator(Cairo::OPERATOR_SOURCE);
setup_fill_context(context);
context->fill ();
context->set_operator(Cairo::OPERATOR_OVER);
break;
}
@ -407,9 +403,7 @@ Curve::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
context->line_to (window_space.x, window_space.y);
context->close_path();
setup_fill_context(context);
context->set_operator(Cairo::OPERATOR_SOURCE);
context->fill ();
context->set_operator(Cairo::OPERATOR_OVER);
break;
case Outside:
context->stroke_preserve ();
@ -418,10 +412,8 @@ Curve::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
window_space = item_to_window (Duple (samples[left].x, 0.0));
context->line_to (window_space.x, window_space.y);
context->close_path();
context->set_operator(Cairo::OPERATOR_SOURCE);
setup_fill_context(context);
context->fill ();
context->set_operator(Cairo::OPERATOR_OVER);
break;
}
context->restore ();

View File

@ -1,114 +0,0 @@
/*
Copyright (C) 2011-2013 Paul Davis
Author: Robin Gareus <robin@gareus.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <iostream>
#include <cairomm/context.h>
#include "canvas/surface_group.h"
using namespace std;
using namespace ArdourCanvas;
SurfaceGroup::SurfaceGroup (Group* parent)
: Group (parent)
, _surface_position (0,0)
, _surface_geometry (0,0)
, _surface (0)
{
}
SurfaceGroup::SurfaceGroup (Group* parent, Duple position)
: Group (parent, position)
, _surface_geometry (0,0)
, _surface (0)
{
}
SurfaceGroup::~SurfaceGroup ()
{
}
void
SurfaceGroup::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
{
bool re_expose = false;
boost::optional<Rect> bb = bounding_box ();
if (bb) {
Duple geo = Duple (bb->width (), bb->height ());
if (geo != _surface_geometry) {
re_expose = true;
#if 0 // DEBUG
printf ("re allocate surface group %1.f x %.1f @ %1.f x %.1f self: %1.f x %.1f\n",
geo.x, geo.y, bb->x0, bb->y0, _position.x, _position.y);
#endif
if (geo.x > 32768 || geo.y > 32768) {
// TODO allocate N surfaces, render at offset and stitch them together.
// OR use one surfacen and re-expose child items when offset changes
return;
}
_surface = Cairo::ImageSurface::create (Cairo::FORMAT_ARGB32, geo.x, geo.y);
_surface_geometry = geo;
_surface_position = Duple (bb->x0, bb->y0);
}
}
if (!_surface) return;
Rect a (0, 0, _surface_geometry.x, _surface_geometry.y);
if (!re_expose) {
Duple tmp_p0 = window_to_item (Duple (area.x0, area.y0));
Duple tmp_p1 = window_to_item (Duple (area.x1, area.y1));
Rect wa (tmp_p0.x, tmp_p0.y, tmp_p1.x, tmp_p1.y);
boost::optional<Rect> d = a.intersection (wa);
assert (d);
a = d.get ();
}
Duple window_space;
window_space = item_to_window (Duple (_position.x + _surface_position.x, _position.y + _surface_position.y));
Cairo::RefPtr<Cairo::Context> cr = Cairo::Context::create (_surface);
#if 1 // clear surface, needed if any content is semi-transparent
cr->save ();
cr->set_operator (Cairo::OPERATOR_CLEAR);
cr->rectangle (a.x0, a.y0, a.x1, a.y1);
cr->fill ();
cr->restore ();
#endif
#if 0 // DEBUG
printf ("EXPOSE: %1.f x %.1f -> %1.f x %.1f\n", a.x0, a.y0, a.x1, a.y1);
Rect dbg = item_to_window (a);
printf ("RENDER: %1.f x %.1f -> %1.f x %.1f WS: %1.f x %.1f \n",
dbg.x0, dbg.y0, dbg.x1, dbg.y1, window_space.x, -window_space.y);
#endif
cr->translate (-window_space.x, -window_space.y);
Group::render (item_to_window (a), cr);
context->set_source (_surface, window_space.x, window_space.y);
context->paint ();
}

View File

@ -51,7 +51,6 @@ canvas_sources = [
'rectangle.cc',
'root_group.cc',
'stateful_image.cc',
'surface_group.cc',
'text.cc',
'types.cc',
'utils.cc',