diff options
author | Greg Daniel <egdaniel@google.com> | 2017-09-26 20:07:58 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-09-26 20:08:07 +0000 |
commit | f46633f8af5296341e33ec4cdb69c71dfa997396 (patch) | |
tree | d6d59760f023f6855d921253d684716ae93bdc28 /tests | |
parent | 58e23039bd4a8aee2c67fa6c9e5105b925d2e561 (diff) |
Revert "guard old apis for querying byte-size of a bitmap/imageinfo/pixmap"
This reverts commit 98a6216b18b57c2f7a0d58f542c60503686aed69.
Reason for revert: breaking the chrome roll. Looks like they may be writing data to create an image across all the row bytes and thus writing to unalloced data on the last row. Link to example failing bot:
https://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_rel_ng/builds/539960
Original change's description:
> guard old apis for querying byte-size of a bitmap/imageinfo/pixmap
>
> Previously we had size_t and uint64_t variations.
>
> The new (simpler) API always..
> - returns size_t, or 0 if the calculation overflowed
> - returns the trimmed size (does not include rowBytes padding for the last row)
>
> Bug: skia:
> Change-Id: I05173e877918327c7b207d2f7f1ab0db36892e2e
> Reviewed-on: https://skia-review.googlesource.com/50980
> Commit-Queue: Mike Reed <reed@google.com>
> Reviewed-by: Florin Malita <fmalita@chromium.org>
> Reviewed-by: Leon Scroggins <scroggo@google.com>
TBR=mtklein@google.com,herb@google.com,scroggo@google.com,fmalita@chromium.org,reed@google.com
Change-Id: I726f6ab1b36b14979ba6f37105e0a469b3f0dbc0
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/51262
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/CanvasTest.cpp | 2 | ||||
-rw-r--r-- | tests/CodecTest.cpp | 4 | ||||
-rw-r--r-- | tests/DrawBitmapRectTest.cpp | 8 | ||||
-rw-r--r-- | tests/Float16Test.cpp | 2 | ||||
-rw-r--r-- | tests/ImageNewShaderTest.cpp | 4 | ||||
-rw-r--r-- | tests/ImageTest.cpp | 2 | ||||
-rw-r--r-- | tests/MallocPixelRefTest.cpp | 6 | ||||
-rw-r--r-- | tests/RecordingXfermodeTest.cpp | 4 | ||||
-rw-r--r-- | tests/ResourceCacheTest.cpp | 2 | ||||
-rw-r--r-- | tests/SurfaceTest.cpp | 4 | ||||
-rw-r--r-- | tests/SwizzlerTest.cpp | 2 | ||||
-rw-r--r-- | tests/WritePixelsTest.cpp | 2 |
12 files changed, 21 insertions, 21 deletions
diff --git a/tests/CanvasTest.cpp b/tests/CanvasTest.cpp index 9b1e0c9bbb..7aaf554015 100644 --- a/tests/CanvasTest.cpp +++ b/tests/CanvasTest.cpp @@ -573,7 +573,7 @@ static void TestOverrideStateConsistency(skiatest::Reporter* reporter, const Tes static void test_newraster(skiatest::Reporter* reporter) { SkImageInfo info = SkImageInfo::MakeN32Premul(10, 10); const size_t minRowBytes = info.minRowBytes(); - const size_t size = info.computeByteSize(minRowBytes); + const size_t size = info.getSafeSize(minRowBytes); SkAutoTMalloc<SkPMColor> storage(size); SkPMColor* baseAddr = storage.get(); sk_bzero(baseAddr, size); diff --git a/tests/CodecTest.cpp b/tests/CodecTest.cpp index 6e253d29c6..f2551d2d95 100644 --- a/tests/CodecTest.cpp +++ b/tests/CodecTest.cpp @@ -588,7 +588,7 @@ static void test_dimensions(skiatest::Reporter* r, const char path[]) { // Set up for the decode size_t rowBytes = scaledDims.width() * sizeof(SkPMColor); - size_t totalBytes = scaledInfo.computeByteSize(rowBytes); + size_t totalBytes = scaledInfo.getSafeSize(rowBytes); SkAutoTMalloc<SkPMColor> pixels(totalBytes); SkAndroidCodec::AndroidOptions options; @@ -1015,7 +1015,7 @@ static void check_color_xform(skiatest::Reporter* r, const char* path) { .makeColorSpace(colorSpace); size_t rowBytes = dstInfo.minRowBytes(); - SkAutoMalloc pixelStorage(dstInfo.computeByteSize(rowBytes)); + SkAutoMalloc pixelStorage(dstInfo.getSafeSize(rowBytes)); SkCodec::Result result = codec->getAndroidPixels(dstInfo, pixelStorage.get(), rowBytes, &opts); REPORTER_ASSERT(r, SkCodec::kSuccess == result); } diff --git a/tests/DrawBitmapRectTest.cpp b/tests/DrawBitmapRectTest.cpp index 8ad177f5c1..991290142e 100644 --- a/tests/DrawBitmapRectTest.cpp +++ b/tests/DrawBitmapRectTest.cpp @@ -144,10 +144,9 @@ static void test_wacky_bitmapshader(skiatest::Reporter* reporter, SkBitmap bm; if (bm.tryAllocN32Pixels(width, height)) { - bm.eraseColor(SK_ColorRED); - } else { - shouldBeDrawn = false; + // allow this to fail silently, to test the code downstream } + bm.eraseColor(SK_ColorRED); matrix.setAll(0.0078740157f, 0, @@ -180,7 +179,7 @@ static void test_wacky_bitmapshader(skiatest::Reporter* reporter, * sign-extension bleed when packing the two values (X,Y) into our 32bit * slot. * - * This tests exercises the original setup, plus 2 more to ensure that we can, + * This tests exercises the original setup, plus 3 more to ensure that we can, * in fact, handle bitmaps at 64K-1 (assuming we don't exceed the total * memory allocation limit). */ @@ -193,6 +192,7 @@ static void test_giantrepeat_crbug118018(skiatest::Reporter* reporter) { { 0x1b294, 0x7f, false }, // crbug 118018 (width exceeds 64K) { 0xFFFF, 0x7f, true }, // should draw, test max width { 0x7f, 0xFFFF, true }, // should draw, test max height + { 0xFFFF, 0xFFFF, false }, // allocation fails (too much RAM) }; for (size_t i = 0; i < SK_ARRAY_COUNT(gTests); ++i) { diff --git a/tests/Float16Test.cpp b/tests/Float16Test.cpp index e67d8f1e79..64873c3fc8 100644 --- a/tests/Float16Test.cpp +++ b/tests/Float16Test.cpp @@ -43,7 +43,7 @@ DEF_TEST(color_half_float, reporter) { SkAutoPixmapStorage pm; pm.alloc(info); - REPORTER_ASSERT(reporter, pm.computeByteSize() == SkToSizeT(w * h * sizeof(uint64_t))); + REPORTER_ASSERT(reporter, pm.getSafeSize() == SkToSizeT(w * h * sizeof(uint64_t))); SkColor4f c4 { 1, 0.5f, 0.25f, 0.5f }; pm.erase(c4); diff --git a/tests/ImageNewShaderTest.cpp b/tests/ImageNewShaderTest.cpp index ff80729d7b..638fa078f0 100644 --- a/tests/ImageNewShaderTest.cpp +++ b/tests/ImageNewShaderTest.cpp @@ -17,8 +17,8 @@ #endif static void test_bitmap_equality(skiatest::Reporter* reporter, SkBitmap& bm1, SkBitmap& bm2) { - REPORTER_ASSERT(reporter, bm1.computeByteSize() == bm2.computeByteSize()); - REPORTER_ASSERT(reporter, 0 == memcmp(bm1.getPixels(), bm2.getPixels(), bm1.computeByteSize())); + REPORTER_ASSERT(reporter, bm1.getSize() == bm2.getSize()); + REPORTER_ASSERT(reporter, 0 == memcmp(bm1.getPixels(), bm2.getPixels(), bm1.getSize())); } static void paint_source(SkSurface* sourceSurface) { diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp index 9e0137f3cf..96b5b29405 100644 --- a/tests/ImageTest.cpp +++ b/tests/ImageTest.cpp @@ -549,7 +549,7 @@ DEF_TEST(ImageEmpty, reporter) { DEF_TEST(ImageDataRef, reporter) { SkImageInfo info = SkImageInfo::MakeN32Premul(1, 1); size_t rowBytes = info.minRowBytes(); - size_t size = info.computeByteSize(rowBytes); + size_t size = info.getSafeSize(rowBytes); sk_sp<SkData> data = SkData::MakeUninitialized(size); REPORTER_ASSERT(reporter, data->unique()); sk_sp<SkImage> image = SkImage::MakeRasterData(info, data, rowBytes); diff --git a/tests/MallocPixelRefTest.cpp b/tests/MallocPixelRefTest.cpp index ac080994e2..957c8b3948 100644 --- a/tests/MallocPixelRefTest.cpp +++ b/tests/MallocPixelRefTest.cpp @@ -32,7 +32,7 @@ DEF_TEST(MallocPixelRef, reporter) { } { size_t rowBytes = info.minRowBytes() - 1; - size_t size = info.computeByteSize(rowBytes); + size_t size = info.getSafeSize(rowBytes); sk_sp<SkData> data(SkData::MakeUninitialized(size)); sk_sp<SkPixelRef> pr( SkMallocPixelRef::MakeWithData(info, rowBytes, data)); @@ -41,7 +41,7 @@ DEF_TEST(MallocPixelRef, reporter) { } { size_t rowBytes = info.minRowBytes() + 2; - size_t size = info.computeByteSize(rowBytes) - 1; + size_t size = info.getSafeSize(rowBytes) - 1; sk_sp<SkData> data(SkData::MakeUninitialized(size)); sk_sp<SkPixelRef> pr( SkMallocPixelRef::MakeWithData(info, rowBytes, data)); @@ -49,7 +49,7 @@ DEF_TEST(MallocPixelRef, reporter) { REPORTER_ASSERT(reporter, nullptr == pr.get()); } size_t rowBytes = info.minRowBytes() + 7; - size_t size = info.computeByteSize(rowBytes) + 9; + size_t size = info.getSafeSize(rowBytes) + 9; { SkAutoMalloc memory(size); sk_sp<SkPixelRef> pr( diff --git a/tests/RecordingXfermodeTest.cpp b/tests/RecordingXfermodeTest.cpp index 25e99ba23d..20dccc6cc2 100644 --- a/tests/RecordingXfermodeTest.cpp +++ b/tests/RecordingXfermodeTest.cpp @@ -151,8 +151,8 @@ DEF_TEST(SkRecordingAccuracyXfermode, reporter) { const SkBitmap& goldenBM = golden.recordAndReplay(drawer, clip, mode); const SkBitmap& pictureBM = picture.recordAndReplay(drawer, clip, mode); - size_t pixelsSize = goldenBM.computeByteSize(); - REPORTER_ASSERT(reporter, pixelsSize == pictureBM.computeByteSize()); + size_t pixelsSize = goldenBM.getSize(); + REPORTER_ASSERT(reporter, pixelsSize == pictureBM.getSize()); // The pixel arrays should match. #if FINEGRAIN diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp index af33f2d9bc..b3d0bd56bb 100644 --- a/tests/ResourceCacheTest.cpp +++ b/tests/ResourceCacheTest.cpp @@ -49,7 +49,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceCacheCache, reporter, ctxInfo) { SkBitmap src; src.allocN32Pixels(size.width(), size.height()); src.eraseColor(SK_ColorBLACK); - size_t srcSize = src.computeByteSize(); + size_t srcSize = src.getSize(); size_t initialCacheSize; context->getResourceCacheUsage(nullptr, &initialCacheSize); diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp index 2fd987fdf6..202df58f3c 100644 --- a/tests/SurfaceTest.cpp +++ b/tests/SurfaceTest.cpp @@ -50,7 +50,7 @@ static sk_sp<SkSurface> create_direct_surface(SkAlphaType at = kPremul_SkAlphaTy *requestedInfo = info; } const size_t rowBytes = info.minRowBytes(); - void* storage = sk_malloc_throw(info.computeByteSize(rowBytes)); + void* storage = sk_malloc_throw(info.getSafeSize(rowBytes)); return SkSurface::MakeRasterDirectReleaseProc(info, storage, rowBytes, release_direct_surface_storage, storage); @@ -565,7 +565,7 @@ DEF_TEST(surface_rowbytes, reporter) { // Try some illegal rowByte values auto s = SkSurface::MakeRaster(info, 396, nullptr); // needs to be at least 400 REPORTER_ASSERT(reporter, nullptr == s); - s = SkSurface::MakeRaster(info, std::numeric_limits<size_t>::max(), nullptr); + s = SkSurface::MakeRaster(info, 1 << 30, nullptr); // allocation to large REPORTER_ASSERT(reporter, nullptr == s); } diff --git a/tests/SwizzlerTest.cpp b/tests/SwizzlerTest.cpp index 8950efb153..655c97eadd 100644 --- a/tests/SwizzlerTest.cpp +++ b/tests/SwizzlerTest.cpp @@ -28,7 +28,7 @@ static void check_fill(skiatest::Reporter* r, // to test on different memory alignments. If offset is nonzero, we need to increase the // size of the memory we allocate in order to make sure that we have enough. We are // still allocating the smallest possible size. - const size_t totalBytes = imageInfo.computeByteSize(rowBytes) + offset; + const size_t totalBytes = imageInfo.getSafeSize(rowBytes) + offset; // Create fake image data where every byte has a value of 0 std::unique_ptr<uint8_t[]> storage(new uint8_t[totalBytes]); diff --git a/tests/WritePixelsTest.cpp b/tests/WritePixelsTest.cpp index 7ea0aad12f..81dcbe7f6d 100644 --- a/tests/WritePixelsTest.cpp +++ b/tests/WritePixelsTest.cpp @@ -394,7 +394,7 @@ DEF_TEST(WritePixels, reporter) { const SkImageInfo info = SkImageInfo::MakeN32Premul(DEV_W, DEV_H); for (auto& tightRowBytes : { true, false }) { const size_t rowBytes = tightRowBytes ? info.minRowBytes() : 4 * DEV_W + 100; - const size_t size = info.computeByteSize(rowBytes); + const size_t size = info.getSafeSize(rowBytes); void* pixels = sk_malloc_throw(size); // if rowBytes isn't tight then set the padding to a known value if (!tightRowBytes) { |