@@ -35,6 +35,7 @@ jfieldID gOptions_mimeFieldID;
3535jfieldID gOptions_mCancelID ;
3636jfieldID gOptions_bitmapFieldID ;
3737jfieldID gBitmap_nativeBitmapFieldID ;
38+ jfieldID gBitmap_layoutBoundsFieldID ;
3839
3940#if 0
4041 #define TRACE_BITMAP(code) code
@@ -276,7 +277,7 @@ static jobject doDecode(JNIEnv* env, SkStream* stream, jobject padding,
276277 }
277278
278279 jbyteArray ninePatchChunk = NULL ;
279- if (peeker.fPatchIsValid ) {
280+ if (peeker.fPatch != NULL ) {
280281 if (willScale) {
281282 scaleNinePatchChunk (peeker.fPatch , scale);
282283 }
@@ -296,6 +297,18 @@ static jobject doDecode(JNIEnv* env, SkStream* stream, jobject padding,
296297 env->ReleasePrimitiveArrayCritical (ninePatchChunk, array, 0 );
297298 }
298299
300+ jintArray layoutBounds = NULL ;
301+ if (peeker.fLayoutBounds != NULL ) {
302+ layoutBounds = env->NewIntArray (4 );
303+ if (layoutBounds == NULL ) {
304+ return nullObjectReturn (" layoutBounds == null" );
305+ }
306+
307+ env->SetIntArrayRegion (layoutBounds, 0 , 4 , (jint*) peeker.fLayoutBounds );
308+ if (javaBitmap != NULL ) {
309+ env->SetObjectField (javaBitmap, gBitmap_layoutBoundsFieldID , layoutBounds);
310+ }
311+ }
299312 // detach bitmap from its autodeleter, since we want to own it now
300313 adb.detach ();
301314
@@ -321,7 +334,7 @@ static jobject doDecode(JNIEnv* env, SkStream* stream, jobject padding,
321334 }
322335
323336 if (padding) {
324- if (peeker.fPatchIsValid ) {
337+ if (peeker.fPatch != NULL ) {
325338 GraphicsJNI::set_jrect (env, padding,
326339 peeker.fPatch ->paddingLeft , peeker.fPatch ->paddingTop ,
327340 peeker.fPatch ->paddingRight , peeker.fPatch ->paddingBottom );
@@ -350,7 +363,7 @@ static jobject doDecode(JNIEnv* env, SkStream* stream, jobject padding,
350363 }
351364 // now create the java bitmap
352365 return GraphicsJNI::createBitmap (env, bitmap, javaAllocator.getStorageObj (),
353- isMutable, ninePatchChunk);
366+ isMutable, ninePatchChunk, layoutBounds, - 1 );
354367}
355368
356369static jobject nativeDecodeStreamScaled (JNIEnv* env, jobject clazz, jobject is, jbyteArray storage,
@@ -576,7 +589,7 @@ int register_android_graphics_BitmapFactory(JNIEnv* env) {
576589 jclass bitmap_class = env->FindClass (" android/graphics/Bitmap" );
577590 SkASSERT (bitmap_class);
578591 gBitmap_nativeBitmapFieldID = getFieldIDCheck (env, bitmap_class, " mNativeBitmap" , " I" );
579-
592+ gBitmap_layoutBoundsFieldID = getFieldIDCheck (env, bitmap_class, " mLayoutBounds " , " [I " );
580593 int ret = AndroidRuntime::registerNativeMethods (env,
581594 " android/graphics/BitmapFactory$Options" ,
582595 gOptionsMethods ,
0 commit comments