[cairo-commit] CairoJava/jni CairoGlitzSurface.cpp,1.5,1.6

Soorya Kuloor commit at pdx.freedesktop.org
Thu Jun 3 15:01:22 PDT 2004


Committed by: skuloor

Update of /cvs/cairo/CairoJava/jni
In directory pdx:/tmp/cvs-serv25551/jni

Modified Files:
	CairoGlitzSurface.cpp 
Log Message:
1. Port to latest glitz API.
2. Some reformatting.
3. Remove unsetting of gtk double buffering from the C
    code, moved to Java.

Index: CairoGlitzSurface.cpp
===================================================================
RCS file: /cvs/cairo/CairoJava/jni/CairoGlitzSurface.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** a/CairoGlitzSurface.cpp	20 May 2004 19:36:38 -0000	1.5
--- b/CairoGlitzSurface.cpp	3 Jun 2004 22:01:20 -0000	1.6
***************
*** 28,32 ****
  
  #ifdef CAIRO_HAS_GL_SURFACE
! #include <glitz-glx.h>
  #endif
  
--- 28,32 ----
  
  #ifdef CAIRO_HAS_GL_SURFACE
! #    include <glitz-glx.h>
  #endif
  
***************
*** 40,50 ****
   * If the mapping doesn't exist return NULL;
   */
  glitz_buffer_t to_glitz_buffer_t(int bufferval) {
! 	switch ( bufferval ) {
! 	case 0: return GLITZ_BUFFER_FRONT;
! 	case 1: return GLITZ_BUFFER_BACK;
! 	default: return (glitz_buffer_t)NULL;
! 	}
  }
  
  /*
--- 40,55 ----
   * If the mapping doesn't exist return NULL;
   */
+ #ifdef CAIRO_HAS_GL_SURFACE
  glitz_buffer_t to_glitz_buffer_t(int bufferval) {
!     switch (bufferval) {
!     case 0: 
!         return GLITZ_BUFFER_FRONT;
!     case 1: 
!         return GLITZ_BUFFER_BACK;
!     default: 
!         return (glitz_buffer_t) NULL;
!     }
  }
