Back to index

lightning-sunbird  0.9+nobinonly
clip_twice.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: Kristian Høgsberg <krh@redhat.com>
00024  */
00025 
00026 #include "cairo_test.h"
00027 
00028 #define WIDTH 64
00029 #define HEIGHT 64
00030 
00031 cairo_test_t test = {
00032     "clip_twice",
00033     "Verifies that the clip mask is updated correctly when it constructed by setting the clip path twice.",
00034     WIDTH, HEIGHT
00035 };
00036 
00037 static void
00038 draw (cairo_t *cr, int width, int height)
00039 {
00040     cairo_set_alpha (cr, 1.0);
00041     cairo_new_path (cr);
00042     cairo_arc (cr, WIDTH / 2, HEIGHT / 2, WIDTH / 3, 0, 2 * M_PI);
00043     cairo_clip (cr);
00044 
00045     cairo_new_path (cr);
00046     cairo_move_to (cr, 0, 0);
00047     cairo_line_to (cr, WIDTH / 4, HEIGHT / 2);
00048     cairo_line_to (cr, 0, HEIGHT);
00049     cairo_line_to (cr, WIDTH, HEIGHT);
00050     cairo_line_to (cr, 3 * WIDTH / 4, HEIGHT / 2);
00051     cairo_line_to (cr, WIDTH, 0);
00052     cairo_close_path (cr);
00053     cairo_clip (cr);
00054 
00055     cairo_set_rgb_color (cr, 0, 0, 0.6);
00056 
00057     cairo_new_path (cr);
00058     cairo_move_to (cr, 0, 0);
00059     cairo_line_to (cr, 0, HEIGHT);
00060     cairo_line_to (cr, WIDTH / 2, 3 * HEIGHT / 4);
00061     cairo_line_to (cr, WIDTH, HEIGHT);
00062     cairo_line_to (cr, WIDTH, 0);
00063     cairo_line_to (cr, WIDTH / 2, HEIGHT / 4);
00064     cairo_close_path (cr);
00065     cairo_fill (cr);
00066 }
00067 
00068 int
00069 main (void)
00070 {
00071     return cairo_test (&test, draw);
00072 }