aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2017-09-29 15:22:56 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-10-02 12:55:37 +0000
commitcd284c532376d16fcc4ed75baf3da65c3e4a2e95 (patch)
tree5c7e34122e72cef44f279b1aa32638d765d3c639 /tests
parent3c83668862521b3bbbd628a522c05688348d6e7f (diff)
Revert "Revert "guard old apis for querying byte-size of a bitmap/imageinfo/pixmap""
This reverts commit 809cbedd4b252be221b2ac3b4269d312fd8f53a0. Bug: skia: Change-Id: I680d8daeeeeb15526b44c1305d8fb0c6bfa38e1d Reviewed-on: https://skia-review.googlesource.com/52665 Commit-Queue: Mike Reed <reed@google.com> Reviewed-by: Florin Malita <fmalita@chromium.org>
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 7aaf554015..9b1e0c9bbb 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.getSafeSize(minRowBytes);
+ const size_t size = info.computeByteSize(minRowBytes);
SkAutoTMalloc<SkPMColor> storage(size);
SkPMColor* baseAddr = storage.get();
sk_bzero(baseAddr, size);
diff --git a/tests/CodecTest.cpp b/tests/CodecTest.cpp
index 8ea3193a4b..91b07ef49e 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.getSafeSize(rowBytes);
+ size_t totalBytes = scaledInfo.computeByteSize(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.getSafeSize(rowBytes));
+ SkAutoMalloc pixelStorage(dstInfo.computeByteSize(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 991290142e..8ad177f5c1 100644
--- a/tests/DrawBitmapRectTest.cpp
+++ b/tests/DrawBitmapRectTest.cpp
@@ -144,9 +144,10 @@ static void test_wacky_bitmapshader(skiatest::Reporter* reporter,
SkBitmap bm;
if (bm.tryAllocN32Pixels(width, height)) {
- // allow this to fail silently, to test the code downstream
+ bm.eraseColor(SK_ColorRED);
+ } else {
+ shouldBeDrawn = false;
}
- bm.eraseColor(SK_ColorRED);
matrix.setAll(0.0078740157f,
0,
@@ -179,7 +180,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 3 more to ensure that we can,
+ * This tests exercises the original setup, plus 2 more to ensure that we can,
* in fact, handle bitmaps at 64K-1 (assuming we don't exceed the total
* memory allocation limit).
*/
@@ -192,7 +193,6 @@ 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 64873c3fc8..e67d8f1e79 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.getSafeSize() == SkToSizeT(w * h * sizeof(uint64_t)));
+ REPORTER_ASSERT(reporter, pm.computeByteSize() == 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 638fa078f0..ff80729d7b 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.getSize() == bm2.getSize());
- REPORTER_ASSERT(reporter, 0 == memcmp(bm1.getPixels(), bm2.getPixels(), bm1.getSize()));
+ REPORTER_ASSERT(reporter, bm1.computeByteSize() == bm2.computeByteSize());
+ REPORTER_ASSERT(reporter, 0 == memcmp(bm1.getPixels(), bm2.getPixels(), bm1.computeByteSize()));
}
static void paint_source(SkSurface* sourceSurface) {
diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp
index 96b5b29405..9e0137f3cf 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.getSafeSize(rowBytes);
+ size_t size = info.computeByteSize(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 957c8b3948..ac080994e2 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.getSafeSize(rowBytes);
+ size_t size = info.computeByteSize(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.getSafeSize(rowBytes) - 1;
+ size_t size = info.computeByteSize(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.getSafeSize(rowBytes) + 9;
+ size_t size = info.computeByteSize(rowBytes) + 9;
{
SkAutoMalloc memory(size);
sk_sp<SkPixelRef> pr(
diff --git a/tests/RecordingXfermodeTest.cpp b/tests/RecordingXfermodeTest.cpp
index 20dccc6cc2..25e99ba23d 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.getSize();
- REPORTER_ASSERT(reporter, pixelsSize == pictureBM.getSize());
+ size_t pixelsSize = goldenBM.computeByteSize();
+ REPORTER_ASSERT(reporter, pixelsSize == pictureBM.computeByteSize());
// The pixel arrays should match.
#if FINEGRAIN
diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp
index b3d0bd56bb..af33f2d9bc 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.getSize();
+ size_t srcSize = src.computeByteSize();
size_t initialCacheSize;
context->getResourceCacheUsage(nullptr, &initialCacheSize);
diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp
index 202df58f3c..2fd987fdf6 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.getSafeSize(rowBytes));
+ void* storage = sk_malloc_throw(info.computeByteSize(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, 1 << 30, nullptr); // allocation to large
+ s = SkSurface::MakeRaster(info, std::numeric_limits<size_t>::max(), nullptr);
REPORTER_ASSERT(reporter, nullptr == s);
}
diff --git a/tests/SwizzlerTest.cpp b/tests/SwizzlerTest.cpp
index 655c97eadd..8950efb153 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.getSafeSize(rowBytes) + offset;
+ const size_t totalBytes = imageInfo.computeByteSize(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 81dcbe7f6d..7ea0aad12f 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.getSafeSize(rowBytes);
+ const size_t size = info.computeByteSize(rowBytes);
void* pixels = sk_malloc_throw(size);
// if rowBytes isn't tight then set the padding to a known value
if (!tightRowBytes) {