am 1b83edc6: Merge "Workaround shader crash" into mnc-dev

* commit '1b83edc6160d18323c7a0e0b892e97c05914ff81':
  Workaround shader crash
This commit is contained in:
Chris Craik
2015-06-11 20:36:24 +00:00
committed by Android Git Automerger
2 changed files with 8 additions and 2 deletions

View File

@@ -84,7 +84,11 @@ static jlong BitmapShader_constructor(JNIEnv* env, jobject o, jobject jbitmap,
jint tileModeX, jint tileModeY)
{
SkBitmap bitmap;
GraphicsJNI::getSkBitmap(env, jbitmap, &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);
}
SkShader* s = SkShader::CreateBitmapShader(bitmap,
(SkShader::TileMode)tileModeX,
(SkShader::TileMode)tileModeY);

View File

@@ -16,6 +16,8 @@
package android.graphics;
import android.annotation.NonNull;
/**
* Shader used to draw a bitmap as a texture. The bitmap can be repeated or
* 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 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;
mTileX = tileX;
mTileY = tileY;