4848
4949def ProcessBlock (dstBlockList , iBlockId , objBlock , bLinearAlgorithm ):
5050 iBlockSize = int (objBlock ['TotalBytes' ])
51- arrSuballocs = objBlock ['Suballocations' ]
51+ arrSuballocs = objBlock ['Suballocations' ]
5252 dstBlockObj = {'ID' : iBlockId , 'Size' :iBlockSize , 'Suballocations' :[]}
5353 if bLinearAlgorithm :
54- dstBlockObj ['LinearAlgorithm' ] = True
55- dstBlockList .append (dstBlockObj )
54+ dstBlockObj ['LinearAlgorithm' ] = True
5655 for objSuballoc in arrSuballocs :
5756 dstBlockObj ['Suballocations' ].append ((objSuballoc ['Type' ], int (objSuballoc ['Size' ]), int (objSuballoc ['Usage' ]) if ('Usage' in objSuballoc ) else 0 ))
57+ dstBlockList .append (dstBlockObj )
5858
5959
6060def GetDataForMemoryType (iMemTypeIndex ):
@@ -77,15 +77,18 @@ def CalcParams():
7777 iMaxBlockSize = 0
7878 for dictMemType in data .values ():
7979 iImgSizeY += IMG_MARGIN + FONT_SIZE
80- iImgSizeY += len (dictMemType ['DedicatedAllocations' ]) * (IMG_MARGIN * 2 + FONT_SIZE + MAP_SIZE )
81- for tDedicatedAlloc in dictMemType ['DedicatedAllocations' ]:
80+ lDedicatedAllocations = dictMemType ['DedicatedAllocations' ]
81+ iImgSizeY += len (lDedicatedAllocations ) * (IMG_MARGIN * 2 + FONT_SIZE + MAP_SIZE )
82+ for tDedicatedAlloc in lDedicatedAllocations :
8283 iMaxBlockSize = max (iMaxBlockSize , tDedicatedAlloc [1 ])
83- iImgSizeY += len (dictMemType ['DefaultPoolBlocks' ]) * (IMG_MARGIN * 2 + FONT_SIZE + MAP_SIZE )
84- for objBlock in dictMemType ['DefaultPoolBlocks' ]:
84+ lDefaultPoolBlocks = dictMemType ['DefaultPoolBlocks' ]
85+ iImgSizeY += len (lDefaultPoolBlocks ) * (IMG_MARGIN * 2 + FONT_SIZE + MAP_SIZE )
86+ for objBlock in lDefaultPoolBlocks :
8587 iMaxBlockSize = max (iMaxBlockSize , objBlock ['Size' ])
86- iImgSizeY += len (dictMemType ['CustomPools' ]) * (IMG_MARGIN * 2 + FONT_SIZE + MAP_SIZE )
87- for listPool in dictMemType ['CustomPools' ].values ():
88- for objBlock in listPool :
88+ dCustomPools = dictMemType ['CustomPools' ]
89+ for lBlocks in dCustomPools .values ():
90+ iImgSizeY += len (lBlocks ) * (IMG_MARGIN * 2 + FONT_SIZE + MAP_SIZE )
91+ for objBlock in lBlocks :
8992 iMaxBlockSize = max (iMaxBlockSize , objBlock ['Size' ])
9093 fPixelsPerByte = (IMG_SIZE_X - IMG_MARGIN * 2 ) / float (iMaxBlockSize )
9194 return iImgSizeY , fPixelsPerByte
@@ -192,9 +195,9 @@ def BytesToStr(iBytes):
192195 typeData = GetDataForMemoryType (iType )
193196 objBlocks = objPool ['Blocks' ]
194197 bLinearAlgorithm = 'LinearAlgorithm' in objPool and objPool ['LinearAlgorithm' ]
198+ dstBlockArray = []
199+ typeData ['CustomPools' ][int (sPoolId )] = dstBlockArray
195200 for sBlockId , objBlock in objBlocks .items ():
196- dstBlockArray = []
197- typeData ['CustomPools' ][int (sPoolId )] = dstBlockArray
198201 ProcessBlock (dstBlockArray , int (sBlockId ), objBlock , bLinearAlgorithm )
199202
200203iImgSizeY , fPixelsPerByte = CalcParams ()
@@ -244,15 +247,15 @@ def BytesToStr(iBytes):
244247 index = 0
245248 for iPoolId , listPool in dictMemType ['CustomPools' ].items ():
246249 for objBlock in listPool :
247- if 'LinearAlgorithm' in objBlock :
248- linearAlgorithmStr = ' (linear algorithm)' ;
249- else :
250- linearAlgorithmStr = '' ;
251- draw .text ((IMG_MARGIN , y ), "Custom pool %d%s block %d" % (iPoolId , linearAlgorithmStr , objBlock ['ID' ]), fill = COLOR_TEXT_H2 , font = font )
252- y += FONT_SIZE + IMG_MARGIN
253- DrawBlock (draw , y , objBlock )
254- y += MAP_SIZE + IMG_MARGIN
255- index += 1
250+ if 'LinearAlgorithm' in objBlock :
251+ linearAlgorithmStr = ' (linear algorithm)' ;
252+ else :
253+ linearAlgorithmStr = '' ;
254+ draw .text ((IMG_MARGIN , y ), "Custom pool %d%s block %d" % (iPoolId , linearAlgorithmStr , objBlock ['ID' ]), fill = COLOR_TEXT_H2 , font = font )
255+ y += FONT_SIZE + IMG_MARGIN
256+ DrawBlock (draw , y , objBlock )
257+ y += MAP_SIZE + IMG_MARGIN
258+ index += 1
256259del draw
257260img .save (args .output )
258261
@@ -267,7 +270,7 @@ def BytesToStr(iBytes):
267270 - Fixed key 'Size'. Value is int.
268271 - Fixed key 'Suballocations'. Value is list of tuples as above.
269272- Fixed key 'CustomPools'. Value is dictionary.
270- - Key is integer pool ID. Value is list of objects, each containing dictionary with:
273+ - Key is integer pool ID. Value is list of objects representing memory blocks , each containing dictionary with:
271274 - Fixed key 'ID'. Value is int.
272275 - Fixed key 'Size'. Value is int.
273276 - Fixed key 'LinearAlgorithm'. Optional. Value is True.
0 commit comments