MCPcopy Create free account
hub / github.com/facebook/chisel / _showLayer

Function _showLayer

commands/FBVisualizationCommands.py:118–146  ·  view source on GitHub ↗
(layer)

Source from the content-addressed store, hash-verified

116
117
118def _showLayer(layer):
119 layer = "(" + layer + ")"
120 size = "((CGRect)[(id)" + layer + " bounds]).size"
121
122 width = float(fb.evaluateExpression("(CGFloat)(" + size + ".width)"))
123 height = float(fb.evaluateExpression("(CGFloat)(" + size + ".height)"))
124 if width == 0.0 or height == 0.0:
125 print(
126 "Nothing to see here - the size of this element is {} x {}.".format(
127 width, height
128 )
129 )
130 return
131
132 fb.evaluateEffect("UIGraphicsBeginImageContextWithOptions(" + size + ", NO, 0.0)")
133 fb.evaluateEffect(
134 "[(id)" + layer + " renderInContext:(void *)UIGraphicsGetCurrentContext()]"
135 )
136
137 result = fb.evaluateExpressionValue(
138 "(UIImage *)UIGraphicsGetImageFromCurrentImageContext()"
139 )
140 if result.GetError() is not None and str(result.GetError()) != "success":
141 print(result.GetError())
142 else:
143 image = result.GetValue()
144 _showImage(image)
145
146 fb.evaluateEffect("UIGraphicsEndImageContext()")
147
148
149def _showPixelBuffer(target):

Callers 1

_visualizeFunction · 0.85

Calls 1

_showImageFunction · 0.85

Tested by

no test coverage detected