< prev index next >

src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c

Print this page




 307         fp_g_value_get_uint64 = dl_symbol("g_value_get_uint64");
 308         fp_g_value_get_float = dl_symbol("g_value_get_float");
 309         fp_g_value_get_double = dl_symbol("g_value_get_double");
 310         fp_g_value_get_string = dl_symbol("g_value_get_string");
 311         fp_g_value_get_enum = dl_symbol("g_value_get_enum");
 312         fp_g_value_get_flags = dl_symbol("g_value_get_flags");
 313         fp_g_value_get_param = dl_symbol("g_value_get_param");
 314         fp_g_value_get_boxed = dl_symbol("g_value_get_boxed");
 315         fp_g_value_get_pointer = dl_symbol("g_value_get_pointer");
 316 
 317         fp_g_object_get = dl_symbol("g_object_get");
 318         fp_g_object_set = dl_symbol("g_object_set");
 319 
 320         fp_g_str_has_prefix = dl_symbol("g_str_has_prefix");
 321         fp_g_strsplit = dl_symbol("g_strsplit");
 322         fp_g_strfreev = dl_symbol("g_strfreev");
 323 
 324         /* GDK */
 325         fp_gdk_get_default_root_window =
 326             dl_symbol("gdk_get_default_root_window");
 327         fp_gdk_window_get_scale_factor =
 328                     dl_symbol("gdk_window_get_scale_factor");
 329 
 330         /* Pixbuf */
 331         fp_gdk_pixbuf_new = dl_symbol("gdk_pixbuf_new");
 332         fp_gdk_pixbuf_new_from_file =
 333                 dl_symbol("gdk_pixbuf_new_from_file");
 334         fp_gdk_pixbuf_get_from_drawable =
 335                     dl_symbol("gdk_pixbuf_get_from_window");
 336         fp_gdk_pixbuf_get_width = dl_symbol("gdk_pixbuf_get_width");
 337         fp_gdk_pixbuf_get_height = dl_symbol("gdk_pixbuf_get_height");
 338         fp_gdk_pixbuf_get_pixels = dl_symbol("gdk_pixbuf_get_pixels");
 339         fp_gdk_pixbuf_get_rowstride =
 340                 dl_symbol("gdk_pixbuf_get_rowstride");
 341         fp_gdk_pixbuf_get_has_alpha =
 342                 dl_symbol("gdk_pixbuf_get_has_alpha");
 343         fp_gdk_pixbuf_get_bits_per_sample =
 344                 dl_symbol("gdk_pixbuf_get_bits_per_sample");
 345         fp_gdk_pixbuf_get_n_channels =
 346                 dl_symbol("gdk_pixbuf_get_n_channels");
 347         fp_gdk_pixbuf_get_colorspace =
 348                 dl_symbol("gdk_pixbuf_get_colorspace");


2873         }
2874 
2875       if (!ruled)
2876         row &= ~(GTK_REGION_EVEN | GTK_REGION_ODD);
2877 
2878       fp_gtk_style_context_add_class (context, "cell");
2879       fp_gtk_style_context_add_region (context, "row", row);
2880       fp_gtk_style_context_add_region (context, "column", col);
2881 
2882       fp_g_strfreev (tokens);
2883     }
2884 }
2885 
2886 static gboolean gtk3_get_drawable_data(JNIEnv *env, jintArray pixelArray,
2887      int x, jint y, jint width, jint height, jint jwidth, int dx, int dy,
2888                                                                    jint scale) {
2889     GdkPixbuf *pixbuf;
2890     jint *ary;
2891 
2892     GdkWindow *root = (*fp_gdk_get_default_root_window)();
2893     int win_scale = (*fp_gdk_window_get_scale_factor)(root);
2894     pixbuf = (*fp_gdk_pixbuf_get_from_drawable)(
2895         root, x, y, (int)(width / (float)win_scale + 0.5), (int)(height / (float)win_scale + 0.5));
2896 
2897     if (pixbuf && scale != 1) {
2898         GdkPixbuf *scaledPixbuf;
2899         x /= scale;
2900         y /= scale;
2901         width /= scale;
2902         height /= scale;
2903         dx /= scale;
2904         dy /= scale;
2905         scaledPixbuf = (*fp_gdk_pixbuf_scale_simple)(pixbuf, width, height,
2906                                                      GDK_INTERP_BILINEAR);
2907         (*fp_g_object_unref)(pixbuf);
2908         pixbuf = scaledPixbuf;
2909     }
2910 
2911     if (pixbuf) {
2912         int nchan = (*fp_gdk_pixbuf_get_n_channels)(pixbuf);
2913         int stride = (*fp_gdk_pixbuf_get_rowstride)(pixbuf);
2914         if ((*fp_gdk_pixbuf_get_width)(pixbuf) >= width
2915                 && (*fp_gdk_pixbuf_get_height)(pixbuf) >= height
2916                 && (*fp_gdk_pixbuf_get_bits_per_sample)(pixbuf) == 8
2917                 && (*fp_gdk_pixbuf_get_colorspace)(pixbuf) == GDK_COLORSPACE_RGB
2918                 && nchan >= 3
2919                 ) {
2920             guchar *p, *pix = (*fp_gdk_pixbuf_get_pixels)(pixbuf);
2921             ary = (*env)->GetPrimitiveArrayCritical(env, pixelArray, NULL);
2922             if (ary) {
2923                 jint _x, _y;
2924                 int index;
2925                 for (_y = 0; _y < height; _y++) {
2926                     for (_x = 0; _x < width; _x++) {
2927                         p = pix + _y * stride + _x * nchan;
2928 
2929                         index = (_y + dy) * jwidth + (_x + dx);
2930                         ary[index] = 0xff000000
2931                                         | (p[0] << 16)
2932                                         | (p[1] << 8)
2933                                         | (p[2]);
2934 
2935                     }




 307         fp_g_value_get_uint64 = dl_symbol("g_value_get_uint64");
 308         fp_g_value_get_float = dl_symbol("g_value_get_float");
 309         fp_g_value_get_double = dl_symbol("g_value_get_double");
 310         fp_g_value_get_string = dl_symbol("g_value_get_string");
 311         fp_g_value_get_enum = dl_symbol("g_value_get_enum");
 312         fp_g_value_get_flags = dl_symbol("g_value_get_flags");
 313         fp_g_value_get_param = dl_symbol("g_value_get_param");
 314         fp_g_value_get_boxed = dl_symbol("g_value_get_boxed");
 315         fp_g_value_get_pointer = dl_symbol("g_value_get_pointer");
 316 
 317         fp_g_object_get = dl_symbol("g_object_get");
 318         fp_g_object_set = dl_symbol("g_object_set");
 319 
 320         fp_g_str_has_prefix = dl_symbol("g_str_has_prefix");
 321         fp_g_strsplit = dl_symbol("g_strsplit");
 322         fp_g_strfreev = dl_symbol("g_strfreev");
 323 
 324         /* GDK */
 325         fp_gdk_get_default_root_window =
 326             dl_symbol("gdk_get_default_root_window");


 327 
 328         /* Pixbuf */
 329         fp_gdk_pixbuf_new = dl_symbol("gdk_pixbuf_new");
 330         fp_gdk_pixbuf_new_from_file =
 331                 dl_symbol("gdk_pixbuf_new_from_file");
 332         fp_gdk_pixbuf_get_from_drawable =
 333                     dl_symbol("gdk_pixbuf_get_from_window");
 334         fp_gdk_pixbuf_get_width = dl_symbol("gdk_pixbuf_get_width");
 335         fp_gdk_pixbuf_get_height = dl_symbol("gdk_pixbuf_get_height");
 336         fp_gdk_pixbuf_get_pixels = dl_symbol("gdk_pixbuf_get_pixels");
 337         fp_gdk_pixbuf_get_rowstride =
 338                 dl_symbol("gdk_pixbuf_get_rowstride");
 339         fp_gdk_pixbuf_get_has_alpha =
 340                 dl_symbol("gdk_pixbuf_get_has_alpha");
 341         fp_gdk_pixbuf_get_bits_per_sample =
 342                 dl_symbol("gdk_pixbuf_get_bits_per_sample");
 343         fp_gdk_pixbuf_get_n_channels =
 344                 dl_symbol("gdk_pixbuf_get_n_channels");
 345         fp_gdk_pixbuf_get_colorspace =
 346                 dl_symbol("gdk_pixbuf_get_colorspace");


2871         }
2872 
2873       if (!ruled)
2874         row &= ~(GTK_REGION_EVEN | GTK_REGION_ODD);
2875 
2876       fp_gtk_style_context_add_class (context, "cell");
2877       fp_gtk_style_context_add_region (context, "row", row);
2878       fp_gtk_style_context_add_region (context, "column", col);
2879 
2880       fp_g_strfreev (tokens);
2881     }
2882 }
2883 
2884 static gboolean gtk3_get_drawable_data(JNIEnv *env, jintArray pixelArray,
2885      int x, jint y, jint width, jint height, jint jwidth, int dx, int dy,
2886                                                                    jint scale) {
2887     GdkPixbuf *pixbuf;
2888     jint *ary;
2889 
2890     GdkWindow *root = (*fp_gdk_get_default_root_window)();
2891     pixbuf = (*fp_gdk_pixbuf_get_from_drawable)(root, x, y, width, height);



2892     if (pixbuf && scale != 1) {
2893         GdkPixbuf *scaledPixbuf;
2894         x /= scale;
2895         y /= scale;
2896         width /= scale;
2897         height /= scale;
2898         dx /= scale;
2899         dy /= scale;
2900         scaledPixbuf = (*fp_gdk_pixbuf_scale_simple)(pixbuf, width, height,
2901                                                      GDK_INTERP_BILINEAR);
2902         (*fp_g_object_unref)(pixbuf);
2903         pixbuf = scaledPixbuf;
2904     }
2905 
2906     if (pixbuf) {
2907         int nchan = (*fp_gdk_pixbuf_get_n_channels)(pixbuf);
2908         int stride = (*fp_gdk_pixbuf_get_rowstride)(pixbuf);
2909         if ((*fp_gdk_pixbuf_get_width)(pixbuf) == width
2910                 && (*fp_gdk_pixbuf_get_height)(pixbuf) == height
2911                 && (*fp_gdk_pixbuf_get_bits_per_sample)(pixbuf) == 8
2912                 && (*fp_gdk_pixbuf_get_colorspace)(pixbuf) == GDK_COLORSPACE_RGB
2913                 && nchan >= 3
2914                 ) {
2915             guchar *p, *pix = (*fp_gdk_pixbuf_get_pixels)(pixbuf);
2916             ary = (*env)->GetPrimitiveArrayCritical(env, pixelArray, NULL);
2917             if (ary) {
2918                 jint _x, _y;
2919                 int index;
2920                 for (_y = 0; _y < height; _y++) {
2921                     for (_x = 0; _x < width; _x++) {
2922                         p = pix + _y * stride + _x * nchan;
2923 
2924                         index = (_y + dy) * jwidth + (_x + dx);
2925                         ary[index] = 0xff000000
2926                                         | (p[0] << 16)
2927                                         | (p[1] << 8)
2928                                         | (p[2]);
2929 
2930                     }


< prev index next >