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

Commit e2436917 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Allow draw hw bitmap on software canvas for hierarchyviewer"

parents 48926cc1 b94f8909
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");
        }
    }