41 |
#include <gdk/gdktypes.h> |
#include <gdk/gdktypes.h> |
42 |
#include <gdk/gdkprivate.h> |
#include <gdk/gdkprivate.h> |
43 |
#include <gdk/gdkx.h> |
#include <gdk/gdkx.h> |
44 |
|
#include <X11/extensions/Xrender.h> |
45 |
|
|
46 |
#include <gdk-pixbuf/gdk-pixbuf.h> |
#include <gdk-pixbuf/gdk-pixbuf.h> |
47 |
#include <gdk-pixbuf/gdk-pixdata.h> |
#include <gdk-pixbuf/gdk-pixdata.h> |
197 |
g_assert (gdk_pixbuf_get_bits_per_sample (gr->drawbuf) == bits_per_sample); |
g_assert (gdk_pixbuf_get_bits_per_sample (gr->drawbuf) == bits_per_sample); |
198 |
g_assert (gdk_pixbuf_get_n_channels (gr->drawbuf) == total_channels); |
g_assert (gdk_pixbuf_get_n_channels (gr->drawbuf) == total_channels); |
199 |
|
|
200 |
gr->surface = cairo_surface_create_for_image ((char *) gdk_pixbuf_get_pixels (gr->drawbuf), |
gr->surface = cairo_image_surface_create_for_data (gdk_pixbuf_get_pixels (gr->drawbuf), |
201 |
CAIRO_FORMAT_ARGB32, |
CAIRO_FORMAT_ARGB32, |
202 |
gdk_pixbuf_get_width (gr->drawbuf), |
gdk_pixbuf_get_width (gr->drawbuf), |
203 |
gdk_pixbuf_get_height (gr->drawbuf), |
gdk_pixbuf_get_height (gr->drawbuf), |
205 |
g_assert (gr->surface != NULL); |
g_assert (gr->surface != NULL); |
206 |
g_assert (gr->cr != NULL); |
g_assert (gr->cr != NULL); |
207 |
gr->mode = MODE_DRAWABLE_NO_RENDER; |
gr->mode = MODE_DRAWABLE_NO_RENDER; |
208 |
cairo_set_target_surface (gr->cr, gr->surface); |
cairo_destroy (gr->cr); |
209 |
|
gr->cr = cairo_create (gr->surface); |
210 |
} |
} |
211 |
|
|
212 |
static void |
static void |
236 |
g_assert (gr->surface != NULL); |
g_assert (gr->surface != NULL); |
237 |
g_assert (gr->cr != NULL); |
g_assert (gr->cr != NULL); |
238 |
gr->mode = MODE_DRAWABLE_WITH_RENDER; |
gr->mode = MODE_DRAWABLE_WITH_RENDER; |
239 |
cairo_set_target_surface (gr->cr, gr->surface); |
cairo_destroy (gr->cr); |
240 |
|
gr->cr = cairo_create (gr->surface); |
241 |
} |
} |
242 |
|
|
243 |
static void |
static void |
276 |
|
|
277 |
case MODE_JAVA_ARRAY: |
case MODE_JAVA_ARRAY: |
278 |
gr->javabuf = (*env)->GetIntArrayElements (env, gr->jarray, &gr->isCopy); |
gr->javabuf = (*env)->GetIntArrayElements (env, gr->jarray, &gr->isCopy); |
279 |
gr->surface = cairo_surface_create_for_image ((char *) gr->javabuf, |
gr->surface = cairo_image_surface_create_for_data ((unsigned char *) gr->javabuf, |
280 |
CAIRO_FORMAT_ARGB32, |
CAIRO_FORMAT_ARGB32, |
281 |
gr->width, |
gr->width, |
282 |
gr->height, |
gr->height, |
283 |
gr->width * 4); |
gr->width * 4); |
284 |
g_assert(gr->surface != NULL); |
g_assert(gr->surface != NULL); |
285 |
g_assert(gr->cr != NULL); |
g_assert(gr->cr != NULL); |
286 |
cairo_set_target_surface (gr->cr, gr->surface); |
cairo_destroy (gr->cr); |
287 |
|
gr->cr = cairo_create (gr->surface); |
288 |
break; |
break; |
289 |
} |
} |
290 |
} |
} |
337 |
static void |
static void |
338 |
update_pattern_transform (struct graphics2d *gr) |
update_pattern_transform (struct graphics2d *gr) |
339 |
{ |
{ |
340 |
double a, b, c, d, tx, ty; |
cairo_matrix_t mat; |
|
cairo_matrix_t *mat = NULL; |
|
341 |
|
|
342 |
g_assert (gr != NULL); |
g_assert (gr != NULL); |
343 |
if (gr->pattern == NULL) |
if (gr->pattern == NULL) |
344 |
return; |
return; |
345 |
|
|
346 |
return; |
cairo_get_matrix (gr->cr, &mat); |
347 |
/* temporarily disabled: ambiguous behavior */ |
cairo_pattern_set_matrix (gr->pattern, &mat); |
|
/* cairo_get_matrix (gr->cr, &a, &b, &c, &d, &tx, &ty); */ |
|
|
mat = cairo_matrix_create (); |
|
|
g_assert (mat != NULL); |
|
|
cairo_matrix_set_affine (mat, a, b, c, d, tx, ty); |
|
|
cairo_pattern_set_matrix (gr->pattern, mat); |
|
|
cairo_matrix_destroy (mat); |
|
348 |
} |
} |
349 |
|
|
350 |
static void |
static void |
393 |
g->drawable = g_old->drawable; |
g->drawable = g_old->drawable; |
394 |
|
|
395 |
g_object_ref (g->drawable); |
g_object_ref (g->drawable); |
396 |
|
|
397 |
g->cr = cairo_create(); |
g->cr = gdk_cairo_create (g->drawable); |
398 |
g_assert (g->cr != NULL); |
g_assert (g->cr != NULL); |
399 |
|
|
400 |
if (x_server_has_render_extension ()) |
if (x_server_has_render_extension ()) |
403 |
init_graphics2d_as_pixbuf (g); |
init_graphics2d_as_pixbuf (g); |
404 |
} |
} |
405 |
|
|
406 |
cairo_surface_set_filter (g->surface, CAIRO_FILTER_FAST); |
cairo_pattern_set_filter (g->pattern, CAIRO_FILTER_FAST); |
407 |
|
|
408 |
NSA_SET_G2D_PTR (env, obj, g); |
NSA_SET_G2D_PTR (env, obj, g); |
409 |
gdk_threads_leave(); |
gdk_threads_leave(); |
426 |
if (gr->debug) printf ("constructing java-backed image of size (%d,%d)\n", |
if (gr->debug) printf ("constructing java-backed image of size (%d,%d)\n", |
427 |
width, height); |
width, height); |
428 |
|
|
429 |
gr->cr = cairo_create(); |
gr->cr = gdk_cairo_create (gr->drawable); |
430 |
g_assert (gr->cr != NULL); |
g_assert (gr->cr != NULL); |
431 |
|
|
432 |
gr->width = width; |
gr->width = width; |
461 |
gdk_rgb_get_visual ()->depth); |
gdk_rgb_get_visual ()->depth); |
462 |
g_assert (gr->drawable != NULL); |
g_assert (gr->drawable != NULL); |
463 |
|
|
464 |
gr->cr = cairo_create(); |
gr->cr = gdk_cairo_create (gr->drawable); |
465 |
g_assert (gr->cr != NULL); |
g_assert (gr->cr != NULL); |
466 |
|
|
467 |
if (x_server_has_render_extension ()) |
if (x_server_has_render_extension ()) |
481 |
{ |
{ |
482 |
struct graphics2d *src = NULL, *dst = NULL; |
struct graphics2d *src = NULL, *dst = NULL; |
483 |
gint s_height, s_width, d_height, d_width, height, width; |
gint s_height, s_width, d_height, d_width, height, width; |
484 |
cairo_matrix_t *matrix; |
cairo_matrix_t matrix; |
485 |
cairo_operator_t tmp_op; |
cairo_operator_t tmp_op; |
486 |
|
|
487 |
gdk_threads_enter(); |
gdk_threads_enter(); |
502 |
width = min (s_width, d_width); |
width = min (s_width, d_width); |
503 |
height = min (s_height, d_height); |
height = min (s_height, d_height); |
504 |
|
|
505 |
matrix = cairo_matrix_create (); |
cairo_get_matrix (src->cr, &matrix); |
506 |
cairo_surface_get_matrix (src->surface, matrix); |
cairo_matrix_translate (&matrix, (double)-x, (double)-y); |
507 |
cairo_matrix_translate (matrix, (double)-x, (double)-y); |
cairo_pattern_set_matrix (src->pattern, &matrix); |
508 |
cairo_surface_set_matrix (src->surface, matrix); |
|
509 |
|
tmp_op = cairo_get_operator (dst->cr); |
510 |
tmp_op = cairo_current_operator (dst->cr); |
cairo_set_operator(dst->cr, CAIRO_OPERATOR_SOURCE); |
511 |
cairo_set_operator(dst->cr, CAIRO_OPERATOR_SRC); |
cairo_set_source_surface (dst->cr, src->surface, width, height); |
512 |
cairo_show_surface (dst->cr, src->surface, width, height); |
cairo_paint (dst->cr); |
513 |
cairo_set_operator(dst->cr, tmp_op); |
cairo_set_operator(dst->cr, tmp_op); |
514 |
|
|
515 |
cairo_matrix_translate (matrix, (double)x, (double)y); |
cairo_matrix_translate (&matrix, (double)x, (double)y); |
516 |
cairo_surface_set_matrix (src->surface, matrix); |
cairo_pattern_set_matrix (src->pattern, &matrix); |
|
cairo_matrix_destroy (matrix); |
|
517 |
|
|
518 |
gdk_flush(); |
gdk_flush(); |
519 |
|
|
542 |
|
|
543 |
check_for_debug (gr); |
check_for_debug (gr); |
544 |
|
|
|
gr->cr = cairo_create(); |
|
|
g_assert (gr->cr != NULL); |
|
|
|
|
545 |
widget = GTK_WIDGET (ptr); |
widget = GTK_WIDGET (ptr); |
546 |
g_assert (widget != NULL); |
g_assert (widget != NULL); |
547 |
|
|
548 |
grab_current_drawable (widget, &(gr->drawable), &(gr->win)); |
grab_current_drawable (widget, &(gr->drawable), &(gr->win)); |
549 |
g_assert (gr->drawable != NULL); |
g_assert (gr->drawable != NULL); |
550 |
|
|
551 |
|
gr->cr = gdk_cairo_create (gr->drawable); |
552 |
|
g_assert (gr->cr != NULL); |
553 |
|
|
554 |
if (x_server_has_render_extension ()) |
if (x_server_has_render_extension ()) |
555 |
init_graphics2d_as_renderable (gr); |
init_graphics2d_as_renderable (gr); |
556 |
else |
else |
630 |
{ |
{ |
631 |
struct graphics2d *gr = NULL; |
struct graphics2d *gr = NULL; |
632 |
cairo_surface_t *surf = NULL; |
cairo_surface_t *surf = NULL; |
633 |
cairo_matrix_t *mat = NULL; |
cairo_t *cr2 = NULL; |
634 |
|
cairo_matrix_t mat; |
635 |
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj); |
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj); |
636 |
g_assert (gr != NULL); |
g_assert (gr != NULL); |
637 |
|
|
643 |
r1, g1, b1, a1, |
r1, g1, b1, a1, |
644 |
r2, g2, b2, a2); |
r2, g2, b2, a2); |
645 |
|
|
|
cairo_save (gr->cr); |
|
|
|
|
646 |
if (cyclic) |
if (cyclic) |
647 |
surf = cairo_surface_create_similar (gr->surface, CAIRO_FORMAT_ARGB32, 3, 2); |
surf = cairo_surface_create_similar (gr->surface, CAIRO_FORMAT_ARGB32, 3, 2); |
648 |
else |
else |
649 |
surf = cairo_surface_create_similar (gr->surface, CAIRO_FORMAT_ARGB32, 2, 2); |
surf = cairo_surface_create_similar (gr->surface, CAIRO_FORMAT_ARGB32, 2, 2); |
650 |
g_assert (surf != NULL); |
g_assert (surf != NULL); |
651 |
|
|
652 |
cairo_set_target_surface (gr->cr, surf); |
cr2 = cairo_create (surf); |
653 |
|
|
654 |
cairo_identity_matrix (gr->cr); |
cairo_identity_matrix (cr2); |
655 |
|
|
656 |
cairo_set_rgb_color (gr->cr, r1 / 255.0, g1 / 255.0, b1 / 255.0); |
cairo_set_source_rgba (cr2, r1 / 255.0, g1 / 255.0, b1 / 255.0, a1 / 255.0); |
657 |
cairo_set_alpha (gr->cr, a1 / 255.0); |
cairo_rectangle (cr2, 0, 0, 1, 2); |
658 |
cairo_rectangle (gr->cr, 0, 0, 1, 2); |
cairo_fill (cr2); |
|
cairo_fill (gr->cr); |
|
659 |
|
|
660 |
cairo_set_rgb_color (gr->cr, r2 / 255.0, g2 / 255.0, b2 / 255.0); |
cairo_set_source_rgba (cr2, r2 / 255.0, g2 / 255.0, b2 / 255.0, a2 / 255.0); |
661 |
cairo_set_alpha (gr->cr, a2 / 255.0); |
cairo_rectangle (cr2, 1, 0, 1, 2); |
662 |
cairo_rectangle (gr->cr, 1, 0, 1, 2); |
cairo_fill (cr2); |
|
cairo_fill (gr->cr); |
|
663 |
|
|
664 |
if (cyclic) |
if (cyclic) |
665 |
{ |
{ |
666 |
cairo_set_rgb_color (gr->cr, r1 / 255.0, g1 / 255.0, b1 / 255.0); |
cairo_set_source_rgba (cr2, r1 / 255.0, g1 / 255.0, b1 / 255.0, a1 / 255.0); |
667 |
cairo_set_alpha (gr->cr, a1 / 255.0); |
cairo_rectangle (cr2, 2, 0, 1, 2); |
668 |
cairo_rectangle (gr->cr, 2, 0, 1, 2); |
cairo_fill (cr2); |
|
cairo_fill (gr->cr); |
|
669 |
} |
} |
670 |
|
|
671 |
mat = cairo_matrix_create (); |
cairo_matrix_init_identity (&mat); |
|
g_assert (mat != NULL); |
|
672 |
|
|
673 |
/* |
/* |
674 |
consider the vector [x2 - x1, y2 - y1] = [p,q] |
consider the vector [x2 - x1, y2 - y1] = [p,q] |
707 |
double c = (y2 - y1 == 0.) ? 0. : (1. / (y2 - y1)); |
double c = (y2 - y1 == 0.) ? 0. : (1. / (y2 - y1)); |
708 |
double dx = (x1 == 0.) ? 0. : 1. / x1; |
double dx = (x1 == 0.) ? 0. : 1. / x1; |
709 |
double dy = (y1 == 0.) ? 0. : 1. / y1; |
double dy = (y1 == 0.) ? 0. : 1. / y1; |
710 |
|
cairo_pattern_t *p; |
711 |
|
|
712 |
cairo_matrix_set_affine (mat, |
cairo_matrix_init (&mat, |
713 |
a, 0., |
a, 0., |
714 |
c, 0., |
c, 0., |
715 |
dx, dy); |
dx, dy); |
716 |
|
|
717 |
cairo_surface_set_matrix (surf, mat); |
p = cairo_pattern_create_for_surface (surf); |
718 |
cairo_matrix_destroy (mat); |
cairo_pattern_set_matrix (p, &mat); |
719 |
cairo_surface_set_filter (surf, CAIRO_FILTER_BILINEAR); |
cairo_pattern_set_filter (p, CAIRO_FILTER_BILINEAR); |
720 |
} |
} |
721 |
|
|
722 |
/* FIXME: repeating gradients (not to mention hold gradients) don't seem to work. */ |
/* FIXME: repeating gradients (not to mention hold gradients) don't seem to work. */ |
735 |
gr->pattern_surface = surf; |
gr->pattern_surface = surf; |
736 |
gr->pattern = cairo_pattern_create_for_surface(surf); |
gr->pattern = cairo_pattern_create_for_surface(surf); |
737 |
|
|
738 |
cairo_restore (gr->cr); |
cairo_set_source (gr->cr, gr->pattern); |
|
cairo_set_pattern (gr->cr, gr->pattern); |
|
739 |
gdk_threads_leave(); |
gdk_threads_leave(); |
740 |
} |
} |
741 |
|
|
775 |
memcpy (gr->pattern_pixels, jpixels, h * stride * 4); |
memcpy (gr->pattern_pixels, jpixels, h * stride * 4); |
776 |
(*env)->ReleaseIntArrayElements (env, jarr, jpixels, 0); |
(*env)->ReleaseIntArrayElements (env, jarr, jpixels, 0); |
777 |
|
|
778 |
gr->pattern_surface = cairo_surface_create_for_image (gr->pattern_pixels, |
gr->pattern_surface = cairo_image_surface_create_for_data ((unsigned char *)gr->pattern_pixels, |
779 |
CAIRO_FORMAT_ARGB32, |
CAIRO_FORMAT_ARGB32, |
780 |
w, h, stride * 4); |
w, h, stride * 4); |
781 |
g_assert (gr->pattern_surface != NULL); |
g_assert (gr->pattern_surface != NULL); |
782 |
cairo_surface_set_repeat (gr->pattern_surface, 1); |
cairo_pattern_set_extend (gr->pattern, 1); |
783 |
gr->pattern = cairo_pattern_create_for_surface (gr->pattern_surface); |
gr->pattern = cairo_pattern_create_for_surface (gr->pattern_surface); |
784 |
g_assert (gr->pattern != NULL); |
g_assert (gr->pattern != NULL); |
785 |
cairo_set_pattern (gr->cr, gr->pattern); |
cairo_set_source (gr->cr, gr->pattern); |
786 |
gdk_threads_leave(); |
gdk_threads_leave(); |
787 |
} |
} |
788 |
|
|
813 |
begin_drawing_operation (env, gr); |
begin_drawing_operation (env, gr); |
814 |
|
|
815 |
{ |
{ |
816 |
cairo_matrix_t *mat = NULL; |
cairo_matrix_t mat; |
817 |
cairo_surface_t *surf = cairo_surface_create_for_image ((char *)native_pixels, |
cairo_pattern_t *p; |
818 |
|
cairo_surface_t *surf = cairo_image_surface_create_for_data ((unsigned char *)native_pixels, |
819 |
CAIRO_FORMAT_ARGB32, |
CAIRO_FORMAT_ARGB32, |
820 |
w, h, stride * 4); |
w, h, stride * 4); |
821 |
mat = cairo_matrix_create (); |
cairo_matrix_init_identity (&mat); |
822 |
cairo_matrix_set_affine (mat, |
cairo_matrix_init (&mat, |
823 |
native_matrix[0], native_matrix[1], |
native_matrix[0], native_matrix[1], |
824 |
native_matrix[2], native_matrix[3], |
native_matrix[2], native_matrix[3], |
825 |
native_matrix[4], native_matrix[5]); |
native_matrix[4], native_matrix[5]); |
826 |
cairo_surface_set_matrix (surf, mat); |
|
827 |
cairo_surface_set_filter (surf, cairo_surface_get_filter(gr->surface)); |
p = cairo_pattern_create_for_surface (surf); |
828 |
cairo_show_surface (gr->cr, surf, w, h); |
cairo_pattern_set_matrix (p, &mat); |
829 |
cairo_matrix_destroy (mat); |
cairo_pattern_set_filter (p, cairo_pattern_get_filter (gr->pattern)); |
830 |
|
cairo_set_source_surface (gr->cr, surf, w, h); |
831 |
|
cairo_paint (gr->cr); |
832 |
cairo_surface_destroy (surf); |
cairo_surface_destroy (surf); |
833 |
} |
} |
834 |
|
|
900 |
native_matrix[4], native_matrix[5]); |
native_matrix[4], native_matrix[5]); |
901 |
|
|
902 |
{ |
{ |
903 |
cairo_matrix_t * mat = cairo_matrix_create (); |
cairo_matrix_t mat; |
904 |
cairo_matrix_set_affine (mat, |
|
905 |
native_matrix[0], native_matrix[1], |
cairo_matrix_init_identity (&mat); |
906 |
native_matrix[2], native_matrix[3], |
cairo_matrix_init (&mat, |
907 |
native_matrix[4], native_matrix[5]); |
native_matrix[0], native_matrix[1], |
908 |
cairo_set_matrix (gr->cr, mat); |
native_matrix[2], native_matrix[3], |
909 |
cairo_matrix_destroy (mat); |
native_matrix[4], native_matrix[5]); |
910 |
|
cairo_set_matrix (gr->cr, &mat); |
911 |
} |
} |
912 |
|
|
913 |
(*env)->ReleaseDoubleArrayElements (env, java_matrix, native_matrix, 0); |
(*env)->ReleaseDoubleArrayElements (env, java_matrix, native_matrix, 0); |
920 |
struct peerfont *pfont, |
struct peerfont *pfont, |
921 |
int debug) |
int debug) |
922 |
{ |
{ |
923 |
cairo_font_t *ft; |
cairo_font_face_t *ft; |
924 |
FT_Face face = NULL; |
FT_Face face = NULL; |
925 |
|
|
926 |
g_assert(cr != NULL); |
g_assert(cr != NULL); |
931 |
face = pango_ft2_font_get_face (pfont->font); |
face = pango_ft2_font_get_face (pfont->font); |
932 |
g_assert (face != NULL); |
g_assert (face != NULL); |
933 |
|
|
934 |
ft = cairo_ft_font_create_for_ft_face (face); |
ft = cairo_ft_font_face_create_for_ft_face (face, 0); |
935 |
g_assert (ft != NULL); |
g_assert (ft != NULL); |
936 |
|
|
937 |
if (debug) printf ("install_font_peer made new cairo font for '%s' at %f\n", |
if (debug) printf ("install_font_peer made new cairo font for '%s' at %f\n", |
939 |
(pango_font_description_get_size (pfont->desc) / |
(pango_font_description_get_size (pfont->desc) / |
940 |
(double)PANGO_SCALE)); |
(double)PANGO_SCALE)); |
941 |
|
|
942 |
cairo_set_font (cr, ft); |
cairo_set_font_face (cr, ft); |
943 |
cairo_font_destroy (ft); |
cairo_font_face_destroy (ft); |
944 |
cairo_scale_font (cr, |
cairo_set_font_size (cr, |
945 |
(pango_font_description_get_size (pfont->desc) / |
(pango_font_description_get_size (pfont->desc) / |
946 |
(double)PANGO_SCALE)); |
(double)PANGO_SCALE)); |
947 |
ft = cairo_current_font (cr); |
ft = cairo_get_font_face (cr); |
948 |
pfont->graphics_resource = ft; |
pfont->graphics_resource = ft; |
949 |
} |
} |
950 |
else |
else |
951 |
{ |
{ |
952 |
if (debug) printf ("install_font_peer reused existing font resource\n"); |
if (debug) printf ("install_font_peer reused existing font resource\n"); |
953 |
ft = (cairo_font_t *) pfont->graphics_resource; |
ft = (cairo_font_face_t *) pfont->graphics_resource; |
954 |
cairo_set_font (cr, ft); |
cairo_set_font_face (cr, ft); |
955 |
} |
} |
956 |
} |
} |
957 |
|
|
969 |
g_assert (pfont != NULL); |
g_assert (pfont != NULL); |
970 |
if (pfont->graphics_resource != NULL) |
if (pfont->graphics_resource != NULL) |
971 |
{ |
{ |
972 |
cairo_font_destroy ((cairo_font_t *) pfont->graphics_resource); |
cairo_font_face_destroy ((cairo_font_face_t *) pfont->graphics_resource); |
973 |
pfont->graphics_resource = NULL; |
pfont->graphics_resource = NULL; |
974 |
} |
} |
975 |
gdk_threads_leave(); |
gdk_threads_leave(); |
1159 |
break; |
break; |
1160 |
|
|
1161 |
case java_awt_alpha_composite_SRC: |
case java_awt_alpha_composite_SRC: |
1162 |
cairo_set_operator (gr->cr, CAIRO_OPERATOR_SRC); |
cairo_set_operator (gr->cr, CAIRO_OPERATOR_SOURCE); |
1163 |
break; |
break; |
1164 |
|
|
1165 |
case java_awt_alpha_composite_SRC_OVER: |
case java_awt_alpha_composite_SRC_OVER: |
1167 |
break; |
break; |
1168 |
|
|
1169 |
case java_awt_alpha_composite_DST_OVER: |
case java_awt_alpha_composite_DST_OVER: |
1170 |
cairo_set_operator (gr->cr, CAIRO_OPERATOR_OVER_REVERSE); |
cairo_set_operator (gr->cr, CAIRO_OPERATOR_DEST_OVER); |
1171 |
break; |
break; |
1172 |
|
|
1173 |
case java_awt_alpha_composite_SRC_IN: |
case java_awt_alpha_composite_SRC_IN: |
1175 |
break; |
break; |
1176 |
|
|
1177 |
case java_awt_alpha_composite_DST_IN: |
case java_awt_alpha_composite_DST_IN: |
1178 |
cairo_set_operator (gr->cr, CAIRO_OPERATOR_IN_REVERSE); |
cairo_set_operator (gr->cr, CAIRO_OPERATOR_DEST_IN); |
1179 |
break; |
break; |
1180 |
|
|
1181 |
case java_awt_alpha_composite_SRC_OUT: |
case java_awt_alpha_composite_SRC_OUT: |
1183 |
break; |
break; |
1184 |
|
|
1185 |
case java_awt_alpha_composite_DST_OUT: |
case java_awt_alpha_composite_DST_OUT: |
1186 |
cairo_set_operator (gr->cr, CAIRO_OPERATOR_OUT_REVERSE); |
cairo_set_operator (gr->cr, CAIRO_OPERATOR_DEST_OUT); |
1187 |
break; |
break; |
1188 |
|
|
1189 |
case java_awt_alpha_composite_DST: |
case java_awt_alpha_composite_DST: |
1190 |
cairo_set_operator (gr->cr, CAIRO_OPERATOR_DST); |
cairo_set_operator (gr->cr, CAIRO_OPERATOR_DEST); |
1191 |
break; |
break; |
1192 |
|
|
1193 |
case java_awt_alpha_composite_SRC_ATOP: |
case java_awt_alpha_composite_SRC_ATOP: |
1195 |
break; |
break; |
1196 |
|
|
1197 |
case java_awt_alpha_composite_DST_ATOP: |
case java_awt_alpha_composite_DST_ATOP: |
1198 |
cairo_set_operator (gr->cr, CAIRO_OPERATOR_ATOP_REVERSE); |
cairo_set_operator (gr->cr, CAIRO_OPERATOR_DEST_ATOP); |
1199 |
break; |
break; |
1200 |
|
|
1201 |
case java_awt_alpha_composite_XOR: |
case java_awt_alpha_composite_XOR: |
1206 |
} |
} |
1207 |
|
|
1208 |
JNIEXPORT void JNICALL |
JNIEXPORT void JNICALL |
1209 |
Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetRGBColor |
Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetRGBAColor |
1210 |
(JNIEnv *env, jobject obj, jdouble r, jdouble g, jdouble b) |
(JNIEnv *env, jobject obj, jdouble r, jdouble g, jdouble b, jdouble a) |
1211 |
{ |
{ |
1212 |
struct graphics2d *gr = NULL; |
struct graphics2d *gr = NULL; |
1213 |
|
|
1222 |
draw to a PixBuf, you must exchange the R and B components of your |
draw to a PixBuf, you must exchange the R and B components of your |
1223 |
color. */ |
color. */ |
1224 |
|
|
1225 |
if (gr->debug) printf ("cairo_set_rgb_color (%f, %f, %f)\n", r, g, b); |
if (gr->debug) printf ("cairo_set_source_rgb (%f, %f, %f)\n", r, g, b); |
1226 |
|
|
1227 |
if (gr->drawbuf) |
if (gr->drawbuf) |
1228 |
cairo_set_rgb_color (gr->cr, b, g, r); |
cairo_set_source_rgba (gr->cr, b, g, r, a); |
1229 |
else |
else |
1230 |
cairo_set_rgb_color (gr->cr, r, g, b); |
cairo_set_source_rgba (gr->cr, r, g, b, a); |
1231 |
|
|
1232 |
gdk_threads_leave(); |
gdk_threads_leave(); |
1233 |
} |
} |
1234 |
|
|
1235 |
JNIEXPORT void JNICALL |
JNIEXPORT void JNICALL |
|
Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetAlpha |
|
|
(JNIEnv *env, jobject obj, jdouble a) |
|
|
{ |
|
|
struct graphics2d *gr = NULL; |
|
|
|
|
|
gdk_threads_enter(); |
|
|
if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; } |
|
|
|
|
|
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj); |
|
|
g_assert (gr != NULL); |
|
|
if (gr->debug) printf ("cairo_set_alpha %f\n", a); |
|
|
cairo_set_alpha (gr->cr, a); |
|
|
gdk_threads_leave(); |
|
|
} |
|
|
|
|
|
JNIEXPORT void JNICALL |
|
1236 |
Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetFillRule |
Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetFillRule |
1237 |
(JNIEnv *env, jobject obj, jint rule) |
(JNIEnv *env, jobject obj, jint rule) |
1238 |
{ |
{ |
1560 |
if (gr == NULL) { gdk_threads_leave (); return; } |
if (gr == NULL) { gdk_threads_leave (); return; } |
1561 |
if (gr->debug) printf ("cairo_clip\n"); |
if (gr->debug) printf ("cairo_clip\n"); |
1562 |
begin_drawing_operation (env, gr); |
begin_drawing_operation (env, gr); |
1563 |
cairo_init_clip (gr->cr); |
cairo_reset_clip (gr->cr); |
1564 |
cairo_clip (gr->cr); |
cairo_clip (gr->cr); |
1565 |
end_drawing_operation (env, gr); |
end_drawing_operation (env, gr); |
1566 |
gdk_threads_leave(); |
gdk_threads_leave(); |
1581 |
switch ((enum java_awt_rendering_hints_filter) filter) |
switch ((enum java_awt_rendering_hints_filter) filter) |
1582 |
{ |
{ |
1583 |
case java_awt_rendering_hints_VALUE_INTERPOLATION_NEAREST_NEIGHBOR: |
case java_awt_rendering_hints_VALUE_INTERPOLATION_NEAREST_NEIGHBOR: |
1584 |
cairo_surface_set_filter (gr->surface, CAIRO_FILTER_NEAREST); |
cairo_pattern_set_filter (gr->pattern, CAIRO_FILTER_NEAREST); |
1585 |
break; |
break; |
1586 |
case java_awt_rendering_hints_VALUE_INTERPOLATION_BILINEAR: |
case java_awt_rendering_hints_VALUE_INTERPOLATION_BILINEAR: |
1587 |
cairo_surface_set_filter (gr->surface, CAIRO_FILTER_BILINEAR); |
cairo_pattern_set_filter (gr->pattern, CAIRO_FILTER_BILINEAR); |
1588 |
break; |
break; |
1589 |
case java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_SPEED: |
case java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_SPEED: |
1590 |
cairo_surface_set_filter (gr->surface, CAIRO_FILTER_FAST); |
cairo_pattern_set_filter (gr->pattern, CAIRO_FILTER_FAST); |
1591 |
break; |
break; |
1592 |
case java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_DEFAULT: |
case java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_DEFAULT: |
1593 |
cairo_surface_set_filter (gr->surface, CAIRO_FILTER_NEAREST); |
cairo_pattern_set_filter (gr->pattern, CAIRO_FILTER_NEAREST); |
1594 |
break; |
break; |
1595 |
case java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_QUALITY: |
case java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_QUALITY: |
1596 |
cairo_surface_set_filter (gr->surface, CAIRO_FILTER_BEST); |
cairo_pattern_set_filter (gr->pattern, CAIRO_FILTER_BEST); |
1597 |
break; |
break; |
1598 |
} |
} |
1599 |
gdk_threads_leave(); |
gdk_threads_leave(); |