[cogl] Give buffer/bitmap bind functions gl infix



commit 6371fbb9637d88ff187dfb6c4bcd18468ba44d19
Author: Robert Bragg <robert linux intel com>
Date:   Wed Sep 19 21:59:19 2012 +0100

    Give buffer/bitmap bind functions gl infix
    
    The buffer and bitmap _bind() functions are GL specific so to clarify
    that, this patch adds a _gl infix to these functions, though it doesn't
    yet move the implementations out into gl specific files.
    
    Reviewed-by: Neil Roberts <neil linux intel com>

 cogl/cogl-bitmap-private.h                     |   21 ++++++++++++---------
 cogl/cogl-bitmap.c                             |   22 +++++++++++-----------
 cogl/cogl-buffer-private.h                     |    8 +++++---
 cogl/cogl-buffer.c                             |    4 ++--
 cogl/cogl-framebuffer.c                        |   16 ++++++++--------
 cogl/driver/gl/cogl-attribute-gl.c             |    4 ++--
 cogl/driver/gl/cogl-framebuffer-gl.c           |    4 ++--
 cogl/driver/gl/gl/cogl-texture-driver-gl.c     |   12 ++++++------
 cogl/driver/gl/gles/cogl-texture-driver-gles.c |   18 +++++++++---------
 9 files changed, 57 insertions(+), 52 deletions(-)
---
diff --git a/cogl/cogl-bitmap-private.h b/cogl/cogl-bitmap-private.h
index e0cf11d..6610460 100644
--- a/cogl/cogl-bitmap-private.h
+++ b/cogl/cogl-bitmap-private.h
@@ -169,18 +169,21 @@ void
 _cogl_bitmap_unmap (CoglBitmap *bitmap);
 
 /* These two are replacements for map and unmap that should used when
-   the pointer is going to be passed to GL for pixel packing or
-   unpacking. The address might not be valid for reading if the bitmap
-   was created with new_from_buffer but it will however be good to
-   pass to glTexImage2D for example. The access should be READ for
-   unpacking and WRITE for packing. It can not be both */
+ * the pointer is going to be passed to GL for pixel packing or
+ * unpacking. The address might not be valid for reading if the bitmap
+ * was created with new_from_buffer but it will however be good to
+ * pass to glTexImage2D for example. The access should be READ for
+ * unpacking and WRITE for packing. It can not be both
+ *
+ * TODO: split this bind/unbind functions out into a GL specific file
+ */
 uint8_t *
-_cogl_bitmap_bind (CoglBitmap *bitmap,
-                   CoglBufferAccess access,
-                   CoglBufferMapHint hints);
+_cogl_bitmap_gl_bind (CoglBitmap *bitmap,
+                      CoglBufferAccess access,
+                      CoglBufferMapHint hints);
 
 void
-_cogl_bitmap_unbind (CoglBitmap *bitmap);
+_cogl_bitmap_gl_unbind (CoglBitmap *bitmap);
 
 CoglContext *
 _cogl_bitmap_get_context (CoglBitmap *bitmap);
diff --git a/cogl/cogl-bitmap.c b/cogl/cogl-bitmap.c
index 09c27c6..cee8c41 100644
--- a/cogl/cogl-bitmap.c
+++ b/cogl/cogl-bitmap.c
@@ -410,15 +410,15 @@ _cogl_bitmap_unmap (CoglBitmap *bitmap)
 }
 
 uint8_t *
