debian: Add graphviz dependency
[gfxprim/pasky.git] / pylib / gp_codegen / pixelsize.py
blob59f7c91006f88f95b4334318a3e33b462a1143c5
2 # gfxprim.pixelsize
4 # 2011 - Tomas Gavenciak <gavento@ucw.cz>
7 LE = "LE"
8 BE = "BE"
10 class PixelSize(object):
11 def __init__(self, size, bit_endian=None, suffix=None):
12 self.size = size
13 assert self.size >= 0
15 self.bit_endian = bit_endian
16 assert self.bit_endian in [None, LE, BE]
17 assert (bit_endian is not None) == self.needs_bit_endian()
18 self.bit_endian_const = "GP_BIT_ENDIAN_" + (self.bit_endian or LE)
20 self.suffix = suffix
21 if not self.suffix:
22 if self.size == 0:
23 self.suffix = "INVALID"
24 else:
25 if bit_endian:
26 self.suffix = '%dBPP_%s' % (size, bit_endian)
27 else:
28 self.suffix = '%dBPP' % (size,)
30 def needs_bit_endian(self):
31 return (self.size % 8) != 0
33 def description(self):
34 if self.bit_endian:
35 return "pixel size %d, bit endian %s, suffix %s" % (self.size,
36 self.bit_endian, self.suffix)
37 else:
38 return "pixel size %d, suffix %s" % (self.size, self.suffix)