19 return std::make_unique<CairoGraphics>(prefs, stores, pi);
35 auto make_surface = [&,
this] {
36 auto surface = Cairo::ImageSurface::create(Cairo::Surface::Format::ARGB32, surface_size.x(), surface_size.y());
51 }
else if (reuse_surface) {
53 cr->set_operator(Cairo::Context::Operator::CLEAR);
60 if (!reuse_outline_surface) {
64 cr->set_operator(Cairo::Context::Operator::CLEAR);
79 auto make_surface = [&,
this] {
80 auto surface = Cairo::ImageSurface::create(Cairo::Surface::Format::ARGB32, surface_size.x(), surface_size.y());
87 auto new_surface = reuse_surface ? std::move(
snapshot.
surface) : make_surface();
90 auto cr = Cairo::Context::create(new_surface);
101 cr->set_operator(Cairo::Context::Operator::CLEAR);
108 cr->rectangle(reuse_rect->left() - dest.
rect.
left(), reuse_rect->top() - dest.
rect.
top(), reuse_rect->width(), reuse_rect->height());
111 cr->set_operator(Cairo::Context::Operator::SOURCE);
124 auto cr = Cairo::Context::create(new_outline_surface);
125 if (reuse_outline_surface) {
126 cr->set_operator(Cairo::Context::Operator::CLEAR);
130 cr->rectangle(reuse_rect->left() - dest.
rect.
left(), reuse_rect->top() - dest.
rect.
top(), reuse_rect->width(), reuse_rect->height());
133 cr->set_operator(Cairo::Context::Operator::SOURCE);
148 auto copy = [&,
this] (Cairo::RefPtr<Cairo::ImageSurface>
const &from,
149 Cairo::RefPtr<Cairo::ImageSurface>
const &to) {
150 auto cr = Cairo::Context::create(to);
151 cr->set_antialias(Cairo::ANTIALIAS_NONE);
152 cr->set_operator(Cairo::Context::Operator::SOURCE);
155 cr->translate(-1.0, -1.0);
157 cr->translate(1.0, 1.0);
160 Cairo::SurfacePattern(cr->get_source()->cobj()).set_filter(Cairo::SurfacePattern::Filter::FAST);
173 auto make_surface = [&] {
174 auto result = Cairo::ImageSurface::create(Cairo::Surface::Format::ARGB32, content_size.x(), content_size.y());
183 auto copy = [&,
this] (Cairo::RefPtr<Cairo::ImageSurface>
const &store_from,
184 Cairo::RefPtr<Cairo::ImageSurface>
const &snapshot_from,
185 Cairo::RefPtr<Cairo::ImageSurface>
const &to,
bool background) {
186 auto cr = Cairo::Context::create(to);
187 cr->set_antialias(Cairo::ANTIALIAS_NONE);
188 cr->set_operator(Cairo::Context::Operator::SOURCE);
194 Cairo::SurfacePattern(cr->get_source()->cobj()).set_filter(Cairo::SurfacePattern::Filter::FAST);
197 cr->translate(-1.0, -1.0);
199 cr->translate(1.0, 1.0);
202 Cairo::SurfacePattern(cr->get_source()->cobj()).set_filter(Cairo::SurfacePattern::Filter::FAST);
226 cr->set_operator(Cairo::Context::Operator::SOURCE);
227 cr->set_source(
surface, diff.x(), diff.y());
228 cr->rectangle(diff.x(), diff.y(),
fragment.rect.width(),
fragment.rect.height());
233 cr->set_operator(Cairo::Context::Operator::SOURCE);
235 cr->rectangle(diff.x(), diff.y(),
fragment.rect.width(),
fragment.rect.height());
246 cr->set_antialias(Cairo::ANTIALIAS_NONE);
260 cr->set_fill_rule(Cairo::Context::FillRule::EVEN_ODD);
264 cr->rectangle(s.rect.left(), s.rect.top(), s.rect.width(), s.rect.height());
273 auto draw_store = [&,
this] (Cairo::RefPtr<Cairo::ImageSurface>
const &
store, Cairo::RefPtr<Cairo::ImageSurface>
const &snapshot_store) {
281 cr->rectangle(r.left(), r.top(), r.width(), r.height());
282 cr->set_source(
store, r.left(), r.top());
283 Cairo::SurfacePattern(cr->get_source()->cobj()).set_filter(Cairo::SurfacePattern::Filter::FAST);
291 cr->set_fill_rule(Cairo::Context::FillRule::EVEN_ODD);
299 cr->rectangle(r.left(), r.top(), r.width(), r.height());
301 cr->set_source(snapshot_store, r.left(), r.top());
302 Cairo::SurfacePattern(cr->get_source()->cobj()).set_filter(Cairo::SurfacePattern::Filter::FAST);
305 cr->set_source_rgba(0, 0, 1, 0.2);
306 cr->set_operator(Cairo::Context::Operator::OVER);
317 Cairo::SurfacePattern(cr->get_source()->cobj()).set_filter(Cairo::SurfacePattern::Filter::FAST);
324 auto draw_overlay = [&,
this] {
331 cr->set_operator(Cairo::Context::Operator::OVER);
332 cr->set_source_rgb(1.0, 1.0, 1.0);
333 cr->paint_with_alpha(outline_overlay_opacity);
345 cr->rectangle(store_clip.left(), store_clip.top(), store_clip.width(), store_clip.height());
347 cr->set_operator(
background_in_stores ? Cairo::Context::Operator::SOURCE : Cairo::Context::Operator::OVER);
355 cr->translate(outline_clip.left(), outline_clip.top());
360 cr->rectangle(outline_clip.left(), outline_clip.top(), outline_clip.width(), outline_clip.height());
362 cr->set_operator(Cairo::Context::Operator::OVER);
369 cr->set_operator(
background_in_stores ? Cairo::Context::Operator::SOURCE : Cairo::Context::Operator::OVER);
376 cr->set_antialias(Cairo::ANTIALIAS_DEFAULT);
379 cr->set_antialias(Cairo::ANTIALIAS_NONE);
383 cr->set_operator(Cairo::Context::Operator::OVER);
389 cr->set_antialias(Cairo::ANTIALIAS_DEFAULT);
Cairo::RefPtr< Cairo::ImageSurface > surface
Cairo::RefPtr< Cairo::ImageSurface > outline_surface
Affine inverse() const
Compute the inverse matrix.
Axis aligned, non-empty, generic rectangle.
C top() const
Return top coordinate of the rectangle (+Y is downwards).
C left() const
Return leftmost coordinate of the rectangle (+X is to the right).
C height() const
Get the vertical extent of the rectangle.
C width() const
Get the horizontal extent of the rectangle.
CPoint min() const
Get the corner of the rectangle with smallest coordinate values.
CPoint dimensions() const
Get rectangle's width and height as a point.
Two-dimensional point with integer coordinates.
Paralellogram, representing a linear transformation of a rectangle.
void shift(T &a, T &b, T const &c)
Abstraction of the store/snapshot mechanism.
RAII object that logs a timing event for the duration of its lifetime.
Cairo::RectangleInt geom_to_cairo(const Geom::IntRect &rect)
Geom::IntRect cairo_to_geom(const Cairo::RectangleInt &rect)
Geom::IntPoint dimensions(const Cairo::RefPtr< Cairo::ImageSurface > &surface)