-_cogl_bitmap_bind (CoglBitmap *bitmap,
-                   CoglBufferAccess access,
-                   CoglBufferMapHint hints)
+_cogl_bitmap_gl_bind (CoglBitmap *bitmap,
+                      CoglBufferAccess access,
+                      CoglBufferMapHint hints)
 {
   uint8_t *ptr;
 
   /* Divert to another bitmap if this data is shared */
   if (bitmap->shared_bmp)
-    return _cogl_bitmap_bind (bitmap->shared_bmp, access, hints);
+    return _cogl_bitmap_gl_bind (bitmap->shared_bmp, access, hints);
 
   g_assert (!bitmap->bound);
 
@@ -435,11 +435,11 @@ _cogl_bitmap_bind (CoglBitmap *bitmap,
   bitmap->bound = TRUE;
 
   if (access == COGL_BUFFER_ACCESS_READ)
-    ptr = _cogl_buffer_bind (bitmap->buffer,
-                             COGL_BUFFER_BIND_TARGET_PIXEL_UNPACK);
+    ptr = _cogl_buffer_gl_bind (bitmap->buffer,
+                                COGL_BUFFER_BIND_TARGET_PIXEL_UNPACK);
   else if (access == COGL_BUFFER_ACCESS_WRITE)
-    ptr = _cogl_buffer_bind (bitmap->buffer,
-                             COGL_BUFFER_BIND_TARGET_PIXEL_PACK);
+    ptr = _cogl_buffer_gl_bind (bitmap->buffer,
+                                COGL_BUFFER_BIND_TARGET_PIXEL_PACK);
   else
     g_assert_not_reached ();
 
@@ -448,12 +448,12 @@ _cogl_bitmap_bind (CoglBitmap *bitmap,
 }
 
 void
-_cogl_bitmap_unbind (CoglBitmap *bitmap)
+_cogl_bitmap_gl_unbind (CoglBitmap *bitmap)
 {
   /* Divert to another bitmap if this data is shared */
   if (bitmap->shared_bmp)
     {
-      _cogl_bitmap_unbind (bitmap->shared_bmp);
+      _cogl_bitmap_gl_unbind (bitmap->shared_bmp);
       return;
     }
 
@@ -463,7 +463,7 @@ _cogl_bitmap_unbind (CoglBitmap *bitmap)
   /* If the bitmap wasn't created from a pixel array then the
      implementation of unbind is the same as unmap */
   if (bitmap->buffer)
-    _cogl_buffer_unbind (bitmap->buffer);
+    _cogl_buffer_gl_unbind (bitmap->buffer);
   else
     _cogl_bitmap_unmap (bitmap);
 }
diff --git a/cogl/cogl-buffer-private.h b/cogl/cogl-buffer-private.h
index 7e81e26..579be5a 100644
--- a/cogl/cogl-buffer-private.h
+++ b/cogl/cogl-buffer-private.h
@@ -123,12 +123,14 @@ _cogl_buffer_initialize (CoglBuffer *buffer,
 void
 _cogl_buffer_fini (CoglBuffer *buffer);
 
+/* TODO: split these GL specific bind and unbind functions out into
+ * some GL specific file. */
 void *
-_cogl_buffer_bind (CoglBuffer *buffer,
-                   CoglBufferBindTarget target);
+_cogl_buffer_gl_bind (CoglBuffer *buffer,
+                      CoglBufferBindTarget target);
 
 void
-_cogl_buffer_unbind (CoglBuffer *buffer);
+_cogl_buffer_gl_unbind (CoglBuffer *buffer);
 
 CoglBufferUsageHint
 _cogl_buffer_get_usage_hint (CoglBuffer *buffer);
diff --git a/cogl/cogl-buffer.c b/cogl/cogl-buffer.c
index 12b2d5a..3fe954b 100644
--- a/cogl/cogl-buffer.c
+++ b/cogl/cogl-buffer.c
@@ -367,7 +367,7 @@ _cogl_buffer_access_to_gl_enum (CoglBufferAccess access)
 }
 
 void *
-_cogl_buffer_bind (CoglBuffer *buffer, CoglBufferBindTarget target)
+_cogl_buffer_gl_bind (CoglBuffer *buffer, CoglBufferBindTarget target)
 {
   void *ret;
 
@@ -384,7 +384,7 @@ _cogl_buffer_bind (CoglBuffer *buffer, CoglBufferBindTarget target)
 }
 
 void
-_cogl_buffer_unbind (CoglBuffer *buffer)
+_cogl_buffer_gl_unbind (CoglBuffer *buffer)
 {
   CoglContext *ctx = buffer->context;
 
diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c
index 91d0418..41f5d18 100644
--- a/cogl/cogl-framebuffer.c
+++ b/cogl/cogl-framebuffer.c
@@ -1575,15 +1575,15 @@ cogl_framebuffer_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
                                                         width,
                                                         bpp);
 
-      tmp_data = _cogl_bitmap_bind (tmp_bmp,
-                                    COGL_BUFFER_ACCESS_WRITE,
-                                    COGL_BUFFER_MAP_HINT_DISCARD);
+      tmp_data = _cogl_bitmap_gl_bind (tmp_bmp,
+                                       COGL_BUFFER_ACCESS_WRITE,
+                                       COGL_BUFFER_MAP_HINT_DISCARD);
 
       GE( ctx, glReadPixels (x, y, width, height,
                              gl_format, gl_type,
                              tmp_data) );
 
-      _cogl_bitmap_unbind (tmp_bmp);
+      _cogl_bitmap_gl_unbind (tmp_bmp);
 
       succeeded = _cogl_bitmap_convert_into_bitmap (tmp_bmp, bitmap);
 
@@ -1626,16 +1626,16 @@ cogl_framebuffer_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
                                                         width,
                                                         bpp);
 
-      pixels = _cogl_bitmap_bind (shared_bmp,
-                                  COGL_BUFFER_ACCESS_WRITE,
-                                  0 /* hints */);
+      pixels = _cogl_bitmap_gl_bind (shared_bmp,
+                                     COGL_BUFFER_ACCESS_WRITE,
+                                     0 /* hints */);
 
       GE( ctx, glReadPixels (x, y,
                              width, height,
                              gl_format, gl_type,
                              pixels) );
 
-      _cogl_bitmap_unbind (shared_bmp);
+      _cogl_bitmap_gl_unbind (shared_bmp);
 
       /* Convert to the premult format specified by the caller
          in-place. This will do nothing if the premult status is already
diff --git a/cogl/driver/gl/cogl-attribute-gl.c b/cogl/driver/gl/cogl-attribute-gl.c
index 3391f48..65fb6e8 100644
--- a/cogl/driver/gl/cogl-attribute-gl.c
+++ b/cogl/driver/gl/cogl-attribute-gl.c
@@ -312,7 +312,7 @@ _cogl_gl_flush_attributes_state (CoglFramebuffer *framebuffer,
 
       attribute_buffer = cogl_attribute_get_buffer (attribute);
       buffer = COGL_BUFFER (attribute_buffer);
-      base = _cogl_buffer_bind (buffer, COGL_BUFFER_BIND_TARGET_ATTRIBUTE_BUFFER);
+      base = _cogl_buffer_gl_bind (buffer, COGL_BUFFER_BIND_TARGET_ATTRIBUTE_BUFFER);
 
       switch (attribute->name_state->name_id)
         {
@@ -388,7 +388,7 @@ _cogl_gl_flush_attributes_state (CoglFramebuffer *framebuffer,
           g_warning ("Unrecognised attribute type 0x%08x", attribute->type);
         }
 
-      _cogl_buffer_unbind (buffer);
+      _cogl_buffer_gl_unbind (buffer);
     }
 
   apply_attribute_enable_updates (ctx, pipeline);
diff --git a/cogl/driver/gl/cogl-framebuffer-gl.c b/cogl/driver/gl/cogl-framebuffer-gl.c
index 2cbea5f..addf15b 100644
--- a/cogl/driver/gl/cogl-framebuffer-gl.c
+++ b/cogl/driver/gl/cogl-framebuffer-gl.c
@@ -1066,7 +1066,7 @@ _cogl_framebuffer_gl_draw_indexed_attributes (CoglFramebuffer *framebuffer,
                                 attributes, n_attributes);
 
   buffer = COGL_BUFFER (cogl_indices_get_buffer (indices));
-  base = _cogl_buffer_bind (buffer, COGL_BUFFER_BIND_TARGET_INDEX_BUFFER);
+  base = _cogl_buffer_gl_bind (buffer, COGL_BUFFER_BIND_TARGET_INDEX_BUFFER);
   buffer_offset = cogl_indices_get_offset (indices);
   index_size = sizeof_index_type (cogl_indices_get_type (indices));
 
@@ -1089,5 +1089,5 @@ _cogl_framebuffer_gl_draw_indexed_attributes (CoglFramebuffer *framebuffer,
                       indices_gl_type,
                       base + buffer_offset + index_size * first_vertex));
 
-  _cogl_buffer_unbind (buffer);
+  _cogl_buffer_gl_unbind (buffer);
 }
diff --git a/cogl/driver/gl/gl/cogl-texture-driver-gl.c b/cogl/driver/gl/gl/cogl-texture-driver-gl.c
index 57c7517..3c681c3 100644
--- a/cogl/driver/gl/gl/cogl-texture-driver-gl.c
+++ b/cogl/driver/gl/gl/cogl-texture-driver-gl.c
@@ -168,7 +168,7 @@ _cogl_texture_driver_upload_subregion_to_gl (CoglContext *ctx,
   CoglPixelFormat source_format = cogl_bitmap_get_format (source_bmp);
   int bpp = _cogl_pixel_format_get_bytes_per_pixel (source_format);
 
-  data = _cogl_bitmap_bind (source_bmp, COGL_BUFFER_ACCESS_READ, 0);
+  data = _cogl_bitmap_gl_bind (source_bmp, COGL_BUFFER_ACCESS_READ, 0);
 
   /* Setup gl alignment to match rowstride and top-left corner */
   prep_gl_for_pixels_upload_full (ctx,
@@ -187,7 +187,7 @@ _cogl_texture_driver_upload_subregion_to_gl (CoglContext *ctx,
                             source_gl_type,
                             data) );
 
-  _cogl_bitmap_unbind (source_bmp);
+  _cogl_bitmap_gl_unbind (source_bmp);
 }
 
 static void
