Bug 101751

Summary: Replaying recording surface in a script surface results in different output the second time
Product: cairo Reporter: Christoph Reiter <reiter.christoph>
Component: generalAssignee: Chris Wilson <chris>
Status: RESOLVED MOVED QA Contact: cairo-bugs mailing list <cairo-bugs>
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: Quick fix

Description Christoph Reiter 2017-07-11 10:38:48 UTC
This was originally filed with pycairo: https://github.com/pygobject/pycairo/issues/49

1) compile the given problem
2) execute it
3) The files 1.txt and 2.txt should appear in the cwd
Expected: The two files should have the same content
Actual: They have different contents

// gcc example.c -o example $(pkg-config --cflags --libs cairo)
#include <cairo/cairo.h>
#include <cairo/cairo-script.h>
#include <stdlib.h>

int main(void) {
    cairo_t *ctx;
    cairo_surface_t * rec;
    cairo_device_t *dev1, *dev2;
    cairo_surface_t *script1, *script2;

    rec = cairo_recording_surface_create(CAIRO_CONTENT_COLOR_ALPHA, NULL);
    ctx = cairo_create(rec);
    cairo_set_source_rgb(ctx, 0.25, 0.5, 0.75);
    cairo_paint(ctx);
    cairo_destroy(ctx);

    dev1 = cairo_script_create("1.txt");
    script1 = cairo_script_surface_create(dev1, CAIRO_CONTENT_COLOR_ALPHA, 100, 100);
    ctx = cairo_create(script1);
    cairo_set_source_surface(ctx, rec, 0, 0);
    cairo_paint(ctx);
    cairo_destroy(ctx);
    cairo_device_destroy(dev1);
    cairo_surface_destroy(script1);

    dev2 = cairo_script_create("2.txt");
    script2 = cairo_script_surface_create(dev2, CAIRO_CONTENT_COLOR_ALPHA, 100, 100);
    ctx = cairo_create(script2);
    cairo_set_source_surface(ctx, rec, 0, 0);
    cairo_paint(ctx);
    cairo_destroy(ctx);
    cairo_device_destroy(dev2);
    cairo_surface_destroy(script2);

    cairo_surface_destroy(rec);

    return 0;
}
Comment 1 Uli Schlachter 2017-07-11 15:45:03 UTC
Created attachment 132619 [details] [review]
Quick fix

The code only checks "was this surface already painted to a script device", not if it was actually painted to this specific device. The attached patch fixes that, but I wonder if something should happen so that the snapshots used can really be used by two script devices simultaneously. Right now the script surfaces will "overwrite their snapshots"...

Chris?
Comment 2 GitLab Migration User 2018-08-25 13:52:52 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/cairo/cairo/issues/244.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.