[cairo-commit] glitz/src Makefile.am, 1.9, 1.10 glitz.h, 1.26, 1.27 glitz_framebuffer.c, NONE, 1.1 glitz_gl.h, 1.14, 1.15 glitz_surface.c, 1.26, 1.27 glitz_util.c, 1.12, 1.13 glitzint.h, 1.31, 1.32

David Reveman commit at pdx.freedesktop.org
Wed Feb 9 17:03:02 PST 2005


Committed by: davidr

Update of /cvs/cairo/glitz/src
In directory gabe:/tmp/cvs-serv26045/src

Modified Files:
	Makefile.am glitz.h glitz_gl.h glitz_surface.c glitz_util.c 
	glitzint.h 
Added Files:
	glitz_framebuffer.c 
Log Message:
Add preliminary support for EXT_framebuffer_object

Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/glitz/src/Makefile.am,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- Makefile.am	25 Jan 2005 19:50:26 -0000	1.9
+++ Makefile.am	10 Feb 2005 01:03:00 -0000	1.10
@@ -3,27 +3,28 @@
 lib_LTLIBRARIES = libglitz.la
 include_HEADERS = glitz.h
 
-libglitz_la_SOURCES =	 \
-	glitz.h		 \
-	glitz.c		 \
-	glitz_operator.c \
-	glitz_drawable.c \
-	glitz_surface.c	 \
-	glitz_texture.c	 \
-	glitz_rect.c	 \
-	glitz_status.c	 \
-	glitz_util.c	 \
-	glitz_region.c	 \
-	glitz_format.c	 \
-	glitz_program.c	 \
-	glitz_compose.c	 \
-	glitz_filter.c	 \
-	glitz_buffer.c	 \
-	glitz_geometry.c \
-	glitz_pixel.c	 \
-	glitz_trap.c	 \
-	glitz_trapimp.h	 \
-	glitz_gl.h	 \
+libglitz_la_SOURCES =	    \
+	glitz.h		    \
+	glitz.c		    \
+	glitz_operator.c    \
+	glitz_drawable.c    \
+	glitz_surface.c	    \
+	glitz_texture.c	    \
+	glitz_rect.c	    \
+	glitz_status.c	    \
+	glitz_util.c	    \
+	glitz_region.c	    \
+	glitz_format.c	    \
+	glitz_program.c	    \
+	glitz_compose.c	    \
+	glitz_filter.c	    \
+	glitz_buffer.c	    \
+	glitz_geometry.c    \
+	glitz_pixel.c	    \
+	glitz_trap.c	    \
+	glitz_framebuffer.c \
+	glitz_trapimp.h	    \
+	glitz_gl.h	    \
 	glitzint.h
 
 libglitz_la_LDFLAGS = -version-info @VERSION_INFO@ -no-undefined

Index: glitz.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- glitz.h	25 Jan 2005 19:50:26 -0000	1.26
+++ glitz.h	10 Feb 2005 01:03:00 -0000	1.27
@@ -135,6 +135,7 @@
 #define GLITZ_FEATURE_BLEND_COLOR_MASK              (1L << 13)
 #define GLITZ_FEATURE_PACKED_PIXELS_MASK            (1L << 14)
 #define GLITZ_FEATURE_MULTI_DRAW_ARRAYS_MASK        (1L << 15)
+#define GLITZ_FEATURE_FRAMEBUFFER_OBJECT_MASK       (1L << 16)
 
 typedef enum {
   GLITZ_STANDARD_ARGB32,
@@ -370,6 +371,9 @@
                                glitz_box_t     *box,
                                int             n_box);
 
+glitz_bool_t
+glitz_surface_valid_target (glitz_surface_t *surface);
+
   
 /* glitz_rect.c */
 

--- NEW FILE: glitz_framebuffer.c ---
(This appears to be a binary file; contents omitted.)

Index: glitz_gl.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_gl.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- glitz_gl.h	25 Jan 2005 19:50:26 -0000	1.14
+++ glitz_gl.h	10 Feb 2005 01:03:00 -0000	1.15
@@ -303,6 +303,18 @@
 #define GLITZ_GL_WRITE_ONLY 0x88B9
 #define GLITZ_GL_READ_WRITE 0x88BA
 
