Only pixel copy if view is hardwell accell
Summary: You can only use pixel copy if the view is drawn by the hardware, this sort of makes sense as there is no hardware buffer to copy from. we were falling back but there was a lot of noise in the logs Reviewed By: lblasa Differential Revision: D50853427 fbshipit-source-id: 9365a3d566a05de9082afb8bc2915922c624fd88
This commit is contained in:
committed by
Facebook GitHub Bot
parent
44b8a39874
commit
bd6e1285da
@@ -55,17 +55,22 @@ class ModernPixelCopySnapshotter(
|
||||
|
||||
override suspend fun takeSnapshot(view: View): BitmapPool.ReusableBitmap? {
|
||||
|
||||
return SnapshotCommon.doSnapshotWithErrorHandling(bitmapPool, view, fallback) { reusableBitmap
|
||||
->
|
||||
suspendCoroutine { continuation ->
|
||||
// Since android U this api is actually async
|
||||
val request =
|
||||
PixelCopy.Request.Builder.ofWindow(view)
|
||||
.setDestinationBitmap(reusableBitmap.bitmap)
|
||||
.build()
|
||||
PixelCopy.request(
|
||||
request, { handler.post(it) }, { continuation.resume(it.status == PixelCopy.SUCCESS) })
|
||||
return if (view.isHardwareAccelerated) {
|
||||
SnapshotCommon.doSnapshotWithErrorHandling(bitmapPool, view, fallback) { reusableBitmap ->
|
||||
suspendCoroutine { continuation ->
|
||||
// Since android U this api is actually async
|
||||
val request =
|
||||
PixelCopy.Request.Builder.ofWindow(view)
|
||||
.setDestinationBitmap(reusableBitmap.bitmap)
|
||||
.build()
|
||||
PixelCopy.request(
|
||||
request,
|
||||
{ handler.post(it) },
|
||||
{ continuation.resume(it.status == PixelCopy.SUCCESS) })
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fallback.takeSnapshot(view)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,8 +90,12 @@ class PixelCopySnapshotter(
|
||||
|
||||
override suspend fun takeSnapshot(view: View): BitmapPool.ReusableBitmap? {
|
||||
|
||||
return SnapshotCommon.doSnapshotWithErrorHandling(bitmapPool, view, fallback) {
|
||||
tryCopyViaActivityWindow(view, it) || tryCopyViaInternalSurface(view, it)
|
||||
return if (view.isHardwareAccelerated) {
|
||||
SnapshotCommon.doSnapshotWithErrorHandling(bitmapPool, view, fallback) {
|
||||
tryCopyViaActivityWindow(view, it) || tryCopyViaInternalSurface(view, it)
|
||||
}
|
||||
} else {
|
||||
fallback.takeSnapshot(view)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user