Back to index

lightning-sunbird  0.9+nobinonly
leaky_polygon.c
Go to the documentation of this file.
00001 /*
00002  * Copyright © 2005 Red Hat, Inc.
00003  *
00004  * Permission to use, copy, modify, distribute, and sell this software
00005  * and its documentation for any purpose is hereby granted without
00006  * fee, provided that the above copyright notice appear in all copies
00007  * and that both that copyright notice and this permission notice
00008  * appear in supporting documentation, and that the name of
00009  * Red Hat, Inc. not be used in advertising or publicity pertaining to
00010  * distribution of the software without specific, written prior
00011  * permission. Red Hat, Inc. makes no representations about the
00012  * suitability of this software for any purpose.  It is provided "as
00013  * is" without express or implied warranty.
00014  *
00015  * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
00016  * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
00017  * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
00018  * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
00019  * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
00020  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
00021  * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
00022  *
00023  * Author: Carl D. Worth <cworth@cworth.org>
00024  */
00025 
00026 /* Bug history
00027  *
00028  * 2005-01-07 Carl Worth <cworth@cworth.org>
00029  *
00030  *   Bug reported:
00031  *
00032  *     From: Chris <fltk@functionalfuture.com>
00033  *     Subject: [cairo] Render to image buffer artifacts
00034  *     To: cairo@cairographics.org
00035  *     Date: Fri, 07 Jan 2005 02:22:28 -0500
00036  *
00037  *     I've attached the code and image that shows this off.  Scaling at
00038  *     different levels seems to change the corruption.
00039  *
00040  *     For some reason there are artifacts in the alpha channel.  I don't know
00041  *     if that's the only place, but the alpha channel looks bad.
00042  *
00043  *     If you run the code and parse the attached image, directing stdout to a
00044  *     file, you can see in the lower left corner there are alpha values where
00045  *     it should be transparent.
00046  *     [...]
00047  *
00048  * 2005-01-11 Carl Worth <cworth@cworth.org>
00049  *
00050  *   I trimmed the original test case down to the code that appears here.
00051  *
00052  */
00053 
00054 #include "cairo_test.h"
00055 
00056 #define WIDTH 21
00057 #define HEIGHT 21
00058 
00059 cairo_test_t test = {
00060     "leaky_polygon",
00061     "Exercises a corner case in the trapezoid rasterization in which pixels outside the trapezoids received a non-zero alpha",
00062     WIDTH, HEIGHT
00063 };
00064 
00065 static void
00066 draw (cairo_t *cr, int width, int height)
00067 {
00068     cairo_scale (cr, 1.0/(1<<16), 1.0/(1<<16));
00069 
00070     cairo_move_to (cr, 131072,39321);
00071     cairo_line_to (cr, 1103072,1288088);
00072     cairo_line_to (cr, 1179648,1294990);
00073     cairo_close_path (cr);
00074 
00075     cairo_fill (cr);
00076 }
00077 
00078 int
00079 main (void)
00080 {
00081     return cairo_test (&test, draw);
00082 }