Loading core/jni/android/graphics/Bitmap.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -727,7 +727,7 @@ static bool bitmapCopyTo(SkBitmap* dst, SkColorType dstCT, const SkBitmap& src, if (!dst->setInfo(dstInfo)) { return false; } if (!dst->tryAllocPixels(alloc, nullptr)) { if (!dst->tryAllocPixels(alloc)) { return false; } Loading Loading @@ -1081,7 +1081,7 @@ static jobject Bitmap_createFromParcel(JNIEnv* env, jobject, jobject parcel) { // Map the pixels in place and take ownership of the ashmem region. nativeBitmap = sk_sp<Bitmap>(GraphicsJNI::mapAshmemBitmap(env, bitmap.get(), nullptr, dupFd, const_cast<void*>(blob.data()), size, !isMutable)); dupFd, const_cast<void*>(blob.data()), size, !isMutable)); if (!nativeBitmap) { close(dupFd); blob.release(); Loading core/jni/android/graphics/BitmapFactory.cpp +5 −5 Original line number Diff line number Diff line Loading @@ -136,7 +136,7 @@ public: : mScale(scale), mSize(size) { } virtual bool allocPixelRef(SkBitmap* bitmap, SkColorTable*) { virtual bool allocPixelRef(SkBitmap* bitmap) { // accounts for scale in final allocation, using eventual size and config const int bytesPerPixel = SkColorTypeBytesPerPixel(bitmap->colorType()); const int requestedSize = bytesPerPixel * Loading @@ -147,7 +147,7 @@ public: mSize, requestedSize); return false; } return SkBitmap::HeapAllocator::allocPixelRef(bitmap, nullptr); return SkBitmap::HeapAllocator::allocPixelRef(bitmap); } private: const float mScale; Loading @@ -163,7 +163,7 @@ public: ~RecyclingPixelAllocator() { } virtual bool allocPixelRef(SkBitmap* bitmap, SkColorTable*) { virtual bool allocPixelRef(SkBitmap* bitmap) { const SkImageInfo& info = bitmap->info(); if (info.colorType() == kUnknown_SkColorType) { ALOGW("unable to reuse a bitmap as the target has an unknown bitmap configuration"); Loading Loading @@ -401,7 +401,7 @@ static jobject doDecode(JNIEnv* env, SkStreamRewindable* stream, jobject padding } SkBitmap decodingBitmap; if (!decodingBitmap.setInfo(bitmapInfo) || !decodingBitmap.tryAllocPixels(decodeAllocator, nullptr)) { !decodingBitmap.tryAllocPixels(decodeAllocator)) { // SkAndroidCodec should recommend a valid SkImageInfo, so setInfo() // should only only fail if the calculated value for rowBytes is too // large. Loading Loading @@ -486,7 +486,7 @@ static jobject doDecode(JNIEnv* env, SkStreamRewindable* stream, jobject padding // to/from unpremultiplied bitmaps. outputBitmap.setInfo( bitmapInfo.makeWH(scaledWidth, scaledHeight).makeColorType(scaledColorType)); if (!outputBitmap.tryAllocPixels(outputAllocator, NULL)) { if (!outputBitmap.tryAllocPixels(outputAllocator)) { // This should only fail on OOM. The recyclingAllocator should have // enough memory since we check this before decoding using the // scaleCheckingAllocator. Loading core/jni/android/graphics/Graphics.cpp +5 −5 Original line number Diff line number Diff line Loading @@ -433,7 +433,7 @@ jobject GraphicsJNI::createRegion(JNIEnv* env, SkRegion* region) /////////////////////////////////////////////////////////////////////////////// android::Bitmap* GraphicsJNI::mapAshmemBitmap(JNIEnv* env, SkBitmap* bitmap, SkColorTable*, int fd, void* addr, size_t size, bool readOnly) { int fd, void* addr, size_t size, bool readOnly) { const SkImageInfo& info = bitmap->info(); if (info.colorType() == kUnknown_SkColorType) { doThrowIAE(env, "unknown bitmap configuration"); Loading Loading @@ -607,7 +607,7 @@ jobject GraphicsJNI::getColorSpace(JNIEnv* env, sk_sp<SkColorSpace>& decodeColor } /////////////////////////////////////////////////////////////////////////////// bool HeapAllocator::allocPixelRef(SkBitmap* bitmap, SkColorTable*) { bool HeapAllocator::allocPixelRef(SkBitmap* bitmap) { mStorage = android::Bitmap::allocateHeapBitmap(bitmap); return !!mStorage; } Loading @@ -624,7 +624,7 @@ RecyclingClippingPixelAllocator::RecyclingClippingPixelAllocator( RecyclingClippingPixelAllocator::~RecyclingClippingPixelAllocator() {} bool RecyclingClippingPixelAllocator::allocPixelRef(SkBitmap* bitmap, SkColorTable*) { bool RecyclingClippingPixelAllocator::allocPixelRef(SkBitmap* bitmap) { // Ensure that the caller did not pass in a NULL bitmap to the constructor or this // function. LOG_ALWAYS_FATAL_IF(!mRecycledBitmap); Loading Loading @@ -683,7 +683,7 @@ bool RecyclingClippingPixelAllocator::allocPixelRef(SkBitmap* bitmap, SkColorTab // decode is complete. mNeedsCopy = true; return heapAllocator.allocPixelRef(bitmap, nullptr); return heapAllocator.allocPixelRef(bitmap); } void RecyclingClippingPixelAllocator::copyIfNecessary() { Loading Loading @@ -714,7 +714,7 @@ AshmemPixelAllocator::AshmemPixelAllocator(JNIEnv *env) { "env->GetJavaVM failed"); } bool AshmemPixelAllocator::allocPixelRef(SkBitmap* bitmap, SkColorTable*) { bool AshmemPixelAllocator::allocPixelRef(SkBitmap* bitmap) { mStorage = android::Bitmap::allocateAshmemBitmap(bitmap); return !!mStorage; } Loading core/jni/android/graphics/GraphicsJNI.h +5 −5 Original line number Diff line number Diff line Loading @@ -91,7 +91,7 @@ public: static jobject createBitmapRegionDecoder(JNIEnv* env, SkBitmapRegionDecoder* bitmap); static android::Bitmap* mapAshmemBitmap(JNIEnv* env, SkBitmap* bitmap, SkColorTable* ctable, int fd, void* addr, size_t size, bool readOnly); int fd, void* addr, size_t size, bool readOnly); /** * Given a bitmap we natively allocate a memory block to store the contents Loading @@ -99,7 +99,7 @@ public: * SkPixelRef, which ensures that upon deletion the appropriate caches * are notified. */ static bool allocatePixels(JNIEnv* env, SkBitmap* bitmap, SkColorTable* ctable); static bool allocatePixels(JNIEnv* env, SkBitmap* bitmap); /** Copy the colors in colors[] to the bitmap, convert to the correct format along the way. Loading Loading @@ -127,7 +127,7 @@ public: HeapAllocator() { }; ~HeapAllocator() { }; virtual bool allocPixelRef(SkBitmap* bitmap, SkColorTable* ctable) override; virtual bool allocPixelRef(SkBitmap* bitmap) override; /** * Fetches the backing allocation object. Must be called! Loading Loading @@ -176,7 +176,7 @@ public: ~RecyclingClippingPixelAllocator(); virtual bool allocPixelRef(SkBitmap* bitmap, SkColorTable* ctable) override; virtual bool allocPixelRef(SkBitmap* bitmap) override; /** * Must be called! Loading Loading @@ -206,7 +206,7 @@ class AshmemPixelAllocator : public SkBitmap::Allocator { public: explicit AshmemPixelAllocator(JNIEnv* env); ~AshmemPixelAllocator() { }; virtual bool allocPixelRef(SkBitmap* bitmap, SkColorTable* ctable); virtual bool allocPixelRef(SkBitmap* bitmap); android::Bitmap* getStorageObjAndReset() { return mStorage.release(); }; Loading core/jni/android/opengl/util.cpp +1 −19 Original line number Diff line number Diff line Loading @@ -713,28 +713,10 @@ static jint util_texImage2D(JNIEnv *env, jclass clazz, const int h = bitmap.height(); const void* p = bitmap.getPixels(); if (internalformat == GL_PALETTE8_RGBA8_OES) { if (sizeof(SkPMColor) != sizeof(uint32_t)) { err = -1; goto error; } const size_t size = bitmap.getSize(); const size_t palette_size = 256*sizeof(SkPMColor); const size_t imageSize = size + palette_size; void* const data = malloc(imageSize); if (data) { void* const pixels = (char*)data + palette_size; SkColorTable* ctable = bitmap.getColorTable(); memcpy(data, ctable->readColors(), ctable->count() * sizeof(SkPMColor)); memcpy(pixels, p, size); glCompressedTexImage2D(target, level, internalformat, w, h, border, imageSize, data); free(data); } else { err = -1; } } else { glTexImage2D(target, level, internalformat, w, h, border, internalformat, type, p); } error: return err; } Loading Loading
core/jni/android/graphics/Bitmap.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -727,7 +727,7 @@ static bool bitmapCopyTo(SkBitmap* dst, SkColorType dstCT, const SkBitmap& src, if (!dst->setInfo(dstInfo)) { return false; } if (!dst->tryAllocPixels(alloc, nullptr)) { if (!dst->tryAllocPixels(alloc)) { return false; } Loading Loading @@ -1081,7 +1081,7 @@ static jobject Bitmap_createFromParcel(JNIEnv* env, jobject, jobject parcel) { // Map the pixels in place and take ownership of the ashmem region. nativeBitmap = sk_sp<Bitmap>(GraphicsJNI::mapAshmemBitmap(env, bitmap.get(), nullptr, dupFd, const_cast<void*>(blob.data()), size, !isMutable)); dupFd, const_cast<void*>(blob.data()), size, !isMutable)); if (!nativeBitmap) { close(dupFd); blob.release(); Loading
core/jni/android/graphics/BitmapFactory.cpp +5 −5 Original line number Diff line number Diff line Loading @@ -136,7 +136,7 @@ public: : mScale(scale), mSize(size) { } virtual bool allocPixelRef(SkBitmap* bitmap, SkColorTable*) { virtual bool allocPixelRef(SkBitmap* bitmap) { // accounts for scale in final allocation, using eventual size and config const int bytesPerPixel = SkColorTypeBytesPerPixel(bitmap->colorType()); const int requestedSize = bytesPerPixel * Loading @@ -147,7 +147,7 @@ public: mSize, requestedSize); return false; } return SkBitmap::HeapAllocator::allocPixelRef(bitmap, nullptr); return SkBitmap::HeapAllocator::allocPixelRef(bitmap); } private: const float mScale; Loading @@ -163,7 +163,7 @@ public: ~RecyclingPixelAllocator() { } virtual bool allocPixelRef(SkBitmap* bitmap, SkColorTable*) { virtual bool allocPixelRef(SkBitmap* bitmap) { const SkImageInfo& info = bitmap->info(); if (info.colorType() == kUnknown_SkColorType) { ALOGW("unable to reuse a bitmap as the target has an unknown bitmap configuration"); Loading Loading @@ -401,7 +401,7 @@ static jobject doDecode(JNIEnv* env, SkStreamRewindable* stream, jobject padding } SkBitmap decodingBitmap; if (!decodingBitmap.setInfo(bitmapInfo) || !decodingBitmap.tryAllocPixels(decodeAllocator, nullptr)) { !decodingBitmap.tryAllocPixels(decodeAllocator)) { // SkAndroidCodec should recommend a valid SkImageInfo, so setInfo() // should only only fail if the calculated value for rowBytes is too // large. Loading Loading @@ -486,7 +486,7 @@ static jobject doDecode(JNIEnv* env, SkStreamRewindable* stream, jobject padding // to/from unpremultiplied bitmaps. outputBitmap.setInfo( bitmapInfo.makeWH(scaledWidth, scaledHeight).makeColorType(scaledColorType)); if (!outputBitmap.tryAllocPixels(outputAllocator, NULL)) { if (!outputBitmap.tryAllocPixels(outputAllocator)) { // This should only fail on OOM. The recyclingAllocator should have // enough memory since we check this before decoding using the // scaleCheckingAllocator. Loading
core/jni/android/graphics/Graphics.cpp +5 −5 Original line number Diff line number Diff line Loading @@ -433,7 +433,7 @@ jobject GraphicsJNI::createRegion(JNIEnv* env, SkRegion* region) /////////////////////////////////////////////////////////////////////////////// android::Bitmap* GraphicsJNI::mapAshmemBitmap(JNIEnv* env, SkBitmap* bitmap, SkColorTable*, int fd, void* addr, size_t size, bool readOnly) { int fd, void* addr, size_t size, bool readOnly) { const SkImageInfo& info = bitmap->info(); if (info.colorType() == kUnknown_SkColorType) { doThrowIAE(env, "unknown bitmap configuration"); Loading Loading @@ -607,7 +607,7 @@ jobject GraphicsJNI::getColorSpace(JNIEnv* env, sk_sp<SkColorSpace>& decodeColor } /////////////////////////////////////////////////////////////////////////////// bool HeapAllocator::allocPixelRef(SkBitmap* bitmap, SkColorTable*) { bool HeapAllocator::allocPixelRef(SkBitmap* bitmap) { mStorage = android::Bitmap::allocateHeapBitmap(bitmap); return !!mStorage; } Loading @@ -624,7 +624,7 @@ RecyclingClippingPixelAllocator::RecyclingClippingPixelAllocator( RecyclingClippingPixelAllocator::~RecyclingClippingPixelAllocator() {} bool RecyclingClippingPixelAllocator::allocPixelRef(SkBitmap* bitmap, SkColorTable*) { bool RecyclingClippingPixelAllocator::allocPixelRef(SkBitmap* bitmap) { // Ensure that the caller did not pass in a NULL bitmap to the constructor or this // function. LOG_ALWAYS_FATAL_IF(!mRecycledBitmap); Loading Loading @@ -683,7 +683,7 @@ bool RecyclingClippingPixelAllocator::allocPixelRef(SkBitmap* bitmap, SkColorTab // decode is complete. mNeedsCopy = true; return heapAllocator.allocPixelRef(bitmap, nullptr); return heapAllocator.allocPixelRef(bitmap); } void RecyclingClippingPixelAllocator::copyIfNecessary() { Loading Loading @@ -714,7 +714,7 @@ AshmemPixelAllocator::AshmemPixelAllocator(JNIEnv *env) { "env->GetJavaVM failed"); } bool AshmemPixelAllocator::allocPixelRef(SkBitmap* bitmap, SkColorTable*) { bool AshmemPixelAllocator::allocPixelRef(SkBitmap* bitmap) { mStorage = android::Bitmap::allocateAshmemBitmap(bitmap); return !!mStorage; } Loading
core/jni/android/graphics/GraphicsJNI.h +5 −5 Original line number Diff line number Diff line Loading @@ -91,7 +91,7 @@ public: static jobject createBitmapRegionDecoder(JNIEnv* env, SkBitmapRegionDecoder* bitmap); static android::Bitmap* mapAshmemBitmap(JNIEnv* env, SkBitmap* bitmap, SkColorTable* ctable, int fd, void* addr, size_t size, bool readOnly); int fd, void* addr, size_t size, bool readOnly); /** * Given a bitmap we natively allocate a memory block to store the contents Loading @@ -99,7 +99,7 @@ public: * SkPixelRef, which ensures that upon deletion the appropriate caches * are notified. */ static bool allocatePixels(JNIEnv* env, SkBitmap* bitmap, SkColorTable* ctable); static bool allocatePixels(JNIEnv* env, SkBitmap* bitmap); /** Copy the colors in colors[] to the bitmap, convert to the correct format along the way. Loading Loading @@ -127,7 +127,7 @@ public: HeapAllocator() { }; ~HeapAllocator() { }; virtual bool allocPixelRef(SkBitmap* bitmap, SkColorTable* ctable) override; virtual bool allocPixelRef(SkBitmap* bitmap) override; /** * Fetches the backing allocation object. Must be called! Loading Loading @@ -176,7 +176,7 @@ public: ~RecyclingClippingPixelAllocator(); virtual bool allocPixelRef(SkBitmap* bitmap, SkColorTable* ctable) override; virtual bool allocPixelRef(SkBitmap* bitmap) override; /** * Must be called! Loading Loading @@ -206,7 +206,7 @@ class AshmemPixelAllocator : public SkBitmap::Allocator { public: explicit AshmemPixelAllocator(JNIEnv* env); ~AshmemPixelAllocator() { }; virtual bool allocPixelRef(SkBitmap* bitmap, SkColorTable* ctable); virtual bool allocPixelRef(SkBitmap* bitmap); android::Bitmap* getStorageObjAndReset() { return mStorage.release(); }; Loading
core/jni/android/opengl/util.cpp +1 −19 Original line number Diff line number Diff line Loading @@ -713,28 +713,10 @@ static jint util_texImage2D(JNIEnv *env, jclass clazz, const int h = bitmap.height(); const void* p = bitmap.getPixels(); if (internalformat == GL_PALETTE8_RGBA8_OES) { if (sizeof(SkPMColor) != sizeof(uint32_t)) { err = -1; goto error; } const size_t size = bitmap.getSize(); const size_t palette_size = 256*sizeof(SkPMColor); const size_t imageSize = size + palette_size; void* const data = malloc(imageSize); if (data) { void* const pixels = (char*)data + palette_size; SkColorTable* ctable = bitmap.getColorTable(); memcpy(data, ctable->readColors(), ctable->count() * sizeof(SkPMColor)); memcpy(pixels, p, size); glCompressedTexImage2D(target, level, internalformat, w, h, border, imageSize, data); free(data); } else { err = -1; } } else { glTexImage2D(target, level, internalformat, w, h, border, internalformat, type, p); } error: return err; } Loading