Skip to content

Commit

Permalink
Brute force redrawing
Browse files Browse the repository at this point in the history
  • Loading branch information
fagu committed Feb 15, 2021
1 parent f05c44e commit 8d0eb20
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ void DrawingLayerPicture::stroke_added(ptr_Stroke stroke) {
draw_stroke(stroke);
}

void DrawingLayerPicture::redraw(QRect rect) {
cr->rectangle(rect.left(), rect.top(), rect.width(), rect.height());
cr->clip();
set_transparent();
draw_strokes();
emit update(rect);
}

void DrawingLayerPicture::stroke_deleted(ptr_Stroke stroke) {
CairoGroup cg(cr);
PathStroke* path_stroke = convert_variant<PathStroke*>(stroke);
Expand All @@ -85,11 +93,7 @@ void DrawingLayerPicture::stroke_deleted(ptr_Stroke stroke) {
// Forget the deleted path
cr->begin_new_path();
// Clip to only redraw the bounding rectangle of the deleted stroke.
cr->rectangle(rect.left(), rect.top(), rect.width(), rect.height());
cr->clip();
set_transparent();
draw_strokes();
emit update(rect);
redraw(rect);
}

void DrawingLayerPicture::setup_stroke(ptr_Stroke stroke) {
Expand Down Expand Up @@ -126,8 +130,8 @@ void DrawingLayerPicture::draw_line(Point a, Point b, ptr_Stroke stroke) {
cr->move_to(a.x * unit2pixel, a.y * unit2pixel);
cr->line_to(b.x * unit2pixel, b.y * unit2pixel);
QRect rect = stroke_extents();
cr->stroke();
emit update(rect);
cr->begin_new_path();
redraw(rect);
}

QRect DrawingLayerPicture::stroke_extents() {
Expand Down
1 change: 1 addition & 0 deletions src/renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class DrawingLayerPicture : public LayerPicture {

private:
void stroke_added(ptr_Stroke stroke);
void redraw(QRect rect);
void stroke_deleted(ptr_Stroke stroke);

std::variant<NormalLayer*, TemporaryLayer*> m_layer;
Expand Down

0 comments on commit 8d0eb20

Please sign in to comment.