From 3b9869e32a996d944c033ef7916d7a166fb7dbf2 Mon Sep 17 00:00:00 2001 From: Derek Sollenberger Date: Fri, 4 Aug 2017 14:13:57 -0400 Subject: Support copying from index8 into another index8. Both bitmap's must share the same color table as we essentially memcopy the pixel data between the buffers. Bug: 64112829 Test: CtsGraphicsTestCases Merged-In: I317e3a814dbd102925fe412d2e19111b0af3af38 Change-Id: I5d99627fe7dd0639bb47a2eb8790510beebe6c6f --- core/jni/android/graphics/Bitmap.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/jni/android/graphics/Bitmap.cpp b/core/jni/android/graphics/Bitmap.cpp index be8b9de47869..b03c346faa8d 100755 --- a/core/jni/android/graphics/Bitmap.cpp +++ b/core/jni/android/graphics/Bitmap.cpp @@ -752,7 +752,8 @@ 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."); + LOG_ALWAYS_FATAL_IF(kIndex_8_SkColorType == dstCT && + kIndex_8_SkColorType != src.colorType(), "Error, cannot copyTo kIndex8."); SkPixmap srcPM; if (!src.peekPixels(&srcPM)) { @@ -787,7 +788,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, srcPM.ctable())) { return false; } -- cgit v1.2.3-59-g8ed1b