+#define GLITZ_GL_FRAMEBUFFER       0x8D40
+#define GLITZ_GL_COLOR_ATTACHMENT0 0x8CE0
+#define GLITZ_GL_FRAMEBUFFER_COMPLETE                        0x8CD5
+#define GLITZ_GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT           0x8CD6
+#define GLITZ_GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT   0x8CD7
+#define GLITZ_GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT 0x8CD8
+#define GLITZ_GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS           0x8CD9
+#define GLITZ_GL_FRAMEBUFFER_INCOMPLETE_FORMATS              0x8CDA
+#define GLITZ_GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER          0x8CDB
+#define GLITZ_GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER          0x8CDC
+#define GLITZ_GL_FRAMEBUFFER_UNSUPPORTED                     0x8CDD
+#define GLITZ_GL_FRAMEBUFFER_STATUS_ERROR                    0x8CDE
 
 typedef glitz_gl_void_t (* glitz_gl_enable_t)
      (glitz_gl_enum_t cap);
@@ -500,5 +512,16 @@
      (glitz_gl_enum_t, glitz_gl_enum_t);
 typedef glitz_gl_boolean_t (* glitz_gl_unmap_buffer_t)
      (glitz_gl_enum_t);
+typedef void (* glitz_gl_gen_framebuffers_t)
+     (glitz_gl_sizei_t, glitz_gl_uint_t *);
+typedef void (* glitz_gl_delete_framebuffers_t)
+     (glitz_gl_sizei_t, const glitz_gl_uint_t *);
+typedef glitz_gl_void_t (* glitz_gl_bind_framebuffer_t)
+     (glitz_gl_enum_t, glitz_gl_uint_t);
+typedef glitz_gl_enum_t (* glitz_gl_check_framebuffer_status_t)
+     (glitz_gl_enum_t);
+typedef void (* glitz_gl_framebuffer_texture_2d_t)
+    (glitz_gl_enum_t, glitz_gl_enum_t, glitz_gl_enum_t,
+     glitz_gl_uint_t, glitz_gl_int_t);
 
 #endif /* GLITZ_GL_H_INCLUDED */

Index: glitz_surface.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_surface.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- glitz_surface.c	31 Jan 2005 23:57:54 -0000	1.26
+++ glitz_surface.c	10 Feb 2005 01:03:00 -0000	1.27
@@ -91,6 +91,8 @@
     glitz_texture_init (&surface->texture, width, height,
                         drawable->backend->texture_formats[format->id],
                         feature_mask, unnormalized);
