From f9ab99aaade8c451c0e9309b4c61a448373019e3 Mon Sep 17 00:00:00 2001 From: "weita@google.com" Date: Sun, 3 May 2009 18:23:30 +0000 Subject: Allow copying an Index8 bitmap when srcConfig and dstConfig are both Index8. Also, change the logic of SkBitmap.copyTo() to do memcpy() if srcConfig and dstConfig are the same. git-svn-id: http://skia.googlecode.com/svn/trunk@164 2bbb7eff-a529-9590-31e7-b0007b416f81 --- tests/BitmapCopyTest.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/BitmapCopyTest.cpp b/tests/BitmapCopyTest.cpp index 5ec64cfc03..f904859156 100644 --- a/tests/BitmapCopyTest.cpp +++ b/tests/BitmapCopyTest.cpp @@ -11,7 +11,7 @@ static const char* gConfigName[] = { }; static void init_src(const SkBitmap& bitmap) { - SkAutoLockPixels lock(bitmap); + SkAutoLockPixels lock(bitmap); if (bitmap.getPixels()) { memset(bitmap.getPixels(), 4, bitmap.getSize()); } @@ -32,7 +32,7 @@ struct Pair { static void TestBitmapCopy(skiatest::Reporter* reporter) { static const Pair gPairs[] = { { SkBitmap::kNo_Config, "00000000" }, - { SkBitmap::kA1_Config, "01101110" }, + { SkBitmap::kA1_Config, "01000000" }, { SkBitmap::kA8_Config, "00101110" }, { SkBitmap::kIndex8_Config, "00111110" }, { SkBitmap::kRGB_565_Config, "00101110" }, @@ -40,15 +40,15 @@ static void TestBitmapCopy(skiatest::Reporter* reporter) { { SkBitmap::kARGB_8888_Config, "00101110" }, { SkBitmap::kRLE_Index8_Config, "00000000" } }; - + const int W = 20; const int H = 33; - + for (size_t i = 0; i < SK_ARRAY_COUNT(gPairs); i++) { for (size_t j = 0; j < SK_ARRAY_COUNT(gPairs); j++) { SkBitmap src, dst; SkColorTable* ct = NULL; - + src.setConfig(gPairs[i].fConfig, W, H); if (SkBitmap::kIndex8_Config == src.config()) { ct = init_ctable(); @@ -66,12 +66,13 @@ static void TestBitmapCopy(skiatest::Reporter* reporter) { boolStr(success)); reporter->reportFailed(str); } - + if (success) { REPORTER_ASSERT(reporter, src.width() == dst.width()); REPORTER_ASSERT(reporter, src.height() == dst.height()); + REPORTER_ASSERT(reporter, dst.config() == gPairs[j].fConfig); if (src.config() == dst.config()) { - SkAutoLockPixels srcLock(src); + SkAutoLockPixels srcLock(src); SkAutoLockPixels dstLock(dst); REPORTER_ASSERT(reporter, src.readyToDraw()); REPORTER_ASSERT(reporter, dst.readyToDraw()); -- cgit v1.2.3