Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 30eb173f authored by Raphael Moll's avatar Raphael Moll Committed by John Reck
Browse files

[RNG] Bitmap::allocateHardwareBitmap() must copy source content.

Merge android12-hostruntime-dev 25874ec in master-layoutlib-native.

The RNG version of Bitmap::allocateHardwareBitmap() is implemented on
top of Bitmap::allocateHeapBitmap(). However, per the class comment
description, this factory method should also copy the content of the
source bitmap into the newly allocated bitmap. That is needed to make
"hardware" bitmaps work with RNG.

Flag: EXEMPT HOST_ONLY
Bug: 310222823,242670053
Test: m -j libandroid_runtime dist
Change-Id: Iddb33172ce95f93f76ebe4733cbbd88a04efefe2
parent fb7fd439
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -212,7 +212,14 @@ sk_sp<Bitmap> Bitmap::allocateHardwareBitmap(const SkBitmap& bitmap) {
#ifdef __ANDROID__  // Layoutlib does not support hardware acceleration
    return uirenderer::HardwareBitmapUploader::allocateHardwareBitmap(bitmap);
#else
    return Bitmap::allocateHeapBitmap(bitmap.info());
    sk_sp<Bitmap> dest = Bitmap::allocateHeapBitmap(bitmap.info());

    // HardwareBitmapUploader::allocateHardwareBitmap(SkBitmap&) copies Bitmap contents
    // to a GL texture. To simulate this with an heap bitmap, we use memcpy.
    auto destPM = dest->getSkBitmap().pixmap();
    LOG_ALWAYS_FATAL_IF(!bitmap.pixmap().readPixels(destPM), "failed to copy pixels");

    return dest;
#endif
}