paint-source-alpha.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright © 2005 Red Hat, Inc.
  3. * Copyright © 2006 Red Hat, Inc.
  4. *
  5. * Permission to use, copy, modify, distribute, and sell this software
  6. * and its documentation for any purpose is hereby granted without
  7. * fee, provided that the above copyright notice appear in all copies
  8. * and that both that copyright notice and this permission notice
  9. * appear in supporting documentation, and that the name of
  10. * Red Hat, Inc. not be used in advertising or publicity pertaining to
  11. * distribution of the software without specific, written prior
  12. * permission. Red Hat, Inc. makes no representations about the
  13. * suitability of this software for any purpose. It is provided "as
  14. * is" without express or implied warranty.
  15. *
  16. * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
  17. * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  18. * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
  19. * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
  20. * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  21. * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
  22. * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  23. *
  24. * Author: Carl D. Worth <cworth@cworth.org>
  25. */
  26. #include "cairo-test.h"
  27. static cairo_test_status_t
  28. draw (cairo_t *cr, int width, int height)
  29. {
  30. cairo_surface_t *surface;
  31. uint32_t data[16] = {
  32. 0x80808080, 0x80808080, 0x80800000, 0x80800000,
  33. 0x80808080, 0x80808080, 0x80800000, 0x80800000,
  34. 0x80008000, 0x80008000, 0x80000080, 0x80000080,
  35. 0x80008000, 0x80008000, 0x80000080, 0x80000080
  36. };
  37. surface = cairo_image_surface_create_for_data ((unsigned char *) data,
  38. CAIRO_FORMAT_ARGB32, 4, 4, 16);
  39. cairo_test_paint_checkered (cr);
  40. cairo_scale (cr, 4, 4);
  41. cairo_set_source_surface (cr, surface, 2 , 2);
  42. cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_NEAREST);
  43. cairo_paint (cr);
  44. cairo_surface_finish (surface); /* data will go out of scope */
  45. cairo_surface_destroy (surface);
  46. return CAIRO_TEST_SUCCESS;
  47. }
  48. CAIRO_TEST (paint_source_alpha,
  49. "Simple test of cairo_paint with a source surface with non-opaque alpha",
  50. "paint, alpha", /* keywords */
  51. NULL, /* requirements */
  52. 32, 32,
  53. NULL, draw)