diff options
author | Mike Reed <reed@google.com> | 2017-04-01 17:21:42 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-04-01 17:21:52 +0000 |
commit | b14131c1851eea6acbd34cc42a8f860daed36b21 (patch) | |
tree | 39e74b29ec1a34ff63fc347ba9b616186f435ff6 /tests | |
parent | 9920b10f5292838f00600f676c4578cd11705e60 (diff) |
Revert "Revert[2] "clean up (partially) colortable api"""
This reverts commit 9920b10f5292838f00600f676c4578cd11705e60.
Reason for revert: trying to get details on w2k failure
https://chromium-swarm.appspot.com/task?id=354345d34ba3b310&refresh=10
Caught exception 3221225477 EXCEPTION_ACCESS_VIOLATION, was running:
unit test HugeBlurImageFilter
unit test FontNames
unit test Codec_PngRoundTrip
unit test ClampRange
unit test FontHost
unit test ColorMatrixFilter
f16 image scaled_codec_premul abnormal.wbmp
565 image brd_android_codec_divisor_0.167 interlaced3.png_0.167
unit test Codec_png
unit test ImageFilterBlurLargeImage
unit test FontObj
unit test DrawText
unit test GrShape
565 image brd_android_codec_divisor_0.333 interlaced2.png_0.333
unit test PathOpsOpCubicsThreaded
unit test PathOpsOpLoopsThreaded
unit test FontMgr
unit test ColorToHSVRoundTrip
unit test Image_Serialize_Encoding_Failure
Likely culprit:
unit test Image_Serialize_Encoding_Failure
step returned non-zero exit code: -1073741819
Original change's description:
> Revert[2] "clean up (partially) colortable api""
>
> This reverts commit 1d1165ca6575e082b892c5460492c411618783ad.
>
> Bug: skia:
> Change-Id: Idbc0634ae3cec2e79f592d252de8751b077e6408
> Reviewed-on: https://skia-review.googlesource.com/11024
> Reviewed-by: Mike Reed <reed@google.com>
> Commit-Queue: Mike Reed <reed@google.com>
>
TBR=reed@google.com,reviews@skia.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Change-Id: Ia4e73434b083224baa36092c69526c2f59bb16aa
Reviewed-on: https://skia-review.googlesource.com/11025
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/BitmapCopyTest.cpp | 16 | ||||
-rw-r--r-- | tests/BitmapTest.cpp | 2 | ||||
-rw-r--r-- | tests/CodecPriv.h | 2 | ||||
-rw-r--r-- | tests/CodecTest.cpp | 11 | ||||
-rw-r--r-- | tests/GifTest.cpp | 2 | ||||
-rw-r--r-- | tests/ImageTest.cpp | 4 | ||||
-rw-r--r-- | tests/MallocPixelRefTest.cpp | 51 | ||||
-rw-r--r-- | tests/PixelRefTest.cpp | 2 | ||||
-rw-r--r-- | tests/WritePixelsTest.cpp | 2 |
9 files changed, 50 insertions, 42 deletions
diff --git a/tests/BitmapCopyTest.cpp b/tests/BitmapCopyTest.cpp index 4578bbb7d7..70958cae55 100644 --- a/tests/BitmapCopyTest.cpp +++ b/tests/BitmapCopyTest.cpp @@ -62,11 +62,11 @@ static void init_src(const SkBitmap& bitmap) { } } -static sk_sp<SkColorTable> init_ctable() { +static SkColorTable* init_ctable() { static const SkColor colors[] = { SK_ColorBLACK, SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE }; - return SkColorTable::Make(colors, SK_ARRAY_COUNT(colors)); + return new SkColorTable(colors, SK_ARRAY_COUNT(colors)); } struct Pair { @@ -194,13 +194,16 @@ static const int H = 33; static void setup_src_bitmaps(SkBitmap* srcOpaque, SkBitmap* srcPremul, SkColorType ct) { - sk_sp<SkColorTable> ctable; + SkColorTable* ctable = nullptr; if (kIndex_8_SkColorType == ct) { ctable = init_ctable(); } - srcOpaque->allocPixels(SkImageInfo::Make(W, H, ct, kOpaque_SkAlphaType), ctable); - srcPremul->allocPixels(SkImageInfo::Make(W, H, ct, kPremul_SkAlphaType), ctable); + srcOpaque->allocPixels(SkImageInfo::Make(W, H, ct, kOpaque_SkAlphaType), + nullptr, ctable); + srcPremul->allocPixels(SkImageInfo::Make(W, H, ct, kPremul_SkAlphaType), + nullptr, ctable); + SkSafeUnref(ctable); init_src(*srcOpaque); init_src(*srcPremul); } @@ -375,7 +378,7 @@ DEF_TEST(BitmapCopy, reporter) { // Create bitmap to act as source for copies and subsets. SkBitmap src, subset; - sk_sp<SkColorTable> ct; + SkColorTable* ct = nullptr; if (kIndex_8_SkColorType == src.colorType()) { ct = init_ctable(); } @@ -391,6 +394,7 @@ DEF_TEST(BitmapCopy, reporter) { kPremul_SkAlphaType))) { // failure is fine, as we will notice later on } + SkSafeUnref(ct); // Either copy src or extract into 'subset', which is used // for subsequent calls to copyPixelsTo/From. diff --git a/tests/BitmapTest.cpp b/tests/BitmapTest.cpp index 76621e6b38..9342d261c2 100644 --- a/tests/BitmapTest.cpp +++ b/tests/BitmapTest.cpp @@ -44,7 +44,7 @@ static void test_bigalloc(skiatest::Reporter* reporter) { SkBitmap bm; REPORTER_ASSERT(reporter, !bm.tryAllocPixels(info)); - sk_sp<SkPixelRef> pr = SkMallocPixelRef::MakeAllocate(info, info.minRowBytes(), nullptr); + SkPixelRef* pr = SkMallocPixelRef::NewAllocate(info, info.minRowBytes(), nullptr); REPORTER_ASSERT(reporter, !pr); } diff --git a/tests/CodecPriv.h b/tests/CodecPriv.h index cfa794ed68..50c205c16a 100644 --- a/tests/CodecPriv.h +++ b/tests/CodecPriv.h @@ -29,7 +29,7 @@ inline bool decode_memory(const void* mem, size_t size, SkBitmap* bm) { colorCountPtr = &maxColors; } - bm->allocPixels(codec->getInfo(), colorTable); + bm->allocPixels(codec->getInfo(), nullptr, colorTable.get()); const SkCodec::Result result = codec->getPixels(codec->getInfo(), bm->getPixels(), bm->rowBytes(), nullptr, colorPtr, colorCountPtr); return result == SkCodec::kSuccess || result == SkCodec::kIncompleteInput; diff --git a/tests/CodecTest.cpp b/tests/CodecTest.cpp index f3a393d7ac..dd11ff84fd 100644 --- a/tests/CodecTest.cpp +++ b/tests/CodecTest.cpp @@ -700,7 +700,8 @@ static void test_invalid_parameters(skiatest::Reporter* r, const char path[]) { } else if (SkCodec::kUnimplemented == result) { // New method should be supported: SkBitmap bm; - bm.allocPixels(info, SkColorTable::Make(colorStorage, 256)); + sk_sp<SkColorTable> colorTable(new SkColorTable(colorStorage, 256)); + bm.allocPixels(info, nullptr, colorTable.get()); result = decoder->startIncrementalDecode(info, bm.getPixels(), bm.rowBytes(), nullptr, colorStorage, &colorCount); REPORTER_ASSERT(r, SkCodec::kSuccess == result); @@ -1107,8 +1108,8 @@ static bool alpha_type_match(SkAlphaType origAlphaType, SkAlphaType codecAlphaTy static void check_round_trip(skiatest::Reporter* r, SkCodec* origCodec, const SkImageInfo& info) { SkBitmap bm1; SkPMColor colors[256]; - sk_sp<SkColorTable> colorTable1 = SkColorTable::Make(colors, 256); - bm1.allocPixels(info, colorTable1); + sk_sp<SkColorTable> colorTable1(new SkColorTable(colors, 256)); + bm1.allocPixels(info, nullptr, colorTable1.get()); int numColors; SkCodec::Result result = origCodec->getPixels(info, bm1.getPixels(), bm1.rowBytes(), nullptr, const_cast<SkPMColor*>(colorTable1->readColors()), @@ -1125,8 +1126,8 @@ static void check_round_trip(skiatest::Reporter* r, SkCodec* origCodec, const Sk REPORTER_ASSERT(r, alpha_type_match(info.alphaType(), codec->getInfo().alphaType())); SkBitmap bm2; - sk_sp<SkColorTable> colorTable2 = SkColorTable::Make(colors, 256); - bm2.allocPixels(info, colorTable2); + sk_sp<SkColorTable> colorTable2(new SkColorTable(colors, 256)); + bm2.allocPixels(info, nullptr, colorTable2.get()); result = codec->getPixels(info, bm2.getPixels(), bm2.rowBytes(), nullptr, const_cast<SkPMColor*>(colorTable2->readColors()), &numColors); REPORTER_ASSERT(r, SkCodec::kSuccess == result); diff --git a/tests/GifTest.cpp b/tests/GifTest.cpp index 0168d89d83..dae2bc9329 100644 --- a/tests/GifTest.cpp +++ b/tests/GifTest.cpp @@ -256,7 +256,7 @@ DEF_TEST(Gif_Sampled, r) { options.fColorCount = colorCountPtr; SkBitmap bm; - bm.allocPixels(codec->getInfo(), colorTable); + bm.allocPixels(codec->getInfo(), nullptr, colorTable.get()); const SkCodec::Result result = codec->getAndroidPixels(codec->getInfo(), bm.getPixels(), bm.rowBytes(), &options); REPORTER_ASSERT(r, result == SkCodec::kSuccess); diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp index 492985c18f..ba49000d9a 100644 --- a/tests/ImageTest.cpp +++ b/tests/ImageTest.cpp @@ -568,8 +568,10 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkImage_drawAbandonedGpuImage, reporter, c DEF_TEST(ImageFromIndex8Bitmap, r) { SkPMColor pmColors[1] = {SkPreMultiplyColor(SK_ColorWHITE)}; SkBitmap bm; + sk_sp<SkColorTable> ctable( new SkColorTable(pmColors, SK_ARRAY_COUNT(pmColors))); SkImageInfo info = SkImageInfo::Make(1, 1, kIndex_8_SkColorType, kPremul_SkAlphaType); - bm.allocPixels(info, SkColorTable::Make(pmColors, SK_ARRAY_COUNT(pmColors))); + bm.allocPixels(info, nullptr, ctable.get()); + SkAutoLockPixels autoLockPixels(bm); *bm.getAddr8(0, 0) = 0; sk_sp<SkImage> img(SkImage::MakeFromBitmap(bm)); REPORTER_ASSERT(r, img != nullptr); diff --git a/tests/MallocPixelRefTest.cpp b/tests/MallocPixelRefTest.cpp index 096e3e69ee..b89d121579 100644 --- a/tests/MallocPixelRefTest.cpp +++ b/tests/MallocPixelRefTest.cpp @@ -25,8 +25,8 @@ DEF_TEST(MallocPixelRef, reporter) { REPORTER_ASSERT(reporter, true); SkImageInfo info = SkImageInfo::MakeN32Premul(10, 13); { - sk_sp<SkPixelRef> pr( - SkMallocPixelRef::MakeAllocate(info, info.minRowBytes() - 1, nullptr)); + sk_sp<SkMallocPixelRef> pr( + SkMallocPixelRef::NewAllocate(info, info.minRowBytes() - 1, nullptr)); // rowbytes too small. REPORTER_ASSERT(reporter, nullptr == pr.get()); } @@ -34,8 +34,8 @@ DEF_TEST(MallocPixelRef, reporter) { size_t rowBytes = info.minRowBytes() - 1; size_t size = info.getSafeSize(rowBytes); sk_sp<SkData> data(SkData::MakeUninitialized(size)); - sk_sp<SkPixelRef> pr( - SkMallocPixelRef::MakeWithData(info, rowBytes, nullptr, data)); + sk_sp<SkMallocPixelRef> pr( + SkMallocPixelRef::NewWithData(info, rowBytes, nullptr, data.get())); // rowbytes too small. REPORTER_ASSERT(reporter, nullptr == pr.get()); } @@ -43,8 +43,8 @@ DEF_TEST(MallocPixelRef, reporter) { size_t rowBytes = info.minRowBytes() + 2; size_t size = info.getSafeSize(rowBytes) - 1; sk_sp<SkData> data(SkData::MakeUninitialized(size)); - sk_sp<SkPixelRef> pr( - SkMallocPixelRef::MakeWithData(info, rowBytes, nullptr, data)); + sk_sp<SkMallocPixelRef> pr( + SkMallocPixelRef::NewWithData(info, rowBytes, nullptr, data.get())); // data too small. REPORTER_ASSERT(reporter, nullptr == pr.get()); } @@ -52,32 +52,32 @@ DEF_TEST(MallocPixelRef, reporter) { size_t size = info.getSafeSize(rowBytes) + 9; { SkAutoMalloc memory(size); - sk_sp<SkPixelRef> pr( - SkMallocPixelRef::MakeDirect(info, memory.get(), rowBytes, nullptr)); + sk_sp<SkMallocPixelRef> pr( + SkMallocPixelRef::NewDirect(info, memory.get(), rowBytes, nullptr)); REPORTER_ASSERT(reporter, pr.get() != nullptr); REPORTER_ASSERT(reporter, memory.get() == pr->pixels()); } { - sk_sp<SkPixelRef> pr( - SkMallocPixelRef::MakeAllocate(info, rowBytes, nullptr)); + sk_sp<SkMallocPixelRef> pr( + SkMallocPixelRef::NewAllocate(info, rowBytes, nullptr)); REPORTER_ASSERT(reporter, pr.get() != nullptr); REPORTER_ASSERT(reporter, pr->pixels()); } { void* addr = static_cast<void*>(new uint8_t[size]); - sk_sp<SkPixelRef> pr( - SkMallocPixelRef::MakeWithProc(info, rowBytes, nullptr, addr, - delete_uint8_proc, nullptr)); + sk_sp<SkMallocPixelRef> pr( + SkMallocPixelRef::NewWithProc(info, rowBytes, nullptr, addr, + delete_uint8_proc, nullptr)); REPORTER_ASSERT(reporter, pr.get() != nullptr); REPORTER_ASSERT(reporter, addr == pr->pixels()); } { int x = 0; SkAutoMalloc memory(size); - sk_sp<SkPixelRef> pr( - SkMallocPixelRef::MakeWithProc(info, rowBytes, nullptr, - memory.get(), set_to_one_proc, - static_cast<void*>(&x))); + sk_sp<SkMallocPixelRef> pr( + SkMallocPixelRef::NewWithProc(info, rowBytes, nullptr, + memory.get(), set_to_one_proc, + static_cast<void*>(&x))); REPORTER_ASSERT(reporter, pr.get() != nullptr); REPORTER_ASSERT(reporter, memory.get() == pr->pixels()); REPORTER_ASSERT(reporter, 0 == x); @@ -88,10 +88,10 @@ DEF_TEST(MallocPixelRef, reporter) { { int x = 0; SkAutoMalloc memory(size); - sk_sp<SkPixelRef> pr( - SkMallocPixelRef::MakeWithProc(SkImageInfo::MakeN32Premul(-1, -1), rowBytes, nullptr, - memory.get(), set_to_one_proc, - static_cast<void*>(&x))); + sk_sp<SkMallocPixelRef> pr( + SkMallocPixelRef::NewWithProc(SkImageInfo::MakeN32Premul(-1, -1), rowBytes, nullptr, + memory.get(), set_to_one_proc, + static_cast<void*>(&x))); REPORTER_ASSERT(reporter, pr.get() == nullptr); // make sure that set_to_one_proc was called. REPORTER_ASSERT(reporter, 1 == x); @@ -99,16 +99,17 @@ DEF_TEST(MallocPixelRef, reporter) { { void* addr = static_cast<void*>(new uint8_t[size]); REPORTER_ASSERT(reporter, addr != nullptr); - sk_sp<SkPixelRef> pr( - SkMallocPixelRef::MakeWithProc(info, rowBytes, nullptr, addr, - delete_uint8_proc, nullptr)); + sk_sp<SkMallocPixelRef> pr( + SkMallocPixelRef::NewWithProc(info, rowBytes, nullptr, addr, + delete_uint8_proc, nullptr)); REPORTER_ASSERT(reporter, addr == pr->pixels()); } { sk_sp<SkData> data(SkData::MakeUninitialized(size)); SkData* dataPtr = data.get(); REPORTER_ASSERT(reporter, dataPtr->unique()); - sk_sp<SkPixelRef> pr = SkMallocPixelRef::MakeWithData(info, rowBytes, nullptr, data); + sk_sp<SkMallocPixelRef> pr( + SkMallocPixelRef::NewWithData(info, rowBytes, nullptr, data.get())); REPORTER_ASSERT(reporter, !(dataPtr->unique())); data.reset(nullptr); REPORTER_ASSERT(reporter, dataPtr->unique()); diff --git a/tests/PixelRefTest.cpp b/tests/PixelRefTest.cpp index 683e249626..487e5195f3 100644 --- a/tests/PixelRefTest.cpp +++ b/tests/PixelRefTest.cpp @@ -69,7 +69,7 @@ private: DEF_TEST(PixelRef_GenIDChange, r) { SkImageInfo info = SkImageInfo::MakeN32Premul(10, 10); - sk_sp<SkPixelRef> pixelRef = SkMallocPixelRef::MakeAllocate(info, 0, nullptr); + sk_sp<SkPixelRef> pixelRef(SkMallocPixelRef::NewAllocate(info, 0, nullptr)); // Register a listener. int count = 0; diff --git a/tests/WritePixelsTest.cpp b/tests/WritePixelsTest.cpp index cace6b196e..c38e4d665d 100644 --- a/tests/WritePixelsTest.cpp +++ b/tests/WritePixelsTest.cpp @@ -263,7 +263,7 @@ static bool alloc_row_bytes(SkBitmap* bm, const SkImageInfo& info, size_t rowByt if (!bm->setInfo(info, rowBytes)) { return false; } - sk_sp<SkPixelRef> pr = SkMallocPixelRef::MakeAllocate(info, rowBytes, nullptr); + sk_sp<SkPixelRef> pr(SkMallocPixelRef::NewAllocate(info, rowBytes, nullptr)); bm->setPixelRef(std::move(pr), 0, 0); return true; } |