mesa: rename _mesa_free_errors_data
[mesa.git] / src / mesa / main / format_parser.py
old mode 100755 (executable)
new mode 100644 (file)
index 799b14f..c0d73c9
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 #
 # Copyright 2009 VMware, Inc.
 # Copyright 2014 Intel Corporation
@@ -62,8 +61,14 @@ class Channel:
       return s
 
    def __eq__(self, other):
+      if other is None:
+         return False
+
       return self.type == other.type and self.norm == other.norm and self.size == other.size
 
+   def __ne__(self, other):
+      return not self.__eq__(other)
+
    def max(self):
       """Returns the maximum representable number."""
       if self.type == FLOAT:
@@ -217,8 +222,8 @@ class Swizzle:
       component, exactly as you would expect.
       """
       rev = [Swizzle.SWIZZLE_NONE] * 4
-      for i in xrange(4):
-         for j in xrange(4):
+      for i in range(4):
+         for j in range(4):
             if self.__list[j] == i and rev[i] == Swizzle.SWIZZLE_NONE:
                rev[i] = j
       return Swizzle(rev)
@@ -227,7 +232,7 @@ class Swizzle:
 class Format:
    """Describes a pixel format."""
 
-   def __init__(self, name, layout, block_width, block_height, channels, swizzle, colorspace):
+   def __init__(self, name, layout, block_width, block_height, block_depth, channels, swizzle, colorspace):
       """Constructs a Format from some metadata and a list of channels.
 
       The channel objects must be unique to this Format and should not be
@@ -241,6 +246,7 @@ class Format:
       layout -- One of 'array', 'packed' 'other', or a compressed layout
       block_width -- The block width if the format is compressed, 1 otherwise
       block_height -- The block height if the format is compressed, 1 otherwise
+      block_depth -- The block depth if the format is compressed, 1 otherwise
       channels -- A list of Channel objects
       swizzle -- A Swizzle from this format to rgba
       colorspace -- one of 'rgb', 'srgb', 'yuv', or 'zs'
@@ -249,6 +255,7 @@ class Format:
       self.layout = layout
       self.block_width = block_width
       self.block_height = block_height
+      self.block_depth = block_depth
       self.channels = channels
       assert isinstance(swizzle, Swizzle)
       self.swizzle = swizzle
@@ -361,7 +368,7 @@ class Format:
 
    def is_compressed(self):
       """Returns true if this is a compressed format."""
-      return self.block_width != 1 or self.block_height != 1
+      return self.block_width != 1 or self.block_height != 1 or self.block_depth != 1
 
    def is_int(self):
       """Returns true if this format is an integer format.
@@ -532,7 +539,7 @@ def _parse_channels(fields, layout, colorspace, swizzle):
    return channels
 
 def parse(filename):
-   """Parse a format descrition in CSV format.
+   """Parse a format description in CSV format.
 
    This function parses the given CSV file and returns an iterable of
    channels."""
@@ -555,12 +562,13 @@ def parse(filename):
          layout = fields[1]
          block_width = int(fields[2])
          block_height = int(fields[3])
-         colorspace = fields[9]
+         block_depth = int(fields[4])
+         colorspace = fields[10]
 
          try:
-            swizzle = Swizzle(fields[8])
+            swizzle = Swizzle(fields[9])
          except:
             sys.exit("error parsing swizzle for format " + name)
-         channels = _parse_channels(fields[4:8], layout, colorspace, swizzle)
+         channels = _parse_channels(fields[5:9], layout, colorspace, swizzle)
 
-         yield Format(name, layout, block_width, block_height, channels, swizzle, colorspace)
+         yield Format(name, layout, block_width, block_height, block_depth, channels, swizzle, colorspace)