MCPcopy Create free account
hub / github.com/Snapchat/Valdi / raster

Method raster

valdi/src/java/com/snap/valdi/ViewRef.kt:241–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239 canvas.setBitmap(null)
240 }
241
242 @Keep
243 fun raster(bitmap: Any?, left: Int, top: Int, right: Int, bottom: Int, rasterScaleX: Float, rasterScaleY: Float, transform: Any?): String? {
244 try {
245 val view = get() ?: return "Cannot resolve view"
246
247 if (view.parent == null) {
248 measureAndLayout(view, left, top, right - left, bottom - top, false)
249 }
250
251 val renderCanvas = Canvas()
252
253 val transformMatrix = Matrix()
254
255 val resolvedRasterScaleX = this.support.coordinateResolver.fromPixel(rasterScaleX)
256 val resolvedRasterScaleY = this.support.coordinateResolver.fromPixel(rasterScaleY)
257
258 transformMatrix.preScale(resolvedRasterScaleX.toFloat(), resolvedRasterScaleY.toFloat())
259 (transform as? FloatArray)?.let { values ->
260 Matrix().apply {
261 setValues(values)
262 transformMatrix.preConcat(this)
263 }
264 }
265
266 transformMatrix.preTranslate(left.toFloat(), top.toFloat())
267
268 drawViewInCanvas(renderCanvas, bitmap as Bitmap, view, transformMatrix, false)
269
270 return null
271 } catch (exc: Exception) {
272 this.support.logger.log(
273 LogLevel.ERROR,
274 exc,
275 "Failed to raster view"
276 )
277 return exc.messageWithCauses()
278 }
279 }
280
281 @Keep

Callers

nothing calls this directly

Calls 8

fromPixelMethod · 0.80
preScaleMethod · 0.80
toFloatMethod · 0.80
preConcatMethod · 0.80
applyMethod · 0.65
logMethod · 0.65
getFunction · 0.50
MatrixClass · 0.50

Tested by

no test coverage detected