mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-09 07:18:04 +02:00
Add tests for the new LCD filter API
This commit is contained in:
parent
45ec5e77bb
commit
65d017a406
12 changed files with 350 additions and 1 deletions
|
|
@ -149,6 +149,10 @@ text-antialias-gray$(EXEEXT) \
|
|||
text-antialias-none$(EXEEXT) \
|
||||
text-antialias-subpixel$(EXEEXT) \
|
||||
text-cache-crash$(EXEEXT) \
|
||||
text-lcd-filter-fir3$(EXEEXT) \
|
||||
text-lcd-filter-fir5$(EXEEXT) \
|
||||
text-lcd-filter-intra-pixel$(EXEEXT) \
|
||||
text-lcd-filter-none$(EXEEXT) \
|
||||
text-pattern$(EXEEXT) \
|
||||
text-rotate$(EXEEXT) \
|
||||
text-transform$(EXEEXT) \
|
||||
|
|
|
|||
|
|
@ -72,7 +72,11 @@ main (void)
|
|||
|
||||
cairo_font_options_set_subpixel_order (NULL, CAIRO_SUBPIXEL_ORDER_DEFAULT);
|
||||
cairo_font_options_get_subpixel_order (NULL);
|
||||
assert (cairo_font_options_get_subpixel_order (default_options) == CAIRO_SUBPIXEL_ORDER_DEFAULT);
|
||||
assert (cairo_font_options_get_subpixel_order (default_options) == CAIRO_SUBPIXEL_ORDER_DEFAULT);
|
||||
|
||||
cairo_font_options_set_lcd_filter (NULL, CAIRO_LCD_FILTER_DEFAULT);
|
||||
cairo_font_options_get_lcd_filter (NULL);
|
||||
assert (cairo_font_options_get_lcd_filter (default_options) == CAIRO_LCD_FILTER_DEFAULT);
|
||||
|
||||
cairo_font_options_set_hint_style (NULL, CAIRO_HINT_STYLE_DEFAULT);
|
||||
cairo_font_options_get_hint_style (NULL);
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 974 B |
|
|
@ -57,6 +57,7 @@ draw (cairo_t *cr, int width, int height)
|
|||
cairo_get_font_options (cr, font_options);
|
||||
cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_SUBPIXEL);
|
||||
cairo_font_options_set_subpixel_order (font_options, CAIRO_SUBPIXEL_ORDER_RGB);
|
||||
cairo_font_options_set_lcd_filter (font_options, CAIRO_LCD_FILTER_NONE);
|
||||
cairo_set_font_options (cr, font_options);
|
||||
|
||||
cairo_font_options_destroy (font_options);
|
||||
|
|
|
|||
BIN
test/text-lcd-filter-fir3-ref.png
Normal file
BIN
test/text-lcd-filter-fir3-ref.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 974 B |
85
test/text-lcd-filter-fir3.c
Normal file
85
test/text-lcd-filter-fir3.c
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* Copyright © 2005 Red Hat, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software
|
||||
* and its documentation for any purpose is hereby granted without
|
||||
* fee, provided that the above copyright notice appear in all copies
|
||||
* and that both that copyright notice and this permission notice
|
||||
* appear in supporting documentation, and that the name of
|
||||
* Red Hat, Inc. not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior
|
||||
* permission. Red Hat, Inc. makes no representations about the
|
||||
* suitability of this software for any purpose. It is provided "as
|
||||
* is" without express or implied warranty.
|
||||
*
|
||||
* RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
|
||||
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
|
||||
* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Author: Carl D. Worth <cworth@cworth.org>
|
||||
*/
|
||||
|
||||
#include "cairo-test.h"
|
||||
|
||||
#define WIDTH 31
|
||||
#define HEIGHT 22
|
||||
#define TEXT_SIZE 12
|
||||
|
||||
static cairo_test_draw_function_t draw;
|
||||
|
||||
cairo_test_t test = {
|
||||
"text-lcd-filter-fir3",
|
||||
"Tests text rendering with a 3x3 kernel FIR LCD filter",
|
||||
WIDTH, HEIGHT,
|
||||
draw
|
||||
};
|
||||
|
||||
static cairo_test_status_t
|
||||
draw (cairo_t *cr, int width, int height)
|
||||
{
|
||||
cairo_text_extents_t extents;
|
||||
cairo_font_options_t *font_options;
|
||||
static char black[] = "black", blue[] = "blue";
|
||||
|
||||
/* We draw in the default black, so paint white first. */
|
||||
cairo_save (cr);
|
||||
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */
|
||||
cairo_paint (cr);
|
||||
cairo_restore (cr);
|
||||
|
||||
cairo_select_font_face (cr, "Bitstream Vera Sans",
|
||||
CAIRO_FONT_SLANT_NORMAL,
|
||||
CAIRO_FONT_WEIGHT_NORMAL);
|
||||
cairo_set_font_size (cr, TEXT_SIZE);
|
||||
|
||||
font_options = cairo_font_options_create ();
|
||||
cairo_get_font_options (cr, font_options);
|
||||
cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_SUBPIXEL);
|
||||
cairo_font_options_set_lcd_filter (font_options, CAIRO_LCD_FILTER_FIR3);
|
||||
cairo_set_font_options (cr, font_options);
|
||||
|
||||
cairo_font_options_destroy (font_options);
|
||||
|
||||
cairo_set_source_rgb (cr, 0, 0, 0); /* black */
|
||||
cairo_text_extents (cr, black, &extents);
|
||||
cairo_move_to (cr, -extents.x_bearing, -extents.y_bearing);
|
||||
cairo_show_text (cr, black);
|
||||
cairo_translate (cr, 0, -extents.y_bearing + 1);
|
||||
|
||||
cairo_set_source_rgb (cr, 0, 0, 1); /* blue */
|
||||
cairo_text_extents (cr, blue, &extents);
|
||||
cairo_move_to (cr, -extents.x_bearing, -extents.y_bearing);
|
||||
cairo_show_text (cr, blue);
|
||||
|
||||
return CAIRO_TEST_SUCCESS;
|
||||
}
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
return cairo_test (&test);
|
||||
}
|
||||
BIN
test/text-lcd-filter-fir5-ref.png
Normal file
BIN
test/text-lcd-filter-fir5-ref.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 974 B |
85
test/text-lcd-filter-fir5.c
Normal file
85
test/text-lcd-filter-fir5.c
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* Copyright © 2005 Red Hat, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software
|
||||
* and its documentation for any purpose is hereby granted without
|
||||
* fee, provided that the above copyright notice appear in all copies
|
||||
* and that both that copyright notice and this permission notice
|
||||
* appear in supporting documentation, and that the name of
|
||||
* Red Hat, Inc. not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior
|
||||
* permission. Red Hat, Inc. makes no representations about the
|
||||
* suitability of this software for any purpose. It is provided "as
|
||||
* is" without express or implied warranty.
|
||||
*
|
||||
* RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
|
||||
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
|
||||
* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Author: Carl D. Worth <cworth@cworth.org>
|
||||
*/
|
||||
|
||||
#include "cairo-test.h"
|
||||
|
||||
#define WIDTH 31
|
||||
#define HEIGHT 22
|
||||
#define TEXT_SIZE 12
|
||||
|
||||
static cairo_test_draw_function_t draw;
|
||||
|
||||
cairo_test_t test = {
|
||||
"text-lcd-filter-fir5",
|
||||
"Tests text rendering with a 5x5 kernel FIR LCD filter",
|
||||
WIDTH, HEIGHT,
|
||||
draw
|
||||
};
|
||||
|
||||
static cairo_test_status_t
|
||||
draw (cairo_t *cr, int width, int height)
|
||||
{
|
||||
cairo_text_extents_t extents;
|
||||
cairo_font_options_t *font_options;
|
||||
static char black[] = "black", blue[] = "blue";
|
||||
|
||||
/* We draw in the default black, so paint white first. */
|
||||
cairo_save (cr);
|
||||
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */
|
||||
cairo_paint (cr);
|
||||
cairo_restore (cr);
|
||||
|
||||
cairo_select_font_face (cr, "Bitstream Vera Sans",
|
||||
CAIRO_FONT_SLANT_NORMAL,
|
||||
CAIRO_FONT_WEIGHT_NORMAL);
|
||||
cairo_set_font_size (cr, TEXT_SIZE);
|
||||
|
||||
font_options = cairo_font_options_create ();
|
||||
cairo_get_font_options (cr, font_options);
|
||||
cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_SUBPIXEL);
|
||||
cairo_font_options_set_lcd_filter (font_options, CAIRO_LCD_FILTER_FIR5);
|
||||
cairo_set_font_options (cr, font_options);
|
||||
|
||||
cairo_font_options_destroy (font_options);
|
||||
|
||||
cairo_set_source_rgb (cr, 0, 0, 0); /* black */
|
||||
cairo_text_extents (cr, black, &extents);
|
||||
cairo_move_to (cr, -extents.x_bearing, -extents.y_bearing);
|
||||
cairo_show_text (cr, black);
|
||||
cairo_translate (cr, 0, -extents.y_bearing + 1);
|
||||
|
||||
cairo_set_source_rgb (cr, 0, 0, 1); /* blue */
|
||||
cairo_text_extents (cr, blue, &extents);
|
||||
cairo_move_to (cr, -extents.x_bearing, -extents.y_bearing);
|
||||
cairo_show_text (cr, blue);
|
||||
|
||||
return CAIRO_TEST_SUCCESS;
|
||||
}
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
return cairo_test (&test);
|
||||
}
|
||||
BIN
test/text-lcd-filter-intra-pixel-ref.png
Normal file
BIN
test/text-lcd-filter-intra-pixel-ref.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 974 B |
85
test/text-lcd-filter-intra-pixel.c
Normal file
85
test/text-lcd-filter-intra-pixel.c
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* Copyright © 2005 Red Hat, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software
|
||||
* and its documentation for any purpose is hereby granted without
|
||||
* fee, provided that the above copyright notice appear in all copies
|
||||
* and that both that copyright notice and this permission notice
|
||||
* appear in supporting documentation, and that the name of
|
||||
* Red Hat, Inc. not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior
|
||||
* permission. Red Hat, Inc. makes no representations about the
|
||||
* suitability of this software for any purpose. It is provided "as
|
||||
* is" without express or implied warranty.
|
||||
*
|
||||
* RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
|
||||
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
|
||||
* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Author: Carl D. Worth <cworth@cworth.org>
|
||||
*/
|
||||
|
||||
#include "cairo-test.h"
|
||||
|
||||
#define WIDTH 31
|
||||
#define HEIGHT 22
|
||||
#define TEXT_SIZE 12
|
||||
|
||||
static cairo_test_draw_function_t draw;
|
||||
|
||||
cairo_test_t test = {
|
||||
"text-lcd-filter-intra-pixel",
|
||||
"Tests text rendering with intra-pixel LCD filter",
|
||||
WIDTH, HEIGHT,
|
||||
draw
|
||||
};
|
||||
|
||||
static cairo_test_status_t
|
||||
draw (cairo_t *cr, int width, int height)
|
||||
{
|
||||
cairo_text_extents_t extents;
|
||||
cairo_font_options_t *font_options;
|
||||
static char black[] = "black", blue[] = "blue";
|
||||
|
||||
/* We draw in the default black, so paint white first. */
|
||||
cairo_save (cr);
|
||||
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */
|
||||
cairo_paint (cr);
|
||||
cairo_restore (cr);
|
||||
|
||||
cairo_select_font_face (cr, "Bitstream Vera Sans",
|
||||
CAIRO_FONT_SLANT_NORMAL,
|
||||
CAIRO_FONT_WEIGHT_NORMAL);
|
||||
cairo_set_font_size (cr, TEXT_SIZE);
|
||||
|
||||
font_options = cairo_font_options_create ();
|
||||
cairo_get_font_options (cr, font_options);
|
||||
cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_SUBPIXEL);
|
||||
cairo_font_options_set_lcd_filter (font_options, CAIRO_LCD_FILTER_INTRA_PIXEL);
|
||||
cairo_set_font_options (cr, font_options);
|
||||
|
||||
cairo_font_options_destroy (font_options);
|
||||
|
||||
cairo_set_source_rgb (cr, 0, 0, 0); /* black */
|
||||
cairo_text_extents (cr, black, &extents);
|
||||
cairo_move_to (cr, -extents.x_bearing, -extents.y_bearing);
|
||||
cairo_show_text (cr, black);
|
||||
cairo_translate (cr, 0, -extents.y_bearing + 1);
|
||||
|
||||
cairo_set_source_rgb (cr, 0, 0, 1); /* blue */
|
||||
cairo_text_extents (cr, blue, &extents);
|
||||
cairo_move_to (cr, -extents.x_bearing, -extents.y_bearing);
|
||||
cairo_show_text (cr, blue);
|
||||
|
||||
return CAIRO_TEST_SUCCESS;
|
||||
}
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
return cairo_test (&test);
|
||||
}
|
||||
BIN
test/text-lcd-filter-none-ref.png
Normal file
BIN
test/text-lcd-filter-none-ref.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 974 B |
85
test/text-lcd-filter-none.c
Normal file
85
test/text-lcd-filter-none.c
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* Copyright © 2005 Red Hat, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software
|
||||
* and its documentation for any purpose is hereby granted without
|
||||
* fee, provided that the above copyright notice appear in all copies
|
||||
* and that both that copyright notice and this permission notice
|
||||
* appear in supporting documentation, and that the name of
|
||||
* Red Hat, Inc. not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior
|
||||
* permission. Red Hat, Inc. makes no representations about the
|
||||
* suitability of this software for any purpose. It is provided "as
|
||||
* is" without express or implied warranty.
|
||||
*
|
||||
* RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
|
||||
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
|
||||
* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Author: Carl D. Worth <cworth@cworth.org>
|
||||
*/
|
||||
|
||||
#include "cairo-test.h"
|
||||
|
||||
#define WIDTH 31
|
||||
#define HEIGHT 22
|
||||
#define TEXT_SIZE 12
|
||||
|
||||
static cairo_test_draw_function_t draw;
|
||||
|
||||
cairo_test_t test = {
|
||||
"text-lcd-filter-none",
|
||||
"Tests text rendering with no LCD filter",
|
||||
WIDTH, HEIGHT,
|
||||
draw
|
||||
};
|
||||
|
||||
static cairo_test_status_t
|
||||
draw (cairo_t *cr, int width, int height)
|
||||
{
|
||||
cairo_text_extents_t extents;
|
||||
cairo_font_options_t *font_options;
|
||||
static char black[] = "black", blue[] = "blue";
|
||||
|
||||
/* We draw in the default black, so paint white first. */
|
||||
cairo_save (cr);
|
||||
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */
|
||||
cairo_paint (cr);
|
||||
cairo_restore (cr);
|
||||
|
||||
cairo_select_font_face (cr, "Bitstream Vera Sans",
|
||||
CAIRO_FONT_SLANT_NORMAL,
|
||||
CAIRO_FONT_WEIGHT_NORMAL);
|
||||
cairo_set_font_size (cr, TEXT_SIZE);
|
||||
|
||||
font_options = cairo_font_options_create ();
|
||||
cairo_get_font_options (cr, font_options);
|
||||
cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_SUBPIXEL);
|
||||
cairo_font_options_set_lcd_filter (font_options, CAIRO_LCD_FILTER_NONE);
|
||||
cairo_set_font_options (cr, font_options);
|
||||
|
||||
cairo_font_options_destroy (font_options);
|
||||
|
||||
cairo_set_source_rgb (cr, 0, 0, 0); /* black */
|
||||
cairo_text_extents (cr, black, &extents);
|
||||
cairo_move_to (cr, -extents.x_bearing, -extents.y_bearing);
|
||||
cairo_show_text (cr, black);
|
||||
cairo_translate (cr, 0, -extents.y_bearing + 1);
|
||||
|
||||
cairo_set_source_rgb (cr, 0, 0, 1); /* blue */
|
||||
cairo_text_extents (cr, blue, &extents);
|
||||
cairo_move_to (cr, -extents.x_bearing, -extents.y_bearing);
|
||||
cairo_show_text (cr, blue);
|
||||
|
||||
return CAIRO_TEST_SUCCESS;
|
||||
}
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
return cairo_test (&test);
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue