aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar Jim Van Verth <jvanverth@google.com>2017-09-27 22:13:44 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-09-27 23:15:07 +0000
commit809cbedd4b252be221b2ac3b4269d312fd8f53a0 (patch)
tree66ff73d8acfd81ebf76afd36d44a06709a4ba457 /tests
parent6ca9c6f41224050d92cae548e915f5b9175efe8b (diff)
Revert "guard old apis for querying byte-size of a bitmap/imageinfo/pixmap"
This reverts commit 88757dacd4f532a0f647c02ae0ee596d31ab5c68. Reason for revert: Still seems to be failing Chromium "telemetry_perf_unittests (with patch) on Android" on android_n5x_swarming_rel. Original change's description: > guard old apis for querying byte-size of a bitmap/imageinfo/pixmap > > Now with legacy behavior for allocpixels > > This was reverted, so the current CL is a "fix" on top of ... > https://skia-review.googlesource.com/c/skia/+/50980 > > Related update to Chrome (in preparation for this change) > https://chromium-review.googlesource.com/c/chromium/src/+/685719 > > Bug: skia: > Change-Id: I4b370ee7e95083ab27421f008132219c9c7b86e9 > Reviewed-on: https://skia-review.googlesource.com/51341 > Reviewed-by: Florin Malita <fmalita@chromium.org> > Commit-Queue: Mike Reed <reed@google.com> TBR=fmalita@chromium.org,reed@google.com Change-Id: I827a0ca1d1e3909e648fde3342cdb8601d34da8d No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia: Reviewed-on: https://skia-review.googlesource.com/52381 Reviewed-by: Jim Van Verth <jvanverth@google.com> Commit-Queue: Jim Van Verth <jvanverth@google.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/CanvasTest.cpp2
-rw-r--r--tests/CodecTest.cpp4
-rw-r--r--tests/DrawBitmapRectTest.cpp8
-rw-r--r--tests/Float16Test.cpp2
-rw-r--r--tests/ImageNewShaderTest.cpp4
-rw-r--r--tests/ImageTest.cpp2
-rw-r--r--tests/MallocPixelRefTest.cpp6
-rw-r--r--tests/RecordingXfermodeTest.cpp4
-rw-r--r--tests/ResourceCacheTest.cpp2
-rw-r--r--tests/SurfaceTest.cpp4
-rw-r--r--tests/SwizzlerTest.cpp2
-rw-r--r--tests/WritePixelsTest.cpp2
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 91b07ef49e..8ea3193a4b 100644
--- a/tests/CodecTest.cpp
+++ b/tests/CodecTest.cpp
@@ -584,7 +584,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;
@@ -1011,7 +1011,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) {