Fix issue #2125720 Weather Forecast Widget - graphics do not scale
I forgot to add the new density field to the Bitmaps' parcelable data.
This commit is contained in:
committed by
Xavier Ducrohet
parent
b91024c19c
commit
1d0086d999
@@ -332,6 +332,7 @@ static jobject Bitmap_createFromParcel(JNIEnv* env, jobject, jobject parcel) {
|
|||||||
const int width = p->readInt32();
|
const int width = p->readInt32();
|
||||||
const int height = p->readInt32();
|
const int height = p->readInt32();
|
||||||
const int rowBytes = p->readInt32();
|
const int rowBytes = p->readInt32();
|
||||||
|
const int density = p->readInt32();
|
||||||
|
|
||||||
if (SkBitmap::kARGB_8888_Config != config &&
|
if (SkBitmap::kARGB_8888_Config != config &&
|
||||||
SkBitmap::kRGB_565_Config != config &&
|
SkBitmap::kRGB_565_Config != config &&
|
||||||
@@ -369,12 +370,13 @@ static jobject Bitmap_createFromParcel(JNIEnv* env, jobject, jobject parcel) {
|
|||||||
memcpy(bitmap->getPixels(), p->readInplace(size), size);
|
memcpy(bitmap->getPixels(), p->readInplace(size), size);
|
||||||
bitmap->unlockPixels();
|
bitmap->unlockPixels();
|
||||||
|
|
||||||
return GraphicsJNI::createBitmap(env, bitmap, isMutable, NULL);
|
return GraphicsJNI::createBitmap(env, bitmap, isMutable, NULL, density);
|
||||||
}
|
}
|
||||||
|
|
||||||
static jboolean Bitmap_writeToParcel(JNIEnv* env, jobject,
|
static jboolean Bitmap_writeToParcel(JNIEnv* env, jobject,
|
||||||
const SkBitmap* bitmap,
|
const SkBitmap* bitmap,
|
||||||
jboolean isMutable, jobject parcel) {
|
jboolean isMutable, jint density,
|
||||||
|
jobject parcel) {
|
||||||
if (parcel == NULL) {
|
if (parcel == NULL) {
|
||||||
SkDebugf("------- writeToParcel null parcel\n");
|
SkDebugf("------- writeToParcel null parcel\n");
|
||||||
return false;
|
return false;
|
||||||
@@ -387,6 +389,7 @@ static jboolean Bitmap_writeToParcel(JNIEnv* env, jobject,
|
|||||||
p->writeInt32(bitmap->width());
|
p->writeInt32(bitmap->width());
|
||||||
p->writeInt32(bitmap->height());
|
p->writeInt32(bitmap->height());
|
||||||
p->writeInt32(bitmap->rowBytes());
|
p->writeInt32(bitmap->rowBytes());
|
||||||
|
p->writeInt32(density);
|
||||||
|
|
||||||
if (bitmap->getConfig() == SkBitmap::kIndex8_Config) {
|
if (bitmap->getConfig() == SkBitmap::kIndex8_Config) {
|
||||||
SkColorTable* ctable = bitmap->getColorTable();
|
SkColorTable* ctable = bitmap->getColorTable();
|
||||||
@@ -546,7 +549,7 @@ static JNINativeMethod gBitmapMethods[] = {
|
|||||||
{ "nativeCreateFromParcel",
|
{ "nativeCreateFromParcel",
|
||||||
"(Landroid/os/Parcel;)Landroid/graphics/Bitmap;",
|
"(Landroid/os/Parcel;)Landroid/graphics/Bitmap;",
|
||||||
(void*)Bitmap_createFromParcel },
|
(void*)Bitmap_createFromParcel },
|
||||||
{ "nativeWriteToParcel", "(IZLandroid/os/Parcel;)Z",
|
{ "nativeWriteToParcel", "(IZILandroid/os/Parcel;)Z",
|
||||||
(void*)Bitmap_writeToParcel },
|
(void*)Bitmap_writeToParcel },
|
||||||
{ "nativeExtractAlpha", "(II[I)Landroid/graphics/Bitmap;",
|
{ "nativeExtractAlpha", "(II[I)Landroid/graphics/Bitmap;",
|
||||||
(void*)Bitmap_extractAlpha },
|
(void*)Bitmap_extractAlpha },
|
||||||
|
|||||||
@@ -351,7 +351,7 @@ SkRegion* GraphicsJNI::getNativeRegion(JNIEnv* env, jobject region)
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
jobject GraphicsJNI::createBitmap(JNIEnv* env, SkBitmap* bitmap, bool isMutable,
|
jobject GraphicsJNI::createBitmap(JNIEnv* env, SkBitmap* bitmap, bool isMutable,
|
||||||
jbyteArray ninepatch)
|
jbyteArray ninepatch, int density)
|
||||||
{
|
{
|
||||||
SkASSERT(bitmap != NULL);
|
SkASSERT(bitmap != NULL);
|
||||||
SkASSERT(NULL != bitmap->pixelRef());
|
SkASSERT(NULL != bitmap->pixelRef());
|
||||||
@@ -359,7 +359,7 @@ jobject GraphicsJNI::createBitmap(JNIEnv* env, SkBitmap* bitmap, bool isMutable,
|
|||||||
jobject obj = env->AllocObject(gBitmap_class);
|
jobject obj = env->AllocObject(gBitmap_class);
|
||||||
if (obj) {
|
if (obj) {
|
||||||
env->CallVoidMethod(obj, gBitmap_constructorMethodID,
|
env->CallVoidMethod(obj, gBitmap_constructorMethodID,
|
||||||
(jint)bitmap, isMutable, ninepatch);
|
(jint)bitmap, isMutable, ninepatch, density);
|
||||||
if (hasException(env)) {
|
if (hasException(env)) {
|
||||||
obj = NULL;
|
obj = NULL;
|
||||||
}
|
}
|
||||||
@@ -541,7 +541,7 @@ int register_android_graphics_Graphics(JNIEnv* env)
|
|||||||
gBitmap_class = make_globalref(env, "android/graphics/Bitmap");
|
gBitmap_class = make_globalref(env, "android/graphics/Bitmap");
|
||||||
gBitmap_nativeInstanceID = getFieldIDCheck(env, gBitmap_class, "mNativeBitmap", "I");
|
gBitmap_nativeInstanceID = getFieldIDCheck(env, gBitmap_class, "mNativeBitmap", "I");
|
||||||
gBitmap_constructorMethodID = env->GetMethodID(gBitmap_class, "<init>",
|
gBitmap_constructorMethodID = env->GetMethodID(gBitmap_class, "<init>",
|
||||||
"(IZ[B)V");
|
"(IZ[BI)V");
|
||||||
|
|
||||||
gBitmapConfig_class = make_globalref(env, "android/graphics/Bitmap$Config");
|
gBitmapConfig_class = make_globalref(env, "android/graphics/Bitmap$Config");
|
||||||
gBitmapConfig_nativeInstanceID = getFieldIDCheck(env, gBitmapConfig_class,
|
gBitmapConfig_nativeInstanceID = getFieldIDCheck(env, gBitmapConfig_class,
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public:
|
|||||||
then the bitmap must be an owner of its natively allocated pixels (via allocPixels).
|
then the bitmap must be an owner of its natively allocated pixels (via allocPixels).
|
||||||
*/
|
*/
|
||||||
static jobject createBitmap(JNIEnv* env, SkBitmap* bitmap, bool isMutable,
|
static jobject createBitmap(JNIEnv* env, SkBitmap* bitmap, bool isMutable,
|
||||||
jbyteArray ninePatch);
|
jbyteArray ninePatch, int density = -1);
|
||||||
|
|
||||||
static jobject createRegion(JNIEnv* env, SkRegion* region);
|
static jobject createRegion(JNIEnv* env, SkRegion* region);
|
||||||
|
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ static jobject android_emoji_EmojiFactory_getBitmapFromAndroidPua(
|
|||||||
jobject obj = env->AllocObject(gBitmap_class);
|
jobject obj = env->AllocObject(gBitmap_class);
|
||||||
if (obj) {
|
if (obj) {
|
||||||
env->CallVoidMethod(obj, gBitmap_constructorMethodID,
|
env->CallVoidMethod(obj, gBitmap_constructorMethodID,
|
||||||
reinterpret_cast<jint>(bitmap), false, NULL);
|
reinterpret_cast<jint>(bitmap), false, NULL, -1);
|
||||||
if (env->ExceptionCheck() != 0) {
|
if (env->ExceptionCheck() != 0) {
|
||||||
LOGE("*** Uncaught exception returned from Java call!\n");
|
LOGE("*** Uncaught exception returned from Java call!\n");
|
||||||
env->ExceptionDescribe();
|
env->ExceptionDescribe();
|
||||||
@@ -294,7 +294,7 @@ static jfieldID getFieldIDCheck(JNIEnv* env, jclass clazz,
|
|||||||
int register_android_emoji_EmojiFactory(JNIEnv* env) {
|
int register_android_emoji_EmojiFactory(JNIEnv* env) {
|
||||||
gBitmap_class = make_globalref(env, "android/graphics/Bitmap");
|
gBitmap_class = make_globalref(env, "android/graphics/Bitmap");
|
||||||
gBitmap_constructorMethodID = env->GetMethodID(gBitmap_class, "<init>",
|
gBitmap_constructorMethodID = env->GetMethodID(gBitmap_class, "<init>",
|
||||||
"(IZ[B)V");
|
"(IZ[BI)V");
|
||||||
gEmojiFactory_class = make_globalref(env, "android/emoji/EmojiFactory");
|
gEmojiFactory_class = make_globalref(env, "android/emoji/EmojiFactory");
|
||||||
gEmojiFactory_constructorMethodID = env->GetMethodID(
|
gEmojiFactory_constructorMethodID = env->GetMethodID(
|
||||||
gEmojiFactory_class, "<init>", "(ILjava/lang/String;)V");
|
gEmojiFactory_class, "<init>", "(ILjava/lang/String;)V");
|
||||||
|
|||||||
@@ -77,7 +77,8 @@ public final class Bitmap implements Parcelable {
|
|||||||
|
|
||||||
This can be called from JNI code.
|
This can be called from JNI code.
|
||||||
*/
|
*/
|
||||||
private Bitmap(int nativeBitmap, boolean isMutable, byte[] ninePatchChunk) {
|
private Bitmap(int nativeBitmap, boolean isMutable, byte[] ninePatchChunk,
|
||||||
|
int density) {
|
||||||
if (nativeBitmap == 0) {
|
if (nativeBitmap == 0) {
|
||||||
throw new RuntimeException("internal error: native bitmap is 0");
|
throw new RuntimeException("internal error: native bitmap is 0");
|
||||||
}
|
}
|
||||||
@@ -86,6 +87,9 @@ public final class Bitmap implements Parcelable {
|
|||||||
mNativeBitmap = nativeBitmap;
|
mNativeBitmap = nativeBitmap;
|
||||||
mIsMutable = isMutable;
|
mIsMutable = isMutable;
|
||||||
mNinePatchChunk = ninePatchChunk;
|
mNinePatchChunk = ninePatchChunk;
|
||||||
|
if (density >= 0) {
|
||||||
|
mDensity = density;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -892,7 +896,7 @@ public final class Bitmap implements Parcelable {
|
|||||||
*/
|
*/
|
||||||
public void writeToParcel(Parcel p, int flags) {
|
public void writeToParcel(Parcel p, int flags) {
|
||||||
checkRecycled("Can't parcel a recycled bitmap");
|
checkRecycled("Can't parcel a recycled bitmap");
|
||||||
if (!nativeWriteToParcel(mNativeBitmap, mIsMutable, p)) {
|
if (!nativeWriteToParcel(mNativeBitmap, mIsMutable, mDensity, p)) {
|
||||||
throw new RuntimeException("native writeToParcel failed");
|
throw new RuntimeException("native writeToParcel failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1006,6 +1010,7 @@ public final class Bitmap implements Parcelable {
|
|||||||
// returns true on success
|
// returns true on success
|
||||||
private static native boolean nativeWriteToParcel(int nativeBitmap,
|
private static native boolean nativeWriteToParcel(int nativeBitmap,
|
||||||
boolean isMutable,
|
boolean isMutable,
|
||||||
|
int density,
|
||||||
Parcel p);
|
Parcel p);
|
||||||
// returns a new bitmap built from the native bitmap's alpha, and the paint
|
// returns a new bitmap built from the native bitmap's alpha, and the paint
|
||||||
private static native Bitmap nativeExtractAlpha(int nativeBitmap,
|
private static native Bitmap nativeExtractAlpha(int nativeBitmap,
|
||||||
|
|||||||
@@ -28,13 +28,13 @@ public final class Bitmap extends _Original_Bitmap {
|
|||||||
private BufferedImage mImage;
|
private BufferedImage mImage;
|
||||||
|
|
||||||
public Bitmap(File input) throws IOException {
|
public Bitmap(File input) throws IOException {
|
||||||
super(1, true, null);
|
super(1, true, null, -1);
|
||||||
|
|
||||||
mImage = ImageIO.read(input);
|
mImage = ImageIO.read(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bitmap(BufferedImage image) {
|
Bitmap(BufferedImage image) {
|
||||||
super(1, true, null);
|
super(1, true, null, -1);
|
||||||
mImage = image;
|
mImage = image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user