From afd99035e9098fc85d68245b3614a3887e3e284e Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Tue, 12 Jul 2022 13:11:58 +0000 Subject: [PATCH] Reduce unnecessary overhead of screenshot bitmap from assist Since hardware bitmap is introduced, it is already fast enough to pass across processes. And Bitmap#asShared becomes an unnecessary operation. This can save 70%+ execution time of requestAssistScreenshot. About from 65ms to 15ms. Bug: 201351584 Test: Measure the time from a test app with looping IWindowManager#requestAssistScreenshot(receiver). Change-Id: Ie5510eae789219e3afbe1a9ecf8911925207c0ba --- .../java/com/android/server/wm/DisplayContent.java | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 6619f985df581..05999b36f16be 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -4811,16 +4811,8 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp final Bitmap bitmap = screenshotBuffer == null ? null : screenshotBuffer.asBitmap(); if (bitmap == null) { Slog.w(TAG_WM, "Failed to take screenshot"); - return null; } - - // Create a copy of the screenshot that is immutable and backed in ashmem. - // This greatly reduces the overhead of passing the bitmap between processes. - final Bitmap ret = bitmap.asShared(); - if (ret != bitmap) { - bitmap.recycle(); - } - return ret; + return bitmap; } @Override