@@ -204,7 +204,7 @@ _cogl_texture_driver_upload_to_gl (CoglContext *ctx,
   CoglPixelFormat source_format = cogl_bitmap_get_format (source_bmp);
   int bpp = _cogl_pixel_format_get_bytes_per_pixel (source_format);
 
-  data = _cogl_bitmap_bind (source_bmp, COGL_BUFFER_ACCESS_READ, 0);
+  data = _cogl_bitmap_gl_bind (source_bmp, COGL_BUFFER_ACCESS_READ, 0);
 
   /* Setup gl alignment to match rowstride and top-left corner */
   prep_gl_for_pixels_upload_full (ctx,
@@ -222,7 +222,7 @@ _cogl_texture_driver_upload_to_gl (CoglContext *ctx,
                          source_gl_type,
                          data) );
 
-  _cogl_bitmap_unbind (source_bmp);
+  _cogl_bitmap_gl_unbind (source_bmp);
 }
 
 static void
@@ -241,7 +241,7 @@ _cogl_texture_driver_upload_to_gl_3d (CoglContext *ctx,
   CoglPixelFormat source_format = cogl_bitmap_get_format (source_bmp);
   int bpp = _cogl_pixel_format_get_bytes_per_pixel (source_format);
 
-  data = _cogl_bitmap_bind (source_bmp, COGL_BUFFER_ACCESS_READ, 0);
+  data = _cogl_bitmap_gl_bind (source_bmp, COGL_BUFFER_ACCESS_READ, 0);
 
   /* Setup gl alignment to match rowstride and top-left corner */
   prep_gl_for_pixels_upload_full (ctx,
@@ -263,7 +263,7 @@ _cogl_texture_driver_upload_to_gl_3d (CoglContext *ctx,
                          source_gl_type,
                          data) );
 
-  _cogl_bitmap_unbind (source_bmp);
+  _cogl_bitmap_gl_unbind (source_bmp);
 }
 
 static CoglBool
