workaround/hack/fix for cairo pattern gradient space exceeding 2^16 size limit
This commit is contained in:
parent
f9936d7d3c
commit
0e656f0a13
@ -879,7 +879,7 @@ TimeAxisViewItem::set_frame_gradient ()
|
|||||||
ArdourCanvas::Color darker = ArdourCanvas::hsv_to_color (h, s, v, a);
|
ArdourCanvas::Color darker = ArdourCanvas::hsv_to_color (h, s, v, a);
|
||||||
stops.push_back (std::make_pair (1.0, darker));
|
stops.push_back (std::make_pair (1.0, darker));
|
||||||
|
|
||||||
frame->set_gradient (stops, _height);
|
frame->set_gradient (stops, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,14 +44,16 @@ public:
|
|||||||
|
|
||||||
typedef std::vector<std::pair<double,Color> > StopList;
|
typedef std::vector<std::pair<double,Color> > StopList;
|
||||||
|
|
||||||
void set_gradient (StopList const & stops, double height);
|
void set_gradient (StopList const & stops, bool is_vertical);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setup_fill_context (Cairo::RefPtr<Cairo::Context>) const;
|
void setup_fill_context (Cairo::RefPtr<Cairo::Context>) const;
|
||||||
|
void setup_gradient_context (Cairo::RefPtr<Cairo::Context>, Rect const &, Duple const &) const;
|
||||||
|
|
||||||
Color _fill_color;
|
Color _fill_color;
|
||||||
bool _fill;
|
bool _fill;
|
||||||
Cairo::RefPtr<Cairo::LinearGradient> _gradient;
|
StopList _stops;
|
||||||
|
bool _vertical_gradient;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -59,37 +59,39 @@ Fill::set_fill (bool fill)
|
|||||||
void
|
void
|
||||||
Fill::setup_fill_context (Cairo::RefPtr<Cairo::Context> context) const
|
Fill::setup_fill_context (Cairo::RefPtr<Cairo::Context> context) const
|
||||||
{
|
{
|
||||||
if (_gradient) {
|
set_source_rgba (context, _fill_color);
|
||||||
Cairo::Matrix m;
|
|
||||||
|
|
||||||
Duple origin = item_to_window (Duple (0, 0));
|
|
||||||
|
|
||||||
context->translate (origin.x, origin.y);
|
|
||||||
context->set_source (_gradient);
|
|
||||||
context->translate (-origin.x, -origin.y);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
set_source_rgba (context, _fill_color);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Fill::set_gradient (StopList const & stops, double height)
|
Fill::setup_gradient_context (Cairo::RefPtr<Cairo::Context> context, Rect const & self, Duple const & draw_origin) const
|
||||||
|
{
|
||||||
|
Cairo::RefPtr<Cairo::LinearGradient> _gradient;
|
||||||
|
|
||||||
|
if (_vertical_gradient) {
|
||||||
|
_gradient = Cairo::LinearGradient::create (draw_origin.x, self.y0, draw_origin.x, self.y1);
|
||||||
|
} else {
|
||||||
|
_gradient = Cairo::LinearGradient::create (self.x0, draw_origin.y, self.x1, draw_origin.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (StopList::const_iterator s = _stops.begin(); s != _stops.end(); ++s) {
|
||||||
|
double r, g, b, a;
|
||||||
|
color_to_rgba (s->second, r, g, b, a);
|
||||||
|
_gradient->add_color_stop_rgba (s->first, r, g, b, a);
|
||||||
|
}
|
||||||
|
|
||||||
|
context->set_source (_gradient);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Fill::set_gradient (StopList const & stops, bool vertical)
|
||||||
{
|
{
|
||||||
begin_visual_change ();
|
begin_visual_change ();
|
||||||
|
|
||||||
if (stops.empty()) {
|
if (stops.empty()) {
|
||||||
_gradient.clear();
|
_stops.clear ();
|
||||||
} else {
|
} else {
|
||||||
|
_stops = stops;
|
||||||
double r, g, b, a;
|
_vertical_gradient = vertical;
|
||||||
|
|
||||||
_gradient = Cairo::LinearGradient::create (0, 0, 0, height);
|
|
||||||
|
|
||||||
for (StopList::const_iterator s = stops.begin(); s != stops.end(); ++s) {
|
|
||||||
color_to_rgba (s->second, r, g, b, a);
|
|
||||||
_gradient->add_color_stop_rgba (s->first, r, g, b, a);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
end_visual_change ();
|
end_visual_change ();
|
||||||
|
@ -72,7 +72,11 @@ Rectangle::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) con
|
|||||||
Rect stroke_rect = fill_rect.expand (0.5);
|
Rect stroke_rect = fill_rect.expand (0.5);
|
||||||
|
|
||||||
if (_fill) {
|
if (_fill) {
|
||||||
setup_fill_context (context);
|
if (_stops.empty()) {
|
||||||
|
setup_fill_context (context);
|
||||||
|
} else {
|
||||||
|
setup_gradient_context (context, self, Duple (draw.x0, draw.y0));
|
||||||
|
}
|
||||||
context->rectangle (fill_rect.x0, fill_rect.y0, fill_rect.width(), fill_rect.height());
|
context->rectangle (fill_rect.x0, fill_rect.y0, fill_rect.width(), fill_rect.height());
|
||||||
context->fill ();
|
context->fill ();
|
||||||
}
|
}
|
||||||
|
@ -151,8 +151,7 @@ Text::compute_bounding_box () const
|
|||||||
Pango::Rectangle const r = layout->get_ink_extents ();
|
Pango::Rectangle const r = layout->get_ink_extents ();
|
||||||
|
|
||||||
_bounding_box = Rect (
|
_bounding_box = Rect (
|
||||||
r.get_x() / Pango::SCALE,
|
0, 0,
|
||||||
r.get_y() / Pango::SCALE,
|
|
||||||
(r.get_x() + r.get_width()) / Pango::SCALE,
|
(r.get_x() + r.get_width()) / Pango::SCALE,
|
||||||
(r.get_y() + r.get_height()) / Pango::SCALE
|
(r.get_y() + r.get_height()) / Pango::SCALE
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user