48
48
49
49
def ProcessBlock (dstBlockList , iBlockId , objBlock , bLinearAlgorithm ):
50
50
iBlockSize = int (objBlock ['TotalBytes' ])
51
- arrSuballocs = objBlock ['Suballocations' ]
51
+ arrSuballocs = objBlock ['Suballocations' ]
52
52
dstBlockObj = {'ID' : iBlockId , 'Size' :iBlockSize , 'Suballocations' :[]}
53
53
if bLinearAlgorithm :
54
- dstBlockObj ['LinearAlgorithm' ] = True
55
- dstBlockList .append (dstBlockObj )
54
+ dstBlockObj ['LinearAlgorithm' ] = True
56
55
for objSuballoc in arrSuballocs :
57
56
dstBlockObj ['Suballocations' ].append ((objSuballoc ['Type' ], int (objSuballoc ['Size' ]), int (objSuballoc ['Usage' ]) if ('Usage' in objSuballoc ) else 0 ))
57
+ dstBlockList .append (dstBlockObj )
58
58
59
59
60
60
def GetDataForMemoryType (iMemTypeIndex ):
@@ -77,15 +77,18 @@ def CalcParams():
77
77
iMaxBlockSize = 0
78
78
for dictMemType in data .values ():
79
79
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 :
82
83
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 :
85
87
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 :
89
92
iMaxBlockSize = max (iMaxBlockSize , objBlock ['Size' ])
90
93
fPixelsPerByte = (IMG_SIZE_X - IMG_MARGIN * 2 ) / float (iMaxBlockSize )
91
94
return iImgSizeY , fPixelsPerByte
@@ -192,9 +195,9 @@ def BytesToStr(iBytes):
192
195
typeData = GetDataForMemoryType (iType )
193
196
objBlocks = objPool ['Blocks' ]
194
197
bLinearAlgorithm = 'LinearAlgorithm' in objPool and objPool ['LinearAlgorithm' ]
198
+ dstBlockArray = []
199
+ typeData ['CustomPools' ][int (sPoolId )] = dstBlockArray
195
200
for sBlockId , objBlock in objBlocks .items ():
196
- dstBlockArray = []
197
- typeData ['CustomPools' ][int (sPoolId )] = dstBlockArray
198
201
ProcessBlock (dstBlockArray , int (sBlockId ), objBlock , bLinearAlgorithm )
199
202
200
203
iImgSizeY , fPixelsPerByte = CalcParams ()
@@ -244,15 +247,15 @@ def BytesToStr(iBytes):
244
247
index = 0
245
248
for iPoolId , listPool in dictMemType ['CustomPools' ].items ():
246
249
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
256
259
del draw
257
260
img .save (args .output )
258
261
@@ -267,7 +270,7 @@ def BytesToStr(iBytes):
267
270
- Fixed key 'Size'. Value is int.
268
271
- Fixed key 'Suballocations'. Value is list of tuples as above.
269
272
- 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:
271
274
- Fixed key 'ID'. Value is int.
272
275
- Fixed key 'Size'. Value is int.
273
276
- Fixed key 'LinearAlgorithm'. Optional. Value is True.
0 commit comments