+
+    glitz_framebuffer_init (&surface->framebuffer);
   
     if (width > 64 || height > 64)
     {
@@ -122,7 +124,11 @@
 
   if (surface->texture.name) {
     glitz_surface_push_current (surface, GLITZ_ANY_CONTEXT_CURRENT);
+    if (surface->framebuffer.name)
+        glitz_framebuffer_fini (&surface->drawable->backend->gl,
+                                &surface->framebuffer);
     glitz_texture_fini (&surface->drawable->backend->gl, &surface->texture);
+  
     glitz_surface_pop_current (surface);
   }
 
@@ -416,40 +422,52 @@
 static void
 _glitz_surface_update_state (glitz_surface_t *surface)
 {
-    glitz_rectangle_t *viewport;
+    glitz_drawable_t  *drawable;
+    int               width, height;
     
     GLITZ_GL_SURFACE (surface);
+
+    if (surface->attached)
+    {
+        drawable = surface->attached;
+        width    = drawable->width;
+        height   = drawable->height;
+    }
+    else
+    {
+        drawable = surface->drawable;
+        width    = surface->texture.width;
+        height   = surface->texture.height;
+    }
     
-    viewport = &surface->attached->viewport;
-    
-    if (surface->attached->update_all ||
-        viewport->x != surface->x ||
-        viewport->y != surface->y ||
-        viewport->width != surface->box.x2 ||
-        viewport->height != surface->box.y2)
+    if (drawable->update_all                          ||
+        drawable->viewport.x      != surface->x      ||
+        drawable->viewport.y      != surface->y      ||
+        drawable->viewport.width  != surface->box.x2 ||
+        drawable->viewport.height != surface->box.y2)
     {
         gl->viewport (surface->x,
-                      surface->attached->height - surface->y - surface->box.y2,
+                      height - surface->y - surface->box.y2,
                       surface->box.x2,
                       surface->box.y2);
         gl->matrix_mode (GLITZ_GL_PROJECTION);
         gl->load_identity ();
         gl->ortho (0.0,
                    surface->box.x2,
-                   surface->attached->height - surface->box.y2,
-                   surface->attached->height,
+                   height - surface->box.y2,
+                   height,
                    -1.0, 1.0);
         gl->matrix_mode (GLITZ_GL_MODELVIEW);
         gl->load_identity ();
         gl->scale_f (1.0f, -1.0f, 1.0f);
-        gl->translate_f (0.0f, -surface->attached->height, 0.0f);
+        gl->translate_f (0.0f, -height, 0.0f);
     
-        viewport->x = surface->x;
-        viewport->y = surface->y;
-        viewport->width = surface->box.x2;
-        viewport->height = surface->box.y2;
+        drawable->viewport.x      = surface->x;
+        drawable->viewport.y      = surface->y;
+        drawable->viewport.width  = surface->box.x2;
+        drawable->viewport.height = surface->box.y2;
     
-        surface->attached->update_all = 0;
+        drawable->update_all = 0;
     }
     
     gl->draw_buffer (surface->buffer);
@@ -458,14 +476,6 @@
         gl->enable (GLITZ_GL_DITHER);
     else
         gl->disable (GLITZ_GL_DITHER);
-
-    if (surface->attached->format->samples > 1)
-    {
-        gl->enable (GLITZ_GL_MULTISAMPLE);
-        if (surface->attached->backend->feature_mask &
-            GLITZ_FEATURE_MULTISAMPLE_FILTER_HINT_MASK)
-            gl->hint (GLITZ_GL_MULTISAMPLE_FILTER_HINT, GLITZ_GL_NICEST);
-    }
 }
 
 void
@@ -512,6 +522,9 @@
   
     glitz_drawable_destroy (surface->attached); 
     surface->attached = NULL;
+    surface->buffer = GLITZ_GL_FRONT;
+    surface->x = 0;
+    surface->y = 0;
     
     REGION_EMPTY (&surface->drawable_damage);
     REGION_INIT (&surface->drawable_damage, &surface->box);
@@ -535,18 +548,42 @@
 glitz_surface_push_current (glitz_surface_t    *surface,
                             glitz_constraint_t constraint)
 {
-  if (surface->attached) {
-    surface->attached->backend->push_current (surface->attached, surface,
-                                              constraint);
-    if (constraint == GLITZ_DRAWABLE_CURRENT) {
-      _glitz_surface_update_state (surface);
-      _glitz_surface_sync_drawable (surface);
-    }
-  } else {
-    surface->drawable->backend->push_current (surface->drawable, NULL,
-                                              constraint);
-    if (constraint == GLITZ_DRAWABLE_CURRENT)
-      return 0;
+  if (surface->attached)
+  {
+      surface->attached->backend->push_current (surface->attached,
+                                                surface,
+                                                constraint);
+      if (constraint == GLITZ_DRAWABLE_CURRENT)
+      {
+          if (surface->attached->backend->feature_mask &
+              GLITZ_FEATURE_FRAMEBUFFER_OBJECT_MASK)
+              glitz_framebuffer_unbind (&surface->attached->backend->gl);
+              
+          _glitz_surface_update_state (surface);
+          _glitz_surface_sync_drawable (surface);
+      }
+  }
+  else
+  {
+      surface->drawable->backend->push_current (surface->drawable,
+                                                surface,
+                                                constraint);
+      if (constraint == GLITZ_DRAWABLE_CURRENT)
+      {
+          if (surface->drawable->backend->feature_mask &
+              GLITZ_FEATURE_FRAMEBUFFER_OBJECT_MASK)
+          {
+              if (glitz_framebuffer_complete (&surface->attached->backend->gl,
+                                              &surface->framebuffer,
+                                              &surface->texture))
+              {       
+                  _glitz_surface_update_state (surface);
+                  return 1;
+              }
+          }
+
+          return 0;
+      }
   }
   
   return 1;
@@ -873,3 +910,9 @@
     }
 }
 slim_hidden_def(glitz_surface_set_clip_region);
+
+glitz_bool_t
+glitz_surface_valid_target (glitz_surface_t *surface)
+{
+    return glitz_surface_push_current (surface, GLITZ_DRAWABLE_CURRENT);
+}

Index: glitz_util.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_util.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- glitz_util.c	25 Jan 2005 19:50:26 -0000	1.12
+++ glitz_util.c	10 Feb 2005 01:03:00 -0000	1.13
@@ -62,6 +62,7 @@
   { 0.0, "GL_EXT_blend_color", GLITZ_FEATURE_BLEND_COLOR_MASK },
   { 0.0, "GL_ARB_imaging", GLITZ_FEATURE_BLEND_COLOR_MASK },
   { 0.0, "GL_APPLE_packed_pixels", GLITZ_FEATURE_PACKED_PIXELS_MASK },
+  { 0.0, "GL_EXT_framebuffer_object", GLITZ_FEATURE_FRAMEBUFFER_OBJECT_MASK },
   { 0.0, NULL, 0 }
 };
 
