mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2025-12-20 04:40:07 +01:00
This test creates surfaces and patterns that it never cleans up. Found via running: CAIRO_TEST_TARGET=image valgrind --leak-check=full ./cairo-test-suite -f bug-431 Output before this commit: ==21310== ==21310== HEAP SUMMARY: ==21310== in use at exit: 569,788 bytes in 26 blocks ==21310== total heap usage: 1,523 allocs, 1,497 frees, 2,034,252 bytes allocated ==21310== ==21310== 336 bytes in 2 blocks are definitely lost in loss record 5 of 17 ==21310== at 0x48407B4: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==21310== by 0x48BE2B0: _cairo_pattern_create_solid (cairo-pattern.c:614) ==21310== by 0x48BE4B1: cairo_pattern_create_rgba (cairo-pattern.c:720) ==21310== by 0x1358C6: draw (bug-431.c:50) ==21310== by 0x129EDB: cairo_test_for_target (cairo-test.c:938) ==21310== by 0x12B36A: _cairo_test_context_run_for_target (cairo-test.c:1545) ==21310== by 0x12C370: _cairo_test_runner_draw (cairo-test-runner.c:258) ==21310== by 0x12DEA0: main (cairo-test-runner.c:962) ==21310== ==21310== 278,534 (144 direct, 278,390 indirect) bytes in 1 blocks are definitely lost in loss record 15 of 17 ==21310== at 0x48407B4: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==21310== by 0x48BE51E: cairo_pattern_create_for_surface (cairo-pattern.c:756) ==21310== by 0x135838: draw (bug-431.c:41) ==21310== by 0x129EDB: cairo_test_for_target (cairo-test.c:938) ==21310== by 0x12B36A: _cairo_test_context_run_for_target (cairo-test.c:1545) ==21310== by 0x12C370: _cairo_test_runner_draw (cairo-test-runner.c:258) ==21310== by 0x12DEA0: main (cairo-test-runner.c:962) ==21310== ==21310== 278,534 (144 direct, 278,390 indirect) bytes in 1 blocks are definitely lost in loss record 16 of 17 ==21310== at 0x48407B4: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==21310== by 0x48BE51E: cairo_pattern_create_for_surface (cairo-pattern.c:756) ==21310== by 0x488274D: _cairo_default_context_set_source_surface (cairo-default-context.c:327) ==21310== by 0x49063DB: cairo_set_source_surface (cairo.c:977) ==21310== by 0x1AC1DD: _cairo_boilerplate_get_image_surface (cairo-boilerplate.c:337) ==21310== by 0x12A486: cairo_test_for_target (cairo-test.c:1145) ==21310== by 0x12B36A: _cairo_test_context_run_for_target (cairo-test.c:1545) ==21310== by 0x12C370: _cairo_test_runner_draw (cairo-test-runner.c:258) ==21310== by 0x12DEA0: main (cairo-test-runner.c:962) ==21310== ==21310== LEAK SUMMARY: ==21310== definitely lost: 624 bytes in 4 blocks ==21310== indirectly lost: 556,780 bytes in 16 blocks ==21310== possibly lost: 0 bytes in 0 blocks ==21310== still reachable: 12,384 bytes in 6 blocks ==21310== suppressed: 0 bytes in 0 blocks ==21310== Reachable blocks (those to which a pointer was found) are not shown. ==21310== To see them, rerun with: --leak-check=full --show-leak-kinds=all ==21310== ==21310== For lists of detected and suppressed errors, rerun with: -s ==21310== ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 0 from 0) Signed-off-by: Uli Schlachter <psychon@znc.in>
68 lines
2.4 KiB
C
68 lines
2.4 KiB
C
/*
|
|
* Copyright © 2021 Lome More
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person
|
|
* obtaining a copy of this software and associated documentation
|
|
* files (the "Software"), to deal in the Software without
|
|
* restriction, including without limitation the rights to use, copy,
|
|
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
* of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be
|
|
* included in all copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*/
|
|
|
|
#include "cairo-test.h"
|
|
|
|
static cairo_test_status_t
|
|
draw (cairo_t *cr, int width, int height)
|
|
{
|
|
cairo_matrix_t test_matrix;
|
|
test_matrix.xx = 614;
|
|
test_matrix.yx = 0;
|
|
test_matrix.xy = 0;
|
|
test_matrix.yy = -794;
|
|
test_matrix.x0 = -1.3831;
|
|
test_matrix.y0 = 793;
|
|
cairo_set_matrix(cr, &test_matrix);
|
|
|
|
const cairo_test_context_t *ctx = cairo_test_get_context (cr);
|
|
cairo_surface_t *png_surface = cairo_test_create_surface_from_png (ctx, "romedalen.png");
|
|
cairo_pattern_t *png_pattern = cairo_pattern_create_for_surface(png_surface);
|
|
cairo_matrix_t matrix;
|
|
matrix.xx = 1228;
|
|
matrix.yx = 0;
|
|
matrix.xy = 0;
|
|
matrix.yy = -1590;
|
|
matrix.x0 = 0;
|
|
matrix.y0 = 1590;
|
|
cairo_pattern_set_matrix (png_pattern, &matrix);
|
|
cairo_pattern_t *mask_pattern = cairo_pattern_create_rgba (1.0, 1.0, 1.0, 0.15);
|
|
cairo_save(cr);
|
|
cairo_set_source(cr, png_pattern);
|
|
cairo_mask(cr, mask_pattern);
|
|
cairo_restore(cr);
|
|
|
|
cairo_surface_destroy (png_surface);
|
|
cairo_pattern_destroy (png_pattern);
|
|
cairo_pattern_destroy (mask_pattern);
|
|
|
|
return CAIRO_TEST_SUCCESS;
|
|
}
|
|
|
|
CAIRO_TEST (bug_431,
|
|
"Bug 431 (Different result on SVG surface)",
|
|
"", /* keywords */
|
|
NULL, /* requirements */
|
|
128, 96,
|
|
NULL, draw)
|