[cairo-commit] CairoJava/src/org/cairographics/cairo CairoGlitzSurface.java, 1.2, 1.3

Soorya Kuloor commit at pdx.freedesktop.org
Thu May 20 12:36:41 PDT 2004


Committed by: skuloor

Update of /cvs/cairo/CairoJava/src/org/cairographics/cairo
In directory pdx:/tmp/cvs-serv30239/src/org/cairographics/cairo

Modified Files:
	CairoGlitzSurface.java 
Log Message:
1. Port to latest cairo CVS version.
2. Add support for glitz_surface_flush etc functions.

Index: CairoGlitzSurface.java
===================================================================
RCS file: /cvs/cairo/CairoJava/src/org/cairographics/cairo/CairoGlitzSurface.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** a/CairoGlitzSurface.java	13 May 2004 16:46:24 -0000	1.2
--- b/CairoGlitzSurface.java	20 May 2004 19:36:38 -0000	1.3
***************
*** 31,40 ****
  public class CairoGlitzSurface extends CairoSurface {
  
      private final static String GLLIB = "libGL.so.1";
      private final static String GLLIB_PROPERTY = "org.cairographics.cairo.gllib";
  
      static {
          cairo_glitz_init(System.getProperty(GLLIB_PROPERTY, GLLIB));
-         System.out.println("DEBUG: " + System.getProperty(GLLIB_PROPERTY, GLLIB));
      }
      
--- 31,58 ----
  public class CairoGlitzSurface extends CairoSurface {
  
+     /**
+      * GL front buffer ID, {@value}.
+      */
+     public final static int GLITZ_BUFFER_FRONT = 0;
+ 
+     /**
+      * GL back buffer ID, {@value}.
+      */
+     public final static int GLITZ_BUFFER_BACK = 1;
+     
+     /**
+      * Name of GL library to use for initialization. Default is <code>libGL.so.1</code>.
+      */
      private final static String GLLIB = "libGL.so.1";
+     
+     /**
+      * Name of property ({@value}) that specifies GL library to use for initialization. If this property is not specified then
+      * the default value of {@link #GLLIB} is used.
+      */
      private final static String GLLIB_PROPERTY = "org.cairographics.cairo.gllib";
  
+     // initialize glitz
      static {
          cairo_glitz_init(System.getProperty(GLLIB_PROPERTY, GLLIB));
      }
      
***************
*** 52,59 ****
      }
  
!     public void flush(int x, int y, int width, int height) {
!         glitz_glx_surface_flush(handle, x, y, width, height);
      }
      
      native static void cairo_set_target_gl(long cr, long surface);
  
--- 70,155 ----
      }
  
!     /**
!      * Flush front buffer.
!      */
!     public void flush() {
!         glitz_surface_flush(handle);
!     }
! 
!     /**
!      * Swap front and back buffers for this surface if double buffering is supported. Otherwise does nothing.
!      *
!      */
!     public void swapBuffers() {
!         glitz_surface_swap_buffers(handle);
!     }
!     
!     /**
!      * Specify which GL buffer is the read buffer for this surface.
!      * 
!      * @param buffer Must be one of {@link #GLITZ_BUFFER_FRONT} or {@link #GLITZ_BUFFER_BACK}.
!      * 
!      * @throws IllegalArgumentException If buffer is not one of the legal values.
!      */
!     public void setReadBuffer(int buffer) throws IllegalArgumentException {
!         validateBufferValue(buffer);
!         glitz_surface_set_read_buffer(handle, buffer);
!     }
!     
!     /**
!      * Specify which GL buffer is the draw buffer for this surface.
!      * 
!      * @param buffer Must be one of {@link #GLITZ_BUFFER_FRONT} or {@link #GLITZ_BUFFER_BACK}.
!      * 
!      * @throws IllegalArgumentException If buffer is not one of the legal values.
!      */
!     public void setDrawBuffer(int buffer) throws IllegalArgumentException {
!         validateBufferValue(buffer);
!         glitz_surface_set_draw_buffer(handle, buffer);
      }
      
+     /**
+      * Copies pixels between surfaces. The source surface is <code>this</code> surface. The destination surface is
+      * <code>dest</code>. The copy area is specifed by an origin at <code>(x_src, y_src)</code>, a width of 
+      * <code>width</code> and a height of <code>height</code>. The copy area is pasted onto the destination surface 
+      * at the point <code>(x_dst, y_dst)</code>.<p>
+      * Pixels can also be copied between buffers on the same surface by setting the destination surface as <code>this</code>
+      * surface. In this case, typically, first the {@link #setDrawBuffer(int) draw buffer is set to the front buffer}
+      * .
+      * @param dest Destination surface. Cannot be <code>null</code>.
+      * @param x_src x coordinate of the copy origin.
+      * @param y_src y coordinate of the copy origin.
+      * @param width Width of the copy area.
+      * @param height Height of the copy area.
+      * @param x_dst x coordinate of the destination point.
+      * @param y_dst y coordinate of the destination point.
+      * 
+      * @throws NullPointerException If <code>dest</code> is <code>null</code>.
+      */
+     public void copyArea(CairoGlitzSurface dest, int  x_src, int y_src, int width, int height,  int x_dst, int y_dst) 
+          throws NullPointerException {
+         if ( dest == null ) {
+             throw new NullPointerException("Destination surface cannot be null!");
+         }
+         glitz_copy_area(this.handle, dest.handle, x_src, y_src, width, height, x_dst, y_dst);
+     }
+     
+     /**
+      * Ensures that <code>buffer</code> is a valid buffer descriptor.
+      * 
+      * @param buffer Must be one of {@link #GLITZ_BUFFER_FRONT} or {@link #GLITZ_BUFFER_BACK}.
+      * 
+      * @throws IllegalArgumentException If <code>buffer</code> is not one of the legal values.
+      */
+     private void validateBufferValue(int buffer) throws IllegalArgumentException {
+         switch (buffer) {
+         case GLITZ_BUFFER_FRONT: 
+         case GLITZ_BUFFER_BACK: 
+             return;
+             default:
+                 throw new IllegalArgumentException("Invalid buffer value of "+buffer);
+         }
+     }
+ 
      native static void cairo_set_target_gl(long cr, long surface);
  
***************
*** 65,72 ****
      native static long glitz_glx_surface_create_for_window(long window);
  
!     native static void glitz_glx_surface_flush(long surface, int x, int y,
!             int width, int height);
  
      native static void cairo_glitz_init(String openglLibname);
  
! }
\ No newline at end of file
--- 161,176 ----
      native static long glitz_glx_surface_create_for_window(long window);
  
!     native static void glitz_surface_flush(long surface);
  
      native static void cairo_glitz_init(String openglLibname);
  
!     native static void glitz_surface_swap_buffers(long handle);
! 
!     native static void glitz_surface_set_read_buffer(long handle, int buffer);
! 
!     native static void glitz_surface_set_draw_buffer(long handle, int buffer);
!     
!     native static void glitz_copy_area(long handle_src, long handle_dest, int  x_src, int y_src, 
!                                                                    int width, int height,  int x_dst, int y_dst);
! 
! }





More information about the cairo-commit mailing list