Skip to content

Commit

Permalink
Clear the screen before drawing, to avoid problems with image sources…
Browse files Browse the repository at this point in the history
… with transparency.
  • Loading branch information
JohannJEG committed Aug 23, 2024
1 parent 185b537 commit 53e5f25
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/filter/mirr0r/mirr0r.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ class Mirr0r : public frei0r::filter {

}

void clearScreen(cairo_t* cr, int width, int height) {
cairo_save (cr);
cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 0.0);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
cairo_paint (cr);
cairo_restore (cr);
}

virtual void update(double time, uint32_t* out, const uint32_t* in) {

int w = this->width;
Expand All @@ -71,6 +79,9 @@ class Mirr0r : public frei0r::filter {
// Create a Cairo drawing context for the destination surface
cairo_t *cr = cairo_create(dest_image);

// Clear the screen
clearScreen(cr, w, h);

// Create a Cairo surface for the source image
cairo_surface_t *image = cairo_image_surface_create_for_data((unsigned char*)in,
CAIRO_FORMAT_ARGB32,
Expand Down

0 comments on commit 53e5f25

Please sign in to comment.