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

Commit 53fadc59 authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android (Google) Code Review
Browse files

Merge "Fix scaling of layout bounds." into jb-dev

parents 8e8798d9 76344241
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -304,7 +304,15 @@ static jobject doDecode(JNIEnv* env, SkStream* stream, jobject padding,
            return nullObjectReturn("layoutBounds == null");
        }

        env->SetIntArrayRegion(layoutBounds, 0, 4, (jint*) peeker.fLayoutBounds);
        jint scaledBounds[4];
        if (willScale) {
            for (int i=0; i<4; i++) {
                scaledBounds[i] = (jint)((((jint*)peeker.fLayoutBounds)[i]*scale) + .5f);
            }
        } else {
            memcpy(scaledBounds, (jint*)peeker.fLayoutBounds, sizeof(scaledBounds));
        }
        env->SetIntArrayRegion(layoutBounds, 0, 4, scaledBounds);
        if (javaBitmap != NULL) {
            env->SetObjectField(javaBitmap, gBitmap_layoutBoundsFieldID, layoutBounds);
        }
+8 −0
Original line number Diff line number Diff line
@@ -556,6 +556,7 @@ public class BitmapFactory {
            return bm;
        }
        byte[] np = bm.getNinePatchChunk();
        int[] lb = bm.getLayoutBounds();
        final boolean isNinePatch = np != null && NinePatch.isNinePatchChunk(np);
        if (opts.inScaled || isNinePatch) {
            float scale = targetDensity / (float) density;
@@ -569,6 +570,13 @@ public class BitmapFactory {
                    np = nativeScaleNinePatch(np, scale, outPadding);
                    bm.setNinePatchChunk(np);
                }
                if (lb != null) {
                    int[] newLb = new int[lb.length];
                    for (int i=0; i<lb.length; i++) {
                        newLb[i] = (int)((lb[i]*scale)+.5f);
                    }
                    bm.setLayoutBounds(newLb);
                }
            }

            bm.setDensity(targetDensity);