[cogl/wip/cogl-sharp: 12/51] cogl-sharp: Expose CoglPixelFormat



commit 47bb9404685ea4bdfd6009fc56ac64cbde0fbf31
Author: Damien Lespiau <damien lespiau intel com>
Date:   Mon Oct 1 21:10:10 2012 +0100

    cogl-sharp: Expose CoglPixelFormat
    
    And thus also enable the generation of yet another method of
    FrameBuffer.
    
    This also introduces a way to tell the generator you want the enum
    members to bo upper case (by default it will generate capitalized enum
    values).

 cogl-sharp/Makefile.am     |    1 +
 cogl-sharp/PixelFormat.cs  |   38 ++++++++++++++++++++++++++++++++++++++
 cogl-sharp/_FrameBuffer.cs |    8 ++++++++
 cogl-sharp/parse-gir.py    |   36 ++++++++++++++++++++++++++++--------
 4 files changed, 75 insertions(+), 8 deletions(-)
---
diff --git a/cogl-sharp/Makefile.am b/cogl-sharp/Makefile.am
index 926ff26..23348d1 100644
--- a/cogl-sharp/Makefile.am
+++ b/cogl-sharp/Makefile.am
@@ -18,6 +18,7 @@ sources =		\
 	Matrix.cs	\
 	Object.cs	\
 	OnScreen.cs	\
+	PixelFormat.cs	\
 	AssemblyInfo.cs	\
 	$(NULL)
 
diff --git a/cogl-sharp/PixelFormat.cs b/cogl-sharp/PixelFormat.cs
new file mode 100644
index 0000000..f0db16f
--- /dev/null
+++ b/cogl-sharp/PixelFormat.cs
@@ -0,0 +1,38 @@
+/* This file has been generated by parse-gir.py, do not hand edit */
+using System;
+
+namespace Cogl
+{
+    public enum PixelFormat
+    {
+        Any = 0,
+        A_8 = 65,
+        RGB_565 = 34,
+        RGBA_4444 = 98,
+        RGBA_4444_PRE = 610,
+        RGBA_5551 = 16777314,
+        RGBA_5551_PRE = 16777826,
+        G_8 = 1,
+        RGB_888 = 3,
+        BGR_888 = 131,
+        RGBA_8888 = 68,
+        BGRA_8888 = 196,
+        ARGB_8888 = 324,
+        ABGR_8888 = 452,
+        RGBA_8888_PRE = 580,
+        BGRA_8888_PRE = 708,
+        ARGB_8888_PRE = 836,
+        ABGR_8888_PRE = 964,
+        RGBA_1010102 = 33554500,
+        BGRA_1010102 = 33554628,
+        ARGB_2101010 = 33554756,
+        ABGR_2101010 = 33554884,
+        RGBA_1010102_PRE = 33555012,
+        BGRA_1010102_PRE = 33555140,
+        ARGB_2101010_PRE = 33555268,
+        ABGR_2101010_PRE = 33555396,
+        DEPTH_16 = 1026,
+        DEPTH_32 = 1028,
+        DEPTH_24_STENCIL_8 = 3076
+    }
+}
diff --git a/cogl-sharp/_FrameBuffer.cs b/cogl-sharp/_FrameBuffer.cs
index 8a32161..6919664 100644
--- a/cogl-sharp/_FrameBuffer.cs
+++ b/cogl-sharp/_FrameBuffer.cs
@@ -71,6 +71,14 @@ namespace Cogl
         }
 
         [DllImport("cogl2.dll")]
+        public static extern PixelFormat cogl_framebuffer_get_color_format(IntPtr o);
+
+        public PixelFormat GetColorFormat()
+        {
+            return cogl_framebuffer_get_color_format(handle);
+        }
+
+        [DllImport("cogl2.dll")]
         public static extern int cogl_framebuffer_get_green_bits(IntPtr o);
 
         public int GetGreenBits()
diff --git a/cogl-sharp/parse-gir.py b/cogl-sharp/parse-gir.py
index a806c4b..ee2b59a 100755
--- a/cogl-sharp/parse-gir.py
+++ b/cogl-sharp/parse-gir.py
@@ -8,7 +8,8 @@ C_NS = "http://www.gtk.org/introspection/c/1.0";
 # enum types to dump (.gir names)
 enum_types = (
     "BufferBit",
-    "ColorMask"
+    "ColorMask",
+    "PixelFormat"
 )
 
 # object types to dump (.gir names)
@@ -35,6 +36,9 @@ name_overrides = {
     },
     'Offscreen': {
         'class': 'OffScreen'
+    },
+    'PixelFormat': {
+        'uppercase': 1
     }
 }
 
@@ -52,20 +56,27 @@ namespace Cogl
 footer_enum="""}
 """
 
-def make_enum_name(gir_name):
-    return gir_name.capitalize()
+def make_enum_name(enum_name, member_name):
+    uppercase = False
+    if enum_name in name_overrides and 'uppercase' in name_overrides[enum_name]:
+        uppercase = True
 
-def generate_bitfields(doc):
-    for node in doc.getElementsByTagName("bitfield"):
+    if uppercase and member_name != 'any':
+        return member_name.upper()
+
+    return member_name.capitalize()
+
+def do_generate_enum(node, is_flags):
         type_name = node.getAttribute("name")
         if type_name not in enum_types:
-            continue
+            return
 
         print("Generate %s" % type_name + ".cs")
 
         fo = open(type_name + ".cs", "w+")
         fo.write(header_enum)
-        fo.write("    [Flags]\n")
+        if is_flags:
+            fo.write("    [Flags]\n")
         fo.write("    public enum %s\n" % type_name)
         fo.write("    {\n")
         members = node.getElementsByTagName("member")
@@ -73,7 +84,7 @@ def generate_bitfields(doc):
         for member in members:
             member_name = member.getAttribute("name")
             value = member.getAttribute("value")
-            enum_name = make_enum_name(member_name)
+            enum_name = make_enum_name(type_name, member_name)
             if n < len(members):
                 fo.write("        %s = %s,\n" % (enum_name, value))
             else:
@@ -83,6 +94,14 @@ def generate_bitfields(doc):
         fo.write(footer_enum)
         fo.close()
 
+def generate_enumerations(doc):
+    for node in doc.getElementsByTagName("enumeration"):
+        do_generate_enum(node, False)
+
+def generate_bitfields(doc):
+    for node in doc.getElementsByTagName("bitfield"):
+        do_generate_enum(node, True)
+
 header_class="""/* This file has been generated by parse-gir.py, do not hand edit */
 using System;
 using System.Runtime.InteropServices;
@@ -248,5 +267,6 @@ def generate_classes(doc):
         fo.close()
 
 doc = xml.dom.minidom.parse(sys.argv[1])
+generate_enumerations(doc)
 generate_bitfields(doc)
 generate_classes(doc)



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