+ #endif
  
  /*
***************
*** 56,65 ****
  (JNIEnv * env, jclass me, jlong crp, jlong sfp)
  {
  #ifdef CAIRO_HAS_GL_SURFACE
!     cairo_set_target_gl(TO_PTR(cairo_t, crp), TO_PTR(glitz_surface_t, sfp));
  #else
!     throw_surface_not_supported_exception(env, "glitz");
  #endif
!     
  }
  
--- 61,71 ----
  (JNIEnv * env, jclass me, jlong crp, jlong sfp)
  {
+ 
  #ifdef CAIRO_HAS_GL_SURFACE
!     cairo_set_target_gl (TO_PTR (cairo_t, crp), TO_PTR (glitz_surface_t, sfp));
  #else
!     throw_surface_not_supported_exception (env, "glitz");
  #endif
! 
  }
  
***************
*** 68,85 ****
   * Method:    glitz_glx_surface_create_for_window
   * Signature: ([SI)J
   */
  JNIEXPORT jlong JNICALL Java_org_cairographics_cairo_CairoGlitzSurface_glitz_1glx_1surface_1create_1for_1window
  (JNIEnv *env, jclass me, jlong widgetp)
  {
- #ifdef CAIRO_HAS_GL_SURFACE
-     GtkWidget *widget = TO_PTR(GtkWidget, widgetp);
-     gtk_widget_set_double_buffered (widget, FALSE);
  
!     Display *dpy = GDK_WINDOW_XDISPLAY(widget->window);
      if (!dpy) {
          fprintf (stderr, "Couldn't find a usable display\n");
          exit (1);
      }
-   
  
      glitz_format_t *format = glitz_glx_find_standard_format (dpy, DefaultScreen (dpy),
--- 74,92 ----
   * Method:    glitz_glx_surface_create_for_window
   * Signature: ([SI)J
+  *
+  * The widget pointed to by widgetp should not be double buffered.
   */
  JNIEXPORT jlong JNICALL Java_org_cairographics_cairo_CairoGlitzSurface_glitz_1glx_1surface_1create_1for_1window
  (JNIEnv *env, jclass me, jlong widgetp)
  {
  
! #ifdef CAIRO_HAS_GL_SURFACE
!     GtkWidget *widget = TO_PTR (GtkWidget, widgetp);
!  
!     Display *dpy = GDK_WINDOW_XDISPLAY (widget->window);
      if (!dpy) {
          fprintf (stderr, "Couldn't find a usable display\n");
          exit (1);
      }
  
      glitz_format_t *format = glitz_glx_find_standard_format (dpy, DefaultScreen (dpy),
***************
*** 91,106 ****
      }
    
!     XVisualInfo *vinfo = glitz_glx_get_visual_info_from_format (dpy,
!                                                                 DefaultScreen (dpy),
!                                                                 format);
!     if (!vinfo) {
!         printf ("no visual info\n");
!         exit (1);
!     }
!   
!     Window win = GDK_WINDOW_XID(widget->window);
      glitz_surface_t *glitz_surface =
!         glitz_glx_surface_create_for_window (dpy, DefaultScreen (dpy),
!                                              format, win);
      if (!glitz_surface) {
          printf ("failed to create glitz surface\n");
--- 98,104 ----
      }
    
!     Window win = GDK_WINDOW_XID (widget->window);
      glitz_surface_t *glitz_surface =
!         glitz_glx_surface_create_for_window (dpy, DefaultScreen (dpy), format, win);
      if (!glitz_surface) {
          printf ("failed to create glitz surface\n");
***************
*** 108,116 ****
      }
    
!     return TO_LONG(glitz_surface);
  #else
!     throw_surface_not_supported_exception(env, "glitz");
      return 0;
  #endif
  }
  
--- 106,115 ----
      }
    
!     return TO_LONG (glitz_surface);
  #else
!     throw_surface_not_supported_exception (env, "glitz");
      return 0;
  #endif
+ 
  }
  
***************
*** 123,131 ****
  (JNIEnv *env, jclass me, jlong glitz_surfacep)
  {
  #ifdef CAIRO_HAS_GL_SURFACE
!     glitz_surface_flush(TO_PTR(glitz_surface_t, glitz_surfacep));
  #else
!     throw_surface_not_supported_exception(env, "glitz");
  #endif
  }
  
--- 122,132 ----
  (JNIEnv *env, jclass me, jlong glitz_surfacep)
  {
+ 
  #ifdef CAIRO_HAS_GL_SURFACE
!     glitz_surface_flush (TO_PTR (glitz_surface_t, glitz_surfacep));
  #else
!     throw_surface_not_supported_exception (env, "glitz");
  #endif
+ 
  }
  
***************
*** 135,146 ****
   * Signature: (J)V
   */
! JNIEXPORT void JNICALL Java_org_cairographics_cairo_CairoGlitzSurface_glitz_1swap_1buffers
  (JNIEnv *env, jclass me, jlong glitz_surfacep)
  {
  #ifdef CAIRO_HAS_GL_SURFACE
!     glitz_surface_swap_buffers(TO_PTR(glitz_surface_t, glitz_surfacep));
  #else
!     throw_surface_not_supported_exception(env, "glitz");
  #endif
  }
  
--- 136,149 ----
   * Signature: (J)V
   */
! JNIEXPORT void JNICALL Java_org_cairographics_cairo_CairoGlitzSurface_glitz_1surface_1swap_1buffers
  (JNIEnv *env, jclass me, jlong glitz_surfacep)
  {
+ 
  #ifdef CAIRO_HAS_GL_SURFACE
!     glitz_surface_swap_buffers (TO_PTR (glitz_surface_t, glitz_surfacep));
  #else
!     throw_surface_not_supported_exception (env, "glitz");
  #endif
+ 
  }
  
***************
*** 153,161 ****
  (JNIEnv *env, jclass me, jlong glitz_surfacep, jint buffer)
  {
  #ifdef CAIRO_HAS_GL_SURFACE
!     glitz_surface_set_read_buffer(TO_PTR(glitz_surface_t, glitz_surfacep), to_glitz_buffer_t(buffer));
  #else
!     throw_surface_not_supported_exception(env, "glitz");
  #endif
  }
  
--- 156,167 ----
  (JNIEnv *env, jclass me, jlong glitz_surfacep, jint buffer)
  {
+ 
  #ifdef CAIRO_HAS_GL_SURFACE
!     glitz_surface_set_read_buffer (TO_PTR (glitz_surface_t, glitz_surfacep), 
!                                    to_glitz_buffer_t (buffer));
  #else
!     throw_surface_not_supported_exception (env, "glitz");
  #endif
+ 
  }
  
***************
*** 168,176 ****
  (JNIEnv *env, jclass me, jlong glitz_surfacep, jint buffer)
  {
  #ifdef CAIRO_HAS_GL_SURFACE
!     glitz_surface_set_draw_buffer(TO_PTR(glitz_surface_t, glitz_surfacep), to_glitz_buffer_t(buffer));
  #else
!     throw_surface_not_supported_exception(env, "glitz");
  #endif
  }
  
--- 174,185 ----
  (JNIEnv *env, jclass me, jlong glitz_surfacep, jint buffer)
  {
+ 
  #ifdef CAIRO_HAS_GL_SURFACE
!     glitz_surface_set_draw_buffer (TO_PTR (glitz_surface_t, glitz_surfacep), 
!                                    to_glitz_buffer_t (buffer));
  #else
!     throw_surface_not_supported_exception (env, "glitz");
  #endif
+ 
  }
  
***************
*** 187,202 ****
  
  #ifdef CAIRO_HAS_GL_SURFACE
!     glitz_copy_area (TO_PTR(glitz_surface_t, glitz_surface_srcp), 
!                      TO_PTR(glitz_surface_t, glitz_surface_destp), 
                       x_src, y_src, 
                       width, height, 
                       x_dst, y_dst);
  #else
!     throw_surface_not_supported_exception(env, "glitz");
  #endif
  }     
              
  /*
   * Class:     org_cairographics_cairo_Cairo
   * Method:    cairo_init
   * Signature: (Ljava/lang/String;)V
--- 196,244 ----
  
  #ifdef CAIRO_HAS_GL_SURFACE
!     glitz_copy_area (TO_PTR (glitz_surface_t, glitz_surface_srcp), 
!                      TO_PTR (glitz_surface_t, glitz_surface_destp), 
                       x_src, y_src, 
                       width, height, 
                       x_dst, y_dst);
  #else
!     throw_surface_not_supported_exception (env, "glitz");
  #endif
+ 
  }     
              
  /*
   * Class:     org_cairographics_cairo_Cairo
+  * Method:    glitz_surface_update_size
+  * Signature: (J)V
+  */
+ JNIEXPORT void JNICALL Java_org_cairographics_cairo_CairoGlitzSurface_glitz_1surface_1update_1size
+   (JNIEnv *env, jclass me, jlong glitz_surface_srcp) {
+   
+ #ifdef CAIRO_HAS_GL_SURFACE
+       glitz_surface_update_size (TO_PTR (glitz_surface_t, glitz_surface_srcp));
+ #else
+     throw_surface_not_supported_exception (env, "glitz");
+ #endif
+   
+ }
+ 
+ /*
+  * Class:     org_cairographics_cairo_Cairo
+  * Method:    glitz_surface_destroy
+  * Signature: (J)V
+  */
+ JNIEXPORT void JNICALL Java_org_cairographics_cairo_CairoGlitzSurface_glitz_1surface_1destroy
+   (JNIEnv *env, jclass me, jlong glitz_surface_srcp) {
+   
+ #ifdef CAIRO_HAS_GL_SURFACE
+       glitz_surface_destroy( TO_PTR (glitz_surface_t, glitz_surface_srcp));
+ #else
+     throw_surface_not_supported_exception (env, "glitz");
+ #endif
+   
+ }
+ 
+ /*
+  * Class:     org_cairographics_cairo_Cairo
   * Method:    cairo_init
   * Signature: (Ljava/lang/String;)V
***************
*** 207,217 ****
  #ifdef CAIRO_HAS_GL_SURFACE
      const char* opengl_lib;
!     if ( j_opengl_lib ) {
!         opengl_lib = env->GetStringUTFChars(j_opengl_lib, NULL);
!         if ( opengl_lib == NULL ) {
              return;  // out of memory exception thrown
          }
!         glitz_glx_init(opengl_lib);
!         env->ReleaseStringUTFChars(j_opengl_lib, opengl_lib);
      }
  #endif
--- 249,259 ----
  #ifdef CAIRO_HAS_GL_SURFACE
      const char* opengl_lib;
!     if (j_opengl_lib) {
!         opengl_lib = env->GetStringUTFChars (j_opengl_lib, NULL);
!         if (opengl_lib == NULL) {
              return;  // out of memory exception thrown
          }
!         glitz_glx_init (opengl_lib);
!         env->ReleaseStringUTFChars (j_opengl_lib, opengl_lib);
      }
  #endif





More information about the cairo-commit mailing list