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

Commit 1b83edc6 authored by Chris Craik's avatar Chris Craik Committed by Android (Google) Code Review
Browse files

Merge "Workaround shader crash" into mnc-dev

parents 02184244 b786bbdd
Loading
Loading
Loading
Loading
+5 −1
Original line number Original line Diff line number Diff line
@@ -84,7 +84,11 @@ static jlong BitmapShader_constructor(JNIEnv* env, jobject o, jobject jbitmap,
                                      jint tileModeX, jint tileModeY)
                                      jint tileModeX, jint tileModeY)
{
{
    SkBitmap bitmap;
    SkBitmap bitmap;
    if (jbitmap) {
        // Only pass a valid SkBitmap object to the constructor if the Bitmap exists. Otherwise,
        // we'll pass an empty SkBitmap to avoid crashing/excepting for compatibility.
        GraphicsJNI::getSkBitmap(env, jbitmap, &bitmap);
        GraphicsJNI::getSkBitmap(env, jbitmap, &bitmap);
    }
    SkShader* s = SkShader::CreateBitmapShader(bitmap,
    SkShader* s = SkShader::CreateBitmapShader(bitmap,
                                        (SkShader::TileMode)tileModeX,
                                        (SkShader::TileMode)tileModeX,
                                        (SkShader::TileMode)tileModeY);
                                        (SkShader::TileMode)tileModeY);
+3 −1
Original line number Original line Diff line number Diff line
@@ -16,6 +16,8 @@


package android.graphics;
package android.graphics;


import android.annotation.NonNull;

/**
/**
 * Shader used to draw a bitmap as a texture. The bitmap can be repeated or
 * Shader used to draw a bitmap as a texture. The bitmap can be repeated or
 * mirrored by setting the tiling mode.
 * mirrored by setting the tiling mode.
@@ -38,7 +40,7 @@ public class BitmapShader extends Shader {
     * @param tileX             The tiling mode for x to draw the bitmap in.
     * @param tileX             The tiling mode for x to draw the bitmap in.
     * @param tileY             The tiling mode for y to draw the bitmap in.
     * @param tileY             The tiling mode for y to draw the bitmap in.
     */
     */
    public BitmapShader(Bitmap bitmap, TileMode tileX, TileMode tileY) {
    public BitmapShader(@NonNull Bitmap bitmap, TileMode tileX, TileMode tileY) {
        mBitmap = bitmap;
        mBitmap = bitmap;
        mTileX = tileX;
        mTileX = tileX;
        mTileY = tileY;
        mTileY = tileY;