[cogl/cogl-1.16] texture-2d: Add _new_from_file api



commit aa92110f83a695de05347ebbd0d228ec4c760387
Author: Robert Bragg <robert linux intel com>
Date:   Sat Jun 8 02:10:15 2013 +0100

    texture-2d: Add _new_from_file api
    
    This adds a cogl_texture_2d_new_from_file() api since we are planning to
    remove cogl_texture_new_from_file() but don't want to loose the
    convenience it had.
    
    Reviewed-by: Neil Roberts <neil linux intel com>
    
    (cherry picked from commit 10e91aa513123ed277a8d45976f8d75445d7dc9c)

 cogl/cogl-texture-2d.c                             |   25 ++++++++++++++++++
 cogl/cogl-texture-2d.h                             |   27 ++++++++++++++++++++
 .../cogl-2.0-experimental-sections.txt             |    1 +
 3 files changed, 53 insertions(+), 0 deletions(-)
---
diff --git a/cogl/cogl-texture-2d.c b/cogl/cogl-texture-2d.c
index d9cc031..4147746 100644
--- a/cogl/cogl-texture-2d.c
+++ b/cogl/cogl-texture-2d.c
@@ -192,6 +192,31 @@ cogl_texture_2d_new_from_bitmap (CoglBitmap *bmp,
 }
 
 CoglTexture2D *
+cogl_texture_2d_new_from_file (CoglContext *ctx,
+                               const char *filename,
+                               CoglPixelFormat internal_format,
+                               CoglError **error)
+{
+  CoglBitmap *bmp;
+  CoglTexture2D *tex_2d = NULL;
+
+  _COGL_RETURN_VAL_IF_FAIL (error == NULL || *error == NULL, NULL);
+
+  bmp = _cogl_bitmap_from_file (ctx, filename, error);
+  if (bmp == NULL)
+    return NULL;
+
+  tex_2d = _cogl_texture_2d_new_from_bitmap (bmp,
+                                             internal_format,
+                                             TRUE, /* can convert in-place */
+                                             error);
+
+  cogl_object_unref (bmp);
+
+  return tex_2d;
+}
+
+CoglTexture2D *
 cogl_texture_2d_new_from_data (CoglContext *ctx,
                                int width,
                                int height,
diff --git a/cogl/cogl-texture-2d.h b/cogl/cogl-texture-2d.h
index 5a5ff2f..c1ae57f 100644
--- a/cogl/cogl-texture-2d.h
+++ b/cogl/cogl-texture-2d.h
@@ -103,6 +103,33 @@ cogl_texture_2d_new_with_size (CoglContext *ctx,
                                CoglPixelFormat internal_format);
 
 /**
+ * cogl_texture_2d_new_from_file:
+ * @ctx: A #CoglContext
+ * @filename: the file to load
+ * @internal_format: the #CoglPixelFormat to use for the GPU storage of the
+ *    texture. If %COGL_PIXEL_FORMAT_ANY is given then a premultiplied
+ *    format similar to the format of the source data will be used. The
+ *    default blending equations of Cogl expect premultiplied color data;
+ *    the main use of passing a non-premultiplied format here is if you
+ *    have non-premultiplied source data and are going to adjust the blend
+ *    mode (see cogl_material_set_blend()) or use the data for something
+ *    other than straight blending.
+ * @error: A #CoglError to catch exceptional errors or %NULL
+ *
+ * Creates a #CoglTexture2D from an image file.
+ *
+ * Return value: A newly created #CoglTexture2D or %NULL on failure
+ *               and @error will be updated.
+ *
+ * Since: 1.16
+ */
+CoglTexture2D *
+cogl_texture_2d_new_from_file (CoglContext *ctx,
+                               const char *filename,
+                               CoglPixelFormat internal_format,
+                               CoglError **error);
+
+/**
  * cogl_texture_2d_new_from_data:
  * @ctx: A #CoglContext
  * @width: width of texture in pixels
diff --git a/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt 
b/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt
index b0feae7..939a4f0 100644
--- a/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt
+++ b/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt
@@ -417,6 +417,7 @@ COGL_TEXTURE_MAX_WASTE
 <TITLE>2D textures</TITLE>
 CoglTexture2D
 cogl_texture_2d_new_with_size
+cogl_texture_2d_new_from_file
 cogl_texture_2d_new_from_bitmap
 cogl_texture_2d_new_from_data
 cogl_texture_2d_new_from_foreign


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