From c63c5b21e8a7495d116b0ba87b25cd02a7dd4f7a Mon Sep 17 00:00:00 2001 From: Leon Scroggins III Date: Mon, 11 Apr 2022 16:54:37 -0400 Subject: [PATCH] GLFunctorDrawable: skip alpha filtering When drawing a GLFunctorDrawable into an AlphaFilterCanvas, there is no gpu device, so topLayerBackendRenderTarget (and therefore GetFboDetails) fails. Applying the alpha would require an extra layer and a performance cost, so draw directly to the underlying gpu canvas. This effectively matches the VkFunctorDrawable fix in I27040347dc25c799b4e75f50526f426e9e33b663. Bug: 208629203 Test: Iab6f59411310fe4f5ea4ccc3bf386dcc6f2007b1 Change-Id: I9b8f0a357b9349fbb568b30dd18b0c150065f13c --- libs/hwui/pipeline/skia/GLFunctorDrawable.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libs/hwui/pipeline/skia/GLFunctorDrawable.cpp b/libs/hwui/pipeline/skia/GLFunctorDrawable.cpp index ab00dd5a487cd..dc72aead48732 100644 --- a/libs/hwui/pipeline/skia/GLFunctorDrawable.cpp +++ b/libs/hwui/pipeline/skia/GLFunctorDrawable.cpp @@ -61,6 +61,17 @@ void GLFunctorDrawable::onDraw(SkCanvas* canvas) { return; } + // canvas may be an AlphaFilterCanvas, which is intended to draw with a + // modified alpha. We do not have a way to do this without drawing into an + // extra layer, which would have a performance cost. Draw directly into the + // underlying gpu canvas. This matches prior behavior and the behavior in + // Vulkan. + { + auto* gpuCanvas = SkAndroidFrameworkUtils::getBaseWrappedCanvas(canvas); + LOG_ALWAYS_FATAL_IF(!gpuCanvas, "GLFunctorDrawable::onDraw is using an invalid canvas!"); + canvas = gpuCanvas; + } + // flush will create a GrRenderTarget if not already present. canvas->flush();