diff --git a/cogl/driver/gl/gles/cogl-texture-driver-gles.c b/cogl/driver/gl/gles/cogl-texture-driver-gles.c
index bd8f748..65407b6 100644
--- a/cogl/driver/gl/gles/cogl-texture-driver-gles.c
+++ b/cogl/driver/gl/gles/cogl-texture-driver-gles.c
@@ -216,7 +216,7 @@ _cogl_texture_driver_upload_subregion_to_gl (CoglContext *ctx,
   /* Setup gl alignment to match rowstride and top-left corner */
   prep_gl_for_pixels_upload_full (ctx, rowstride, src_x, src_y, bpp);
 
-  data = _cogl_bitmap_bind (slice_bmp, COGL_BUFFER_ACCESS_READ, 0);
+  data = _cogl_bitmap_gl_bind (slice_bmp, COGL_BUFFER_ACCESS_READ, 0);
 
   _cogl_bind_gl_texture_transient (gl_target, gl_handle, is_foreign);
 
@@ -227,7 +227,7 @@ _cogl_texture_driver_upload_subregion_to_gl (CoglContext *ctx,
                             source_gl_type,
                             data) );
 
-  _cogl_bitmap_unbind (slice_bmp);
+  _cogl_bitmap_gl_unbind (slice_bmp);
 
   cogl_object_unref (slice_bmp);
 }
