Loading core/jni/android/graphics/Bitmap.cpp +19 −128 Original line number Diff line number Diff line Loading @@ -485,11 +485,9 @@ bool GraphicsJNI::SetPixels(JNIEnv* env, jintArray srcColors, int srcOffset, int //////////////////// ToColor procs typedef void (*ToColorProc)(SkColor dst[], const void* src, int width, SkColorTable*); typedef void (*ToColorProc)(SkColor dst[], const void* src, int width); static void ToColor_F16_Alpha(SkColor dst[], const void* src, int width, SkColorTable*) { static void ToColor_F16_Alpha(SkColor dst[], const void* src, int width) { SkASSERT(width > 0); uint64_t* s = (uint64_t*)src; do { Loading @@ -497,8 +495,7 @@ static void ToColor_F16_Alpha(SkColor dst[], const void* src, int width, } while (--width != 0); } static void ToColor_F16_Raw(SkColor dst[], const void* src, int width, SkColorTable*) { static void ToColor_F16_Raw(SkColor dst[], const void* src, int width) { SkASSERT(width > 0); uint64_t* s = (uint64_t*)src; do { Loading @@ -506,8 +503,7 @@ static void ToColor_F16_Raw(SkColor dst[], const void* src, int width, } while (--width != 0); } static void ToColor_S32_Alpha(SkColor dst[], const void* src, int width, SkColorTable*) { static void ToColor_S32_Alpha(SkColor dst[], const void* src, int width) { SkASSERT(width > 0); const SkPMColor* s = (const SkPMColor*)src; do { Loading @@ -515,8 +511,7 @@ static void ToColor_S32_Alpha(SkColor dst[], const void* src, int width, } while (--width != 0); } static void ToColor_S32_Raw(SkColor dst[], const void* src, int width, SkColorTable*) { static void ToColor_S32_Raw(SkColor dst[], const void* src, int width) { SkASSERT(width > 0); const SkPMColor* s = (const SkPMColor*)src; do { Loading @@ -526,8 +521,7 @@ static void ToColor_S32_Raw(SkColor dst[], const void* src, int width, } while (--width != 0); } static void ToColor_S32_Opaque(SkColor dst[], const void* src, int width, SkColorTable*) { static void ToColor_S32_Opaque(SkColor dst[], const void* src, int width) { SkASSERT(width > 0); const SkPMColor* s = (const SkPMColor*)src; do { Loading @@ -537,8 +531,7 @@ static void ToColor_S32_Opaque(SkColor dst[], const void* src, int width, } while (--width != 0); } static void ToColor_S4444_Alpha(SkColor dst[], const void* src, int width, SkColorTable*) { static void ToColor_S4444_Alpha(SkColor dst[], const void* src, int width) { SkASSERT(width > 0); const SkPMColor16* s = (const SkPMColor16*)src; do { Loading @@ -546,8 +539,7 @@ static void ToColor_S4444_Alpha(SkColor dst[], const void* src, int width, } while (--width != 0); } static void ToColor_S4444_Raw(SkColor dst[], const void* src, int width, SkColorTable*) { static void ToColor_S4444_Raw(SkColor dst[], const void* src, int width) { SkASSERT(width > 0); const SkPMColor16* s = (const SkPMColor16*)src; do { Loading @@ -557,8 +549,7 @@ static void ToColor_S4444_Raw(SkColor dst[], const void* src, int width, } while (--width != 0); } static void ToColor_S4444_Opaque(SkColor dst[], const void* src, int width, SkColorTable*) { static void ToColor_S4444_Opaque(SkColor dst[], const void* src, int width) { SkASSERT(width > 0); const SkPMColor16* s = (const SkPMColor16*)src; do { Loading @@ -568,8 +559,7 @@ static void ToColor_S4444_Opaque(SkColor dst[], const void* src, int width, } while (--width != 0); } static void ToColor_S565(SkColor dst[], const void* src, int width, SkColorTable*) { static void ToColor_S565(SkColor dst[], const void* src, int width) { SkASSERT(width > 0); const uint16_t* s = (const uint16_t*)src; do { Loading @@ -579,41 +569,7 @@ static void ToColor_S565(SkColor dst[], const void* src, int width, } while (--width != 0); } static void ToColor_SI8_Alpha(SkColor dst[], const void* src, int width, SkColorTable* ctable) { SkASSERT(width > 0); const uint8_t* s = (const uint8_t*)src; const SkPMColor* colors = ctable->readColors(); do { *dst++ = SkUnPreMultiply::PMColorToColor(colors[*s++]); } while (--width != 0); } static void ToColor_SI8_Raw(SkColor dst[], const void* src, int width, SkColorTable* ctable) { SkASSERT(width > 0); const uint8_t* s = (const uint8_t*)src; const SkPMColor* colors = ctable->readColors(); do { SkPMColor c = colors[*s++]; *dst++ = SkColorSetARGB(SkGetPackedA32(c), SkGetPackedR32(c), SkGetPackedG32(c), SkGetPackedB32(c)); } while (--width != 0); } static void ToColor_SI8_Opaque(SkColor dst[], const void* src, int width, SkColorTable* ctable) { SkASSERT(width > 0); const uint8_t* s = (const uint8_t*)src; const SkPMColor* colors = ctable->readColors(); do { SkPMColor c = colors[*s++]; *dst++ = SkColorSetRGB(SkGetPackedR32(c), SkGetPackedG32(c), SkGetPackedB32(c)); } while (--width != 0); } static void ToColor_SA8(SkColor dst[], const void* src, int width, SkColorTable*) { static void ToColor_SA8(SkColor dst[], const void* src, int width) { SkASSERT(width > 0); const uint8_t* s = (const uint8_t*)src; do { Loading Loading @@ -649,20 +605,6 @@ static ToColorProc ChooseToColorProc(const SkBitmap& src) { } case kRGB_565_SkColorType: return ToColor_S565; case kIndex_8_SkColorType: if (src.getColorTable() == NULL) { return NULL; } switch (src.alphaType()) { case kOpaque_SkAlphaType: return ToColor_SI8_Opaque; case kPremul_SkAlphaType: return ToColor_SI8_Alpha; case kUnpremul_SkAlphaType: return ToColor_SI8_Raw; default: return NULL; } case kAlpha_8_SkColorType: return ToColor_SA8; case kRGBA_F16_SkColorType: Loading Loading @@ -738,7 +680,7 @@ static jobject Bitmap_creator(JNIEnv* env, jobject, jintArray jColors, bitmap.setInfo(SkImageInfo::Make(width, height, colorType, kPremul_SkAlphaType, colorSpace)); sk_sp<Bitmap> nativeBitmap = Bitmap::allocateHeapBitmap(&bitmap, NULL); sk_sp<Bitmap> nativeBitmap = Bitmap::allocateHeapBitmap(&bitmap); if (!nativeBitmap) { return NULL; } Loading @@ -752,8 +694,6 @@ static jobject Bitmap_creator(JNIEnv* env, jobject, jintArray jColors, static bool bitmapCopyTo(SkBitmap* dst, SkColorType dstCT, const SkBitmap& src, SkBitmap::Allocator* alloc) { LOG_ALWAYS_FATAL_IF(kIndex_8_SkColorType == dstCT, "Error, cannot copyTo kIndex8."); SkPixmap srcPM; if (!src.peekPixels(&srcPM)) { return false; Loading @@ -766,7 +706,7 @@ static bool bitmapCopyTo(SkBitmap* dst, SkColorType dstCT, const SkBitmap& src, // allow the call to readPixels() to succeed and preserve this lenient behavior. if (kOpaque_SkAlphaType != srcPM.alphaType()) { srcPM = SkPixmap(srcPM.info().makeAlphaType(kOpaque_SkAlphaType), srcPM.addr(), srcPM.rowBytes(), srcPM.ctable()); srcPM.rowBytes()); dstInfo = dstInfo.makeAlphaType(kOpaque_SkAlphaType); } break; Loading Loading @@ -800,7 +740,7 @@ static bool bitmapCopyTo(SkBitmap* dst, SkColorType dstCT, const SkBitmap& src, for (int y = 0; y < src.height(); y++) { const uint8_t* srcRow = srcPM.addr8(0, y); uint32_t* dstRow = dst->getAddr32(0, y); ToColor_SA8(dstRow, srcRow, src.width(), nullptr); ToColor_SA8(dstRow, srcRow, src.width()); } return true; } Loading Loading @@ -1099,7 +1039,6 @@ static jobject Bitmap_createFromParcel(JNIEnv* env, jobject, jobject parcel) { kRGBA_F16_SkColorType != colorType && kRGB_565_SkColorType != colorType && kARGB_4444_SkColorType != colorType && kIndex_8_SkColorType != colorType && kAlpha_8_SkColorType != colorType) { SkDebugf("Bitmap_createFromParcel unknown colortype: %d\n", colorType); return NULL; Loading @@ -1111,24 +1050,6 @@ static jobject Bitmap_createFromParcel(JNIEnv* env, jobject, jobject parcel) { return NULL; } sk_sp<SkColorTable> ctable = NULL; if (colorType == kIndex_8_SkColorType) { int count = p->readInt32(); if (count < 0 || count > 256) { // The data is corrupt, since SkColorTable enforces a value between 0 and 256, // inclusive. return NULL; } if (count > 0) { size_t size = count * sizeof(SkPMColor); const SkPMColor* src = (const SkPMColor*)p->readInplace(size); if (src == NULL) { return NULL; } ctable = SkColorTable::Make(src, count); } } // Read the bitmap blob. size_t size = bitmap->getSize(); android::Parcel::ReadableBlob blob; Loading Loading @@ -1160,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(), ctable.get(), dupFd, const_cast<void*>(blob.data()), size, !isMutable)); nullptr, dupFd, const_cast<void*>(blob.data()), size, !isMutable)); if (!nativeBitmap) { close(dupFd); blob.release(); Loading @@ -1185,7 +1106,7 @@ static jobject Bitmap_createFromParcel(JNIEnv* env, jobject, jobject parcel) { #endif // Copy the pixels into a new buffer. nativeBitmap = Bitmap::allocateHeapBitmap(bitmap.get(), ctable); nativeBitmap = Bitmap::allocateHeapBitmap(bitmap.get()); if (!nativeBitmap) { blob.release(); doThrowRE(env, "Could not allocate java pixel ref."); Loading Loading @@ -1240,19 +1161,6 @@ static jboolean Bitmap_writeToParcel(JNIEnv* env, jobject, p->writeInt32(bitmap.rowBytes()); p->writeInt32(density); if (bitmap.colorType() == kIndex_8_SkColorType) { // The bitmap needs to be locked to access its color table. SkColorTable* ctable = bitmap.getColorTable(); if (ctable != NULL) { int count = ctable->count(); p->writeInt32(count); memcpy(p->writeInplace(count * sizeof(SkPMColor)), ctable->readColors(), count * sizeof(SkPMColor)); } else { p->writeInt32(0); // indicate no ctable } } // Transfer the underlying ashmem region if we have one and it's immutable. android::status_t status; int fd = bitmapWrapper->bitmap().getAshmemFd(); Loading Loading @@ -1394,7 +1302,7 @@ static jint Bitmap_getPixel(JNIEnv* env, jobject, jlong bitmapHandle, } SkColor dst[1]; proc(dst, src, 1, bitmap.getColorTable()); proc(dst, src, 1); SkColorSpace* colorSpace = bitmap.colorSpace(); if (bitmap.colorType() != kRGBA_F16_SkColorType && Loading Loading @@ -1424,7 +1332,6 @@ static void Bitmap_getPixels(JNIEnv* env, jobject, jlong bitmapHandle, return; } SkColorTable* ctable = bitmap.getColorTable(); jint* dst = env->GetIntArrayElements(pixelArray, NULL); SkColor* d = (SkColor*)dst + offset; Loading @@ -1432,7 +1339,7 @@ static void Bitmap_getPixels(JNIEnv* env, jobject, jlong bitmapHandle, if (bitmap.colorType() == kRGBA_F16_SkColorType || GraphicsJNI::isColorSpaceSRGB(colorSpace)) { while (--height >= 0) { proc(d, src, width, ctable); proc(d, src, width); d += stride; src = (void*)((const char*)src + bitmap.rowBytes()); } Loading @@ -1441,7 +1348,7 @@ static void Bitmap_getPixels(JNIEnv* env, jobject, jlong bitmapHandle, auto xform = SkColorSpaceXform::New(colorSpace, sRGB.get()); while (--height >= 0) { proc(d, src, width, ctable); proc(d, src, width); xform->apply(SkColorSpaceXform::kBGRA_8888_ColorFormat, d, SkColorSpaceXform::kBGRA_8888_ColorFormat, d, width, Loading Loading @@ -1551,22 +1458,6 @@ static jboolean Bitmap_sameAs(JNIEnv* env, jobject, jlong bm0Handle, jlong bm1Ha return JNI_FALSE; } if (bm0.colorType() == kIndex_8_SkColorType) { SkColorTable* ct0 = bm0.getColorTable(); SkColorTable* ct1 = bm1.getColorTable(); if (NULL == ct0 || NULL == ct1) { return JNI_FALSE; } if (ct0->count() != ct1->count()) { return JNI_FALSE; } const size_t size = ct0->count() * sizeof(SkPMColor); if (memcmp(ct0->readColors(), ct1->readColors(), size) != 0) { return JNI_FALSE; } } // now compare each scanline. We can't do the entire buffer at once, // since we don't care about the pixel values that might extend beyond // the width (since the scanline might be larger than the logical width) Loading core/jni/android/graphics/BitmapFactory.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -136,7 +136,7 @@ public: : mScale(scale), mSize(size) { } virtual bool allocPixelRef(SkBitmap* bitmap, SkColorTable* ctable) { virtual bool allocPixelRef(SkBitmap* bitmap, SkColorTable*) { // 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, ctable); return SkBitmap::HeapAllocator::allocPixelRef(bitmap, nullptr); } private: const float mScale; Loading @@ -163,7 +163,7 @@ public: ~RecyclingPixelAllocator() { } virtual bool allocPixelRef(SkBitmap* bitmap, SkColorTable* ctable) { virtual bool allocPixelRef(SkBitmap* bitmap, SkColorTable*) { 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 @@ -183,7 +183,7 @@ public: return false; } mBitmap->reconfigure(info, bitmap->rowBytes(), sk_ref_sp(ctable)); mBitmap->reconfigure(info, bitmap->rowBytes()); bitmap->setPixelRef(sk_ref_sp(mBitmap), 0, 0); return true; } Loading core/jni/android/graphics/Graphics.cpp +11 −13 Original line number Diff line number Diff line Loading @@ -327,8 +327,6 @@ jint GraphicsJNI::colorTypeToLegacyBitmapConfig(SkColorType colorType) { return kARGB_4444_LegacyBitmapConfig; case kRGB_565_SkColorType: return kRGB_565_LegacyBitmapConfig; case kIndex_8_SkColorType: return kIndex8_LegacyBitmapConfig; case kAlpha_8_SkColorType: return kA8_LegacyBitmapConfig; case kUnknown_SkColorType: Loading @@ -342,7 +340,7 @@ SkColorType GraphicsJNI::legacyBitmapConfigToColorType(jint legacyConfig) { const uint8_t gConfig2ColorType[] = { kUnknown_SkColorType, kAlpha_8_SkColorType, kIndex_8_SkColorType, kUnknown_SkColorType, // Previously kIndex_8_SkColorType, kRGB_565_SkColorType, kARGB_4444_SkColorType, kN32_SkColorType, Loading Loading @@ -435,7 +433,7 @@ jobject GraphicsJNI::createRegion(JNIEnv* env, SkRegion* region) /////////////////////////////////////////////////////////////////////////////// android::Bitmap* GraphicsJNI::mapAshmemBitmap(JNIEnv* env, SkBitmap* bitmap, SkColorTable* ctable, int fd, void* addr, size_t size, bool readOnly) { SkColorTable*, 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 @@ -456,7 +454,7 @@ android::Bitmap* GraphicsJNI::mapAshmemBitmap(JNIEnv* env, SkBitmap* bitmap, // attempting to compute our own. const size_t rowBytes = bitmap->rowBytes(); auto wrapper = new android::Bitmap(addr, fd, size, info, rowBytes, sk_ref_sp(ctable)); auto wrapper = new android::Bitmap(addr, fd, size, info, rowBytes); wrapper->getSkBitmap(bitmap); if (readOnly) { bitmap->pixelRef()->setImmutable(); Loading Loading @@ -609,8 +607,8 @@ jobject GraphicsJNI::getColorSpace(JNIEnv* env, sk_sp<SkColorSpace>& decodeColor } /////////////////////////////////////////////////////////////////////////////// bool HeapAllocator::allocPixelRef(SkBitmap* bitmap, SkColorTable* ctable) { mStorage = android::Bitmap::allocateHeapBitmap(bitmap, sk_ref_sp(ctable)); bool HeapAllocator::allocPixelRef(SkBitmap* bitmap, SkColorTable*) { mStorage = android::Bitmap::allocateHeapBitmap(bitmap); return !!mStorage; } Loading @@ -626,7 +624,7 @@ RecyclingClippingPixelAllocator::RecyclingClippingPixelAllocator( RecyclingClippingPixelAllocator::~RecyclingClippingPixelAllocator() {} bool RecyclingClippingPixelAllocator::allocPixelRef(SkBitmap* bitmap, SkColorTable* ctable) { bool RecyclingClippingPixelAllocator::allocPixelRef(SkBitmap* bitmap, SkColorTable*) { // Ensure that the caller did not pass in a NULL bitmap to the constructor or this // function. LOG_ALWAYS_FATAL_IF(!mRecycledBitmap); Loading @@ -649,7 +647,7 @@ bool RecyclingClippingPixelAllocator::allocPixelRef(SkBitmap* bitmap, SkColorTab const size_t rowBytes = maxInfo.minRowBytes(); const size_t bytesNeeded = maxInfo.getSafeSize(rowBytes); if (bytesNeeded <= mRecycledBytes) { // Here we take advantage of reconfigure() to reset the rowBytes and ctable // Here we take advantage of reconfigure() to reset the rowBytes // of mRecycledBitmap. It is very important that we pass in // mRecycledBitmap->info() for the SkImageInfo. According to the // specification for BitmapRegionDecoder, we are not allowed to change Loading @@ -658,7 +656,7 @@ bool RecyclingClippingPixelAllocator::allocPixelRef(SkBitmap* bitmap, SkColorTab // storage needs mRecycledBitmap->reconfigure( mRecycledBitmap->info().makeColorSpace(bitmap->refColorSpace()), rowBytes, sk_ref_sp(ctable)); rowBytes); // Give the bitmap the same pixelRef as mRecycledBitmap. // skbug.com/4538: We also need to make sure that the rowBytes on the pixel ref Loading @@ -685,7 +683,7 @@ bool RecyclingClippingPixelAllocator::allocPixelRef(SkBitmap* bitmap, SkColorTab // decode is complete. mNeedsCopy = true; return heapAllocator.allocPixelRef(bitmap, ctable); return heapAllocator.allocPixelRef(bitmap, nullptr); } void RecyclingClippingPixelAllocator::copyIfNecessary() { Loading Loading @@ -716,8 +714,8 @@ AshmemPixelAllocator::AshmemPixelAllocator(JNIEnv *env) { "env->GetJavaVM failed"); } bool AshmemPixelAllocator::allocPixelRef(SkBitmap* bitmap, SkColorTable* ctable) { mStorage = android::Bitmap::allocateAshmemBitmap(bitmap, sk_ref_sp(ctable)); bool AshmemPixelAllocator::allocPixelRef(SkBitmap* bitmap, SkColorTable*) { mStorage = android::Bitmap::allocateAshmemBitmap(bitmap); return !!mStorage; } Loading core/jni/android/opengl/util.cpp +0 −7 Original line number Diff line number Diff line Loading @@ -623,9 +623,6 @@ void util_multiplyMV(JNIEnv *env, jclass clazz, static int checkFormat(SkColorType colorType, int format, int type) { switch(colorType) { case kIndex_8_SkColorType: if (format == GL_PALETTE8_RGBA8_OES) return 0; case kN32_SkColorType: case kAlpha_8_SkColorType: if (type == GL_UNSIGNED_BYTE) Loading Loading @@ -657,8 +654,6 @@ static int getInternalFormat(SkColorType colorType) return GL_RGBA; case kN32_SkColorType: return GL_RGBA; case kIndex_8_SkColorType: return GL_PALETTE8_RGBA8_OES; case kRGB_565_SkColorType: return GL_RGB; default: Loading @@ -675,8 +670,6 @@ static int getType(SkColorType colorType) return GL_UNSIGNED_SHORT_4_4_4_4; case kN32_SkColorType: return GL_UNSIGNED_BYTE; case kIndex_8_SkColorType: return -1; // No type for compressed data. case kRGB_565_SkColorType: return GL_UNSIGNED_SHORT_5_6_5; default: Loading core/jni/android_graphics_Canvas.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -452,7 +452,7 @@ static void drawBitmapArray(JNIEnv* env, jobject, jlong canvasHandle, GraphicsJNI::defaultColorSpace()); SkBitmap bitmap; bitmap.setInfo(info); sk_sp<Bitmap> androidBitmap = Bitmap::allocateHeapBitmap(&bitmap, NULL); sk_sp<Bitmap> androidBitmap = Bitmap::allocateHeapBitmap(&bitmap); if (!androidBitmap) { return; } Loading Loading
core/jni/android/graphics/Bitmap.cpp +19 −128 Original line number Diff line number Diff line Loading @@ -485,11 +485,9 @@ bool GraphicsJNI::SetPixels(JNIEnv* env, jintArray srcColors, int srcOffset, int //////////////////// ToColor procs typedef void (*ToColorProc)(SkColor dst[], const void* src, int width, SkColorTable*); typedef void (*ToColorProc)(SkColor dst[], const void* src, int width); static void ToColor_F16_Alpha(SkColor dst[], const void* src, int width, SkColorTable*) { static void ToColor_F16_Alpha(SkColor dst[], const void* src, int width) { SkASSERT(width > 0); uint64_t* s = (uint64_t*)src; do { Loading @@ -497,8 +495,7 @@ static void ToColor_F16_Alpha(SkColor dst[], const void* src, int width, } while (--width != 0); } static void ToColor_F16_Raw(SkColor dst[], const void* src, int width, SkColorTable*) { static void ToColor_F16_Raw(SkColor dst[], const void* src, int width) { SkASSERT(width > 0); uint64_t* s = (uint64_t*)src; do { Loading @@ -506,8 +503,7 @@ static void ToColor_F16_Raw(SkColor dst[], const void* src, int width, } while (--width != 0); } static void ToColor_S32_Alpha(SkColor dst[], const void* src, int width, SkColorTable*) { static void ToColor_S32_Alpha(SkColor dst[], const void* src, int width) { SkASSERT(width > 0); const SkPMColor* s = (const SkPMColor*)src; do { Loading @@ -515,8 +511,7 @@ static void ToColor_S32_Alpha(SkColor dst[], const void* src, int width, } while (--width != 0); } static void ToColor_S32_Raw(SkColor dst[], const void* src, int width, SkColorTable*) { static void ToColor_S32_Raw(SkColor dst[], const void* src, int width) { SkASSERT(width > 0); const SkPMColor* s = (const SkPMColor*)src; do { Loading @@ -526,8 +521,7 @@ static void ToColor_S32_Raw(SkColor dst[], const void* src, int width, } while (--width != 0); } static void ToColor_S32_Opaque(SkColor dst[], const void* src, int width, SkColorTable*) { static void ToColor_S32_Opaque(SkColor dst[], const void* src, int width) { SkASSERT(width > 0); const SkPMColor* s = (const SkPMColor*)src; do { Loading @@ -537,8 +531,7 @@ static void ToColor_S32_Opaque(SkColor dst[], const void* src, int width, } while (--width != 0); } static void ToColor_S4444_Alpha(SkColor dst[], const void* src, int width, SkColorTable*) { static void ToColor_S4444_Alpha(SkColor dst[], const void* src, int width) { SkASSERT(width > 0); const SkPMColor16* s = (const SkPMColor16*)src; do { Loading @@ -546,8 +539,7 @@ static void ToColor_S4444_Alpha(SkColor dst[], const void* src, int width, } while (--width != 0); } static void ToColor_S4444_Raw(SkColor dst[], const void* src, int width, SkColorTable*) { static void ToColor_S4444_Raw(SkColor dst[], const void* src, int width) { SkASSERT(width > 0); const SkPMColor16* s = (const SkPMColor16*)src; do { Loading @@ -557,8 +549,7 @@ static void ToColor_S4444_Raw(SkColor dst[], const void* src, int width, } while (--width != 0); } static void ToColor_S4444_Opaque(SkColor dst[], const void* src, int width, SkColorTable*) { static void ToColor_S4444_Opaque(SkColor dst[], const void* src, int width) { SkASSERT(width > 0); const SkPMColor16* s = (const SkPMColor16*)src; do { Loading @@ -568,8 +559,7 @@ static void ToColor_S4444_Opaque(SkColor dst[], const void* src, int width, } while (--width != 0); } static void ToColor_S565(SkColor dst[], const void* src, int width, SkColorTable*) { static void ToColor_S565(SkColor dst[], const void* src, int width) { SkASSERT(width > 0); const uint16_t* s = (const uint16_t*)src; do { Loading @@ -579,41 +569,7 @@ static void ToColor_S565(SkColor dst[], const void* src, int width, } while (--width != 0); } static void ToColor_SI8_Alpha(SkColor dst[], const void* src, int width, SkColorTable* ctable) { SkASSERT(width > 0); const uint8_t* s = (const uint8_t*)src; const SkPMColor* colors = ctable->readColors(); do { *dst++ = SkUnPreMultiply::PMColorToColor(colors[*s++]); } while (--width != 0); } static void ToColor_SI8_Raw(SkColor dst[], const void* src, int width, SkColorTable* ctable) { SkASSERT(width > 0); const uint8_t* s = (const uint8_t*)src; const SkPMColor* colors = ctable->readColors(); do { SkPMColor c = colors[*s++]; *dst++ = SkColorSetARGB(SkGetPackedA32(c), SkGetPackedR32(c), SkGetPackedG32(c), SkGetPackedB32(c)); } while (--width != 0); } static void ToColor_SI8_Opaque(SkColor dst[], const void* src, int width, SkColorTable* ctable) { SkASSERT(width > 0); const uint8_t* s = (const uint8_t*)src; const SkPMColor* colors = ctable->readColors(); do { SkPMColor c = colors[*s++]; *dst++ = SkColorSetRGB(SkGetPackedR32(c), SkGetPackedG32(c), SkGetPackedB32(c)); } while (--width != 0); } static void ToColor_SA8(SkColor dst[], const void* src, int width, SkColorTable*) { static void ToColor_SA8(SkColor dst[], const void* src, int width) { SkASSERT(width > 0); const uint8_t* s = (const uint8_t*)src; do { Loading Loading @@ -649,20 +605,6 @@ static ToColorProc ChooseToColorProc(const SkBitmap& src) { } case kRGB_565_SkColorType: return ToColor_S565; case kIndex_8_SkColorType: if (src.getColorTable() == NULL) { return NULL; } switch (src.alphaType()) { case kOpaque_SkAlphaType: return ToColor_SI8_Opaque; case kPremul_SkAlphaType: return ToColor_SI8_Alpha; case kUnpremul_SkAlphaType: return ToColor_SI8_Raw; default: return NULL; } case kAlpha_8_SkColorType: return ToColor_SA8; case kRGBA_F16_SkColorType: Loading Loading @@ -738,7 +680,7 @@ static jobject Bitmap_creator(JNIEnv* env, jobject, jintArray jColors, bitmap.setInfo(SkImageInfo::Make(width, height, colorType, kPremul_SkAlphaType, colorSpace)); sk_sp<Bitmap> nativeBitmap = Bitmap::allocateHeapBitmap(&bitmap, NULL); sk_sp<Bitmap> nativeBitmap = Bitmap::allocateHeapBitmap(&bitmap); if (!nativeBitmap) { return NULL; } Loading @@ -752,8 +694,6 @@ static jobject Bitmap_creator(JNIEnv* env, jobject, jintArray jColors, static bool bitmapCopyTo(SkBitmap* dst, SkColorType dstCT, const SkBitmap& src, SkBitmap::Allocator* alloc) { LOG_ALWAYS_FATAL_IF(kIndex_8_SkColorType == dstCT, "Error, cannot copyTo kIndex8."); SkPixmap srcPM; if (!src.peekPixels(&srcPM)) { return false; Loading @@ -766,7 +706,7 @@ static bool bitmapCopyTo(SkBitmap* dst, SkColorType dstCT, const SkBitmap& src, // allow the call to readPixels() to succeed and preserve this lenient behavior. if (kOpaque_SkAlphaType != srcPM.alphaType()) { srcPM = SkPixmap(srcPM.info().makeAlphaType(kOpaque_SkAlphaType), srcPM.addr(), srcPM.rowBytes(), srcPM.ctable()); srcPM.rowBytes()); dstInfo = dstInfo.makeAlphaType(kOpaque_SkAlphaType); } break; Loading Loading @@ -800,7 +740,7 @@ static bool bitmapCopyTo(SkBitmap* dst, SkColorType dstCT, const SkBitmap& src, for (int y = 0; y < src.height(); y++) { const uint8_t* srcRow = srcPM.addr8(0, y); uint32_t* dstRow = dst->getAddr32(0, y); ToColor_SA8(dstRow, srcRow, src.width(), nullptr); ToColor_SA8(dstRow, srcRow, src.width()); } return true; } Loading Loading @@ -1099,7 +1039,6 @@ static jobject Bitmap_createFromParcel(JNIEnv* env, jobject, jobject parcel) { kRGBA_F16_SkColorType != colorType && kRGB_565_SkColorType != colorType && kARGB_4444_SkColorType != colorType && kIndex_8_SkColorType != colorType && kAlpha_8_SkColorType != colorType) { SkDebugf("Bitmap_createFromParcel unknown colortype: %d\n", colorType); return NULL; Loading @@ -1111,24 +1050,6 @@ static jobject Bitmap_createFromParcel(JNIEnv* env, jobject, jobject parcel) { return NULL; } sk_sp<SkColorTable> ctable = NULL; if (colorType == kIndex_8_SkColorType) { int count = p->readInt32(); if (count < 0 || count > 256) { // The data is corrupt, since SkColorTable enforces a value between 0 and 256, // inclusive. return NULL; } if (count > 0) { size_t size = count * sizeof(SkPMColor); const SkPMColor* src = (const SkPMColor*)p->readInplace(size); if (src == NULL) { return NULL; } ctable = SkColorTable::Make(src, count); } } // Read the bitmap blob. size_t size = bitmap->getSize(); android::Parcel::ReadableBlob blob; Loading Loading @@ -1160,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(), ctable.get(), dupFd, const_cast<void*>(blob.data()), size, !isMutable)); nullptr, dupFd, const_cast<void*>(blob.data()), size, !isMutable)); if (!nativeBitmap) { close(dupFd); blob.release(); Loading @@ -1185,7 +1106,7 @@ static jobject Bitmap_createFromParcel(JNIEnv* env, jobject, jobject parcel) { #endif // Copy the pixels into a new buffer. nativeBitmap = Bitmap::allocateHeapBitmap(bitmap.get(), ctable); nativeBitmap = Bitmap::allocateHeapBitmap(bitmap.get()); if (!nativeBitmap) { blob.release(); doThrowRE(env, "Could not allocate java pixel ref."); Loading Loading @@ -1240,19 +1161,6 @@ static jboolean Bitmap_writeToParcel(JNIEnv* env, jobject, p->writeInt32(bitmap.rowBytes()); p->writeInt32(density); if (bitmap.colorType() == kIndex_8_SkColorType) { // The bitmap needs to be locked to access its color table. SkColorTable* ctable = bitmap.getColorTable(); if (ctable != NULL) { int count = ctable->count(); p->writeInt32(count); memcpy(p->writeInplace(count * sizeof(SkPMColor)), ctable->readColors(), count * sizeof(SkPMColor)); } else { p->writeInt32(0); // indicate no ctable } } // Transfer the underlying ashmem region if we have one and it's immutable. android::status_t status; int fd = bitmapWrapper->bitmap().getAshmemFd(); Loading Loading @@ -1394,7 +1302,7 @@ static jint Bitmap_getPixel(JNIEnv* env, jobject, jlong bitmapHandle, } SkColor dst[1]; proc(dst, src, 1, bitmap.getColorTable()); proc(dst, src, 1); SkColorSpace* colorSpace = bitmap.colorSpace(); if (bitmap.colorType() != kRGBA_F16_SkColorType && Loading Loading @@ -1424,7 +1332,6 @@ static void Bitmap_getPixels(JNIEnv* env, jobject, jlong bitmapHandle, return; } SkColorTable* ctable = bitmap.getColorTable(); jint* dst = env->GetIntArrayElements(pixelArray, NULL); SkColor* d = (SkColor*)dst + offset; Loading @@ -1432,7 +1339,7 @@ static void Bitmap_getPixels(JNIEnv* env, jobject, jlong bitmapHandle, if (bitmap.colorType() == kRGBA_F16_SkColorType || GraphicsJNI::isColorSpaceSRGB(colorSpace)) { while (--height >= 0) { proc(d, src, width, ctable); proc(d, src, width); d += stride; src = (void*)((const char*)src + bitmap.rowBytes()); } Loading @@ -1441,7 +1348,7 @@ static void Bitmap_getPixels(JNIEnv* env, jobject, jlong bitmapHandle, auto xform = SkColorSpaceXform::New(colorSpace, sRGB.get()); while (--height >= 0) { proc(d, src, width, ctable); proc(d, src, width); xform->apply(SkColorSpaceXform::kBGRA_8888_ColorFormat, d, SkColorSpaceXform::kBGRA_8888_ColorFormat, d, width, Loading Loading @@ -1551,22 +1458,6 @@ static jboolean Bitmap_sameAs(JNIEnv* env, jobject, jlong bm0Handle, jlong bm1Ha return JNI_FALSE; } if (bm0.colorType() == kIndex_8_SkColorType) { SkColorTable* ct0 = bm0.getColorTable(); SkColorTable* ct1 = bm1.getColorTable(); if (NULL == ct0 || NULL == ct1) { return JNI_FALSE; } if (ct0->count() != ct1->count()) { return JNI_FALSE; } const size_t size = ct0->count() * sizeof(SkPMColor); if (memcmp(ct0->readColors(), ct1->readColors(), size) != 0) { return JNI_FALSE; } } // now compare each scanline. We can't do the entire buffer at once, // since we don't care about the pixel values that might extend beyond // the width (since the scanline might be larger than the logical width) Loading
core/jni/android/graphics/BitmapFactory.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -136,7 +136,7 @@ public: : mScale(scale), mSize(size) { } virtual bool allocPixelRef(SkBitmap* bitmap, SkColorTable* ctable) { virtual bool allocPixelRef(SkBitmap* bitmap, SkColorTable*) { // 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, ctable); return SkBitmap::HeapAllocator::allocPixelRef(bitmap, nullptr); } private: const float mScale; Loading @@ -163,7 +163,7 @@ public: ~RecyclingPixelAllocator() { } virtual bool allocPixelRef(SkBitmap* bitmap, SkColorTable* ctable) { virtual bool allocPixelRef(SkBitmap* bitmap, SkColorTable*) { 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 @@ -183,7 +183,7 @@ public: return false; } mBitmap->reconfigure(info, bitmap->rowBytes(), sk_ref_sp(ctable)); mBitmap->reconfigure(info, bitmap->rowBytes()); bitmap->setPixelRef(sk_ref_sp(mBitmap), 0, 0); return true; } Loading
core/jni/android/graphics/Graphics.cpp +11 −13 Original line number Diff line number Diff line Loading @@ -327,8 +327,6 @@ jint GraphicsJNI::colorTypeToLegacyBitmapConfig(SkColorType colorType) { return kARGB_4444_LegacyBitmapConfig; case kRGB_565_SkColorType: return kRGB_565_LegacyBitmapConfig; case kIndex_8_SkColorType: return kIndex8_LegacyBitmapConfig; case kAlpha_8_SkColorType: return kA8_LegacyBitmapConfig; case kUnknown_SkColorType: Loading @@ -342,7 +340,7 @@ SkColorType GraphicsJNI::legacyBitmapConfigToColorType(jint legacyConfig) { const uint8_t gConfig2ColorType[] = { kUnknown_SkColorType, kAlpha_8_SkColorType, kIndex_8_SkColorType, kUnknown_SkColorType, // Previously kIndex_8_SkColorType, kRGB_565_SkColorType, kARGB_4444_SkColorType, kN32_SkColorType, Loading Loading @@ -435,7 +433,7 @@ jobject GraphicsJNI::createRegion(JNIEnv* env, SkRegion* region) /////////////////////////////////////////////////////////////////////////////// android::Bitmap* GraphicsJNI::mapAshmemBitmap(JNIEnv* env, SkBitmap* bitmap, SkColorTable* ctable, int fd, void* addr, size_t size, bool readOnly) { SkColorTable*, 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 @@ -456,7 +454,7 @@ android::Bitmap* GraphicsJNI::mapAshmemBitmap(JNIEnv* env, SkBitmap* bitmap, // attempting to compute our own. const size_t rowBytes = bitmap->rowBytes(); auto wrapper = new android::Bitmap(addr, fd, size, info, rowBytes, sk_ref_sp(ctable)); auto wrapper = new android::Bitmap(addr, fd, size, info, rowBytes); wrapper->getSkBitmap(bitmap); if (readOnly) { bitmap->pixelRef()->setImmutable(); Loading Loading @@ -609,8 +607,8 @@ jobject GraphicsJNI::getColorSpace(JNIEnv* env, sk_sp<SkColorSpace>& decodeColor } /////////////////////////////////////////////////////////////////////////////// bool HeapAllocator::allocPixelRef(SkBitmap* bitmap, SkColorTable* ctable) { mStorage = android::Bitmap::allocateHeapBitmap(bitmap, sk_ref_sp(ctable)); bool HeapAllocator::allocPixelRef(SkBitmap* bitmap, SkColorTable*) { mStorage = android::Bitmap::allocateHeapBitmap(bitmap); return !!mStorage; } Loading @@ -626,7 +624,7 @@ RecyclingClippingPixelAllocator::RecyclingClippingPixelAllocator( RecyclingClippingPixelAllocator::~RecyclingClippingPixelAllocator() {} bool RecyclingClippingPixelAllocator::allocPixelRef(SkBitmap* bitmap, SkColorTable* ctable) { bool RecyclingClippingPixelAllocator::allocPixelRef(SkBitmap* bitmap, SkColorTable*) { // Ensure that the caller did not pass in a NULL bitmap to the constructor or this // function. LOG_ALWAYS_FATAL_IF(!mRecycledBitmap); Loading @@ -649,7 +647,7 @@ bool RecyclingClippingPixelAllocator::allocPixelRef(SkBitmap* bitmap, SkColorTab const size_t rowBytes = maxInfo.minRowBytes(); const size_t bytesNeeded = maxInfo.getSafeSize(rowBytes); if (bytesNeeded <= mRecycledBytes) { // Here we take advantage of reconfigure() to reset the rowBytes and ctable // Here we take advantage of reconfigure() to reset the rowBytes // of mRecycledBitmap. It is very important that we pass in // mRecycledBitmap->info() for the SkImageInfo. According to the // specification for BitmapRegionDecoder, we are not allowed to change Loading @@ -658,7 +656,7 @@ bool RecyclingClippingPixelAllocator::allocPixelRef(SkBitmap* bitmap, SkColorTab // storage needs mRecycledBitmap->reconfigure( mRecycledBitmap->info().makeColorSpace(bitmap->refColorSpace()), rowBytes, sk_ref_sp(ctable)); rowBytes); // Give the bitmap the same pixelRef as mRecycledBitmap. // skbug.com/4538: We also need to make sure that the rowBytes on the pixel ref Loading @@ -685,7 +683,7 @@ bool RecyclingClippingPixelAllocator::allocPixelRef(SkBitmap* bitmap, SkColorTab // decode is complete. mNeedsCopy = true; return heapAllocator.allocPixelRef(bitmap, ctable); return heapAllocator.allocPixelRef(bitmap, nullptr); } void RecyclingClippingPixelAllocator::copyIfNecessary() { Loading Loading @@ -716,8 +714,8 @@ AshmemPixelAllocator::AshmemPixelAllocator(JNIEnv *env) { "env->GetJavaVM failed"); } bool AshmemPixelAllocator::allocPixelRef(SkBitmap* bitmap, SkColorTable* ctable) { mStorage = android::Bitmap::allocateAshmemBitmap(bitmap, sk_ref_sp(ctable)); bool AshmemPixelAllocator::allocPixelRef(SkBitmap* bitmap, SkColorTable*) { mStorage = android::Bitmap::allocateAshmemBitmap(bitmap); return !!mStorage; } Loading
core/jni/android/opengl/util.cpp +0 −7 Original line number Diff line number Diff line Loading @@ -623,9 +623,6 @@ void util_multiplyMV(JNIEnv *env, jclass clazz, static int checkFormat(SkColorType colorType, int format, int type) { switch(colorType) { case kIndex_8_SkColorType: if (format == GL_PALETTE8_RGBA8_OES) return 0; case kN32_SkColorType: case kAlpha_8_SkColorType: if (type == GL_UNSIGNED_BYTE) Loading Loading @@ -657,8 +654,6 @@ static int getInternalFormat(SkColorType colorType) return GL_RGBA; case kN32_SkColorType: return GL_RGBA; case kIndex_8_SkColorType: return GL_PALETTE8_RGBA8_OES; case kRGB_565_SkColorType: return GL_RGB; default: Loading @@ -675,8 +670,6 @@ static int getType(SkColorType colorType) return GL_UNSIGNED_SHORT_4_4_4_4; case kN32_SkColorType: return GL_UNSIGNED_BYTE; case kIndex_8_SkColorType: return -1; // No type for compressed data. case kRGB_565_SkColorType: return GL_UNSIGNED_SHORT_5_6_5; default: Loading
core/jni/android_graphics_Canvas.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -452,7 +452,7 @@ static void drawBitmapArray(JNIEnv* env, jobject, jlong canvasHandle, GraphicsJNI::defaultColorSpace()); SkBitmap bitmap; bitmap.setInfo(info); sk_sp<Bitmap> androidBitmap = Bitmap::allocateHeapBitmap(&bitmap, NULL); sk_sp<Bitmap> androidBitmap = Bitmap::allocateHeapBitmap(&bitmap); if (!androidBitmap) { return; } Loading