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

Commit b94f8909 authored by sergeyv's avatar sergeyv Committed by Sergey Vasilinets
Browse files

Allow draw hw bitmap on software canvas for hierarchyviewer

Test: runs hierarchyviewer on app with hw bitmaps
bug:34745484
Change-Id: I35f70f7927be23edebac171f3bc96405b14ca794
parent 2eb54b6b
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -17892,7 +17892,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            // This case should hopefully never or seldom happen
            canvas = new Canvas(bitmap);
        }
        boolean enabledHwBitmapsInSwMode = canvas.isHwBitmapsInSwModeEnabled();
        canvas.setHwBitmapsInSwModeEnabled(true);
        if ((backgroundColor & 0xff000000) != 0) {
            bitmap.eraseColor(backgroundColor);
        }
@@ -17920,6 +17921,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        canvas.restoreToCount(restoreCount);
        canvas.setBitmap(null);
        canvas.setHwBitmapsInSwModeEnabled(enabledHwBitmapsInSwMode);
        if (attachInfo != null) {
            // Restore the cached Canvas for our siblings
+17 −1
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ public abstract class BaseCanvas {
     */
    protected int mScreenDensity = Bitmap.DENSITY_NONE;
    protected int mDensity = Bitmap.DENSITY_NONE;
    private boolean mAllowHwBitmapsInSwMode = false;

    protected void throwIfCannotDraw(Bitmap bitmap) {
        if (bitmap.isRecycled()) {
@@ -511,8 +512,23 @@ public abstract class BaseCanvas {
                indices, indexOffset, indexCount, paint.getNativeInstance());
    }

    /**
     * @hide
     */
    public void setHwBitmapsInSwModeEnabled(boolean enabled) {
        mAllowHwBitmapsInSwMode = enabled;
    }

    /**
     * @hide
     */
    public boolean isHwBitmapsInSwModeEnabled() {
        return mAllowHwBitmapsInSwMode;
    }

    private void throwIfHwBitmapInSwMode(Bitmap bitmap) {
        if (!isHardwareAccelerated() && bitmap.getConfig() == Bitmap.Config.HARDWARE) {
        if (!mAllowHwBitmapsInSwMode && !isHardwareAccelerated()
                && bitmap.getConfig() == Bitmap.Config.HARDWARE) {
            throw new IllegalStateException("Software rendering doesn't support hardware bitmaps");
        }
    }