@@ -253,6 +254,27 @@
       backend->feature_mask &= ~GLITZ_FEATURE_PIXEL_BUFFER_OBJECT_MASK;
     }
   }
+
+  if (backend->feature_mask & GLITZ_FEATURE_FRAMEBUFFER_OBJECT_MASK) {
+    backend->gl.gen_framebuffers = (glitz_gl_gen_framebuffers_t)
+      get_proc_address ("glGenFramebuffersEXT", closure);
+    backend->gl.delete_framebuffers = (glitz_gl_delete_framebuffers_t)
+      get_proc_address ("glDeleteFramebuffersEXT", closure);
+    backend->gl.bind_framebuffer = (glitz_gl_bind_framebuffer_t)
+      get_proc_address ("glBindFramebufferEXT", closure);
+    backend->gl.check_framebuffer_status =
+      (glitz_gl_check_framebuffer_status_t)
+      get_proc_address ("glCheckFramebufferStatusEXT", closure);
+    backend->gl.framebuffer_texture_2d = (glitz_gl_framebuffer_texture_2d_t)
+      get_proc_address ("glFramebufferTexture2DEXT", closure);
+    
+    if ((!backend->gl.gen_framebuffers) ||
+        (!backend->gl.delete_framebuffers) ||
+        (!backend->gl.bind_framebuffer) ||
+        (!backend->gl.check_framebuffer_status) ||
+        (!backend->gl.framebuffer_texture_2d))
+      backend->feature_mask &= ~GLITZ_FEATURE_FRAMEBUFFER_OBJECT_MASK;
+  }
 }
 
 void

Index: glitzint.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glitzint.h,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- glitzint.h	25 Jan 2005 19:50:26 -0000	1.31
+++ glitzint.h	10 Feb 2005 01:03:00 -0000	1.32
@@ -170,6 +170,11 @@
   glitz_gl_get_buffer_sub_data_t        get_buffer_sub_data;
   glitz_gl_map_buffer_t                 map_buffer;
   glitz_gl_unmap_buffer_t               unmap_buffer;
+  glitz_gl_gen_framebuffers_t           gen_framebuffers;
+  glitz_gl_delete_framebuffers_t        delete_framebuffers;
+  glitz_gl_bind_framebuffer_t           bind_framebuffer;
+  glitz_gl_check_framebuffer_status_t   check_framebuffer_status;
+  glitz_gl_framebuffer_texture_2d_t     framebuffer_texture_2d;
 } glitz_gl_proc_address_list_t;
 
 typedef int glitz_surface_type_t;
@@ -525,6 +530,10 @@
   glitz_float_t m[16];
 } glitz_matrix_t;
 
+typedef struct _glitz_framebuffer {
+    glitz_gl_uint_t name;
+} glitz_framebuffer_t;
+
 #define GLITZ_DAMAGE_TEXTURE_MASK  (1 << 0)
 #define GLITZ_DAMAGE_DRAWABLE_MASK (1 << 1)
 #define GLITZ_DAMAGE_SOLID_MASK    (1 << 2)
@@ -559,6 +568,7 @@
   int                   *primcount;
   glitz_region_t        texture_damage;
   glitz_region_t        drawable_damage;
+  glitz_framebuffer_t   framebuffer;
 };
 
 #define GLITZ_GL_SURFACE(surface) \
@@ -808,6 +818,22 @@
                             glitz_box_t                  *bounds,
                             int                          damage);
 
+extern void __internal_linkage
+glitz_framebuffer_init (glitz_framebuffer_t *framebuffer);
+
+extern void __internal_linkage
+glitz_framebuffer_fini (glitz_gl_proc_address_list_t *gl,
+                        glitz_framebuffer_t          *framebuffer);
+
+extern void __internal_linkage
+glitz_framebuffer_unbind (glitz_gl_proc_address_list_t *gl);
+
+extern glitz_bool_t __internal_linkage
+glitz_framebuffer_complete (glitz_gl_proc_address_list_t *gl,
+                            glitz_framebuffer_t          *framebuffer,
+                            glitz_texture_t              *texture);
+
+
 #define MAXSHORT SHRT_MAX
 #define MINSHORT SHRT_MIN
 




More information about the cairo-commit mailing list