@@ -258,7 +258,7 @@ _cogl_texture_driver_upload_to_gl (CoglContext *ctx,
 
   _cogl_bind_gl_texture_transient (gl_target, gl_handle, is_foreign);
 
-  data = _cogl_bitmap_bind (bmp, COGL_BUFFER_ACCESS_READ, 0);
+  data = _cogl_bitmap_gl_bind (bmp, COGL_BUFFER_ACCESS_READ, 0);
 
   GE( ctx, glTexImage2D (gl_target, 0,
                          internal_gl_format,
@@ -268,7 +268,7 @@ _cogl_texture_driver_upload_to_gl (CoglContext *ctx,
                          source_gl_type,
                          data) );
 
-  _cogl_bitmap_unbind (bmp);
+  _cogl_bitmap_gl_unbind (bmp);
 
   cogl_object_unref (bmp);
 }
@@ -335,8 +335,8 @@ _cogl_texture_driver_upload_to_gl_3d (CoglContext *ctx,
                                        bmp_width,
                                        height);
 
-          data = _cogl_bitmap_bind (bmp,
-                                    COGL_BUFFER_ACCESS_READ, 0);
+          data = _cogl_bitmap_gl_bind (bmp,
+                                       COGL_BUFFER_ACCESS_READ, 0);
 
           GE( ctx, glTexSubImage3D (gl_target,
                                     0, /* level */
@@ -350,14 +350,14 @@ _cogl_texture_driver_upload_to_gl_3d (CoglContext *ctx,
                                     source_gl_type,
                                     data) );
 
-          _cogl_bitmap_unbind (bmp);
+          _cogl_bitmap_gl_unbind (bmp);
         }
 
       cogl_object_unref (bmp);
     }
   else
     {
-      data = _cogl_bitmap_bind (source_bmp, COGL_BUFFER_ACCESS_READ, 0);
+      data = _cogl_bitmap_gl_bind (source_bmp, COGL_BUFFER_ACCESS_READ, 0);
 
       _cogl_texture_driver_prep_gl_for_pixels_upload (ctx, rowstride, bpp);
 
@@ -372,7 +372,7 @@ _cogl_texture_driver_upload_to_gl_3d (CoglContext *ctx,
                              source_gl_type,
                              data) );
 
-      _cogl_bitmap_unbind (source_bmp);
+      _cogl_bitmap_gl_unbind (source_bmp);
     }
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]