Loading core/jni/android/graphics/BitmapFactory.cpp +17 −4 Original line number Diff line number Diff line Loading @@ -125,12 +125,18 @@ static void scaleNinePatchChunk(android::Res_png_9patch* chunk, float scale) { static SkPixelRef* installPixelRef(SkBitmap* bitmap, SkStreamRewindable* stream, int sampleSize, bool ditherImage) { SkImageInfo bitmapInfo; if (!bitmap->asImageInfo(&bitmapInfo)) { ALOGW("bitmap has unknown configuration so no memory has been allocated"); return NULL; } SkImageRef* pr; // only use ashmem for large images, since mmaps come at a price if (bitmap->getSize() >= 32 * 1024) { pr = new SkImageRef_ashmem(stream, bitmap->config(), sampleSize); pr = new SkImageRef_ashmem(bitmapInfo, stream, sampleSize); } else { pr = new SkImageRef_GlobalPool(stream, bitmap->config(), sampleSize); pr = new SkImageRef_GlobalPool(bitmapInfo, stream, sampleSize); } pr->setDitherImage(ditherImage); bitmap->setPixelRef(pr)->unref(); Loading Loading @@ -192,8 +198,15 @@ public: return false; } SkImageInfo bitmapInfo; if (!bitmap->asImageInfo(&bitmapInfo)) { ALOGW("unable to reuse a bitmap as the target has an unknown bitmap configuration"); return false; } // Create a new pixelref with the new ctable that wraps the previous pixelref SkPixelRef* pr = new AndroidPixelRef(*static_cast<AndroidPixelRef*>(mPixelRef), ctable); SkPixelRef* pr = new AndroidPixelRef(*static_cast<AndroidPixelRef*>(mPixelRef), bitmapInfo, bitmap->rowBytes(), ctable); bitmap->setPixelRef(pr)->unref(); // since we're already allocated, we lockPixels right away Loading Loading @@ -418,7 +431,7 @@ static jobject doDecode(JNIEnv* env, SkStreamRewindable* stream, jobject padding } SkPaint paint; paint.setFilterBitmap(true); paint.setFilterLevel(SkPaint::kLow_FilterLevel); SkCanvas canvas(*outputBitmap); canvas.scale(sx, sy); Loading core/jni/android/graphics/Canvas.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -555,7 +555,7 @@ public: if (paint) { filteredPaint = *paint; } filteredPaint.setFilterBitmap(true); filteredPaint.setFilterLevel(SkPaint::kLow_FilterLevel); canvas->drawBitmap(*bitmap, left_, top_, &filteredPaint); } else { canvas->drawBitmap(*bitmap, left_, top_, paint); Loading @@ -570,7 +570,7 @@ public: if (paint) { filteredPaint = *paint; } filteredPaint.setFilterBitmap(true); filteredPaint.setFilterLevel(SkPaint::kLow_FilterLevel); canvas->drawBitmap(*bitmap, 0, 0, &filteredPaint); Loading @@ -593,7 +593,7 @@ public: if (paint) { filteredPaint = *paint; } filteredPaint.setFilterBitmap(true); filteredPaint.setFilterLevel(SkPaint::kLow_FilterLevel); canvas->drawBitmapRect(*bitmap, srcPtr, dst, &filteredPaint); } else { canvas->drawBitmapRect(*bitmap, srcPtr, dst, paint); Loading core/jni/android/graphics/Graphics.cpp +17 −6 Original line number Diff line number Diff line Loading @@ -444,8 +444,9 @@ static JNIEnv* vm2env(JavaVM* vm) /////////////////////////////////////////////////////////////////////////////// AndroidPixelRef::AndroidPixelRef(JNIEnv* env, void* storage, size_t size, jbyteArray storageObj, SkColorTable* ctable) : SkMallocPixelRef(storage, size, ctable, (storageObj == NULL)), AndroidPixelRef::AndroidPixelRef(JNIEnv* env, const SkImageInfo& info, void* storage, size_t rowBytes, jbyteArray storageObj, SkColorTable* ctable) : SkMallocPixelRef(info, storage, rowBytes, ctable, (storageObj == NULL)), fWrappedPixelRef(NULL) { SkASSERT(storage); SkASSERT(env); Loading @@ -463,8 +464,9 @@ AndroidPixelRef::AndroidPixelRef(JNIEnv* env, void* storage, size_t size, jbyteA } AndroidPixelRef::AndroidPixelRef(AndroidPixelRef& wrappedPixelRef, SkColorTable* ctable) : SkMallocPixelRef(wrappedPixelRef.getAddr(), wrappedPixelRef.getSize(), ctable, false), AndroidPixelRef::AndroidPixelRef(AndroidPixelRef& wrappedPixelRef, const SkImageInfo& info, size_t rowBytes, SkColorTable* ctable) : SkMallocPixelRef(info, wrappedPixelRef.getAddr(), rowBytes, ctable, false), fWrappedPixelRef(wrappedPixelRef.fWrappedPixelRef ? wrappedPixelRef.fWrappedPixelRef : &wrappedPixelRef) { Loading Loading @@ -568,6 +570,14 @@ jbyteArray GraphicsJNI::allocateJavaPixelRef(JNIEnv* env, SkBitmap* bitmap, "bitmap size exceeds 32bits"); return NULL; } SkImageInfo bitmapInfo; if (!bitmap->asImageInfo(&bitmapInfo)) { jniThrowException(env, "java/lang/IllegalArgumentException", "unknown bitmap configuration"); return NULL; } size_t size = size64.get32(); jbyteArray arrayObj = (jbyteArray) env->CallObjectMethod(gVMRuntime, gVMRuntime_newNonMovableArray, Loading @@ -581,7 +591,8 @@ jbyteArray GraphicsJNI::allocateJavaPixelRef(JNIEnv* env, SkBitmap* bitmap, return NULL; } SkASSERT(addr); SkPixelRef* pr = new AndroidPixelRef(env, (void*) addr, size, arrayObj, ctable); SkPixelRef* pr = new AndroidPixelRef(env, bitmapInfo, (void*) addr, bitmap->rowBytes(), arrayObj, ctable); bitmap->setPixelRef(pr)->unref(); // since we're already allocated, we lockPixels right away // HeapAllocator behaves this way too Loading core/jni/android/graphics/GraphicsJNI.h +4 −3 Original line number Diff line number Diff line Loading @@ -92,15 +92,16 @@ public: class AndroidPixelRef : public SkMallocPixelRef { public: AndroidPixelRef(JNIEnv* env, void* storage, size_t size, jbyteArray storageObj, SkColorTable* ctable); AndroidPixelRef(JNIEnv* env, const SkImageInfo& info, void* storage, size_t rowBytes, jbyteArray storageObj, SkColorTable* ctable); /** * Creates an AndroidPixelRef that wraps (and refs) another to reuse/share * the same storage and java byte array refcounting, yet have a different * color table. */ AndroidPixelRef(AndroidPixelRef& wrappedPixelRef, SkColorTable* ctable); AndroidPixelRef(AndroidPixelRef& wrappedPixelRef, const SkImageInfo& info, size_t rowBytes, SkColorTable* ctable); virtual ~AndroidPixelRef(); Loading core/jni/android/graphics/Paint.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -155,7 +155,8 @@ public: static void setFilterBitmap(JNIEnv* env, jobject paint, jboolean filterBitmap) { NPE_CHECK_RETURN_VOID(env, paint); GraphicsJNI::getNativePaint(env, paint)->setFilterBitmap(filterBitmap); GraphicsJNI::getNativePaint(env, paint)->setFilterLevel( filterBitmap ? SkPaint::kLow_FilterLevel : SkPaint::kNone_FilterLevel); } static void setDither(JNIEnv* env, jobject paint, jboolean dither) { Loading Loading
core/jni/android/graphics/BitmapFactory.cpp +17 −4 Original line number Diff line number Diff line Loading @@ -125,12 +125,18 @@ static void scaleNinePatchChunk(android::Res_png_9patch* chunk, float scale) { static SkPixelRef* installPixelRef(SkBitmap* bitmap, SkStreamRewindable* stream, int sampleSize, bool ditherImage) { SkImageInfo bitmapInfo; if (!bitmap->asImageInfo(&bitmapInfo)) { ALOGW("bitmap has unknown configuration so no memory has been allocated"); return NULL; } SkImageRef* pr; // only use ashmem for large images, since mmaps come at a price if (bitmap->getSize() >= 32 * 1024) { pr = new SkImageRef_ashmem(stream, bitmap->config(), sampleSize); pr = new SkImageRef_ashmem(bitmapInfo, stream, sampleSize); } else { pr = new SkImageRef_GlobalPool(stream, bitmap->config(), sampleSize); pr = new SkImageRef_GlobalPool(bitmapInfo, stream, sampleSize); } pr->setDitherImage(ditherImage); bitmap->setPixelRef(pr)->unref(); Loading Loading @@ -192,8 +198,15 @@ public: return false; } SkImageInfo bitmapInfo; if (!bitmap->asImageInfo(&bitmapInfo)) { ALOGW("unable to reuse a bitmap as the target has an unknown bitmap configuration"); return false; } // Create a new pixelref with the new ctable that wraps the previous pixelref SkPixelRef* pr = new AndroidPixelRef(*static_cast<AndroidPixelRef*>(mPixelRef), ctable); SkPixelRef* pr = new AndroidPixelRef(*static_cast<AndroidPixelRef*>(mPixelRef), bitmapInfo, bitmap->rowBytes(), ctable); bitmap->setPixelRef(pr)->unref(); // since we're already allocated, we lockPixels right away Loading Loading @@ -418,7 +431,7 @@ static jobject doDecode(JNIEnv* env, SkStreamRewindable* stream, jobject padding } SkPaint paint; paint.setFilterBitmap(true); paint.setFilterLevel(SkPaint::kLow_FilterLevel); SkCanvas canvas(*outputBitmap); canvas.scale(sx, sy); Loading
core/jni/android/graphics/Canvas.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -555,7 +555,7 @@ public: if (paint) { filteredPaint = *paint; } filteredPaint.setFilterBitmap(true); filteredPaint.setFilterLevel(SkPaint::kLow_FilterLevel); canvas->drawBitmap(*bitmap, left_, top_, &filteredPaint); } else { canvas->drawBitmap(*bitmap, left_, top_, paint); Loading @@ -570,7 +570,7 @@ public: if (paint) { filteredPaint = *paint; } filteredPaint.setFilterBitmap(true); filteredPaint.setFilterLevel(SkPaint::kLow_FilterLevel); canvas->drawBitmap(*bitmap, 0, 0, &filteredPaint); Loading @@ -593,7 +593,7 @@ public: if (paint) { filteredPaint = *paint; } filteredPaint.setFilterBitmap(true); filteredPaint.setFilterLevel(SkPaint::kLow_FilterLevel); canvas->drawBitmapRect(*bitmap, srcPtr, dst, &filteredPaint); } else { canvas->drawBitmapRect(*bitmap, srcPtr, dst, paint); Loading
core/jni/android/graphics/Graphics.cpp +17 −6 Original line number Diff line number Diff line Loading @@ -444,8 +444,9 @@ static JNIEnv* vm2env(JavaVM* vm) /////////////////////////////////////////////////////////////////////////////// AndroidPixelRef::AndroidPixelRef(JNIEnv* env, void* storage, size_t size, jbyteArray storageObj, SkColorTable* ctable) : SkMallocPixelRef(storage, size, ctable, (storageObj == NULL)), AndroidPixelRef::AndroidPixelRef(JNIEnv* env, const SkImageInfo& info, void* storage, size_t rowBytes, jbyteArray storageObj, SkColorTable* ctable) : SkMallocPixelRef(info, storage, rowBytes, ctable, (storageObj == NULL)), fWrappedPixelRef(NULL) { SkASSERT(storage); SkASSERT(env); Loading @@ -463,8 +464,9 @@ AndroidPixelRef::AndroidPixelRef(JNIEnv* env, void* storage, size_t size, jbyteA } AndroidPixelRef::AndroidPixelRef(AndroidPixelRef& wrappedPixelRef, SkColorTable* ctable) : SkMallocPixelRef(wrappedPixelRef.getAddr(), wrappedPixelRef.getSize(), ctable, false), AndroidPixelRef::AndroidPixelRef(AndroidPixelRef& wrappedPixelRef, const SkImageInfo& info, size_t rowBytes, SkColorTable* ctable) : SkMallocPixelRef(info, wrappedPixelRef.getAddr(), rowBytes, ctable, false), fWrappedPixelRef(wrappedPixelRef.fWrappedPixelRef ? wrappedPixelRef.fWrappedPixelRef : &wrappedPixelRef) { Loading Loading @@ -568,6 +570,14 @@ jbyteArray GraphicsJNI::allocateJavaPixelRef(JNIEnv* env, SkBitmap* bitmap, "bitmap size exceeds 32bits"); return NULL; } SkImageInfo bitmapInfo; if (!bitmap->asImageInfo(&bitmapInfo)) { jniThrowException(env, "java/lang/IllegalArgumentException", "unknown bitmap configuration"); return NULL; } size_t size = size64.get32(); jbyteArray arrayObj = (jbyteArray) env->CallObjectMethod(gVMRuntime, gVMRuntime_newNonMovableArray, Loading @@ -581,7 +591,8 @@ jbyteArray GraphicsJNI::allocateJavaPixelRef(JNIEnv* env, SkBitmap* bitmap, return NULL; } SkASSERT(addr); SkPixelRef* pr = new AndroidPixelRef(env, (void*) addr, size, arrayObj, ctable); SkPixelRef* pr = new AndroidPixelRef(env, bitmapInfo, (void*) addr, bitmap->rowBytes(), arrayObj, ctable); bitmap->setPixelRef(pr)->unref(); // since we're already allocated, we lockPixels right away // HeapAllocator behaves this way too Loading
core/jni/android/graphics/GraphicsJNI.h +4 −3 Original line number Diff line number Diff line Loading @@ -92,15 +92,16 @@ public: class AndroidPixelRef : public SkMallocPixelRef { public: AndroidPixelRef(JNIEnv* env, void* storage, size_t size, jbyteArray storageObj, SkColorTable* ctable); AndroidPixelRef(JNIEnv* env, const SkImageInfo& info, void* storage, size_t rowBytes, jbyteArray storageObj, SkColorTable* ctable); /** * Creates an AndroidPixelRef that wraps (and refs) another to reuse/share * the same storage and java byte array refcounting, yet have a different * color table. */ AndroidPixelRef(AndroidPixelRef& wrappedPixelRef, SkColorTable* ctable); AndroidPixelRef(AndroidPixelRef& wrappedPixelRef, const SkImageInfo& info, size_t rowBytes, SkColorTable* ctable); virtual ~AndroidPixelRef(); Loading
core/jni/android/graphics/Paint.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -155,7 +155,8 @@ public: static void setFilterBitmap(JNIEnv* env, jobject paint, jboolean filterBitmap) { NPE_CHECK_RETURN_VOID(env, paint); GraphicsJNI::getNativePaint(env, paint)->setFilterBitmap(filterBitmap); GraphicsJNI::getNativePaint(env, paint)->setFilterLevel( filterBitmap ? SkPaint::kLow_FilterLevel : SkPaint::kNone_FilterLevel); } static void setDither(JNIEnv* env, jobject paint, jboolean dither) { Loading