From f5f27cd828084456bbc01520b44688df2b49b4b2 Mon Sep 17 00:00:00 2001 From: Stan Iliev Date: Mon, 22 May 2017 15:02:25 -0400 Subject: [PATCH] Fix recent apps in system UI for Skia pipeline Enable HW Bitmaps for Skia pipelines by using a readback to convert GraphicBuffer into a raster SkImage. Both BitmapShader and drawing HW bitmaps into a canvas are supported. Test: recent apps work, no memory leaks, CTS graphics and UiRendering tests passed, HWUI unit test passed bug: 38136140 Change-Id: I23fed5febad3b1009e0417fb7e21a347a8d11b0d Merged-In: I23fed5febad3b1009e0417fb7e21a347a8d11b0d --- libs/hwui/hwui/Bitmap.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/libs/hwui/hwui/Bitmap.cpp b/libs/hwui/hwui/Bitmap.cpp index d765584a7530c..b033c965f682b 100644 --- a/libs/hwui/hwui/Bitmap.cpp +++ b/libs/hwui/hwui/Bitmap.cpp @@ -486,7 +486,13 @@ void Bitmap::setAlphaType(SkAlphaType alphaType) { void Bitmap::getSkBitmap(SkBitmap* outBitmap) { outBitmap->setHasHardwareMipMap(mHasHardwareMipMap); if (isHardware()) { - outBitmap->allocPixels(info()); + if (uirenderer::Properties::isSkiaEnabled()) { + // TODO: add color correctness for Skia pipeline - pass null color space for now + outBitmap->allocPixels(SkImageInfo::Make(info().width(), info().height(), + info().colorType(), info().alphaType(), nullptr)); + } else { + outBitmap->allocPixels(info()); + } uirenderer::renderthread::RenderProxy::copyGraphicBufferInto(graphicBuffer(), outBitmap); return; } @@ -495,9 +501,13 @@ void Bitmap::getSkBitmap(SkBitmap* outBitmap) { } void Bitmap::getSkBitmapForShaders(SkBitmap* outBitmap) { - outBitmap->setInfo(info(), rowBytes()); - outBitmap->setPixelRef(this); - outBitmap->setHasHardwareMipMap(mHasHardwareMipMap); + if (isHardware() && uirenderer::Properties::isSkiaEnabled()) { + getSkBitmap(outBitmap); + } else { + outBitmap->setInfo(info(), rowBytes()); + outBitmap->setPixelRef(this); + outBitmap->setHasHardwareMipMap(mHasHardwareMipMap); + } } void Bitmap::getBounds(SkRect* bounds) const {