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

Commit 0965a324 authored by Romain Guy's avatar Romain Guy
Browse files

Allow Canvas.setBitmap() to receive a null Bitmap.

Change-Id: I6096f0b44866e532ccd96a29c816bf34d48c1dc2
parent a60c3889
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -10287,6 +10287,7 @@ public class View implements Drawable.Callback2, KeyEvent.Callback, Accessibilit
        canvas.restoreToCount(restoreCount);
        if (attachInfo != null) {
            canvas.setBitmap(null);
            // Restore the cached Canvas for our siblings
            attachInfo.mCanvas = canvas;
        }
+6 −3
Original line number Diff line number Diff line
@@ -88,9 +88,12 @@ public:
        return canvas->getDevice()->accessBitmap(false).height();
    }

    static void setBitmap(JNIEnv* env, jobject, SkCanvas* canvas,
                          SkBitmap* bitmap) {
    static void setBitmap(JNIEnv* env, jobject, SkCanvas* canvas, SkBitmap* bitmap) {
        if (bitmap) {
            canvas->setBitmapDevice(*bitmap);
        } else {
            canvas->setDevice(NULL);
        }
    }
 
    static int saveAll(JNIEnv* env, jobject jcanvas) {
+11 −6
Original line number Diff line number Diff line
@@ -178,17 +178,22 @@ public class Canvas {
     * @see #getDensity()
     */
    public void setBitmap(Bitmap bitmap) {
        if (!bitmap.isMutable()) {
            throw new IllegalStateException();
        }
        if (isHardwareAccelerated()) {
            throw new RuntimeException("Can't set a bitmap device on a GL canvas");
        }

        int pointer = 0;
        if (bitmap != null) {
            if (!bitmap.isMutable()) {
                throw new IllegalStateException();
            }
            throwIfRecycled(bitmap);
            mDensity = bitmap.mDensity;
            pointer = bitmap.ni();
        }

        native_setBitmap(mNativeCanvas, bitmap.ni());
        native_setBitmap(mNativeCanvas, pointer);
        mBitmap = bitmap;
        mDensity = bitmap.mDensity;
    }
    
    /**
+1 −0
Original line number Diff line number Diff line
@@ -101,6 +101,7 @@ public class PathsActivity extends Activity {
            Canvas canvas = new Canvas(mBitmap);
            canvas.translate(-mPathBounds.left + mOffset * 1.5f, -mPathBounds.top + mOffset * 1.5f);
            canvas.drawPath(mPath, mMediumPaint);
            canvas.setBitmap(null);
        }

        @Override